Skip to content

Commit 69ae0fb

Browse files
author
James Calfee
committed
Check chainId when constructing eos EOSIO#131
1 parent d303b11 commit 69ae0fb

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/index.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,15 @@ Eos.Localnet = development(api.Localnet)
6666
function createEos(config, Network, network) {
6767
config = Object.assign({}, config, {network})
6868

69-
config.assetCache =AssetCache(network)
69+
config.assetCache = AssetCache(network)
7070
config.abiCache = AbiCache(network, config)
7171

7272
if(!config.chainId) {
7373
config.chainId = 'a4fe43c897279a677025624555f3835b949f995f87923c97f0392dcff835bfd0'
7474
}
7575

76+
checkChainId(network, config.chainId)
77+
7678
if(config.mockTransactions != null) {
7779
if(typeof config.mockTransactions === 'string') {
7880
const mock = config.mockTransactions
@@ -244,3 +246,13 @@ const defaultSignProvider = (eos, config) => async function({sign, buf, transact
244246
return sigs
245247
})
246248
}
249+
250+
function checkChainId(network, chainId) {
251+
network.getInfo({}).then(info => {
252+
assert.equal(info.chain_id, chainId,
253+
'chainId mismatch, signatures will not match transaction authority'
254+
)
255+
}).catch(error => {
256+
console.error(error)
257+
})
258+
}

0 commit comments

Comments
 (0)