|
|
@ -231,6 +231,7 @@ export default class MetamaskController extends EventEmitter { |
|
|
|
initState: initState.TransactionController || initState.TransactionManager, |
|
|
|
initState: initState.TransactionController || initState.TransactionManager, |
|
|
|
getPermittedAccounts: this.permissionsController.getAccounts.bind(this.permissionsController), |
|
|
|
getPermittedAccounts: this.permissionsController.getAccounts.bind(this.permissionsController), |
|
|
|
networkStore: this.networkController.networkStore, |
|
|
|
networkStore: this.networkController.networkStore, |
|
|
|
|
|
|
|
getCurrentChainId: this.networkController.getCurrentChainId.bind(this.networkController), |
|
|
|
preferencesStore: this.preferencesController.store, |
|
|
|
preferencesStore: this.preferencesController.store, |
|
|
|
txHistoryLimit: 40, |
|
|
|
txHistoryLimit: 40, |
|
|
|
getNetwork: this.networkController.getNetworkState.bind(this), |
|
|
|
getNetwork: this.networkController.getNetworkState.bind(this), |
|
|
@ -382,6 +383,7 @@ export default class MetamaskController extends EventEmitter { |
|
|
|
createPublicConfigStore () { |
|
|
|
createPublicConfigStore () { |
|
|
|
// subset of state for metamask inpage provider
|
|
|
|
// subset of state for metamask inpage provider
|
|
|
|
const publicConfigStore = new ObservableStore() |
|
|
|
const publicConfigStore = new ObservableStore() |
|
|
|
|
|
|
|
const { networkController } = this |
|
|
|
|
|
|
|
|
|
|
|
// setup memStore subscription hooks
|
|
|
|
// setup memStore subscription hooks
|
|
|
|
this.on('update', updatePublicConfigStore) |
|
|
|
this.on('update', updatePublicConfigStore) |
|
|
@ -392,16 +394,17 @@ export default class MetamaskController extends EventEmitter { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function updatePublicConfigStore (memState) { |
|
|
|
function updatePublicConfigStore (memState) { |
|
|
|
|
|
|
|
const chainId = networkController.getCurrentChainId() |
|
|
|
if (memState.network !== 'loading') { |
|
|
|
if (memState.network !== 'loading') { |
|
|
|
publicConfigStore.putState(selectPublicState(memState)) |
|
|
|
publicConfigStore.putState(selectPublicState(chainId, memState)) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function selectPublicState ({ isUnlocked, network }) { |
|
|
|
function selectPublicState (chainId, { isUnlocked, network }) { |
|
|
|
return { |
|
|
|
return { |
|
|
|
isUnlocked, |
|
|
|
isUnlocked, |
|
|
|
chainId: network, |
|
|
|
chainId, |
|
|
|
networkVersion: Number.parseInt(network, 16).toString(), |
|
|
|
networkVersion: network, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return publicConfigStore |
|
|
|
return publicConfigStore |
|
|
|