1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-26 04:20:53 +01:00

harden export account (#17241)

harden export account
This commit is contained in:
Michal 2023-01-17 15:01:12 +00:00 committed by GitHub
parent d5fea389e3
commit 49c8b279be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 6 deletions

View File

@ -1593,7 +1593,6 @@ export default class MetamaskController extends EventEmitter {
detectTokensController, detectTokensController,
ensController, ensController,
gasFeeController, gasFeeController,
keyringController,
metaMetricsController, metaMetricsController,
networkController, networkController,
announcementController, announcementController,
@ -1813,7 +1812,7 @@ export default class MetamaskController extends EventEmitter {
setLocked: this.setLocked.bind(this), setLocked: this.setLocked.bind(this),
createNewVaultAndKeychain: this.createNewVaultAndKeychain.bind(this), createNewVaultAndKeychain: this.createNewVaultAndKeychain.bind(this),
createNewVaultAndRestore: this.createNewVaultAndRestore.bind(this), createNewVaultAndRestore: this.createNewVaultAndRestore.bind(this),
exportAccount: keyringController.exportAccount.bind(keyringController), exportAccount: this.exportAccount.bind(this),
// txController // txController
cancelTransaction: txController.cancelTransaction.bind(txController), cancelTransaction: txController.cancelTransaction.bind(txController),
@ -2056,6 +2055,11 @@ export default class MetamaskController extends EventEmitter {
}; };
} }
async exportAccount(address, password) {
await this.verifyPassword(password);
return this.keyringController.exportAccount(address, password);
}
async getTokenStandardAndDetails(address, userAddress, tokenId) { async getTokenStandardAndDetails(address, userAddress, tokenId) {
const details = const details =
await this.assetsContractController.getTokenStandardAndDetails( await this.assetsContractController.getTokenStandardAndDetails(

View File

@ -2385,7 +2385,7 @@ export function exportAccount(password, address) {
log.debug(`background.exportAccount`); log.debug(`background.exportAccount`);
callBackgroundMethod( callBackgroundMethod(
'exportAccount', 'exportAccount',
[address], [address, password],
function (err2, result) { function (err2, result) {
dispatch(hideLoadingIndication()); dispatch(hideLoadingIndication());
@ -2421,7 +2421,7 @@ export function exportAccounts(password, addresses) {
new Promise((resolve2, reject2) => new Promise((resolve2, reject2) =>
callBackgroundMethod( callBackgroundMethod(
'exportAccount', 'exportAccount',
[address], [address, password],
function (err2, result) { function (err2, result) {
if (err2) { if (err2) {
log.error(err2); log.error(err2);

View File

@ -1259,7 +1259,7 @@ describe('Actions', () => {
const exportAccountStub = sinon const exportAccountStub = sinon
.stub() .stub()
.callsFake((_, cb) => cb(null, testPrivKey)); .callsFake((_, _2, cb) => cb(null, testPrivKey));
background.getApi.returns({ background.getApi.returns({
verifyPassword: verifyPasswordStub, verifyPassword: verifyPasswordStub,
@ -1318,7 +1318,7 @@ describe('Actions', () => {
const exportAccountStub = sinon const exportAccountStub = sinon
.stub() .stub()
.callsFake((_, cb) => cb(new Error('error'))); .callsFake((_, _2, cb) => cb(new Error('error')));
background.getApi.returns({ background.getApi.returns({
verifyPassword: verifyPasswordStub, verifyPassword: verifyPasswordStub,