Skip to content

Commit ee6ef33

Browse files
authored
Merge pull request #18 from Someguy123/testnet
Hive Testnet Network Support
2 parents 8d979ce + 59b2c10 commit ee6ef33

File tree

5 files changed

+27
-10
lines changed

5 files changed

+27
-10
lines changed

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Hive Feed JS
44
This is a Hive Price Feed for witnesses on the [HIVE Network](https://hive.io). It's
55
written in Node.JS and uses Hive's [Hive-JS](https://www.npmjs.com/package/@hiveio/hive-js).
66

7-
Recommended NodeJS version: v12.19.0
7+
Recommended NodeJS version: v12.19.0.
88

99
Installation
1010
========
@@ -18,7 +18,7 @@ cp config.example.json config.json
1818
nano config.json
1919
```
2020

21-
I recommend using Docker, however you can also use a locally installed copy of Node v8.11.4.
21+
I recommend using Docker, however you can also use a locally installed copy of Node v8.11.4 or higher.
2222

2323
**Starting Via Docker**
2424

@@ -103,7 +103,7 @@ Configuration
103103

104104
- **interval** (default: `60`) - The number of minutes between publishing the feed
105105

106-
- **network** (default: `hive`) - The network (chain) you're using this for. Options are: `hive`
106+
- **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`
107107

108108
- **peg** (default: `false`) - Set to true only if you want to adjust your price feed bias
109109

@@ -129,6 +129,9 @@ Just set the correct `network`, and those settings will be automatically updated
129129

130130
`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"]`
131131

132+
`chain_id` - Chain id of the chain that you are using. Default: `beeab0de00000000000000000000000000000000000000000000000000000000`
133+
134+
`address_prefix` - Address prefix of the chain that you are using. Default: `STM`
132135

133136
`disable_exchanges` - A list of exchange `code` 's to disable. Exchanges listed here will not be used
134137
directly (i.e. get price for A/B), nor indirectly (i.e. get price for A/D by converting A/C then C/D).

app.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ log(`Loaded configuration:
2222
Username: ${config.name}
2323
Bias: ${config.peg ? config.peg_multi : 'Disabled'}
2424
RPC Node: ${config.node}
25-
Alternate Nodes: ${config.alternate_nodes.join(", ")}`);
25+
Alternate Nodes: ${config.alternate_nodes.join(', ')}`);
2626
console.log('-------------');
2727

2828
global.verbose = false;
@@ -32,7 +32,7 @@ for (var t_arg of process.argv) {
3232
}
3333
}
3434

35-
hive.api.setOptions({url: config.node});
35+
hive.api.setOptions({url: config.node, address_prefix: config.address_prefix ,chain_id: config.chain_id})
3636

3737
// used for re-trying failed promises
3838
function delay(t) {
@@ -226,8 +226,8 @@ class HiveAcc {
226226
let signing = result.signing_key;
227227
if (signing_keys.hasOwnProperty(signing)) {
228228
let props = {
229-
"key": signing,
230-
"hbd_exchange_rate": exchangeRate
229+
'key': signing,
230+
'hbd_exchange_rate': exchangeRate
231231
};
232232
let op = hive.utils.buildWitnessUpdateOp(username, props);
233233
hive.broadcast.witnessSetProperties(signing_keys[signing], username, op[1].props, [], async (err, result) => {
@@ -364,7 +364,7 @@ function startup(){
364364
console.error(`An error occurred attempting to log into ${config.name}...`);
365365
console.error(`Reason: ${e}`, e);
366366
if (config.signing_keys === undefined || !Object.keys(config.signing_keys).length){
367-
console.error("Exiting");
367+
console.error('Exiting');
368368
process.exit(1);
369369
} else {
370370
console.log(`Trying again in ${config.interval} minute(s)`);

config.advanced.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
"peg_multi": 1.0,
1111
"node": "https://hivded.privex.io",
1212
"alternate_nodes" : ["https://api.deathwing.me", "https://api.hive.blog"],
13+
"chain_id" : "beeab0de00000000000000000000000000000000000000000000000000000000",
14+
"address_prefix" : "STM",
1315
"ex_symbol": "hive",
1416
"ex_compare": "usd",
1517
"base_symbol": "HBD",

lib/settings.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,19 @@ var settings = {
1818
var defaults = {
1919
hive: {
2020
node: 'https://hived.privex.io/',
21-
alternate_nodes : ["https://api.deathwing.me", "https://api.hive.blog"],
21+
alternate_nodes : ['https://api.deathwing.me', 'https://api.hive.blog'],
2222
ex_symbol: 'hive', ex_compare: 'usd',
2323
base_symbol: 'HBD', quote_symbol: 'HIVE',
24+
chain_id: 'beeab0de00000000000000000000000000000000000000000000000000000000',
25+
address_prefix : 'SMT',
26+
},
27+
testnet : {
28+
node: 'https://testnet.openhive.network/',
29+
alternate_nodes : [],
30+
ex_symbol: 'hive', ex_compare: 'usd',
31+
base_symbol: 'TBD', quote_symbol: 'TESTS',
32+
chain_id : '18dcf0a285365fc58b71f18b3d3fec954aa0c141c44e4e5cb4cf777b9eab274e',
33+
address_prefix : 'TST',
2434
}
2535
};
2636

@@ -31,6 +41,8 @@ var ndef = defaults[config.network];
3141

3242
if(!('node' in config)) { config.node = ndef.node; }
3343
if(!('alternate_nodes' in config)) { config.alternate_nodes = ndef.alternate_nodes; }
44+
if(!('chain_id' in config)) { config.chain_id = ndef.chain_id; }
45+
if(!('address_prefix' in config)) { config.address_prefix = ndef.address_prefix; }
3446
// disable peg by default. 0% peg (bias)
3547
if(!('peg' in config)) { config.peg = false; }
3648
if(!('peg_multi' in config)) { config.peg_multi = 1; }

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hivefeed-js",
3-
"version": "4.2.0",
3+
"version": "4.3.0",
44
"description": "Hive Price Feed in JS with automatic retry for down nodes",
55
"repository": "https://github.com/someguy123/hivefeed-js",
66
"main": "app.js",

0 commit comments

Comments
 (0)