|
|
@ -228,37 +228,21 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
|
|
|
|
|
|
|
|
initPublicConfigStore () { |
|
|
|
initPublicConfigStore () { |
|
|
|
// get init state
|
|
|
|
// get init state
|
|
|
|
var initPublicState = extend( |
|
|
|
var initPublicState = configToPublic(this.configManager.getConfig()) |
|
|
|
keyringControllerToPublic(this.keyringController.getState()), |
|
|
|
|
|
|
|
configToPublic(this.configManager.getConfig()) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var publicConfigStore = new HostStore(initPublicState) |
|
|
|
var publicConfigStore = new HostStore(initPublicState) |
|
|
|
|
|
|
|
|
|
|
|
// subscribe to changes
|
|
|
|
// subscribe to changes
|
|
|
|
this.configManager.subscribe(function (state) { |
|
|
|
this.configManager.subscribe(function (state) { |
|
|
|
storeSetFromObj(publicConfigStore, configToPublic(state)) |
|
|
|
storeSetFromObj(publicConfigStore, configToPublic(state)) |
|
|
|
}) |
|
|
|
}) |
|
|
|
this.keyringController.on('update', () => { |
|
|
|
|
|
|
|
const state = this.keyringController.getState() |
|
|
|
|
|
|
|
storeSetFromObj(publicConfigStore, keyringControllerToPublic(state)) |
|
|
|
|
|
|
|
this.sendUpdate() |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.keyringController.on('newAccount', (account) => { |
|
|
|
this.keyringController.on('newAccount', (account) => { |
|
|
|
autoFaucet(account) |
|
|
|
autoFaucet(account) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
// keyringController substate
|
|
|
|
|
|
|
|
function keyringControllerToPublic (state) { |
|
|
|
|
|
|
|
return { |
|
|
|
|
|
|
|
selectedAccount: state.selectedAccount, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// config substate
|
|
|
|
// config substate
|
|
|
|
function configToPublic (state) { |
|
|
|
function configToPublic (state) { |
|
|
|
return { |
|
|
|
return { |
|
|
|
provider: state.provider, |
|
|
|
|
|
|
|
selectedAccount: state.selectedAccount, |
|
|
|
selectedAccount: state.selectedAccount, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|