Commit 28b10397 authored by Mahdi Yari's avatar Mahdi Yari

Merge branch 'hf24-chainid-swap' into 'master'

Hf24 chainid swap

Closes #7

See merge request !5
parents 89a3d619 379a3d81
......@@ -6,7 +6,7 @@
"dev_uri": "",
"stage_uri": "",
"address_prefix": "STM",
"chain_id": "0000000000000000000000000000000000000000000000000000000000000000",
"chain_id": "beeab0de00000000000000000000000000000000000000000000000000000000",
"alternative_api_endpoints": ["https://api.hive.blog", "https://anyx.io"],
"failover_threshold": 3
}
{
"name": "@hiveio/hive-js",
"version": "0.1.0",
"version": "0.8.0",
"description": "Hive.js the JavaScript API for Hive blockchain",
"main": "lib/index.js",
"scripts": {
......
......@@ -8,6 +8,11 @@ import steemApi from '../api';
import steemAuth from '../auth';
import { camelCase } from '../utils';
const config = require('../config')
const HF23_CHAIN_ID = '0000000000000000000000000000000000000000000000000000000000000000'
const HF24_CHAIN_ID = 'beeab0de00000000000000000000000000000000000000000000000000000000'
const debug = newDebug('steem:broadcast');
const noop = function() {}
const formatter = formatterFactory(steemApi);
......@@ -51,19 +56,27 @@ steemBroadcast._prepareTransaction = function steemBroadcast$_prepareTransaction
const propertiesP = steemApi.getDynamicGlobalPropertiesAsync();
return propertiesP
.then((properties) => {
// Set defaults on the transaction
const chainDate = new Date(properties.time + 'Z');
const refBlockNum = (properties.last_irreversible_block_num - 1) & 0xFFFF;
return steemApi.getBlockHeaderAsync(properties.last_irreversible_block_num).then((block) => {
const headBlockId = block ? block.previous : '0000000000000000000000000000000000000000';
return Object.assign({
ref_block_num: refBlockNum,
ref_block_prefix: new Buffer(headBlockId, 'hex').readUInt32LE(4),
expiration: new Date(
chainDate.getTime() +
600 * 1000
),
}, tx);
const hfVersion = steemApi.getHardforkVersionAsync();
return hfVersion.then(HFV => {
if (HFV == '0.23.0') {
config.set('chain_id', HF23_CHAIN_ID)
} else {
config.set('chain_id', HF24_CHAIN_ID)
}
// Set defaults on the transaction
const chainDate = new Date(properties.time + 'Z');
const refBlockNum = (properties.last_irreversible_block_num - 1) & 0xFFFF;
return steemApi.getBlockHeaderAsync(properties.last_irreversible_block_num).then((block) => {
const headBlockId = block ? block.previous : '0000000000000000000000000000000000000000';
return Object.assign({
ref_block_num: refBlockNum,
ref_block_prefix: new Buffer(headBlockId, 'hex').readUInt32LE(4),
expiration: new Date(
chainDate.getTime() +
600 * 1000
),
}, tx);
});
});
});
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment