Skip to content

Commit

Permalink
Merge branch 'develop' into fix/19125
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettbear authored Jul 24, 2023
2 parents 0c7a991 + 23c30d9 commit 288cdff
Show file tree
Hide file tree
Showing 148 changed files with 2,334 additions and 1,649 deletions.
21 changes: 11 additions & 10 deletions .github/workflows/stale-issues-pr.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: 'Close stale issues and PRs'

# run every 2 hours
on:
schedule:
- cron: '0 12 * * *'
- cron: '0 */2 * * *'

jobs:
stale:
Expand All @@ -12,17 +14,16 @@ jobs:
steps:
- uses: actions/stale@72afbce2b0dbd1d903bb142cebe2d15dc307ae57
with:
stale-issue-message: 'This issue has been automatically marked as stale because it has not had recent activity in the last 90 days. It will be closed in 45 days. Thank you for your contributions.'
stale-issue-label: 'stale'
only-issue-labels: 'type-bug'
exempt-issue-labels: 'type-security, type-pinned, feature-request, awaiting-metamask'
stale-pr-message: 'This PR has been automatically marked as stale because it has not had recent activity in the last 60 days. It will be closed in 14 days. Thank you for your contributions.'
stale-pr-label: 'stale'
exempt-pr-labels: 'work-in-progress'
close-issue-message: 'This issue was closed because there has been no follow up activity in the last 7 days. If you feel this was closed in error, please reopen and provide evidence on the latest release of the extension. Thank you for your contributions.'
close-pr-message: 'This PR was closed because there has been no follow up activity in the last 7 days. Thank you for your contributions.'
exempt-issue-labels: 'type-security'
days-before-issue-stale: 90
days-before-pr-stale: 60
stale-issue-message: 'This issue has been automatically marked as stale because it has not had recent activity in the last 90 days. It will be closed in 45 days if there is no further activity. The MetaMask team intends on reviewing this issue before close, and removing the stale label if it is still a bug. We welcome new comments on this issue. We do not intend on closing issues if they report bugs that are still reproducible. Thank you for your contributions.'
days-before-issue-close: 45
close-issue-message: 'This issue was closed because there has been no follow up activity in the last 45 days. If you feel this was closed in error, please reopen and provide evidence on the latest release of the extension. Thank you for your contributions.'
stale-pr-label: 'stale'
days-before-pr-stale: 60
stale-pr-message: 'This PR has been automatically marked as stale because it has not had recent activity in the last 60 days. It will be closed in 14 days. Thank you for your contributions.'
days-before-pr-close: 14
operations-per-run: 1
close-pr-message: 'This PR was closed because there has been no follow up activity in the last 14 days. Thank you for your contributions.'
operations-per-run: 600

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
diff --git a/dist/SignatureController.js b/dist/SignatureController.js
index a2f064efa2a2700db00767daa4ce6bd22b1932c4..17edb51b6c526f27fb4c19f2d2fda3d7140c66b4 100644
--- a/dist/SignatureController.js
+++ b/dist/SignatureController.js
@@ -283,8 +283,11 @@ _SignatureController_keyringController = new WeakMap(), _SignatureController_isE
resultCallbacks = acceptResult.resultCallbacks;
}
catch (_a) {
+ signaturePromise.catch(() => {
+ // Expecting reject error but throwing manually rather than waiting
+ });
__classPrivateFieldGet(this, _SignatureController_instances, "m", _SignatureController_cancelAbstractMessage).call(this, messageManager, messageId);
- throw eth_rpc_errors_1.ethErrors.provider.userRejectedRequest('User rejected the request.');
+ throw eth_rpc_errors_1.ethErrors.provider.userRejectedRequest(`MetaMask ${messageName} Signature: User denied message signature.`);
}
yield signMessage(messageParamsWithId, signingOpts);
const signatureResult = yield signaturePromise;
@@ -305,7 +308,7 @@ _SignatureController_keyringController = new WeakMap(), _SignatureController_isE
return __awaiter(this, void 0, void 0, function* () {
return yield __classPrivateFieldGet(this, _SignatureController_instances, "m", _SignatureController_signAbstractMessage).call(this, __classPrivateFieldGet(this, _SignatureController_personalMessageManager, "f"), controller_utils_1.ApprovalType.PersonalSign, msgParams, (cleanMsgParams) => __awaiter(this, void 0, void 0, function* () { return yield __classPrivateFieldGet(this, _SignatureController_keyringController, "f").signPersonalMessage(cleanMsgParams); }));
});
-}, _SignatureController_signTypedMessage = function _SignatureController_signTypedMessage(msgParams,
+}, _SignatureController_signTypedMessage = function _SignatureController_signTypedMessage(msgParams,
/* istanbul ignore next */
opts = { parseJsonData: true }) {
return __awaiter(this, void 0, void 0, function* () {
31 changes: 31 additions & 0 deletions app/_locales/en/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

81 changes: 61 additions & 20 deletions app/scripts/controllers/mmi-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ import EventEmitter from 'events';
import log from 'loglevel';
import { captureException } from '@sentry/browser';
import { isEqual } from 'lodash';
import {
PersonalMessageManager,
TypedMessageManager,
} from '@metamask/message-manager';
import { CUSTODIAN_TYPES } from '@metamask-institutional/custody-keyring';
import {
updateCustodianTransactions,
Expand Down Expand Up @@ -48,20 +44,10 @@ export default class MMIController extends EventEmitter {
this.metaMetricsController = opts.metaMetricsController;
this.networkController = opts.networkController;
this.permissionController = opts.permissionController;
this.signatureController = opts.signatureController;
this.platform = opts.platform;
this.extension = opts.extension;

this.personalMessageManager = new PersonalMessageManager(
undefined,
undefined,
this.securityProviderRequest,
);
this.typedMessageManager = new TypedMessageManager(
undefined,
undefined,
this.securityProviderRequest,
);

// Prepare event listener after transactionUpdateController gets initiated
this.transactionUpdateController.prepareEventListener(
this.custodianEventHandlerFactory.bind(this),
Expand All @@ -87,6 +73,20 @@ export default class MMIController extends EventEmitter {
await this.prepareMmiPortfolio();
}, this.preferencesController.store.getState()),
);

this.signatureController.hub.on(
'personal_sign:signed',
async ({ signature, messageId }) => {
await this.handleSigningEvents(signature, messageId, 'personal');
},
);

this.signatureController.hub.on(
'eth_signTypedData:signed',
async ({ signature, messageId }) => {
await this.handleSigningEvents(signature, messageId, 'v4');
},
);
} // End of constructor

async persistKeyringsAfterRefreshTokenChange() {
Expand All @@ -111,8 +111,7 @@ export default class MMIController extends EventEmitter {
getState: () => this.getState(),
getPendingNonce: (address) => this.getPendingNonce(address),
setTxHash: (txId, txHash) => this.txController.setTxHash(txId, txHash),
typedMessageManager: this.typedMessageManager,
personalMessageManager: this.personalMessageManager,
signatureController: this.signatureController,
txStateManager: this.txController.txStateManager,
custodyController: this.custodyController,
trackTransactionEvent:
Expand Down Expand Up @@ -185,9 +184,10 @@ export default class MMIController extends EventEmitter {
keyring,
type,
txList,
getPendingNonce: this.getPendingNonce.bind(this),
getPendingNonce: (address) => this.getPendingNonce(address),
setTxHash: (txId, txHash) =>
this.txController.setTxHash(txId, txHash),
txStateManager: this.txController.txStateManager,
setTxHash: this.txController.setTxHash.bind(this.txController),
custodyController: this.custodyController,
transactionUpdateController: this.transactionUpdateController,
});
Expand Down Expand Up @@ -542,8 +542,13 @@ export default class MMIController extends EventEmitter {
const getAccountDetails = (address) =>
this.custodyController.getAccountDetails(address);
const extensionId = this.extension.runtime.id;

const { networkConfigurations: networkConfigurationsById } =
this.networkController.state;
const networkConfigurations = Object.values(networkConfigurationsById);

const networks = [
...this.preferencesController.getRpcMethodPreferences(),
...networkConfigurations,
{ chainId: CHAIN_IDS.MAINNET },
{ chainId: CHAIN_IDS.GOERLI },
];
Expand Down Expand Up @@ -572,6 +577,42 @@ export default class MMIController extends EventEmitter {
}
}

async newUnsignedMessage(msgParams, req, version) {
const updatedMsgParams = { ...msgParams, deferSetAsSigned: true };

if (req.method.includes('eth_signTypedData')) {
return await this.signatureController.newUnsignedTypedMessage(
updatedMsgParams,
req,
version,
);
} else if (req.method.includes('personal_sign')) {
return await this.signatureController.newUnsignedPersonalMessage(
updatedMsgParams,
req,
);
}
return await this.signatureController.newUnsignedMessage(
updatedMsgParams,
req,
);
}

async handleSigningEvents(signature, messageId, signOperation) {
if (signature.custodian_transactionId) {
this.transactionUpdateController.addTransactionToWatchList(
signature.custodian_transactionId,
signature.from,
signOperation,
true,
);
}

this.signatureController.setMessageMetadata(messageId, signature);

return this.getState();
}

async setAccountAndNetwork(origin, address, chainId) {
await this.appStateController.getUnlockPromise(true);
const selectedAddress = this.preferencesController.getSelectedAddress();
Expand Down
15 changes: 15 additions & 0 deletions app/scripts/controllers/mmi-controller.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { KeyringController } from '@metamask/eth-keyring-controller';
import { MmiConfigurationController } from '@metamask-institutional/custody-keyring';
import { TransactionUpdateController } from '@metamask-institutional/transaction-update';
import { SignatureController } from '@metamask/signature-controller';

import MMIController from './mmi-controller';
import TransactionController from './transactions';
Expand Down Expand Up @@ -33,6 +34,20 @@ describe('MMIController', function () {
getNetworkId: jest.fn(),
onNetworkStateChange: jest.fn(),
}),
signatureController: new SignatureController({
messenger: {
registerActionHandler: jest.fn(),
publish: jest.fn(),
call: jest.fn(),
},
keyringController: new KeyringController({
initState: {},
}),
isEthSignEnabled: jest.fn(),
getAllState: jest.fn(),
securityProviderRequest: jest.fn(),
getCurrentChainId: jest.fn(),
}),
preferencesController: new PreferencesController({
initState: {},
onInfuraIsBlocked: jest.fn(),
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/lib/setupSentry.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,6 @@ function toMetamaskUrl(origUrl) {
if (!filePath) {
return origUrl;
}
const metamaskUrl = `metamask${filePath}`;
const metamaskUrl = `/metamask${filePath}`;
return metamaskUrl;
}
Loading

0 comments on commit 288cdff

Please sign in to comment.