1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 09:57:02 +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,
ensController,
gasFeeController,
keyringController,
metaMetricsController,
networkController,
announcementController,
@ -1813,7 +1812,7 @@ export default class MetamaskController extends EventEmitter {
setLocked: this.setLocked.bind(this),
createNewVaultAndKeychain: this.createNewVaultAndKeychain.bind(this),
createNewVaultAndRestore: this.createNewVaultAndRestore.bind(this),
exportAccount: keyringController.exportAccount.bind(keyringController),
exportAccount: this.exportAccount.bind(this),
// 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) {
const details =
await this.assetsContractController.getTokenStandardAndDetails(

View File

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

View File

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