From 1a584027cfa980308ca7512fac20d88a060be489 Mon Sep 17 00:00:00 2001 From: Rishi Panthee Date: Thu, 27 May 2021 16:18:41 -0500 Subject: [PATCH 1/4] testnet support --- app.js | 3 ++- lib/settings.js | 14 +++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index 40c6d81..4799f3a 100755 --- a/app.js +++ b/app.js @@ -32,7 +32,8 @@ for (var t_arg of process.argv) { } } -hive.api.setOptions({url: config.node}); +// hive.api.setOptions({url: config.node}); +hive.api.setOptions({url: config.node, address_prefix: config.address_prefix ,chain_id: config.chain_id}) // used for re-trying failed promises function delay(t) { diff --git a/lib/settings.js b/lib/settings.js index d9d5d41..1a7ff3c 100644 --- a/lib/settings.js +++ b/lib/settings.js @@ -18,9 +18,19 @@ var settings = { var defaults = { hive: { node: 'https://hived.privex.io/', - alternate_nodes : ["https://api.deathwing.me", "https://api.hive.blog"], + alternate_nodes : ['https://api.deathwing.me', 'https://api.hive.blog'], ex_symbol: 'hive', ex_compare: 'usd', base_symbol: 'HBD', quote_symbol: 'HIVE', + chain_id: 'beeab0de00000000000000000000000000000000000000000000000000000000', + address_prefix : 'SMT', + }, + testnet : { + node: 'https://testnet.openhive.network/', + alternate_nodes : [], + ex_symbol: 'hive', ex_compare: 'usd', + base_symbol: 'TBD', quote_symbol: 'TESTS', + chain_id : '18dcf0a285365fc58b71f18b3d3fec954aa0c141c44e4e5cb4cf777b9eab274e', + address_prefix : 'TST', } }; @@ -31,6 +41,8 @@ var ndef = defaults[config.network]; if(!('node' in config)) { config.node = ndef.node; } if(!('alternate_nodes' in config)) { config.alternate_nodes = ndef.alternate_nodes; } +if(!('chain_id' in config)) { config.chain_id = ndef.chain_id; } +if(!('address_prefix' in config)) { config.address_prefix = ndef.address_prefix; } // disable peg by default. 0% peg (bias) if(!('peg' in config)) { config.peg = false; } if(!('peg_multi' in config)) { config.peg_multi = 1; } From d30b8b386ce669ba0b3a5307034129ea6b66f99c Mon Sep 17 00:00:00 2001 From: Rishi Panthee Date: Thu, 27 May 2021 17:12:36 -0500 Subject: [PATCH 2/4] Styling --- app.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app.js b/app.js index 4799f3a..2d46b71 100755 --- a/app.js +++ b/app.js @@ -22,7 +22,7 @@ log(`Loaded configuration: Username: ${config.name} Bias: ${config.peg ? config.peg_multi : 'Disabled'} RPC Node: ${config.node} -Alternate Nodes: ${config.alternate_nodes.join(", ")}`); +Alternate Nodes: ${config.alternate_nodes.join(', ')}`); console.log('-------------'); global.verbose = false; @@ -32,7 +32,6 @@ for (var t_arg of process.argv) { } } -// hive.api.setOptions({url: config.node}); hive.api.setOptions({url: config.node, address_prefix: config.address_prefix ,chain_id: config.chain_id}) // used for re-trying failed promises @@ -227,8 +226,8 @@ class HiveAcc { let signing = result.signing_key; if (signing_keys.hasOwnProperty(signing)) { let props = { - "key": signing, - "hbd_exchange_rate": exchangeRate + 'key': signing, + 'hbd_exchange_rate': exchangeRate }; let op = hive.utils.buildWitnessUpdateOp(username, props); hive.broadcast.witnessSetProperties(signing_keys[signing], username, op[1].props, [], async (err, result) => { @@ -365,7 +364,7 @@ function startup(){ console.error(`An error occurred attempting to log into ${config.name}...`); console.error(`Reason: ${e}`, e); if (config.signing_keys === undefined || !Object.keys(config.signing_keys).length){ - console.error("Exiting"); + console.error('Exiting'); process.exit(1); } else { console.log(`Trying again in ${config.interval} minute(s)`); From 0dd802a8fa8ef73e8a69851857ef4b807dfae2b9 Mon Sep 17 00:00:00 2001 From: Rishi Panthee Date: Thu, 27 May 2021 17:13:28 -0500 Subject: [PATCH 3/4] Bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e8aa7b0..09530ee 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hivefeed-js", - "version": "4.2.0", + "version": "4.3.0", "description": "Hive Price Feed in JS with automatic retry for down nodes", "repository": "https://github.com/someguy123/hivefeed-js", "main": "app.js", From 59b2c10ac7656049885bff1b3b2c502d4300fc57 Mon Sep 17 00:00:00 2001 From: Rishi Panthee Date: Thu, 27 May 2021 17:17:58 -0500 Subject: [PATCH 4/4] Update advanced config and readme --- README.md | 9 ++++++--- config.advanced.json | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a11dcd3..2ff85c3 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Hive Feed JS This is a Hive Price Feed for witnesses on the [HIVE Network](https://hive.io). It's written in Node.JS and uses Hive's [Hive-JS](https://www.npmjs.com/package/@hiveio/hive-js). -Recommended NodeJS version: v12.19.0 +Recommended NodeJS version: v12.19.0. Installation ======== @@ -18,7 +18,7 @@ cp config.example.json config.json nano config.json ``` -I recommend using Docker, however you can also use a locally installed copy of Node v8.11.4. +I recommend using Docker, however you can also use a locally installed copy of Node v8.11.4 or higher. **Starting Via Docker** @@ -103,7 +103,7 @@ Configuration - **interval** (default: `60`) - The number of minutes between publishing the feed -- **network** (default: `hive`) - The network (chain) you're using this for. Options are: `hive` +- **network** (default: `hive`) - The network (chain) you're using this for. For using the hive long term testnet, set to `testnet`. Options are: `hive` `testnet` - **peg** (default: `false`) - Set to true only if you want to adjust your price feed bias @@ -129,6 +129,9 @@ Just set the correct `network`, and those settings will be automatically updated `alternate_nodes` - Alternate nodes to use if the main provided one is down. Provided as an array of nodes. Default : `["https://api.hive.blog", "https://api.deathwing.me"]` +`chain_id` - Chain id of the chain that you are using. Default: `beeab0de00000000000000000000000000000000000000000000000000000000` + +`address_prefix` - Address prefix of the chain that you are using. Default: `STM` `disable_exchanges` - A list of exchange `code` 's to disable. Exchanges listed here will not be used directly (i.e. get price for A/B), nor indirectly (i.e. get price for A/D by converting A/C then C/D). diff --git a/config.advanced.json b/config.advanced.json index b562f76..cd3bac9 100644 --- a/config.advanced.json +++ b/config.advanced.json @@ -10,6 +10,8 @@ "peg_multi": 1.0, "node": "https://hivded.privex.io", "alternate_nodes" : ["https://api.deathwing.me", "https://api.hive.blog"], + "chain_id" : "beeab0de00000000000000000000000000000000000000000000000000000000", + "address_prefix" : "STM", "ex_symbol": "hive", "ex_compare": "usd", "base_symbol": "HBD",