Skip to content

Commit a3ccf2d

Browse files
committed
feat: Update all networks' chain and genesis hash when NetworkService
starts up
1 parent 1979e8a commit a3ccf2d

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

packages/neuron-wallet/src/services/networks.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,19 @@ export default class NetworksService extends Store {
4646
currentNetworkList,
4747
})
4848
Promise.all(currentNetworkList.map(n => {
49-
const core = new Core(n.remote)
50-
return core.rpc
51-
.getBlockchainInfo()
52-
.then(info => info.chain)
53-
.catch(() => '')
54-
.then(chain => ({
49+
if (n.type == NetworkType.Default) {
50+
return n
51+
} else {
52+
const core = new Core(n.remote)
53+
return Promise.all([
54+
core.rpc.getBlockchainInfo(),
55+
core.rpc.getBlockHash('0x0')
56+
]).then(([info, genesisHash]) => ({
5557
...n,
56-
chain,
58+
chain: info.chain,
59+
genesisHash
5760
}))
61+
}
5862
})).then(networkList => {
5963
this.updateAll(networkList)
6064
}).catch((err: Error) => {

0 commit comments

Comments
 (0)