|
|
|
@ -217,13 +217,11 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
initializeProvider () { |
|
|
|
|
return this.networkController.initializeProvider({ |
|
|
|
|
const providerOpts = { |
|
|
|
|
static: { |
|
|
|
|
eth_syncing: false, |
|
|
|
|
web3_clientVersion: `MetaMask/v${version}`, |
|
|
|
|
}, |
|
|
|
|
// rpc data source
|
|
|
|
|
rpcUrl: this.networkController.getCurrentRpcAddress(), |
|
|
|
|
originHttpHeaderKey: 'X-Metamask-Origin', |
|
|
|
|
// account mgmt
|
|
|
|
|
getAccounts: (cb) => { |
|
|
|
@ -243,7 +241,9 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
|
processMessage: this.newUnsignedMessage.bind(this), |
|
|
|
|
// personal_sign msg signing
|
|
|
|
|
processPersonalMessage: this.newUnsignedPersonalMessage.bind(this), |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
const providerProxy = this.networkController.initializeProvider(providerOpts) |
|
|
|
|
return providerProxy |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
initPublicConfigStore () { |
|
|
|
@ -312,13 +312,14 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
|
const txController = this.txController |
|
|
|
|
const noticeController = this.noticeController |
|
|
|
|
const addressBookController = this.addressBookController |
|
|
|
|
const networkController = this.networkController |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
// etc
|
|
|
|
|
getState: (cb) => cb(null, this.getState()), |
|
|
|
|
setProviderType: this.networkController.setProviderType.bind(this.networkController), |
|
|
|
|
setCurrentCurrency: this.setCurrentCurrency.bind(this), |
|
|
|
|
markAccountsFound: this.markAccountsFound.bind(this), |
|
|
|
|
|
|
|
|
|
// coinbase
|
|
|
|
|
buyEth: this.buyEth.bind(this), |
|
|
|
|
// shapeshift
|
|
|
|
@ -333,12 +334,15 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
|
// vault management
|
|
|
|
|
submitPassword: this.submitPassword.bind(this), |
|
|
|
|
|
|
|
|
|
// network management
|
|
|
|
|
setProviderType: nodeify(networkController.setProviderType, networkController), |
|
|
|
|
setDefaultRpc: nodeify(this.setDefaultRpc, this), |
|
|
|
|
setCustomRpc: nodeify(this.setCustomRpc, this), |
|
|
|
|
|
|
|
|
|
// PreferencesController
|
|
|
|
|
setSelectedAddress: nodeify(preferencesController.setSelectedAddress, preferencesController), |
|
|
|
|
addToken: nodeify(preferencesController.addToken, preferencesController), |
|
|
|
|
setCurrentAccountTab: nodeify(preferencesController.setCurrentAccountTab, preferencesController), |
|
|
|
|
setDefaultRpc: nodeify(this.setDefaultRpc, this), |
|
|
|
|
setCustomRpc: nodeify(this.setCustomRpc, this), |
|
|
|
|
|
|
|
|
|
// AddressController
|
|
|
|
|
setAddressBook: nodeify(addressBookController.setAddressBook, addressBookController), |
|
|
|
@ -689,19 +693,19 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
|
createShapeShiftTx (depositAddress, depositType) { |
|
|
|
|
this.shapeshiftController.createShapeShiftTx(depositAddress, depositType) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// network
|
|
|
|
|
|
|
|
|
|
setDefaultRpc () { |
|
|
|
|
this.networkController.setRpcTarget('http://localhost:8545') |
|
|
|
|
return Promise.resolve('http://localhost:8545') |
|
|
|
|
async setDefaultRpc () { |
|
|
|
|
const localhost = 'http://localhost:8545' |
|
|
|
|
this.networkController.setRpcTarget(localhost) |
|
|
|
|
return localhost |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
setCustomRpc (rpcTarget, rpcList) { |
|
|
|
|
async setCustomRpc (rpcTarget, rpcList) { |
|
|
|
|
this.networkController.setRpcTarget(rpcTarget) |
|
|
|
|
|
|
|
|
|
return this.preferencesController.updateFrequentRpcList(rpcTarget) |
|
|
|
|
.then(() => { |
|
|
|
|
return Promise.resolve(rpcTarget) |
|
|
|
|
}) |
|
|
|
|
await this.preferencesController.updateFrequentRpcList(rpcTarget) |
|
|
|
|
return rpcTarget |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|