npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

open-oracle-poster

v1.1.31

Published

A Customizable Poster for the Compound Open Price Feed

Downloads

72

Readme

The Open Price Feed Poster

The poster is a simple application to pull prices from a set of source feeds and post them to the blockchain. The posters main job is to make sure that the requested source data is posted to the Ethereum blockchain, and thus is concerned about nonces, gas prices, etc.

Installation

The Open Price Feed poster can be run as a standalone process or as a module for configuration. To install as a global process:

yarn global add open-oracle-poster
# npm install -g open-oracle-poster

Or, if you plan on customizing the poster, you can install in a project:

yarn add open-oracle-poster
# npm install open-oracle-poster

Command-Line Interface

The poster is a simple CLI to post prices. The following options are available:

| Option | Description | | ------ | ----------- | | --sources, -s | sources to pull price messages from, a list of https endpoints created by open oracle reporters serving open oracle payloads as json. For complex sources, such as Coinbase, this can be JSON-encoded. Note: specify multiple times to specify multiple sources. | | --poster-key, -k | Private key holding enough gas to post (try: file:<file> or env:<env>) | | --view-function, -f | Function signature for the view (e.g. postPrices(bytes[],bytes[])) | | --web3-provider | Web3 provider | | --view-address | Address of open oracle view to post through | | --timeout, -t | how many seconds to wait before retrying with more gas, defaults to 180 | | --asset, -a | List of assets to post prices for. Pass multiple times to specify multiple assets. |

Sources

A source can simply be a URL, e.g. http://localhost:3000/prices.json or you can pass a JSON-encoded structure for complex sources. Specifically, for the Coinbase API, you can use the following structure:

"{\"source\": \"coinbase\", \"endpoint\": \"https://api.pro.coinbase.com/oracle\", \"api_key_id\": \"<your api key>\", \"api_secret\": \"<your api secret>\", \"api_passphrase\": \"<your api passphrase>\"}"

Examples

To run as standalone from this project's root, simply invoke the start script.

 yarn run start --view-address=0xViewAddress --poster-key=0xWalletWithGas --sources=http://localhost:3000/prices.json

Here's an example for the Kovan testnet:

 yarn prepare && yarn run start --web3-provider=https://kovan-eth.compound.finance/ --view-address=0x60F1FFB2FE2bFE6CFFA0A66e258B623f06E1949F --poster-key="$(cat ~/.ethereum/kovan)" --sources="{\"source\": \"coinbase\", \"endpoint\": \"https://api.pro.coinbase.com/oracle\", \"api_key_id\": \"$COINBASE_API_KEY\", \"api_secret\": \"$COINBASE_API_SECRET\", \"api_passphrase\": \"$COINBASE_API_PASSPHRASE\"}"

Running in JavaScript

You can include the Open Price Feed poster in an app for configuration:

import poster from 'open-oracle-poster';
import Web3 from 'web3';

// sample arguments, fill these in with real data :)
let sources: string[] = /* [list of sources, possibly JSON-encoded] */;
let posterKey: string = /* ...a key to a wallet holding eth for gas */;
let viewAddress: string = /* "0xDelfiPriceView" */;
let viewFunction: string = 'postPrices(bytes[],bytes[],string[])' /* ...view function signature */;
let provider = new Web3();

await poster.main(sources, posterKey, viewAddress, viewFunction, provider);

Testing

To run tests, simply run:

yarn test

To run a single test run:

yarn test tests/poster_test.ts

Contributing

For all contributions, please open an issue or pull request to discuss. Ensure that all test cases are passing and that top-level (integration) tests also pass (see the open-oracle root project). See top-level README for license notice and contribution agreement.