Skip to content

Commit

Permalink
Coburn/update-for-better-cli-use (#22)
Browse files Browse the repository at this point in the history
* v1.0.3

* allow yargs from env

* v1.0.5

* use - in args to work with env version

* v1.0.6

* shebang

* v1.0.7

* snake case everything to make env args happier

* v1.0.8

* aggressively use the same dependency

* v1.0.9

* remove unnecesary typecasts

* v1.0.10
  • Loading branch information
coburncoburn authored Aug 1, 2019
1 parent 6fff429 commit e9c91d9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
5 changes: 3 additions & 2 deletions poster/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "open-oracle-poster",
"version": "1.0.0",
"version": "1.0.10",
"description": "A Customizable Poster for the Compound Open Oracle",
"main": ".tsbuilt/poster.js",
"bin": ".tsbuilt/index.js",
"repository": "https://compound.finance/open-oracle",
"author": "Compound Labs, Inc.",
"license": "MIT",
Expand All @@ -21,7 +22,7 @@
},
"dependencies": {
"node-fetch": "^2.6.0",
"web3": "^1.0.0-beta.55",
"web3": "1.0.0-beta.55",
"yargs": "^13.2.4"
}
}
18 changes: 10 additions & 8 deletions poster/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
#! /usr/bin/env node
import {main} from './poster';
import Web3 from 'web3';
import yargs from 'yargs';

async function run() {
const argv = yargs
.env('POSTER')
.option('sources', {alias: 's', description: 'Sources to pull price messages from, a list of https endpoints created by open oracle reporters serving open oracle payloads as json', type: 'string'})
.option('poster_key', {alias: 'k', description: 'Private key holding enough gas to post (try: `file:<file> or env:<env>)`', type: 'string'})
.option('view_address', {alias: 'a', description: 'Address of open oracle view to post through', type: 'string'})
.option('view_function', {alias: 'f', description: 'Function signature for the view', type: 'string', default: 'postPrices(bytes[],bytes[],string[])'})
.option('web3_provider', {description: 'Web 3 provider', type: 'string', default: 'http://127.0.0.1:8545'})
.option('posterKey', {alias: 'k', description: 'Private key holding enough gas to post (try: `file:<file> or env:<env>)`', type: 'string'})
.option('viewAddress', {alias: 'a', description: 'Address of open oracle view to post through', type: 'string'})
.option('viewFunction', {alias: 'f', description: 'Function signature for the view', type: 'string', default: 'postPrices(bytes[],bytes[],string[])'})
.option('web3Provider', {description: 'Web 3 provider', type: 'string', default: 'http://127.0.0.1:8545'})
.option('timeout', {alias: 't', description: 'How many seconds to wait before retrying with more gas', type: 'number', default: 180})
.help()
.alias('help', 'h')
.demandOption(['poster_key', 'sources', 'view_function', 'web3_provider', 'view_address'], 'Provide all the arguments')
.demandOption(['posterKey', 'sources', 'viewFunction', 'web3Provider', 'viewAddress'], 'Provide all the arguments')
.argv;

// posting promise will reject and retry once with higher gas after this timeout
const web3 = await new Web3(argv.web3_provider, undefined, {transactionPollingTimeout: argv.timeout});
const web3 = await new Web3(argv.web3Provider, undefined, {transactionPollingTimeout: argv.timeout});

if (argv.web3_provider.match(/.*:8545$/)) {
if (argv.web3Provider.match(/.*:8545$/)) {
// confirm immediately in dev
web3.eth.transactionConfirmationBlocks = 1

Expand All @@ -36,7 +38,7 @@ async function run() {
}

try {
await main(argv.sources, argv.poster_key, argv.view_address, argv.view_function, web3);
await main(argv.sources, argv.posterKey, argv.viewAddress, argv.viewFunction, web3);
} catch (e) {
console.error(`Poster failed to run`, e);
}
Expand Down
2 changes: 1 addition & 1 deletion poster/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4360,7 +4360,7 @@ [email protected]:
randombytes "^2.1.0"
utf8 "2.1.1"

web3@^1.0.0-beta.55:
[email protected]:
version "1.0.0-beta.55"
resolved "https://registry.yarnpkg.com/web3/-/web3-1.0.0-beta.55.tgz#8845075129299da172c2eb41a748c8a87c2a2b5a"
integrity sha512-yJpwy4IUA3T/F9hWzYQVn0GbJCrAaZ0KTIO3iuqkhaYH0Y09KV7k4GzFi4hN7hT4cFTj4yIKaeVCwQ5kzvi2Vg==
Expand Down

0 comments on commit e9c91d9

Please sign in to comment.