Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/neuron-wallet/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ const env: ENV = {
name: 'Testnet',
remote: 'http://localhost:8114',
type: 0,
chain: 'ckb_testnet',
chain: '',
},
{
id: 'local',
name: 'Local',
remote: 'http://localhost:8114',
type: 1,
chain: 'ckb_dev',
chain: '',
},
],
},
Expand Down
16 changes: 16 additions & 0 deletions packages/neuron-wallet/src/services/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Validate, Required } from 'decorators'
import { UsedName, NetworkNotFound, InvalidFormat } from 'exceptions'
import { NetworkListSubject, CurrentNetworkIDSubject } from 'models/subjects/networks'
import { NetworkID, NetworkName, NetworkRemote, NetworksKey, NetworkType, Network, NetworkWithID } from 'types/network'
import logger from 'utils/logger'

export const networkSwitchSubject = new BehaviorSubject<undefined | NetworkWithID>(undefined)

Expand All @@ -31,6 +32,21 @@ export default class NetworksService extends Store {
NetworkListSubject.next({
currentNetworkList,
})
Promise.all(currentNetworkList.map(n => {
const core = new Core(n.remote)
return core.rpc
.getBlockchainInfo()
.then(info => info.chain)
.catch(() => '')
.then(chain => ({
...n,
chain,
}))
})).then(networkList => {
this.updateAll(networkList)
}).catch((err: Error) => {
logger.error(err)
})
}
})

Expand Down