|
|
@ -49,7 +49,7 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @constructor |
|
|
|
* @constructor |
|
|
|
* @param {Object} opts
|
|
|
|
* @param {Object} opts |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
constructor (opts) { |
|
|
|
constructor (opts) { |
|
|
|
super() |
|
|
|
super() |
|
|
@ -297,8 +297,8 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* The metamask-state of the various controllers, made available to the UI |
|
|
|
* The metamask-state of the various controllers, made available to the UI |
|
|
|
*
|
|
|
|
* |
|
|
|
* @returns {Object} status
|
|
|
|
* @returns {Object} status |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
getState () { |
|
|
|
getState () { |
|
|
|
const wallet = this.configManager.getWallet() |
|
|
|
const wallet = this.configManager.getWallet() |
|
|
@ -336,8 +336,8 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns an api-object which is consumed by the UI |
|
|
|
* Returns an api-object which is consumed by the UI |
|
|
|
*
|
|
|
|
* |
|
|
|
* @returns {Object}
|
|
|
|
* @returns {Object} |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
getApi () { |
|
|
|
getApi () { |
|
|
|
const keyringController = this.keyringController |
|
|
|
const keyringController = this.keyringController |
|
|
@ -367,7 +367,7 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
placeSeedWords: this.placeSeedWords.bind(this), |
|
|
|
placeSeedWords: this.placeSeedWords.bind(this), |
|
|
|
verifySeedPhrase: nodeify(this.verifySeedPhrase, this), |
|
|
|
verifySeedPhrase: nodeify(this.verifySeedPhrase, this), |
|
|
|
clearSeedWordCache: this.clearSeedWordCache.bind(this), |
|
|
|
clearSeedWordCache: this.clearSeedWordCache.bind(this), |
|
|
|
resetAccount: this.resetAccount.bind(this), |
|
|
|
resetAccount: nodeify(this.resetAccount, this), |
|
|
|
importAccountWithStrategy: this.importAccountWithStrategy.bind(this), |
|
|
|
importAccountWithStrategy: this.importAccountWithStrategy.bind(this), |
|
|
|
|
|
|
|
|
|
|
|
// vault management
|
|
|
|
// vault management
|
|
|
@ -428,14 +428,14 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Creates a new Vault(?) and create a new keychain(?) |
|
|
|
* Creates a new Vault(?) and create a new keychain(?) |
|
|
|
*
|
|
|
|
* |
|
|
|
* A vault is ... |
|
|
|
* A vault is ... |
|
|
|
*
|
|
|
|
* |
|
|
|
* A keychain is ... |
|
|
|
* A keychain is ... |
|
|
|
*
|
|
|
|
* |
|
|
|
* |
|
|
|
* |
|
|
|
* @param {} password |
|
|
|
* @param {} password |
|
|
|
*
|
|
|
|
* |
|
|
|
* @returns {} vault |
|
|
|
* @returns {} vault |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
async createNewVaultAndKeychain (password) { |
|
|
|
async createNewVaultAndKeychain (password) { |
|
|
@ -481,9 +481,9 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Retrieves the first Identiy from the passed Vault and selects the related address |
|
|
|
* Retrieves the first Identiy from the passed Vault and selects the related address |
|
|
|
*
|
|
|
|
* |
|
|
|
* An Identity is ... |
|
|
|
* An Identity is ... |
|
|
|
*
|
|
|
|
* |
|
|
|
* @param {} vault |
|
|
|
* @param {} vault |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
selectFirstIdentity (vault) { |
|
|
|
selectFirstIdentity (vault) { |
|
|
@ -497,8 +497,8 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Adds a new account to ...
|
|
|
|
* Adds a new account to ... |
|
|
|
*
|
|
|
|
* |
|
|
|
* @returns {} keyState |
|
|
|
* @returns {} keyState |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
async addNewAccount () { |
|
|
|
async addNewAccount () { |
|
|
@ -524,10 +524,10 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Adds the current vault's seed words to the UI's state tree. |
|
|
|
* Adds the current vault's seed words to the UI's state tree. |
|
|
|
*
|
|
|
|
* |
|
|
|
* Used when creating a first vault, to allow confirmation. |
|
|
|
* Used when creating a first vault, to allow confirmation. |
|
|
|
* Also used when revealing the seed words in the confirmation view. |
|
|
|
* Also used when revealing the seed words in the confirmation view. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
placeSeedWords (cb) { |
|
|
|
placeSeedWords (cb) { |
|
|
|
|
|
|
|
|
|
|
|
this.verifySeedPhrase() |
|
|
|
this.verifySeedPhrase() |
|
|
@ -542,7 +542,7 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Verifies the validity of the current vault's seed phrase. |
|
|
|
* Verifies the validity of the current vault's seed phrase. |
|
|
|
*
|
|
|
|
* |
|
|
|
* Validity: seed phrase restores the accounts belonging to the current vault. |
|
|
|
* Validity: seed phrase restores the accounts belonging to the current vault. |
|
|
|
* |
|
|
|
* |
|
|
|
* Called when the first account is created and on unlocking the vault. |
|
|
|
* Called when the first account is created and on unlocking the vault. |
|
|
@ -573,27 +573,32 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Remove the primary account seed phrase from the UI's state tree. |
|
|
|
* Remove the primary account seed phrase from the UI's state tree. |
|
|
|
*
|
|
|
|
* |
|
|
|
* The seed phrase remains available in the background process. |
|
|
|
* The seed phrase remains available in the background process. |
|
|
|
*
|
|
|
|
* |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
clearSeedWordCache (cb) { |
|
|
|
clearSeedWordCache (cb) { |
|
|
|
this.configManager.setSeedWords(null) |
|
|
|
this.configManager.setSeedWords(null) |
|
|
|
cb(null, this.preferencesController.getSelectedAddress()) |
|
|
|
cb(null, this.preferencesController.getSelectedAddress()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* ? |
|
|
|
* ? |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
resetAccount (cb) { |
|
|
|
async resetAccount (cb) { |
|
|
|
const selectedAddress = this.preferencesController.getSelectedAddress() |
|
|
|
const selectedAddress = this.preferencesController.getSelectedAddress() |
|
|
|
this.txController.wipeTransactions(selectedAddress) |
|
|
|
this.txController.wipeTransactions(selectedAddress) |
|
|
|
cb(null, selectedAddress) |
|
|
|
|
|
|
|
|
|
|
|
const networkController = this.networkController |
|
|
|
|
|
|
|
const oldType = networkController.getProviderConfig().type |
|
|
|
|
|
|
|
await networkController.setProviderType(oldType, true) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return selectedAddress |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Imports an account ... ? |
|
|
|
* Imports an account ... ? |
|
|
|
*
|
|
|
|
* |
|
|
|
* @param {} strategy |
|
|
|
* @param {} strategy |
|
|
|
* @param {} args |
|
|
|
* @param {} args |
|
|
|
* @param {} cb |
|
|
|
* @param {} cb |
|
|
@ -636,9 +641,9 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Prefixed Style Message Signing Methods:
|
|
|
|
// Prefixed Style Message Signing Methods:
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
*
|
|
|
|
* |
|
|
|
* @param {} msgParams |
|
|
|
* @param {} msgParams |
|
|
|
* @param {} cb |
|
|
|
* @param {} cb |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -657,7 +662,7 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @param {} msgParams |
|
|
|
* @param {} msgParams |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -678,7 +683,7 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
return this.getState() |
|
|
|
return this.getState() |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @param {} msgParams |
|
|
|
* @param {} msgParams |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -699,13 +704,13 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
return this.getState() |
|
|
|
return this.getState() |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// Account Restauration
|
|
|
|
// Account Restauration
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* ? |
|
|
|
* ? |
|
|
|
*
|
|
|
|
* |
|
|
|
* @param {} migratorOutput |
|
|
|
* @param {} migratorOutput |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
restoreOldVaultAccounts (migratorOutput) { |
|
|
|
restoreOldVaultAccounts (migratorOutput) { |
|
|
@ -716,7 +721,7 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* ? |
|
|
|
* ? |
|
|
|
*
|
|
|
|
* |
|
|
|
* @param {} migratorOutput |
|
|
|
* @param {} migratorOutput |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
restoreOldLostAccounts (migratorOutput) { |
|
|
|
restoreOldLostAccounts (migratorOutput) { |
|
|
@ -730,9 +735,9 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Import (lost) Accounts |
|
|
|
* Import (lost) Accounts |
|
|
|
*
|
|
|
|
* |
|
|
|
* @param {Object} {lostAccounts} @Array accounts <{ address, privateKey }> |
|
|
|
* @param {Object} {lostAccounts} @Array accounts <{ address, privateKey }> |
|
|
|
*
|
|
|
|
* |
|
|
|
* Uses the array's private keys to create a new Simple Key Pair keychain |
|
|
|
* Uses the array's private keys to create a new Simple Key Pair keychain |
|
|
|
* and add it to the keyring controller. |
|
|
|
* and add it to the keyring controller. |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -825,7 +830,7 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
if (cb && typeof cb === 'function') { |
|
|
|
if (cb && typeof cb === 'function') { |
|
|
|
cb(null, this.getState()) |
|
|
|
cb(null, this.getState()) |
|
|
|
} |
|
|
|
} |
|
|
|
}
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
cancelPersonalMessage (msgId, cb) { |
|
|
|
cancelPersonalMessage (msgId, cb) { |
|
|
|
const messageManager = this.personalMessageManager |
|
|
|
const messageManager = this.personalMessageManager |
|
|
@ -980,7 +985,7 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
const percentileNum = percentile(50, lowestPrices) |
|
|
|
const percentileNum = percentile(50, lowestPrices) |
|
|
|
const percentileNumBn = new BN(percentileNum) |
|
|
|
const percentileNumBn = new BN(percentileNum) |
|
|
|
return '0x' + percentileNumBn.mul(GWEI_BN).toString(16) |
|
|
|
return '0x' + percentileNumBn.mul(GWEI_BN).toString(16) |
|
|
|
}
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//=============================================================================
|
|
|
|
// CONFIG
|
|
|
|
// CONFIG
|
|
|
|