Skip to content

Commit

Permalink
feat(neuron-ui): update chain types on launch
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-CY committed Nov 14, 2019
1 parent a7b463b commit 2cb5047
Showing 1 changed file with 16 additions and 0 deletions.
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

0 comments on commit 2cb5047

Please sign in to comment.