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