From c705b7d79a1d1342f43f084c68574a1564059c78 Mon Sep 17 00:00:00 2001 From: Richard Liu Date: Sun, 29 Jan 2023 19:47:42 -0800 Subject: [PATCH 1/6] initial boilerplate for plume sig --- app/scripts/background.js | 14 + .../lib/createRPCMethodTrackingMiddleware.js | 6 + app/scripts/lib/plume-signature-manager.js | 307 ++++++++++++++++++ app/scripts/metamask-controller.js | 51 +++ shared/constants/app.ts | 1 + 5 files changed, 379 insertions(+) create mode 100644 app/scripts/lib/plume-signature-manager.js diff --git a/app/scripts/background.js b/app/scripts/background.js index 9ea1a9de9778..6e2a8afebf83 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -608,6 +608,10 @@ function setupController(initState, initLangCode) { METAMASK_CONTROLLER_EVENTS.UPDATE_BADGE, updateBadge, ); + controller.plumeSignatureManager.on( + METAMASK_CONTROLLER_EVENTS.UPDATE_BADGE, + updateBadge, + ); controller.typedMessageManager.on( METAMASK_CONTROLLER_EVENTS.UPDATE_BADGE, updateBadge, @@ -649,6 +653,7 @@ function setupController(initState, initLangCode) { const { unapprovedDecryptMsgCount } = controller.decryptMessageManager; const { unapprovedEncryptionPublicKeyMsgCount } = controller.encryptionPublicKeyManager; + const { unapprovedPlumeMsgCount } = controller.plumeSignatureManager; const { unapprovedTypedMessagesCount } = controller.typedMessageManager; const pendingApprovalCount = controller.approvalController.getTotalApprovalCount(); @@ -660,6 +665,7 @@ function setupController(initState, initLangCode) { unapprovedPersonalMsgCount + unapprovedDecryptMsgCount + unapprovedEncryptionPublicKeyMsgCount + + unapprovedPlumeMsgCount + unapprovedTypedMessagesCount + pendingApprovalCount + waitingForUnlockCount @@ -723,6 +729,14 @@ function setupController(initState, initLangCode) { REJECT_NOTFICIATION_CLOSE, ), ); + controller.plumeSignatureManager.messages + .filter((msg) => msg.status === 'unapproved') + .forEach((tx) => + controller.plumeSignatureManager.rejectMsg( + tx.id, + REJECT_NOTFICIATION_CLOSE, + ), + ); // Finally, resolve snap dialog approvals on Flask and reject all the others managed by the ApprovalController. Object.values(controller.approvalController.state.pendingApprovals).forEach( diff --git a/app/scripts/lib/createRPCMethodTrackingMiddleware.js b/app/scripts/lib/createRPCMethodTrackingMiddleware.js index 8829bf5e2dd0..541a02a58cbf 100644 --- a/app/scripts/lib/createRPCMethodTrackingMiddleware.js +++ b/app/scripts/lib/createRPCMethodTrackingMiddleware.js @@ -22,6 +22,7 @@ const RATE_LIMIT_MAP = { [MESSAGE_TYPE.ETH_SIGN_TYPED_DATA]: RATE_LIMIT_TYPES.NON_RATE_LIMITED, [MESSAGE_TYPE.ETH_SIGN_TYPED_DATA_V3]: RATE_LIMIT_TYPES.NON_RATE_LIMITED, [MESSAGE_TYPE.ETH_SIGN_TYPED_DATA_V4]: RATE_LIMIT_TYPES.NON_RATE_LIMITED, + [MESSAGE_TYPE.ETH_GET_PLUME_SIGNATURE]: RATE_LIMIT_TYPES.NON_RATE_LIMITED, [MESSAGE_TYPE.PERSONAL_SIGN]: RATE_LIMIT_TYPES.NON_RATE_LIMITED, [MESSAGE_TYPE.ETH_DECRYPT]: RATE_LIMIT_TYPES.NON_RATE_LIMITED, [MESSAGE_TYPE.ETH_GET_ENCRYPTION_PUBLIC_KEY]: @@ -53,6 +54,11 @@ const EVENT_NAME_MAP = { REJECTED: EVENT_NAMES.SIGNATURE_REJECTED, REQUESTED: EVENT_NAMES.SIGNATURE_REQUESTED, }, + [MESSAGE_TYPE.ETH_GET_PLUME_SIGNATURE]: { + APPROVED: EVENT_NAMES.SIGNATURE_APPROVED, + REJECTED: EVENT_NAMES.SIGNATURE_REJECTED, + REQUESTED: EVENT_NAMES.SIGNATURE_REQUESTED, + }, [MESSAGE_TYPE.ETH_SIGN_TYPED_DATA_V4]: { APPROVED: EVENT_NAMES.SIGNATURE_APPROVED, REJECTED: EVENT_NAMES.SIGNATURE_REJECTED, diff --git a/app/scripts/lib/plume-signature-manager.js b/app/scripts/lib/plume-signature-manager.js new file mode 100644 index 000000000000..46d0330c874b --- /dev/null +++ b/app/scripts/lib/plume-signature-manager.js @@ -0,0 +1,307 @@ +import EventEmitter from 'events'; +import { ObservableStore } from '@metamask/obs-store'; +import { ethErrors } from 'eth-rpc-errors'; +import log from 'loglevel'; +import { MESSAGE_TYPE } from '../../../shared/constants/app'; +import { EVENT } from '../../../shared/constants/metametrics'; +import { METAMASK_CONTROLLER_EVENTS } from '../metamask-controller'; +import createId from '../../../shared/modules/random-id'; + +export default class PlumeSignatureManager extends EventEmitter { + /** + * Controller in charge of managing - storing, adding, removing, updating - PlumeSignatureManager. + * + * @param {object} opts - Controller options + * @param {Function} opts.metricEvent - A function for emitting a metric event. + */ + constructor(opts) { + super(); + this.memStore = new ObservableStore({ + unapprovedPlumeMsgs: {}, + unapprovedPlumeMsgCount: 0, + }); + + this.resetState = () => { + this.memStore.updateState({ + unapprovedPlumeMsgs: {}, + unapprovedPlumeMsgCount: 0, + }); + }; + + this.messages = []; + this.metricsEvent = opts.metricsEvent; + } + + /** + * A getter for the number of 'unapproved' PlumeMessages in this.messages + * + * @returns {number} The number of 'unapproved' PlumeMessages in this.messages + */ + get unapprovedPlumeMsgCount() { + return Object.keys(this.getUnapprovedMsgs()).length; + } + + /** + * A getter for the 'unapproved' PlumeMessages in this.messages + * + * @returns {object} An index of PlumeMessage ids to PlumeMessages, for all 'unapproved' PlumeMessages in + * this.messages + */ + getUnapprovedMsgs() { + return this.messages + .filter((msg) => msg.status === 'unapproved') + .reduce((result, msg) => { + result[msg.id] = msg; + return result; + }, {}); + } + + /** + * Creates a new PlumeMessage with an 'unapproved' status using the passed msgParams. this.addMsg is called to add + * the new PlumeMessage to this.messages, and to save the unapproved PlumeMessages from that list to + * this.memStore. + * + * @param {object} address - The param for the eth_getPlumeSignature call to be made after the message is approved. + * @param {object} [req] - The original request object possibly containing the origin + * @returns {Promise} The genereated plume signature + */ + addUnapprovedMessageAsync(address, req) { + return new Promise((resolve, reject) => { + if (!address) { + reject(new Error('MetaMask Message: address field is required.')); + return; + } + const msgId = this.addUnapprovedMessage(address, req); + this.once(`${msgId}:finished`, (data) => { + switch (data.status) { + case 'received': + resolve(data.rawData); + return; + case 'rejected': + reject( + ethErrors.provider.userRejectedRequest( + 'MetaMask PlumeSignature: User denied message PlumeSignature.', + ), + ); + return; + case 'errored': + reject(new Error('Plume signature error')); + return; + default: + reject( + new Error( + `MetaMask PlumeSignature: Unknown problem: ${JSON.stringify( + address, + )}`, + ), + ); + } + }); + }); + } + + /** + * Creates a new PlumeMessage with an 'unapproved' status using the passed msgParams. this.addMsg is called to add + * the new PlumeMessage to this.messages, and to save the unapproved PlumeMessages from that list to + * this.memStore. + * + * @param {object} address - The param for the eth_getPlumeSignature call to be made after the message is approved. + * @param {object} [req] - The original request object possibly containing the origin + * @returns {number} The id of the newly created PlumeMessage. + */ + addUnapprovedMessage(address, req) { + log.debug(`PlumeSignatureManager addUnapprovedMessage: ${address}`); + // create txData obj with parameters and meta data + const time = new Date().getTime(); + const msgId = createId(); + const msgData = { + id: msgId, + msgParams: address, + time, + status: 'unapproved', + type: MESSAGE_TYPE.ETH_GET_PLUME_SIGNATURE, + }; + + if (req) { + msgData.origin = req.origin; + } + + this.addMsg(msgData); + + // signal update + this.emit('update'); + return msgId; + } + + /** + * Adds a passed PlumeMessage to this.messages, and calls this._saveMsgList() to save the unapproved PlumeMessages from that + * list to this.memStore. + * + * @param {Message} msg - The PlumeMessage to add to this.messages + */ + addMsg(msg) { + this.messages.push(msg); + this._saveMsgList(); + } + + /** + * Returns a specified PlumeMessage. + * + * @param {number} msgId - The id of the PlumeMessage to get + * @returns {PlumeMessage|undefined} The PlumeMessage with the id that matches the passed msgId, or undefined + * if no PlumeMessage has that id. + */ + getMsg(msgId) { + return this.messages.find((msg) => msg.id === msgId); + } + + /** + * Approves a PlumeMessage. Sets the message status via a call to this.setMsgStatusApproved, and returns a promise + * with the message params modified for proper signing. + * + * @param {object} msgParams - The msgParams to be used when eth_getPlumeSignature is called, plus data added by MetaMask. + * @param {object} msgParams.metamaskId - Added to msgParams for tracking and identification within MetaMask. + * @returns {Promise} Promises the msgParams object with metamaskId removed. + */ + approveMessage(msgParams) { + this.setMsgStatusApproved(msgParams.metamaskId); + return this.prepMsgForPlumeSignature(msgParams); + } + + /** + * Sets a PlumeMessage status to 'approved' via a call to this._setMsgStatus. + * + * @param {number} msgId - The id of the PlumeMessage to approve. + */ + setMsgStatusApproved(msgId) { + this._setMsgStatus(msgId, 'approved'); + } + + /** + * Sets a PlumeMessage status to 'received' via a call to this._setMsgStatus and updates that PlumeMessage in + * this.messages by adding the raw data of the PlumeMessage request to the PlumeMessage + * + * @param {number} msgId - The id of the PlumeMessage. + * @param {buffer} rawData - The raw data of the message request + */ + setMsgStatusReceived(msgId, rawData) { + const msg = this.getMsg(msgId); + msg.rawData = rawData; + this._updateMsg(msg); + this._setMsgStatus(msgId, 'received'); + } + + /** + * Removes the metamaskId property from passed msgParams and returns a promise which resolves the updated msgParams + * + * @param {object} msgParams - The msgParams to modify + * @returns {Promise} Promises the msgParams with the metamaskId property removed + */ + prepMsgForPlumeSignature(msgParams) { + delete msgParams.metamaskId; + return Promise.resolve(msgParams); + } + + /** + * Sets a PlumeMessage status to 'rejected' via a call to this._setMsgStatus. + * + * @param {number} msgId - The id of the PlumeMessage to reject. + * @param reason + */ + rejectMsg(msgId, reason = undefined) { + if (reason) { + this.metricsEvent({ + event: reason, + category: EVENT.CATEGORIES.MESSAGES, + properties: { + action: 'Plume Message Request', + }, + }); + } + this._setMsgStatus(msgId, 'rejected'); + } + + /** + * Sets a TypedMessage status to 'errored' via a call to this._setMsgStatus. + * + * @param {number} msgId - The id of the TypedMessage to error + * @param error + */ + errorMessage(msgId, error) { + const msg = this.getMsg(msgId); + msg.error = error; + this._updateMsg(msg); + this._setMsgStatus(msgId, 'errored'); + } + + /** + * Clears all unapproved messages from memory. + */ + clearUnapproved() { + this.messages = this.messages.filter((msg) => msg.status !== 'unapproved'); + this._saveMsgList(); + } + + /** + * Updates the status of a PlumeMessage in this.messages via a call to this._updateMsg + * + * @private + * @param {number} msgId - The id of the PlumeMessage to update. + * @param {string} status - The new status of the PlumeMessage. + * @throws A 'PlumeMessageManager - PlumeMessage not found for id: "${msgId}".' if there is no PlumeMessage + * in this.messages with an id equal to the passed msgId + * @fires An event with a name equal to `${msgId}:${status}`. The PlumeMessage is also fired. + * @fires If status is 'rejected' or 'received', an event with a name equal to `${msgId}:finished` is fired along + * with the PlumeMessage + */ + _setMsgStatus(msgId, status) { + const msg = this.getMsg(msgId); + if (!msg) { + throw new Error( + `PlumeMessageManager - Message not found for id: "${msgId}".`, + ); + } + msg.status = status; + this._updateMsg(msg); + this.emit(`${msgId}:${status}`, msg); + if ( + status === 'rejected' || + status === 'received' || + status === 'errored' + ) { + this.emit(`${msgId}:finished`, msg); + } + } + + /** + * Sets a PlumeMessage in this.messages to the passed PlumeMessage if the ids are equal. Then saves the + * unapprovedMsgs index to storage via this._saveMsgList + * + * @private + * @param {PlumeMessage} msg - A PlumeMessage that will replace an existing PlumeMessage (with the same + * id) in this.messages + */ + _updateMsg(msg) { + const index = this.messages.findIndex((message) => message.id === msg.id); + if (index !== -1) { + this.messages[index] = msg; + } + this._saveMsgList(); + } + + /** + * Saves the unapproved PlumeMessages, and their count, to this.memStore + * + * @private + * @fires 'updateBadge' + */ + _saveMsgList() { + const unapprovedPlumeMsgs = this.getUnapprovedMsgs(); + const unapprovedPlumeMsgCount = Object.keys(unapprovedPlumeMsgs).length; + this.memStore.updateState({ + unapprovedPlumeMsgs, + unapprovedPlumeMsgCount, + }); + this.emit(METAMASK_CONTROLLER_EVENTS.UPDATE_BADGE); + } +} diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index ba94f8493546..b4e14122cd1b 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -135,6 +135,7 @@ import IncomingTransactionsController from './controllers/incoming-transactions' import MessageManager, { normalizeMsgData } from './lib/message-manager'; import DecryptMessageManager from './lib/decrypt-message-manager'; import EncryptionPublicKeyManager from './lib/encryption-public-key-manager'; +import PlumeSignatureManager from './lib/plume-signature-manager'; import PersonalMessageManager from './lib/personal-message-manager'; import TypedMessageManager from './lib/typed-message-manager'; import TransactionController from './controllers/transactions'; @@ -1023,6 +1024,11 @@ export default class MetamaskController extends EventEmitter { this.metaMetricsController, ), }); + this.plumeSignatureManager = new PlumeSignatureManager({ + metricsEvent: this.metaMetricsController.trackEvent.bind( + this.metaMetricsController, + ), + }); this.typedMessageManager = new TypedMessageManager({ getCurrentChainId: this.networkController.getCurrentChainId.bind( this.networkController, @@ -1126,6 +1132,7 @@ export default class MetamaskController extends EventEmitter { processTypedMessageV4: this.newUnsignedTypedMessage.bind(this), processPersonalMessage: this.newUnsignedPersonalMessage.bind(this), processDecryptMessage: this.newRequestDecryptMessage.bind(this), + processGetPlumeSignature: this.newRequestGetPlumeSignature.bind(this), processEncryptionPublicKey: this.newRequestEncryptionPublicKey.bind(this), getPendingNonce: this.getPendingNonce.bind(this), getPendingTransactionByHash: (hash) => @@ -3135,6 +3142,50 @@ export default class MetamaskController extends EventEmitter { return this.getState(); } + // eth_getPlumeSignature methods + + /** + * + * @param {object} msgParams - The params of the message to sign & return to the Dapp. + * @param {object} req - (optional) the original request, containing the origin + * Passed back to the requesting Dapp. + */ + async newRequestGetPlumeSignature(msgParams, req) { + const promise = this.plumeSignatureManager.addUnapprovedMessageAsync( + msgParams, + req, + ); + this.sendUpdate(); + this.opts.showUserConfirmation(); + return promise; + } + + /** + * Signifies a user's approval to receiving plume in queue. + * Triggers receiving, and the callback function from newUnsignedPlumeMessage. + * + * @param {object} msgParams - The params of the message to receive & return to the Dapp. + * @returns {Promise} A full state update. + */ + async getPlumeSignature(msgParams) { + log.info('MetaMaskController - plumeMessage'); + const msgId = msgParams.metamaskId; + // sets the status op the message to 'approved' + // and removes the metamaskId for decryption + try { + const params = await this.plumeSignatureManager.approveMessage(msgParams); + // TODO / FIXME: Import and use zk-nullifier library + const mockPlume = `mockPlume-${params.data}`; + + // tells the listener that the message has been decrypted and can be returned to the dapp + this.plumeSignatureManager.setMsgStatusReceived(msgId, mockPlume); + } catch (error) { + log.info('MetaMaskController - eth_getPlumeSignature failed.', error); + this.plumeSignatureManager.errorMessage(msgId, error); + } + return this.getState(); + } + // eth_decrypt methods /** diff --git a/shared/constants/app.ts b/shared/constants/app.ts index a84c02e7b119..05627954ca7d 100644 --- a/shared/constants/app.ts +++ b/shared/constants/app.ts @@ -47,6 +47,7 @@ export const MESSAGE_TYPE = { ETH_SIGN_TYPED_DATA: 'eth_signTypedData', ETH_SIGN_TYPED_DATA_V3: 'eth_signTypedData_v3', ETH_SIGN_TYPED_DATA_V4: 'eth_signTypedData_v4', + ETH_GET_PLUME_SIGNATURE: 'eth_getPlumeSignature', GET_PROVIDER_STATE: 'metamask_getProviderState', LOG_WEB3_SHIM_USAGE: 'metamask_logWeb3ShimUsage', PERSONAL_SIGN: 'personal_sign', From e7676205021728dbe3ddcbe7d8c8412fe20051f7 Mon Sep 17 00:00:00 2001 From: Richard Liu Date: Sun, 5 Feb 2023 04:49:34 -0800 Subject: [PATCH 2/6] working in browser -- TODO integrate logic --- .../controllers/permissions/specifications.js | 1 + app/scripts/lib/createMetamaskMiddleware.js | 3 +++ .../lib/createRPCMethodTrackingMiddleware.js | 5 +++++ app/scripts/lib/middleware/plume.js | 13 +++++++++++++ shared/constants/metametrics.js | 3 +++ ui/store/actions.js | 11 +++++++++++ 6 files changed, 36 insertions(+) create mode 100644 app/scripts/lib/middleware/plume.js diff --git a/app/scripts/controllers/permissions/specifications.js b/app/scripts/controllers/permissions/specifications.js index 3779a904a232..718c2e820df7 100644 --- a/app/scripts/controllers/permissions/specifications.js +++ b/app/scripts/controllers/permissions/specifications.js @@ -235,6 +235,7 @@ export const unrestrictedMethods = Object.freeze([ 'eth_getFilterChanges', 'eth_getFilterLogs', 'eth_getLogs', + 'eth_getPlumeSignature', 'eth_getProof', 'eth_getStorageAt', 'eth_getTransactionByBlockHashAndIndex', diff --git a/app/scripts/lib/createMetamaskMiddleware.js b/app/scripts/lib/createMetamaskMiddleware.js index cee6b9b95e2c..c74606d658b2 100644 --- a/app/scripts/lib/createMetamaskMiddleware.js +++ b/app/scripts/lib/createMetamaskMiddleware.js @@ -4,6 +4,7 @@ import { createPendingNonceMiddleware, createPendingTxMiddleware, } from './middleware/pending'; +import { createGetPlumeSignatureMiddleware } from './middleware/plume'; export default function createMetamaskMiddleware({ version, @@ -16,6 +17,7 @@ export default function createMetamaskMiddleware({ processPersonalMessage, processDecryptMessage, processEncryptionPublicKey, + getPlumeSignature, getPendingNonce, getPendingTransactionByHash, }) { @@ -37,6 +39,7 @@ export default function createMetamaskMiddleware({ }), createPendingNonceMiddleware({ getPendingNonce }), createPendingTxMiddleware({ getPendingTransactionByHash }), + createGetPlumeSignatureMiddleware({ getPlumeSignature }), ]); return metamaskMiddleware; } diff --git a/app/scripts/lib/createRPCMethodTrackingMiddleware.js b/app/scripts/lib/createRPCMethodTrackingMiddleware.js index 541a02a58cbf..6696c824c768 100644 --- a/app/scripts/lib/createRPCMethodTrackingMiddleware.js +++ b/app/scripts/lib/createRPCMethodTrackingMiddleware.js @@ -79,6 +79,11 @@ const EVENT_NAME_MAP = { REJECTED: EVENT_NAMES.ENCRYPTION_PUBLIC_KEY_REJECTED, REQUESTED: EVENT_NAMES.ENCRYPTION_PUBLIC_KEY_REQUESTED, }, + [MESSAGE_TYPE.ETH_GET_PLUME_SIGNATURE]: { + APPROVED: EVENT_NAMES.PLUME_APPROVED, + REJECTED: EVENT_NAMES.PLUME_REJECTED, + REQUESTED: EVENT_NAMES.PLUME_REQUESTED, + }, [MESSAGE_TYPE.ETH_REQUEST_ACCOUNTS]: { APPROVED: EVENT_NAMES.PERMISSIONS_APPROVED, REJECTED: EVENT_NAMES.PERMISSIONS_REJECTED, diff --git a/app/scripts/lib/middleware/plume.js b/app/scripts/lib/middleware/plume.js new file mode 100644 index 000000000000..505ba22dcc67 --- /dev/null +++ b/app/scripts/lib/middleware/plume.js @@ -0,0 +1,13 @@ +import { createAsyncMiddleware } from 'json-rpc-engine'; + +export function createGetPlumeSignatureMiddleware({ getPlumeSignature }) { + return createAsyncMiddleware(async (req, res, next) => { + const { method, params } = req; + if (method !== 'eth_getPlumeSignature') { + next(); + return; + } + res.result = `plume result ${params.data}`; + // TODO: Insert Plume logic here + }); +} diff --git a/shared/constants/metametrics.js b/shared/constants/metametrics.js index ef0fc26b5ffe..df2d086cc39b 100644 --- a/shared/constants/metametrics.js +++ b/shared/constants/metametrics.js @@ -331,6 +331,9 @@ export const EVENT_NAMES = { PERMISSIONS_APPROVED: 'Permissions Approved', PERMISSIONS_REJECTED: 'Permissions Rejected', PERMISSIONS_REQUESTED: 'Permissions Requested', + PLUME_APPROVED: 'Plume Approved', + PLUME_REJECTED: 'Plume Rejected', + PLUME_REQUESTED: 'Plume Requested', PORTFOLIO_LINK_CLICKED: 'Portfolio Link Clicked', PUBLIC_ADDRESS_COPIED: 'Public Address Copied', PROVIDER_METHOD_CALLED: 'Provider Method Called', diff --git a/ui/store/actions.js b/ui/store/actions.js index 2d18a4905759..a60e1e0f441e 100644 --- a/ui/store/actions.js +++ b/ui/store/actions.js @@ -1178,6 +1178,17 @@ export function cancelMsgs(msgDataList) { }, ); return; + case MESSAGE_TYPE.ETH_GET_PLUME_SIGNATURE: + // TODO: Remove + console.log('ETH_GET_PLUME_SIGNATURE'); + callBackgroundMethod('cancelGetPlumeSignature', [id], (err) => { + if (err) { + reject(err); + return; + } + resolve(); + }); + return; case MESSAGE_TYPE.ETH_SIGN: callBackgroundMethod('cancelMessage', [id], (err) => { if (err) { From 9d8ac5956b3a2b50de169d29ed43207a3c87674c Mon Sep 17 00:00:00 2001 From: Richard Liu Date: Tue, 7 Feb 2023 11:11:41 -0800 Subject: [PATCH 3/6] add plume-sig --- package.json | 1 + yarn.lock | 885 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 883 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 99b5e45eb32b..be95a2093041 100644 --- a/package.json +++ b/package.json @@ -312,6 +312,7 @@ "nonce-tracker": "^1.0.0", "obj-multiplex": "^1.0.0", "pify": "^5.0.0", + "plume-sig": "^1.0.0", "promise-to-callback": "^1.0.0", "prop-types": "^15.6.1", "pubnub": "4.27.3", diff --git a/yarn.lock b/yarn.lock index e4b3744c0012..4434efe1dd47 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2685,6 +2685,20 @@ __metadata: languageName: node linkType: hard +"@jest/console@npm:^29.4.2": + version: 29.4.2 + resolution: "@jest/console@npm:29.4.2" + dependencies: + "@jest/types": ^29.4.2 + "@types/node": "*" + chalk: ^4.0.0 + jest-message-util: ^29.4.2 + jest-util: ^29.4.2 + slash: ^3.0.0 + checksum: 2c44449689494104c0c703567849f165718be3413263cf113aeda5a52a46c0aebf64d86ea077e19cf8b2078c67430461cc95f79e47cab3690b2483a34113d065 + languageName: node + linkType: hard + "@jest/core@npm:^28.1.3": version: 28.1.3 resolution: "@jest/core@npm:28.1.3" @@ -2768,6 +2782,47 @@ __metadata: languageName: node linkType: hard +"@jest/core@npm:^29.4.2": + version: 29.4.2 + resolution: "@jest/core@npm:29.4.2" + dependencies: + "@jest/console": ^29.4.2 + "@jest/reporters": ^29.4.2 + "@jest/test-result": ^29.4.2 + "@jest/transform": ^29.4.2 + "@jest/types": ^29.4.2 + "@types/node": "*" + ansi-escapes: ^4.2.1 + chalk: ^4.0.0 + ci-info: ^3.2.0 + exit: ^0.1.2 + graceful-fs: ^4.2.9 + jest-changed-files: ^29.4.2 + jest-config: ^29.4.2 + jest-haste-map: ^29.4.2 + jest-message-util: ^29.4.2 + jest-regex-util: ^29.4.2 + jest-resolve: ^29.4.2 + jest-resolve-dependencies: ^29.4.2 + jest-runner: ^29.4.2 + jest-runtime: ^29.4.2 + jest-snapshot: ^29.4.2 + jest-util: ^29.4.2 + jest-validate: ^29.4.2 + jest-watcher: ^29.4.2 + micromatch: ^4.0.4 + pretty-format: ^29.4.2 + slash: ^3.0.0 + strip-ansi: ^6.0.0 + peerDependencies: + node-notifier: ^8.0.1 || ^9.0.0 || ^10.0.0 + peerDependenciesMeta: + node-notifier: + optional: true + checksum: 9ef41d55a9ab49d808179b93584921157106fe48ed5cedfeefd6b8a7a25b074175d6d5aaa50b093e891ccb60fb3719fdd44e39dcaad2f439733341a799a737c8 + languageName: node + linkType: hard + "@jest/environment@npm:^28.1.3": version: 28.1.3 resolution: "@jest/environment@npm:28.1.3" @@ -2792,6 +2847,18 @@ __metadata: languageName: node linkType: hard +"@jest/environment@npm:^29.4.2": + version: 29.4.2 + resolution: "@jest/environment@npm:29.4.2" + dependencies: + "@jest/fake-timers": ^29.4.2 + "@jest/types": ^29.4.2 + "@types/node": "*" + jest-mock: ^29.4.2 + checksum: 007a2db50b4245b80d3dae189773773634ab8f013adfc7ad41654ae03bcd4e620d472bcd1b58629b1744653f8de07335b71dd00f83d8d0d73170f91c8c07a2d7 + languageName: node + linkType: hard + "@jest/expect-utils@npm:^28.1.3": version: 28.1.3 resolution: "@jest/expect-utils@npm:28.1.3" @@ -2810,6 +2877,15 @@ __metadata: languageName: node linkType: hard +"@jest/expect-utils@npm:^29.4.2": + version: 29.4.2 + resolution: "@jest/expect-utils@npm:29.4.2" + dependencies: + jest-get-type: ^29.4.2 + checksum: 5d23a09a4f85f0cb8da3bac3a6118efe4365dce6923702bc7f1a0edf36699c5c91d9c77e95349e71e305d36ae35d4e06086c923bf9635ccf3fffda05cc7cc2e8 + languageName: node + linkType: hard + "@jest/expect@npm:^28.1.3": version: 28.1.3 resolution: "@jest/expect@npm:28.1.3" @@ -2830,6 +2906,16 @@ __metadata: languageName: node linkType: hard +"@jest/expect@npm:^29.4.2": + version: 29.4.2 + resolution: "@jest/expect@npm:29.4.2" + dependencies: + expect: ^29.4.2 + jest-snapshot: ^29.4.2 + checksum: b15eaa66dad33a080cfeceaed0c170163fbc1544e59b5fe42480edde333f0ef2fb789bf1f99e7e258663b5e8878af0ae0e9ad7898336230245d6f95538b5435f + languageName: node + linkType: hard + "@jest/fake-timers@npm:^28.1.3": version: 28.1.3 resolution: "@jest/fake-timers@npm:28.1.3" @@ -2858,6 +2944,20 @@ __metadata: languageName: node linkType: hard +"@jest/fake-timers@npm:^29.4.2": + version: 29.4.2 + resolution: "@jest/fake-timers@npm:29.4.2" + dependencies: + "@jest/types": ^29.4.2 + "@sinonjs/fake-timers": ^10.0.2 + "@types/node": "*" + jest-message-util: ^29.4.2 + jest-mock: ^29.4.2 + jest-util: ^29.4.2 + checksum: 22f322614668a910ff393f8ba0b7c865cb37a101ab1af6cfc3247e09fdce6737797e6075193fb24b94239865c35f2dce43cb43ea1ae712e23bd23c3f857e3386 + languageName: node + linkType: hard + "@jest/globals@npm:^28.1.3": version: 28.1.3 resolution: "@jest/globals@npm:28.1.3" @@ -2881,6 +2981,18 @@ __metadata: languageName: node linkType: hard +"@jest/globals@npm:^29.4.2": + version: 29.4.2 + resolution: "@jest/globals@npm:29.4.2" + dependencies: + "@jest/environment": ^29.4.2 + "@jest/expect": ^29.4.2 + "@jest/types": ^29.4.2 + jest-mock: ^29.4.2 + checksum: 6914fbc7c3dbc92f1d73639764c872476e24ca21c629373f35a63cd7e9f8df4635ab4a10e8057e87a7e6a45febcf4ee80d09e92feafce7c938f7496bc359a1a8 + languageName: node + linkType: hard + "@jest/reporters@npm:^28.1.3": version: 28.1.3 resolution: "@jest/reporters@npm:28.1.3" @@ -2957,6 +3069,43 @@ __metadata: languageName: node linkType: hard +"@jest/reporters@npm:^29.4.2": + version: 29.4.2 + resolution: "@jest/reporters@npm:29.4.2" + dependencies: + "@bcoe/v8-coverage": ^0.2.3 + "@jest/console": ^29.4.2 + "@jest/test-result": ^29.4.2 + "@jest/transform": ^29.4.2 + "@jest/types": ^29.4.2 + "@jridgewell/trace-mapping": ^0.3.15 + "@types/node": "*" + chalk: ^4.0.0 + collect-v8-coverage: ^1.0.0 + exit: ^0.1.2 + glob: ^7.1.3 + graceful-fs: ^4.2.9 + istanbul-lib-coverage: ^3.0.0 + istanbul-lib-instrument: ^5.1.0 + istanbul-lib-report: ^3.0.0 + istanbul-lib-source-maps: ^4.0.0 + istanbul-reports: ^3.1.3 + jest-message-util: ^29.4.2 + jest-util: ^29.4.2 + jest-worker: ^29.4.2 + slash: ^3.0.0 + string-length: ^4.0.1 + strip-ansi: ^6.0.0 + v8-to-istanbul: ^9.0.1 + peerDependencies: + node-notifier: ^8.0.1 || ^9.0.0 || ^10.0.0 + peerDependenciesMeta: + node-notifier: + optional: true + checksum: 5f7525d9c382a06c7d4003e5c2c345ddc1d7f76ff45f66f89253f640e2d361e87a96bacda2b5dca2b7d777b06ae48adb86daaba2b5bb62d68f2db4ee74d868c9 + languageName: node + linkType: hard + "@jest/schemas@npm:^28.1.3": version: 28.1.3 resolution: "@jest/schemas@npm:28.1.3" @@ -2975,6 +3124,15 @@ __metadata: languageName: node linkType: hard +"@jest/schemas@npm:^29.4.2": + version: 29.4.2 + resolution: "@jest/schemas@npm:29.4.2" + dependencies: + "@sinclair/typebox": ^0.25.16 + checksum: 85d9416dce85604400e65ba0b2146fea5ba313612d6d1fa8f39c30bcb42fabd7120193d277327fb10228ea3112f3b83e914bc7ab42137d19a1e1c37093f32363 + languageName: node + linkType: hard + "@jest/source-map@npm:^28.1.2": version: 28.1.2 resolution: "@jest/source-map@npm:28.1.2" @@ -2997,6 +3155,17 @@ __metadata: languageName: node linkType: hard +"@jest/source-map@npm:^29.4.2": + version: 29.4.2 + resolution: "@jest/source-map@npm:29.4.2" + dependencies: + "@jridgewell/trace-mapping": ^0.3.15 + callsites: ^3.0.0 + graceful-fs: ^4.2.9 + checksum: 362ad36a84354939e5f2dee6a081b4b3558e0f96d3d5d6afbb9dc6142c7d34490516f2906aa2950b1fd0293fde5965c9c9d6c56d0d04c8e3bd8cc20148b1251c + languageName: node + linkType: hard + "@jest/test-result@npm:^28.1.3": version: 28.1.3 resolution: "@jest/test-result@npm:28.1.3" @@ -3021,6 +3190,18 @@ __metadata: languageName: node linkType: hard +"@jest/test-result@npm:^29.4.2": + version: 29.4.2 + resolution: "@jest/test-result@npm:29.4.2" + dependencies: + "@jest/console": ^29.4.2 + "@jest/types": ^29.4.2 + "@types/istanbul-lib-coverage": ^2.0.0 + collect-v8-coverage: ^1.0.0 + checksum: 2dddcd761cf07f5ccd694ec30cd7775c1e31377da922d5a33e60185d76143566c7bee2b5fa85202300536bc3c11730e1a0e7d821309f5e52b8f1f9c146f3aabf + languageName: node + linkType: hard + "@jest/test-sequencer@npm:^28.1.3": version: 28.1.3 resolution: "@jest/test-sequencer@npm:28.1.3" @@ -3045,6 +3226,18 @@ __metadata: languageName: node linkType: hard +"@jest/test-sequencer@npm:^29.4.2": + version: 29.4.2 + resolution: "@jest/test-sequencer@npm:29.4.2" + dependencies: + "@jest/test-result": ^29.4.2 + graceful-fs: ^4.2.9 + jest-haste-map: ^29.4.2 + slash: ^3.0.0 + checksum: efa99382c73930d5ad529c23f5aafb8ba68fb194f113203aa3c3aca757352bed7926020b24dc2824a3f860a65aff330da6a09215930fef694db33f1298245d43 + languageName: node + linkType: hard + "@jest/transform@npm:^26.6.2": version: 26.6.2 resolution: "@jest/transform@npm:26.6.2" @@ -3114,6 +3307,29 @@ __metadata: languageName: node linkType: hard +"@jest/transform@npm:^29.4.2": + version: 29.4.2 + resolution: "@jest/transform@npm:29.4.2" + dependencies: + "@babel/core": ^7.11.6 + "@jest/types": ^29.4.2 + "@jridgewell/trace-mapping": ^0.3.15 + babel-plugin-istanbul: ^6.1.1 + chalk: ^4.0.0 + convert-source-map: ^2.0.0 + fast-json-stable-stringify: ^2.1.0 + graceful-fs: ^4.2.9 + jest-haste-map: ^29.4.2 + jest-regex-util: ^29.4.2 + jest-util: ^29.4.2 + micromatch: ^4.0.4 + pirates: ^4.0.4 + slash: ^3.0.0 + write-file-atomic: ^4.0.2 + checksum: 3c653dff6ccaa010e83789d22582217b02fe9919f46d50ba07157a6004c9153edec987efba51edf0c261b409f6178e4fa1e34e59ce8dd4cb5c2197d42b30960e + languageName: node + linkType: hard + "@jest/types@npm:^25.5.0": version: 25.5.0 resolution: "@jest/types@npm:25.5.0" @@ -3167,6 +3383,20 @@ __metadata: languageName: node linkType: hard +"@jest/types@npm:^29.4.2": + version: 29.4.2 + resolution: "@jest/types@npm:29.4.2" + dependencies: + "@jest/schemas": ^29.4.2 + "@types/istanbul-lib-coverage": ^2.0.0 + "@types/istanbul-reports": ^3.0.0 + "@types/node": "*" + "@types/yargs": ^17.0.8 + chalk: ^4.0.0 + checksum: da2caa2c1d3ce7461167faddf9a4158a4be5c900e44f22db9c370b189c804b7492051c635a8c0c62ac4e41aff3bc6c324a008043e193bc5d6ce7b44aaa449258 + languageName: node + linkType: hard + "@jridgewell/gen-mapping@npm:^0.1.0": version: 0.1.1 resolution: "@jridgewell/gen-mapping@npm:0.1.1" @@ -4744,6 +4974,13 @@ __metadata: languageName: node linkType: hard +"@sinclair/typebox@npm:^0.25.16": + version: 0.25.21 + resolution: "@sinclair/typebox@npm:0.25.21" + checksum: 763af1163fe4eabee9b914d4e4548a39fbba3287d2b3b1ff043c1da3c5a321e99d50a3ca94eb182988131e00b006a6f019799cde8da2f61e2f118b30b0276a00 + languageName: node + linkType: hard + "@sindresorhus/is@npm:^0.14.0": version: 0.14.0 resolution: "@sindresorhus/is@npm:0.14.0" @@ -4767,6 +5004,24 @@ __metadata: languageName: node linkType: hard +"@sinonjs/commons@npm:^2.0.0": + version: 2.0.0 + resolution: "@sinonjs/commons@npm:2.0.0" + dependencies: + type-detect: 4.0.8 + checksum: 5023ba17edf2b85ed58262313b8e9b59e23c6860681a9af0200f239fe939e2b79736d04a260e8270ddd57196851dde3ba754d7230be5c5234e777ae2ca8af137 + languageName: node + linkType: hard + +"@sinonjs/fake-timers@npm:^10.0.2": + version: 10.0.2 + resolution: "@sinonjs/fake-timers@npm:10.0.2" + dependencies: + "@sinonjs/commons": ^2.0.0 + checksum: c62aa98e7cefda8dedc101ce227abc888dc46b8ff9706c5f0a8dfd9c3ada97d0a5611384738d9ba0b26b59f99c2ba24efece8e779bb08329e9e87358fa309824 + languageName: node + linkType: hard + "@sinonjs/fake-timers@npm:^6.0.0": version: 6.0.1 resolution: "@sinonjs/fake-timers@npm:6.0.1" @@ -8823,6 +9078,15 @@ __metadata: languageName: node linkType: hard +"amcl-js@npm:^3.0.0": + version: 3.0.0 + resolution: "amcl-js@npm:3.0.0" + dependencies: + prompt: ^1.0.0 + checksum: 66c6c0fbf00aa1a9deed0f2fd6ba18e84eea9674135815b5b0e10f5f1944da5ffb22639e9b1ab28d650dab6e4fe3920f1b850bc7d55c02d6db13929008ed5878 + languageName: node + linkType: hard + "amdefine@npm:>=0.0.4": version: 1.0.1 resolution: "amdefine@npm:1.0.1" @@ -9552,6 +9816,13 @@ __metadata: languageName: node linkType: hard +"async@npm:3.2.3": + version: 3.2.3 + resolution: "async@npm:3.2.3" + checksum: c4bee57ab2249af3dc83ca3ef9acfa8e822c0d5e5aa41bae3eaf7f673648343cd64ecd7d26091ffd357f3f044428b17b5f00098494b6cf8b6b3e9681f0636ca1 + languageName: node + linkType: hard + "async@npm:^1.4.2": version: 1.5.2 resolution: "async@npm:1.5.2" @@ -9746,6 +10017,23 @@ __metadata: languageName: node linkType: hard +"babel-jest@npm:^29.4.2": + version: 29.4.2 + resolution: "babel-jest@npm:29.4.2" + dependencies: + "@jest/transform": ^29.4.2 + "@types/babel__core": ^7.1.14 + babel-plugin-istanbul: ^6.1.1 + babel-preset-jest: ^29.4.2 + chalk: ^4.0.0 + graceful-fs: ^4.2.9 + slash: ^3.0.0 + peerDependencies: + "@babel/core": ^7.8.0 + checksum: 294b90e8193d72fb5d194126ce62d9d306cb1c1292f4737302c01c2a43d8975be9a476b001e43334fb63a1d25c9b5ea62e59d907cf1ff877e94d78772f3c7813 + languageName: node + linkType: hard + "babel-loader@npm:^8.0.0": version: 8.2.5 resolution: "babel-loader@npm:8.2.5" @@ -9844,6 +10132,18 @@ __metadata: languageName: node linkType: hard +"babel-plugin-jest-hoist@npm:^29.4.2": + version: 29.4.2 + resolution: "babel-plugin-jest-hoist@npm:29.4.2" + dependencies: + "@babel/template": ^7.3.3 + "@babel/types": ^7.3.3 + "@types/babel__core": ^7.1.14 + "@types/babel__traverse": ^7.0.6 + checksum: 674be77ed8cef3e55ac4a4b829aaf1cb81b5f20930f6e1018979cef0008cd67a4fa66ee7fc6b13eee4569c3daba4f172f57c21dfca35f3a1d18d7910c50cc6dd + languageName: node + linkType: hard + "babel-plugin-macros@npm:^2.0.0": version: 2.8.0 resolution: "babel-plugin-macros@npm:2.8.0" @@ -10008,6 +10308,18 @@ __metadata: languageName: node linkType: hard +"babel-preset-jest@npm:^29.4.2": + version: 29.4.2 + resolution: "babel-preset-jest@npm:29.4.2" + dependencies: + babel-plugin-jest-hoist: ^29.4.2 + babel-preset-current-node-syntax: ^1.0.0 + peerDependencies: + "@babel/core": ^7.0.0 + checksum: e4fa9855441a6eff0dcde1ccb15c25d27efcdfc6be7d4e6b53e446a8f172cd68fd17022d9bd9140dda12ee345da2b7370ad4e66a288889f7318a4713e89953c0 + languageName: node + linkType: hard + "babel-runtime@npm:^6.26.0": version: 6.26.0 resolution: "babel-runtime@npm:6.26.0" @@ -12116,6 +12428,13 @@ __metadata: languageName: node linkType: hard +"colors@npm:1.0.x": + version: 1.0.3 + resolution: "colors@npm:1.0.3" + checksum: 234e8d3ab7e4003851cdd6a1f02eaa16dabc502ee5f4dc576ad7959c64b7477b15bd21177bab4055a4c0a66aa3d919753958030445f87c39a253d73b7a3637f5 + languageName: node + linkType: hard + "colors@npm:1.4.0": version: 1.4.0 resolution: "colors@npm:1.4.0" @@ -12495,6 +12814,13 @@ __metadata: languageName: node linkType: hard +"convert-source-map@npm:^2.0.0": + version: 2.0.0 + resolution: "convert-source-map@npm:2.0.0" + checksum: 63ae9933be5a2b8d4509daca5124e20c14d023c820258e484e32dc324d34c2754e71297c94a05784064ad27615037ef677e3f0c00469fb55f409d2bb21261035 + languageName: node + linkType: hard + "convert-source-map@patch:convert-source-map@npm%3A1.1.3#./.yarn/patches/convert-source-map-npm-1.1.3-7f1bfeabd4.patch::locator=metamask-crx%40workspace%3A.": version: 1.1.3 resolution: "convert-source-map@patch:convert-source-map@npm%3A1.1.3#./.yarn/patches/convert-source-map-npm-1.1.3-7f1bfeabd4.patch::version=1.1.3&hash=1551e3&locator=metamask-crx%40workspace%3A." @@ -13123,6 +13449,13 @@ __metadata: languageName: node linkType: hard +"cycle@npm:1.0.x": + version: 1.0.3 + resolution: "cycle@npm:1.0.3" + checksum: b9f131094fb832a8c4ba18c6d2dc9c87fc80d3242847a45f0a5f70911b2acab68abc1c25eb23e5155fcf2135a27d8fcc3635556745b03b488c4f360cfbc352df + languageName: node + linkType: hard + "cyclist@npm:~0.2.2": version: 0.2.2 resolution: "cyclist@npm:0.2.2" @@ -13898,6 +14231,13 @@ __metadata: languageName: node linkType: hard +"diff-sequences@npm:^29.4.2": + version: 29.4.2 + resolution: "diff-sequences@npm:29.4.2" + checksum: 70a9f7c5516fb62f7e2fb5aea8d9580cc319880b364779093669fa8e7bc6c47b7251e0e9f0d3289a4db0263708fbf0baa81f4305c2b839dd06b4771159835d31 + languageName: node + linkType: hard + "diff@npm:3.5.0": version: 3.5.0 resolution: "diff@npm:3.5.0" @@ -16335,6 +16675,19 @@ __metadata: languageName: node linkType: hard +"expect@npm:^29.4.2": + version: 29.4.2 + resolution: "expect@npm:29.4.2" + dependencies: + "@jest/expect-utils": ^29.4.2 + jest-get-type: ^29.4.2 + jest-matcher-utils: ^29.4.2 + jest-message-util: ^29.4.2 + jest-util: ^29.4.2 + checksum: 32315804ec40011b4550b03b5549579b57af4d5d9b109727ecc611ee9fc911de9c40a174333bee7972ddc5732260592e3a9f37c82bf4f5851fb36e6f0eae7ff1 + languageName: node + linkType: hard + "express-graphql@npm:^0.11.0": version: 0.11.0 resolution: "express-graphql@npm:0.11.0" @@ -16492,6 +16845,13 @@ __metadata: languageName: node linkType: hard +"eyes@npm:0.1.x": + version: 0.1.8 + resolution: "eyes@npm:0.1.8" + checksum: c31703a92bf36ba75ee8d379ee7985c24ee6149f3a6175f44cec7a05b178c38bce9836d3ca48c9acb0329a960ac2c4b2ead4e60cdd4fe6e8c92cad7cd6913687 + languageName: node + linkType: hard + "fake-merkle-patricia-tree@npm:^1.0.1": version: 1.0.1 resolution: "fake-merkle-patricia-tree@npm:1.0.1" @@ -20733,7 +21093,7 @@ __metadata: languageName: node linkType: hard -"isstream@npm:~0.1.2": +"isstream@npm:0.1.x, isstream@npm:~0.1.2": version: 0.1.2 resolution: "isstream@npm:0.1.2" checksum: 1eb2fe63a729f7bdd8a559ab552c69055f4f48eb5c2f03724430587c6f450783c8f1cd936c1c952d0a927925180fcc892ebd5b174236cf1065d4bd5bdb37e963 @@ -20886,6 +21246,16 @@ __metadata: languageName: node linkType: hard +"jest-changed-files@npm:^29.4.2": + version: 29.4.2 + resolution: "jest-changed-files@npm:29.4.2" + dependencies: + execa: ^5.0.0 + p-limit: ^3.1.0 + checksum: 44e4541479a8aabffa96e73ec42c88a155255edef797c3d5cc6a482ef10935564958f3135529c390a154dad8191a698818fa0dcdd8ea25c83d6b9e1ca270f869 + languageName: node + linkType: hard + "jest-circus@npm:^28.0.0, jest-circus@npm:^28.1.3": version: 28.1.3 resolution: "jest-circus@npm:28.1.3" @@ -20940,6 +21310,33 @@ __metadata: languageName: node linkType: hard +"jest-circus@npm:^29.4.2": + version: 29.4.2 + resolution: "jest-circus@npm:29.4.2" + dependencies: + "@jest/environment": ^29.4.2 + "@jest/expect": ^29.4.2 + "@jest/test-result": ^29.4.2 + "@jest/types": ^29.4.2 + "@types/node": "*" + chalk: ^4.0.0 + co: ^4.6.0 + dedent: ^0.7.0 + is-generator-fn: ^2.0.0 + jest-each: ^29.4.2 + jest-matcher-utils: ^29.4.2 + jest-message-util: ^29.4.2 + jest-runtime: ^29.4.2 + jest-snapshot: ^29.4.2 + jest-util: ^29.4.2 + p-limit: ^3.1.0 + pretty-format: ^29.4.2 + slash: ^3.0.0 + stack-utils: ^2.0.3 + checksum: d16022eb3dbab097a85da2d1857b77bc4c478f8a19bf518e1554791cf462180c9d54e36765ba3c6ce98a4332c362604f662501639cdd57572852ebd64f1010ed + languageName: node + linkType: hard + "jest-cli@npm:^28.1.3": version: 28.1.3 resolution: "jest-cli@npm:28.1.3" @@ -20994,6 +21391,33 @@ __metadata: languageName: node linkType: hard +"jest-cli@npm:^29.4.2": + version: 29.4.2 + resolution: "jest-cli@npm:29.4.2" + dependencies: + "@jest/core": ^29.4.2 + "@jest/test-result": ^29.4.2 + "@jest/types": ^29.4.2 + chalk: ^4.0.0 + exit: ^0.1.2 + graceful-fs: ^4.2.9 + import-local: ^3.0.2 + jest-config: ^29.4.2 + jest-util: ^29.4.2 + jest-validate: ^29.4.2 + prompts: ^2.0.1 + yargs: ^17.3.1 + peerDependencies: + node-notifier: ^8.0.1 || ^9.0.0 || ^10.0.0 + peerDependenciesMeta: + node-notifier: + optional: true + bin: + jest: bin/jest.js + checksum: 7ce0d82c877e0ab57c02fbfca050b4d3742d0eced497c52d2d0d2f15af2e59481fc3c25ee0734bcc2d8b8af880312c470bd9f4bf180b65e3a82cfa978039ffe5 + languageName: node + linkType: hard + "jest-config@npm:^28.1.3": version: 28.1.3 resolution: "jest-config@npm:28.1.3" @@ -21070,6 +21494,44 @@ __metadata: languageName: node linkType: hard +"jest-config@npm:^29.4.2": + version: 29.4.2 + resolution: "jest-config@npm:29.4.2" + dependencies: + "@babel/core": ^7.11.6 + "@jest/test-sequencer": ^29.4.2 + "@jest/types": ^29.4.2 + babel-jest: ^29.4.2 + chalk: ^4.0.0 + ci-info: ^3.2.0 + deepmerge: ^4.2.2 + glob: ^7.1.3 + graceful-fs: ^4.2.9 + jest-circus: ^29.4.2 + jest-environment-node: ^29.4.2 + jest-get-type: ^29.4.2 + jest-regex-util: ^29.4.2 + jest-resolve: ^29.4.2 + jest-runner: ^29.4.2 + jest-util: ^29.4.2 + jest-validate: ^29.4.2 + micromatch: ^4.0.4 + parse-json: ^5.2.0 + pretty-format: ^29.4.2 + slash: ^3.0.0 + strip-json-comments: ^3.1.1 + peerDependencies: + "@types/node": "*" + ts-node: ">=9.0.0" + peerDependenciesMeta: + "@types/node": + optional: true + ts-node: + optional: true + checksum: 4d0a2ea90a9387462242a6f39ad19898703706f82c63f59cdb5687728256c3bac5809e10af2a34dccb602e5c47b44403f56373fe42cd606f1bbc4c21667cf839 + languageName: node + linkType: hard + "jest-diff@npm:^26.0.0": version: 26.6.2 resolution: "jest-diff@npm:26.6.2" @@ -21106,6 +21568,18 @@ __metadata: languageName: node linkType: hard +"jest-diff@npm:^29.4.2": + version: 29.4.2 + resolution: "jest-diff@npm:29.4.2" + dependencies: + chalk: ^4.0.0 + diff-sequences: ^29.4.2 + jest-get-type: ^29.4.2 + pretty-format: ^29.4.2 + checksum: 5f8ee70ed2cbfa8a76b7614e9d0736fc218a786df500aae6c5876ad7c58f658901fec7777112dc404e7146582c1537564d570eb7b989922f0dfcb3d6c8844952 + languageName: node + linkType: hard + "jest-docblock@npm:^28.1.1": version: 28.1.1 resolution: "jest-docblock@npm:28.1.1" @@ -21124,6 +21598,15 @@ __metadata: languageName: node linkType: hard +"jest-docblock@npm:^29.4.2": + version: 29.4.2 + resolution: "jest-docblock@npm:29.4.2" + dependencies: + detect-newline: ^3.0.0 + checksum: b79a9da3098535762e9d0e4c298b4e958cef7a0065ebf9afca36391dd82d123be3d497289d55e6829664a939e92f93108474d69c715bec28b459e571634fcb93 + languageName: node + linkType: hard + "jest-each@npm:^28.1.3": version: 28.1.3 resolution: "jest-each@npm:28.1.3" @@ -21150,6 +21633,19 @@ __metadata: languageName: node linkType: hard +"jest-each@npm:^29.4.2": + version: 29.4.2 + resolution: "jest-each@npm:29.4.2" + dependencies: + "@jest/types": ^29.4.2 + chalk: ^4.0.0 + jest-get-type: ^29.4.2 + jest-util: ^29.4.2 + pretty-format: ^29.4.2 + checksum: 51471971032fcd23f659f90f9d821e7b815fe75421cc66a0489fdd4d309f01ad64c14c87e0e819342341d411d633bf02e9eb1657f16ed402271aa5427c8b8fe1 + languageName: node + linkType: hard + "jest-environment-jsdom@npm:^29.1.2": version: 29.1.2 resolution: "jest-environment-jsdom@npm:29.1.2" @@ -21194,6 +21690,20 @@ __metadata: languageName: node linkType: hard +"jest-environment-node@npm:^29.4.2": + version: 29.4.2 + resolution: "jest-environment-node@npm:29.4.2" + dependencies: + "@jest/environment": ^29.4.2 + "@jest/fake-timers": ^29.4.2 + "@jest/types": ^29.4.2 + "@types/node": "*" + jest-mock: ^29.4.2 + jest-util: ^29.4.2 + checksum: b0ff0ebf45889aaa2e7f1b6ad93be8ba98fd11cf74a2b049d74990db197028f4f24fcf9145b25722c5c0c241f4126f617e1a79a44305a9d4bbeb9d18724887b4 + languageName: node + linkType: hard + "jest-get-type@npm:^26.3.0": version: 26.3.0 resolution: "jest-get-type@npm:26.3.0" @@ -21215,6 +21725,13 @@ __metadata: languageName: node linkType: hard +"jest-get-type@npm:^29.4.2": + version: 29.4.2 + resolution: "jest-get-type@npm:29.4.2" + checksum: 52b69cfdc8817a106ed58b44ac0ee77df36073d0deb7357ea9eb208fd8fb9be2abcc2cc6d72019460b7ca262687da482c47bd9c357eb2fbe52279397739e8c11 + languageName: node + linkType: hard + "jest-haste-map@npm:^26.6.2": version: 26.6.2 resolution: "jest-haste-map@npm:26.6.2" @@ -21286,6 +21803,29 @@ __metadata: languageName: node linkType: hard +"jest-haste-map@npm:^29.4.2": + version: 29.4.2 + resolution: "jest-haste-map@npm:29.4.2" + dependencies: + "@jest/types": ^29.4.2 + "@types/graceful-fs": ^4.1.3 + "@types/node": "*" + anymatch: ^3.0.3 + fb-watchman: ^2.0.0 + fsevents: ^2.3.2 + graceful-fs: ^4.2.9 + jest-regex-util: ^29.4.2 + jest-util: ^29.4.2 + jest-worker: ^29.4.2 + micromatch: ^4.0.4 + walker: ^1.0.8 + dependenciesMeta: + fsevents: + optional: true + checksum: 0aa4a66702f020ea7e6a0ce58c6d2ef363c8f9f4302254f865dab4e1c6e9ac3926db088a42893a7207cc77559d563f6e8f396430f9bfb7784c3cc81862151df0 + languageName: node + linkType: hard + "jest-junit@npm:^14.0.0, jest-junit@npm:^14.0.1": version: 14.0.1 resolution: "jest-junit@npm:14.0.1" @@ -21318,6 +21858,16 @@ __metadata: languageName: node linkType: hard +"jest-leak-detector@npm:^29.4.2": + version: 29.4.2 + resolution: "jest-leak-detector@npm:29.4.2" + dependencies: + jest-get-type: ^29.4.2 + pretty-format: ^29.4.2 + checksum: d4df0cd2dbf0e79d25966d12907865f09c37847c14e86a1604ff50c4e824e42d9f7bbae19f8e03c06fc0fffa9cefad9bf667920db36164ae157701f41498b0bf + languageName: node + linkType: hard + "jest-matcher-utils@npm:^28.1.3": version: 28.1.3 resolution: "jest-matcher-utils@npm:28.1.3" @@ -21342,6 +21892,18 @@ __metadata: languageName: node linkType: hard +"jest-matcher-utils@npm:^29.4.2": + version: 29.4.2 + resolution: "jest-matcher-utils@npm:29.4.2" + dependencies: + chalk: ^4.0.0 + jest-diff: ^29.4.2 + jest-get-type: ^29.4.2 + pretty-format: ^29.4.2 + checksum: e8549f8534f31ae60c81b6c5f690b5dd6d42190318165bba943b3d2c278730c59b4933d5941c70e577f08c0c633b7d92edec43696b79a5cce8e2b4080cccae3c + languageName: node + linkType: hard + "jest-message-util@npm:^28.1.3": version: 28.1.3 resolution: "jest-message-util@npm:28.1.3" @@ -21376,6 +21938,23 @@ __metadata: languageName: node linkType: hard +"jest-message-util@npm:^29.4.2": + version: 29.4.2 + resolution: "jest-message-util@npm:29.4.2" + dependencies: + "@babel/code-frame": ^7.12.13 + "@jest/types": ^29.4.2 + "@types/stack-utils": ^2.0.0 + chalk: ^4.0.0 + graceful-fs: ^4.2.9 + micromatch: ^4.0.4 + pretty-format: ^29.4.2 + slash: ^3.0.0 + stack-utils: ^2.0.3 + checksum: d3b32fbf5c16100817bdf6d3eaae0cf618d39df62df0c9e8dcfa2ffc9fe2afb0c71312b9b86d4afb33b87795dc1dc3b7f7f024ae1fe21e818d2caf90c3ba6fdc + languageName: node + linkType: hard + "jest-mock@npm:^28.1.3": version: 28.1.3 resolution: "jest-mock@npm:28.1.3" @@ -21397,6 +21976,17 @@ __metadata: languageName: node linkType: hard +"jest-mock@npm:^29.4.2": + version: 29.4.2 + resolution: "jest-mock@npm:29.4.2" + dependencies: + "@jest/types": ^29.4.2 + "@types/node": "*" + jest-util: ^29.4.2 + checksum: 8fa94bb71a0a12feeedd79ff3d7467cb249b8504a5dbad24acc060cdd9b2fbe96c67206f4c4c2b1da5d1b56bda8f9d5f1715632f82b3a9ed9d2ad97b05b519c5 + languageName: node + linkType: hard + "jest-playwright-preset@npm:^2.0.0": version: 2.0.0 resolution: "jest-playwright-preset@npm:2.0.0" @@ -21467,6 +22057,13 @@ __metadata: languageName: node linkType: hard +"jest-regex-util@npm:^29.4.2": + version: 29.4.2 + resolution: "jest-regex-util@npm:29.4.2" + checksum: a85bb9b5c64e57dba3fba1fe1a93eb78b53b5bb98c78fa3b5876baf3b831d8fc3067c05e93c0115b3100e7e3046d1109bc01671407527f8691742604be459a66 + languageName: node + linkType: hard + "jest-resolve-dependencies@npm:^28.1.3": version: 28.1.3 resolution: "jest-resolve-dependencies@npm:28.1.3" @@ -21487,6 +22084,16 @@ __metadata: languageName: node linkType: hard +"jest-resolve-dependencies@npm:^29.4.2": + version: 29.4.2 + resolution: "jest-resolve-dependencies@npm:29.4.2" + dependencies: + jest-regex-util: ^29.4.2 + jest-snapshot: ^29.4.2 + checksum: f961b70c8c921b36c7dc4577c2823a78a0967604802cd2f3f294d2c8c2e7e7b03817127014b3c1affa8b786960ad410e903de995e78f889d7444be878181da8d + languageName: node + linkType: hard + "jest-resolve@npm:^28.1.3": version: 28.1.3 resolution: "jest-resolve@npm:28.1.3" @@ -21521,6 +22128,23 @@ __metadata: languageName: node linkType: hard +"jest-resolve@npm:^29.4.2": + version: 29.4.2 + resolution: "jest-resolve@npm:29.4.2" + dependencies: + chalk: ^4.0.0 + graceful-fs: ^4.2.9 + jest-haste-map: ^29.4.2 + jest-pnp-resolver: ^1.2.2 + jest-util: ^29.4.2 + jest-validate: ^29.4.2 + resolve: ^1.20.0 + resolve.exports: ^2.0.0 + slash: ^3.0.0 + checksum: 94fac5d1438d90aefc24d4ee29f89a96c4b35ab8effdd582341310a1478b895bd3d48f4ccadbc69e56344f6bb5d03bcce8eba045b5a71609f571d91bb5c0ef73 + languageName: node + linkType: hard + "jest-runner@npm:^28.0.0, jest-runner@npm:^28.1.3": version: 28.1.3 resolution: "jest-runner@npm:28.1.3" @@ -21579,6 +22203,35 @@ __metadata: languageName: node linkType: hard +"jest-runner@npm:^29.4.2": + version: 29.4.2 + resolution: "jest-runner@npm:29.4.2" + dependencies: + "@jest/console": ^29.4.2 + "@jest/environment": ^29.4.2 + "@jest/test-result": ^29.4.2 + "@jest/transform": ^29.4.2 + "@jest/types": ^29.4.2 + "@types/node": "*" + chalk: ^4.0.0 + emittery: ^0.13.1 + graceful-fs: ^4.2.9 + jest-docblock: ^29.4.2 + jest-environment-node: ^29.4.2 + jest-haste-map: ^29.4.2 + jest-leak-detector: ^29.4.2 + jest-message-util: ^29.4.2 + jest-resolve: ^29.4.2 + jest-runtime: ^29.4.2 + jest-util: ^29.4.2 + jest-watcher: ^29.4.2 + jest-worker: ^29.4.2 + p-limit: ^3.1.0 + source-map-support: 0.5.13 + checksum: c5a7540f79083bca9f642095efdff91981ead9264b58dbe294669ba837f06b831c65eba2f3d83cee7c4ecdadaf2ac25e3524a665d3722dcf447ba07379dbc256 + languageName: node + linkType: hard + "jest-runtime@npm:^28.1.3": version: 28.1.3 resolution: "jest-runtime@npm:28.1.3" @@ -21639,6 +22292,37 @@ __metadata: languageName: node linkType: hard +"jest-runtime@npm:^29.4.2": + version: 29.4.2 + resolution: "jest-runtime@npm:29.4.2" + dependencies: + "@jest/environment": ^29.4.2 + "@jest/fake-timers": ^29.4.2 + "@jest/globals": ^29.4.2 + "@jest/source-map": ^29.4.2 + "@jest/test-result": ^29.4.2 + "@jest/transform": ^29.4.2 + "@jest/types": ^29.4.2 + "@types/node": "*" + chalk: ^4.0.0 + cjs-module-lexer: ^1.0.0 + collect-v8-coverage: ^1.0.0 + glob: ^7.1.3 + graceful-fs: ^4.2.9 + jest-haste-map: ^29.4.2 + jest-message-util: ^29.4.2 + jest-mock: ^29.4.2 + jest-regex-util: ^29.4.2 + jest-resolve: ^29.4.2 + jest-snapshot: ^29.4.2 + jest-util: ^29.4.2 + semver: ^7.3.5 + slash: ^3.0.0 + strip-bom: ^4.0.0 + checksum: 12de2ab7e77be28d2b58fdb797f156e9a27bc8b7454786fb641ad354c5af7aa9976fd729311ffa2f508be96e774924e9bb067eccbdd49e76b928f47a9d64ac7d + languageName: node + linkType: hard + "jest-serializer-html@npm:^7.1.0": version: 7.1.0 resolution: "jest-serializer-html@npm:7.1.0" @@ -21721,6 +22405,38 @@ __metadata: languageName: node linkType: hard +"jest-snapshot@npm:^29.4.2": + version: 29.4.2 + resolution: "jest-snapshot@npm:29.4.2" + dependencies: + "@babel/core": ^7.11.6 + "@babel/generator": ^7.7.2 + "@babel/plugin-syntax-jsx": ^7.7.2 + "@babel/plugin-syntax-typescript": ^7.7.2 + "@babel/traverse": ^7.7.2 + "@babel/types": ^7.3.3 + "@jest/expect-utils": ^29.4.2 + "@jest/transform": ^29.4.2 + "@jest/types": ^29.4.2 + "@types/babel__traverse": ^7.0.6 + "@types/prettier": ^2.1.5 + babel-preset-current-node-syntax: ^1.0.0 + chalk: ^4.0.0 + expect: ^29.4.2 + graceful-fs: ^4.2.9 + jest-diff: ^29.4.2 + jest-get-type: ^29.4.2 + jest-haste-map: ^29.4.2 + jest-matcher-utils: ^29.4.2 + jest-message-util: ^29.4.2 + jest-util: ^29.4.2 + natural-compare: ^1.4.0 + pretty-format: ^29.4.2 + semver: ^7.3.5 + checksum: 8ef4a30fa110ddc166fb8e2733403a33848cc1ca29553d51e145e5a355ede615865dc40f0c2ee3c2b982bd75eaf1c0da06dedcc27911d749084553d89437511f + languageName: node + linkType: hard + "jest-util@npm:^26.6.2": version: 26.6.2 resolution: "jest-util@npm:26.6.2" @@ -21763,6 +22479,20 @@ __metadata: languageName: node linkType: hard +"jest-util@npm:^29.4.2": + version: 29.4.2 + resolution: "jest-util@npm:29.4.2" + dependencies: + "@jest/types": ^29.4.2 + "@types/node": "*" + chalk: ^4.0.0 + ci-info: ^3.2.0 + graceful-fs: ^4.2.9 + picomatch: ^2.2.3 + checksum: c570de97ccae9f6eca736a4559c77205db1b115d1d3e63f3855b0f016708306de610615f9502291f9382b8e5c9be0443841c392d6ce3197a2915997ced88bc84 + languageName: node + linkType: hard + "jest-validate@npm:^28.1.3": version: 28.1.3 resolution: "jest-validate@npm:28.1.3" @@ -21791,6 +22521,20 @@ __metadata: languageName: node linkType: hard +"jest-validate@npm:^29.4.2": + version: 29.4.2 + resolution: "jest-validate@npm:29.4.2" + dependencies: + "@jest/types": ^29.4.2 + camelcase: ^6.2.0 + chalk: ^4.0.0 + jest-get-type: ^29.4.2 + leven: ^3.1.0 + pretty-format: ^29.4.2 + checksum: ea7f724a0e5d58742594b9d72240bbac5154a4f3f5dd54a6062c408744ec931055a30a436d852ef85af43bf1f5ddb0b4b51b67bff9aabd03985c3a8063d93f29 + languageName: node + linkType: hard + "jest-watch-typeahead@npm:^2.0.0": version: 2.2.1 resolution: "jest-watch-typeahead@npm:2.2.1" @@ -21840,6 +22584,22 @@ __metadata: languageName: node linkType: hard +"jest-watcher@npm:^29.4.2": + version: 29.4.2 + resolution: "jest-watcher@npm:29.4.2" + dependencies: + "@jest/test-result": ^29.4.2 + "@jest/types": ^29.4.2 + "@types/node": "*" + ansi-escapes: ^4.2.1 + chalk: ^4.0.0 + emittery: ^0.13.1 + jest-util: ^29.4.2 + string-length: ^4.0.1 + checksum: 09b3819205af65945368449f0e8816d384e44c75e3e04ff2bd80a2653c663222655d1078978590a13223095a9db626dc7f740f8238b4bc68d24808e91bd02bf9 + languageName: node + linkType: hard + "jest-worker@npm:^26.5.0, jest-worker@npm:^26.6.2": version: 26.6.2 resolution: "jest-worker@npm:26.6.2" @@ -21885,6 +22645,18 @@ __metadata: languageName: node linkType: hard +"jest-worker@npm:^29.4.2": + version: 29.4.2 + resolution: "jest-worker@npm:29.4.2" + dependencies: + "@types/node": "*" + jest-util: ^29.4.2 + merge-stream: ^2.0.0 + supports-color: ^8.0.0 + checksum: 6fd42900da0047e161fcb7d887f95dcc4aca824decc4a59b019011b9609621902bac71b3d4085ceb4f2d9f266263c547ddc1b29159383b45c04b0ab9944df2f5 + languageName: node + linkType: hard + "jest@npm:^28.0.0": version: 28.1.3 resolution: "jest@npm:28.1.3" @@ -21923,6 +22695,25 @@ __metadata: languageName: node linkType: hard +"jest@npm:^29.3.1": + version: 29.4.2 + resolution: "jest@npm:29.4.2" + dependencies: + "@jest/core": ^29.4.2 + "@jest/types": ^29.4.2 + import-local: ^3.0.2 + jest-cli: ^29.4.2 + peerDependencies: + node-notifier: ^8.0.1 || ^9.0.0 || ^10.0.0 + peerDependenciesMeta: + node-notifier: + optional: true + bin: + jest: bin/jest.js + checksum: f08bf93a406ec3e76ff081d1b19e57775dfb6928e9503c4f2f630166d31e808b47faddb2cff6d2fdcfe5c2d0bb04b13a231946ef0efbcba7524b543975b2ecf4 + languageName: node + linkType: hard + "joi@npm:^17.3.0, joi@npm:^17.7.0": version: 17.7.0 resolution: "joi@npm:17.7.0" @@ -21971,6 +22762,13 @@ __metadata: languageName: node linkType: hard +"js-sha512@npm:^0.8.0": + version: 0.8.0 + resolution: "js-sha512@npm:0.8.0" + checksum: 32ca371ebd14c6c5c83360fd8b036cad2211537bef546b199ac8b901917299cab4c68f7f7c26ae72f836bbce0349cb463df9a62cdb4c90e38090fdb4db89ee87 + languageName: node + linkType: hard + "js-string-escape@npm:^1.0.1": version: 1.0.1 resolution: "js-string-escape@npm:1.0.1" @@ -24319,6 +25117,7 @@ __metadata: obj-multiplex: ^1.0.0 pify: ^5.0.0 playwright: ^1.29.2 + plume-sig: ^1.0.0 polyfill-crypto.getrandomvalues: ^1.0.0 prettier: ^2.7.1 prettier-plugin-sort-json: ^1.0.0 @@ -25159,6 +25958,13 @@ __metadata: languageName: node linkType: hard +"mute-stream@npm:~0.0.4": + version: 0.0.8 + resolution: "mute-stream@npm:0.0.8" + checksum: ff48d251fc3f827e5b1206cda0ffdaec885e56057ee86a3155e1951bc940fd5f33531774b1cc8414d7668c10a8907f863f6561875ee6e8768931a62121a531a1 + languageName: node + linkType: hard + "nan@npm:^2.12.1, nan@npm:^2.13.2, nan@npm:^2.14.0": version: 2.15.0 resolution: "nan@npm:2.15.0" @@ -27223,6 +28029,18 @@ __metadata: languageName: node linkType: hard +"plume-sig@npm:^1.0.0": + version: 1.0.0 + resolution: "plume-sig@npm:1.0.0" + dependencies: + "@noble/secp256k1": ^1.7.0 + amcl-js: ^3.0.0 + jest: ^29.3.1 + js-sha512: ^0.8.0 + checksum: 7557f6335ee506eeb3fdf471028bba7d03d6f0ba159ecac8032cde9ea5f93f763ce9b6ea52834a7a14aad93a9f3308354d3f85aa90385008bfb6c79316872cad + languageName: node + linkType: hard + "pluralize@npm:^8.0.0": version: 8.0.0 resolution: "pluralize@npm:8.0.0" @@ -27801,6 +28619,17 @@ __metadata: languageName: node linkType: hard +"pretty-format@npm:^29.4.2": + version: 29.4.2 + resolution: "pretty-format@npm:29.4.2" + dependencies: + "@jest/schemas": ^29.4.2 + ansi-styles: ^5.0.0 + react-is: ^18.0.0 + checksum: ef322c76b617494efda4a7fe277fe10ac4b34ffc4dc2149adbd2533f3b03a67a58ab0c32ee6a9a9ac143a4822c971a071502f6c9ecd87b07ba5d43c58619c2e1 + languageName: node + linkType: hard + "pretty-hrtime@npm:^1.0.0, pretty-hrtime@npm:^1.0.3": version: 1.0.3 resolution: "pretty-hrtime@npm:1.0.3" @@ -27926,6 +28755,19 @@ __metadata: languageName: node linkType: hard +"prompt@npm:^1.0.0": + version: 1.3.0 + resolution: "prompt@npm:1.3.0" + dependencies: + "@colors/colors": 1.5.0 + async: 3.2.3 + read: 1.0.x + revalidator: 0.1.x + winston: 2.x + checksum: d2bebb05bfc39a86215011ee9f32660f23d54d373bd450d1193883b66bac817eca6d2267d42374735e3a57209fc52ab152bbe7c6d6d312f0edc6959cbcd0205a + languageName: node + linkType: hard + "prompts@npm:^2.0.1, prompts@npm:^2.4.0, prompts@npm:^2.4.1": version: 2.4.2 resolution: "prompts@npm:2.4.2" @@ -29045,6 +29887,15 @@ __metadata: languageName: node linkType: hard +"read@npm:1.0.x": + version: 1.0.7 + resolution: "read@npm:1.0.7" + dependencies: + mute-stream: ~0.0.4 + checksum: 2777c254e5732cac96f5d0a1c0f6b836c89ae23d8febd405b206f6f24d5de1873420f1a0795e0e3721066650d19adf802c7882c4027143ee0acf942a4f34f97b + languageName: node + linkType: hard + "readable-stream@npm:1 || 2, readable-stream@npm:^2.0.0, readable-stream@npm:^2.0.1, readable-stream@npm:^2.0.2, readable-stream@npm:^2.0.4, readable-stream@npm:^2.0.5, readable-stream@npm:^2.0.6, readable-stream@npm:^2.1.5, readable-stream@npm:^2.2.2, readable-stream@npm:^2.2.6, readable-stream@npm:^2.2.9, readable-stream@npm:^2.3.3, readable-stream@npm:^2.3.5, readable-stream@npm:~2.3.3, readable-stream@npm:~2.3.6": version: 2.3.7 resolution: "readable-stream@npm:2.3.7" @@ -29925,6 +30776,13 @@ __metadata: languageName: node linkType: hard +"resolve.exports@npm:^2.0.0": + version: 2.0.0 + resolution: "resolve.exports@npm:2.0.0" + checksum: d8bee3b0cc0a0ae6c8323710983505bc6a3a2574f718e96f01e048a0f0af035941434b386cc9efc7eededc5e1199726185c306ec6f6a1aa55d5fbad926fd0634 + languageName: node + linkType: hard + "resolve@npm:1.1.7": version: 1.1.7 resolution: "resolve@npm:1.1.7" @@ -30040,6 +30898,13 @@ __metadata: languageName: node linkType: hard +"revalidator@npm:0.1.x": + version: 0.1.8 + resolution: "revalidator@npm:0.1.8" + checksum: 9ac69162ce8fc86f5fa77f37f3ad634d3797ea70eff4faff13619167ebbf3f3ccf2ec115ccd9c3c860658f8859426022d61d2a1e49183db095ba4f0a016905fe + languageName: node + linkType: hard + "rework-visit@npm:1.0.0": version: 1.0.0 resolution: "rework-visit@npm:1.0.0" @@ -31563,7 +32428,7 @@ __metadata: languageName: node linkType: hard -"stack-trace@npm:0.0.10": +"stack-trace@npm:0.0.10, stack-trace@npm:0.0.x": version: 0.0.10 resolution: "stack-trace@npm:0.0.10" checksum: 473036ad32f8c00e889613153d6454f9be0536d430eb2358ca51cad6b95cea08a3cc33cc0e34de66b0dad221582b08ed2e61ef8e13f4087ab690f388362d6610 @@ -35180,6 +36045,20 @@ __metadata: languageName: node linkType: hard +"winston@npm:2.x": + version: 2.4.7 + resolution: "winston@npm:2.4.7" + dependencies: + async: ^2.6.4 + colors: 1.0.x + cycle: 1.0.x + eyes: 0.1.x + isstream: 0.1.x + stack-trace: 0.0.x + checksum: 0843f39e7d5298b0bffbdea51bc0662715b3c49414fd2b245ebf9b9a4aca452683f35f03ae60e93542b7b16e1eeee34eb3c62bb7ec644201587a4067e8d64dda + languageName: node + linkType: hard + "word-wrap@npm:^1.2.3": version: 1.2.3 resolution: "word-wrap@npm:1.2.3" @@ -35285,7 +36164,7 @@ __metadata: languageName: node linkType: hard -"write-file-atomic@npm:^4.0.1": +"write-file-atomic@npm:^4.0.1, write-file-atomic@npm:^4.0.2": version: 4.0.2 resolution: "write-file-atomic@npm:4.0.2" dependencies: From 0662bf3c45ed45def199ac15f73444804215551b Mon Sep 17 00:00:00 2001 From: Richard Liu Date: Wed, 8 Feb 2023 02:07:17 -0800 Subject: [PATCH 4/6] fix lavamoat --- lavamoat/browserify/beta/policy.json | 30 +++++++++++++++++---------- lavamoat/browserify/flask/policy.json | 30 +++++++++++++++++---------- lavamoat/browserify/main/policy.json | 30 +++++++++++++++++---------- 3 files changed, 57 insertions(+), 33 deletions(-) diff --git a/lavamoat/browserify/beta/policy.json b/lavamoat/browserify/beta/policy.json index 6b3430cefe89..1a320eae929a 100644 --- a/lavamoat/browserify/beta/policy.json +++ b/lavamoat/browserify/beta/policy.json @@ -1239,11 +1239,11 @@ "@metamask/rpc-methods>@metamask/key-tree": { "packages": { "@metamask/rpc-methods>@metamask/key-tree>@noble/ed25519": true, - "@metamask/rpc-methods>@metamask/key-tree>@noble/secp256k1": true, "@metamask/scure-bip39": true, "@metamask/snaps-utils>@noble/hashes": true, "@metamask/snaps-utils>@scure/base": true, - "@metamask/utils": true + "@metamask/utils": true, + "plume-sig>@noble/secp256k1": true } }, "@metamask/rpc-methods>@metamask/key-tree>@noble/ed25519": { @@ -1254,14 +1254,6 @@ "browserify>browser-resolve": true } }, - "@metamask/rpc-methods>@metamask/key-tree>@noble/secp256k1": { - "globals": { - "crypto": true - }, - "packages": { - "browserify>browser-resolve": true - } - }, "@metamask/rpc-methods>nanoid": { "globals": { "crypto.getRandomValues": true @@ -2683,7 +2675,15 @@ "packages": { "@metamask/snaps-utils>@noble/hashes": true, "@metamask/snaps-utils>@scure/base": true, - "eth-lattice-keyring>@ethereumjs/util>ethereum-cryptography>@noble/secp256k1": true + "eth-lattice-keyring>@ethereumjs/util>ethereum-cryptography>@scure/bip32>@noble/secp256k1": true + } + }, + "eth-lattice-keyring>@ethereumjs/util>ethereum-cryptography>@scure/bip32>@noble/secp256k1": { + "globals": { + "crypto": true + }, + "packages": { + "browserify>browser-resolve": true } }, "eth-lattice-keyring>bn.js": { @@ -3569,6 +3569,14 @@ "readable-stream": true } }, + "plume-sig>@noble/secp256k1": { + "globals": { + "crypto": true + }, + "packages": { + "browserify>browser-resolve": true + } + }, "promise-to-callback": { "packages": { "promise-to-callback>is-fn": true, diff --git a/lavamoat/browserify/flask/policy.json b/lavamoat/browserify/flask/policy.json index dc443403542d..7b74cab94ced 100644 --- a/lavamoat/browserify/flask/policy.json +++ b/lavamoat/browserify/flask/policy.json @@ -1331,11 +1331,11 @@ "@metamask/rpc-methods>@metamask/key-tree": { "packages": { "@metamask/rpc-methods>@metamask/key-tree>@noble/ed25519": true, - "@metamask/rpc-methods>@metamask/key-tree>@noble/secp256k1": true, "@metamask/scure-bip39": true, "@metamask/snaps-utils>@noble/hashes": true, "@metamask/snaps-utils>@scure/base": true, - "@metamask/utils": true + "@metamask/utils": true, + "plume-sig>@noble/secp256k1": true } }, "@metamask/rpc-methods>@metamask/key-tree>@noble/ed25519": { @@ -1346,14 +1346,6 @@ "browserify>browser-resolve": true } }, - "@metamask/rpc-methods>@metamask/key-tree>@noble/secp256k1": { - "globals": { - "crypto": true - }, - "packages": { - "browserify>browser-resolve": true - } - }, "@metamask/rpc-methods>nanoid": { "globals": { "crypto.getRandomValues": true @@ -3007,7 +2999,15 @@ "packages": { "@metamask/snaps-utils>@noble/hashes": true, "@metamask/snaps-utils>@scure/base": true, - "eth-lattice-keyring>@ethereumjs/util>ethereum-cryptography>@noble/secp256k1": true + "eth-lattice-keyring>@ethereumjs/util>ethereum-cryptography>@scure/bip32>@noble/secp256k1": true + } + }, + "eth-lattice-keyring>@ethereumjs/util>ethereum-cryptography>@scure/bip32>@noble/secp256k1": { + "globals": { + "crypto": true + }, + "packages": { + "browserify>browser-resolve": true } }, "eth-lattice-keyring>bn.js": { @@ -3911,6 +3911,14 @@ "readable-stream": true } }, + "plume-sig>@noble/secp256k1": { + "globals": { + "crypto": true + }, + "packages": { + "browserify>browser-resolve": true + } + }, "promise-to-callback": { "packages": { "promise-to-callback>is-fn": true, diff --git a/lavamoat/browserify/main/policy.json b/lavamoat/browserify/main/policy.json index 6b3430cefe89..1a320eae929a 100644 --- a/lavamoat/browserify/main/policy.json +++ b/lavamoat/browserify/main/policy.json @@ -1239,11 +1239,11 @@ "@metamask/rpc-methods>@metamask/key-tree": { "packages": { "@metamask/rpc-methods>@metamask/key-tree>@noble/ed25519": true, - "@metamask/rpc-methods>@metamask/key-tree>@noble/secp256k1": true, "@metamask/scure-bip39": true, "@metamask/snaps-utils>@noble/hashes": true, "@metamask/snaps-utils>@scure/base": true, - "@metamask/utils": true + "@metamask/utils": true, + "plume-sig>@noble/secp256k1": true } }, "@metamask/rpc-methods>@metamask/key-tree>@noble/ed25519": { @@ -1254,14 +1254,6 @@ "browserify>browser-resolve": true } }, - "@metamask/rpc-methods>@metamask/key-tree>@noble/secp256k1": { - "globals": { - "crypto": true - }, - "packages": { - "browserify>browser-resolve": true - } - }, "@metamask/rpc-methods>nanoid": { "globals": { "crypto.getRandomValues": true @@ -2683,7 +2675,15 @@ "packages": { "@metamask/snaps-utils>@noble/hashes": true, "@metamask/snaps-utils>@scure/base": true, - "eth-lattice-keyring>@ethereumjs/util>ethereum-cryptography>@noble/secp256k1": true + "eth-lattice-keyring>@ethereumjs/util>ethereum-cryptography>@scure/bip32>@noble/secp256k1": true + } + }, + "eth-lattice-keyring>@ethereumjs/util>ethereum-cryptography>@scure/bip32>@noble/secp256k1": { + "globals": { + "crypto": true + }, + "packages": { + "browserify>browser-resolve": true } }, "eth-lattice-keyring>bn.js": { @@ -3569,6 +3569,14 @@ "readable-stream": true } }, + "plume-sig>@noble/secp256k1": { + "globals": { + "crypto": true + }, + "packages": { + "browserify>browser-resolve": true + } + }, "promise-to-callback": { "packages": { "promise-to-callback>is-fn": true, From 2c303d4e4a5aacb20f837f23e5eba52eb065ad7c Mon Sep 17 00:00:00 2001 From: Richard Liu Date: Mon, 13 Feb 2023 02:18:27 -0800 Subject: [PATCH 5/6] WIP --- app/_locales/en/messages.json | 7 + app/scripts/background.js | 5 + app/scripts/lib/createMetamaskMiddleware.js | 4 +- app/scripts/lib/middleware/plume.js | 11 +- app/scripts/lib/plume-signature-manager.js | 20 +- app/scripts/metamask-controller.js | 53 ++- lavamoat/browserify/beta/policy.json | 27 +- lavamoat/browserify/flask/policy.json | 27 +- lavamoat/browserify/main/policy.json | 27 +- package.json | 3 +- ui/helpers/constants/routes.ts | 4 + .../confirm-plume-signature.component.js | 305 ++++++++++++++++++ .../confirm-plume-signature.container.js | 74 +++++ .../confirm-plume-signature.scss | 278 ++++++++++++++++ ui/pages/confirm-plume-signature/index.js | 1 + .../confirm-transaction-switch.component.js | 3 + .../confirm-transaction.component.js | 7 + ui/pages/pages.scss | 1 + yarn.lock | 17 +- 19 files changed, 828 insertions(+), 46 deletions(-) create mode 100644 ui/pages/confirm-plume-signature/confirm-plume-signature.component.js create mode 100644 ui/pages/confirm-plume-signature/confirm-plume-signature.container.js create mode 100644 ui/pages/confirm-plume-signature/confirm-plume-signature.scss create mode 100644 ui/pages/confirm-plume-signature/index.js diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 5870df9b4d9d..7fda4bae68e8 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -2846,6 +2846,13 @@ "pleaseConfirm": { "message": "Please confirm" }, + "plumeNotice": { + "message": "$1 would like to sign this message with your Plume. This does not reveal anything about your account.", + "description": "$1 is the web3 site name" + }, + "plumeRequest": { + "message": "Sign message with Plume" + }, "plusXMore": { "message": "+ $1 more", "description": "$1 is a number of additional but unshown items in a list- this message will be shown in place of those items" diff --git a/app/scripts/background.js b/app/scripts/background.js index 7d0273a1b9d5..6b19116d6646 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -772,10 +772,14 @@ function setupController(initState, initLangCode) { * Opens the browser popup for user confirmation */ async function triggerUi() { + console.log('trigger UI'); + console.log(1); const tabs = await platform.getActiveTabs(); + console.log(2, { tabs }); const currentlyActiveMetamaskTab = Boolean( tabs.find((tab) => openMetamaskTabsIDs[tab.id]), ); + console.log(2, { currentlyActiveMetamaskTab }); // Vivaldi is not closing port connection on popup close, so popupIsOpen does not work correctly // To be reviewed in the future if this behaviour is fixed - also the way we determine isVivaldi variable might change at some point const isVivaldi = @@ -794,6 +798,7 @@ async function triggerUi() { uiIsTriggering = false; } } + console.log(3, { isVivaldi, popupIsOpen, uiIsTriggering }); } /** diff --git a/app/scripts/lib/createMetamaskMiddleware.js b/app/scripts/lib/createMetamaskMiddleware.js index c74606d658b2..8c5a44d12f92 100644 --- a/app/scripts/lib/createMetamaskMiddleware.js +++ b/app/scripts/lib/createMetamaskMiddleware.js @@ -17,7 +17,7 @@ export default function createMetamaskMiddleware({ processPersonalMessage, processDecryptMessage, processEncryptionPublicKey, - getPlumeSignature, + processGetPlumeSignature, getPendingNonce, getPendingTransactionByHash, }) { @@ -39,7 +39,7 @@ export default function createMetamaskMiddleware({ }), createPendingNonceMiddleware({ getPendingNonce }), createPendingTxMiddleware({ getPendingTransactionByHash }), - createGetPlumeSignatureMiddleware({ getPlumeSignature }), + createGetPlumeSignatureMiddleware({ processGetPlumeSignature }), ]); return metamaskMiddleware; } diff --git a/app/scripts/lib/middleware/plume.js b/app/scripts/lib/middleware/plume.js index 505ba22dcc67..caa5715a3250 100644 --- a/app/scripts/lib/middleware/plume.js +++ b/app/scripts/lib/middleware/plume.js @@ -1,13 +1,20 @@ +import { ethErrors } from 'eth-rpc-errors'; import { createAsyncMiddleware } from 'json-rpc-engine'; -export function createGetPlumeSignatureMiddleware({ getPlumeSignature }) { +export function createGetPlumeSignatureMiddleware({ + processGetPlumeSignature, +}) { return createAsyncMiddleware(async (req, res, next) => { + if (!processGetPlumeSignature) { + throw ethErrors.rpc.methodNotSupported(); + } const { method, params } = req; if (method !== 'eth_getPlumeSignature') { next(); return; } - res.result = `plume result ${params.data}`; + const [data, from] = params; + res.result = await processGetPlumeSignature({ data, from }, req); // TODO: Insert Plume logic here }); } diff --git a/app/scripts/lib/plume-signature-manager.js b/app/scripts/lib/plume-signature-manager.js index 46d0330c874b..33e71a75faf2 100644 --- a/app/scripts/lib/plume-signature-manager.js +++ b/app/scripts/lib/plume-signature-manager.js @@ -61,17 +61,17 @@ export default class PlumeSignatureManager extends EventEmitter { * the new PlumeMessage to this.messages, and to save the unapproved PlumeMessages from that list to * this.memStore. * - * @param {object} address - The param for the eth_getPlumeSignature call to be made after the message is approved. + * @param {object} msgParams - The param for the eth_getPlumeSignature call to be made after the message is approved. * @param {object} [req] - The original request object possibly containing the origin * @returns {Promise} The genereated plume signature */ - addUnapprovedMessageAsync(address, req) { + addUnapprovedMessageAsync(msgParams, req) { return new Promise((resolve, reject) => { - if (!address) { - reject(new Error('MetaMask Message: address field is required.')); + if (!msgParams.from) { + reject(new Error('MetaMask Message: from field is required.')); return; } - const msgId = this.addUnapprovedMessage(address, req); + const msgId = this.addUnapprovedMessage(msgParams, req); this.once(`${msgId}:finished`, (data) => { switch (data.status) { case 'received': @@ -91,7 +91,7 @@ export default class PlumeSignatureManager extends EventEmitter { reject( new Error( `MetaMask PlumeSignature: Unknown problem: ${JSON.stringify( - address, + msgParams, )}`, ), ); @@ -105,18 +105,18 @@ export default class PlumeSignatureManager extends EventEmitter { * the new PlumeMessage to this.messages, and to save the unapproved PlumeMessages from that list to * this.memStore. * - * @param {object} address - The param for the eth_getPlumeSignature call to be made after the message is approved. + * @param {object} msgParams - The param for the eth_getPlumeSignature call to be made after the message is approved. * @param {object} [req] - The original request object possibly containing the origin * @returns {number} The id of the newly created PlumeMessage. */ - addUnapprovedMessage(address, req) { - log.debug(`PlumeSignatureManager addUnapprovedMessage: ${address}`); + addUnapprovedMessage(msgParams, req) { + log.debug(`PlumeSignatureManager addUnapprovedMessage: ${msgParams}`); // create txData obj with parameters and meta data const time = new Date().getTime(); const msgId = createId(); const msgData = { id: msgId, - msgParams: address, + msgParams, time, status: 'unapproved', type: MESSAGE_TYPE.ETH_GET_PLUME_SIGNATURE, diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index e6136c0a181a..e7a019c01cd5 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -6,6 +6,7 @@ import { JsonRpcEngine } from 'json-rpc-engine'; import { debounce } from 'lodash'; import createEngineStream from 'json-rpc-middleware-stream/engineStream'; import { providerAsMiddleware } from 'eth-json-rpc-middleware'; +import { computeAllInputs } from 'plume-sig'; import { KeyringController, keyringBuilderFactory, @@ -1162,6 +1163,7 @@ export default class MetamaskController extends EventEmitter { processDecryptMessage: this.newRequestDecryptMessage.bind(this), processGetPlumeSignature: this.newRequestGetPlumeSignature.bind(this), processEncryptionPublicKey: this.newRequestEncryptionPublicKey.bind(this), + getPlumeSignature: this.getPlumeSignature.bind(this), getPendingNonce: this.getPendingNonce.bind(this), getPendingTransactionByHash: (hash) => this.txController.getTransactions({ @@ -3184,13 +3186,43 @@ export default class MetamaskController extends EventEmitter { * Passed back to the requesting Dapp. */ async newRequestGetPlumeSignature(msgParams, req) { - const promise = this.plumeSignatureManager.addUnapprovedMessageAsync( - msgParams, - req, + console.log('newRequestGetPlumeSignature', { msgParams, req }); + console.log(1); + + // return this.keyringController.exportAccount(msgParams.from); + const privateKey = await this.keyringController.exportAccount( + msgParams.from, ); - this.sendUpdate(); - this.opts.showUserConfirmation(); - return promise; + // return { window: typeof window, hi: 'zxcv' }; + const { plume, s, publicKey, c, gPowR, hashMPKPowR } = + await computeAllInputs(msgParams.data, privateKey); + console.log({ privateKey, gPowR, plume, s, publicKey, c, hashMPKPowR }); + return { + plume: plume.toHex(true), + publicKey: Buffer.from(publicKey).toString('hex'), + hashMPKPowR: hashMPKPowR.toHex(true), + gPowR: gPowR.toHex(true), + c, + s, + }; + + // const promise = this.plumeSignatureManager.addUnapprovedMessageAsync( + // msgParams, + // req, + // ); + // REMOVE FROM HERE + // const privateKey = await this.keyringController.exportAccount( + // msgParams.from, + // ); + + // // console.log({ privateKey }); + // // computeHashMPk(); + // // REMOVE END HERE + // console.log(2); + // this.sendUpdate(); + // console.log(3); + // this.opts.showUserConfirmation(); + // return promise; } /** @@ -3204,14 +3236,13 @@ export default class MetamaskController extends EventEmitter { log.info('MetaMaskController - plumeMessage'); const msgId = msgParams.metamaskId; // sets the status op the message to 'approved' - // and removes the metamaskId for decryption + // and removes the metamaskId for generating plume try { const params = await this.plumeSignatureManager.approveMessage(msgParams); - // TODO / FIXME: Import and use zk-nullifier library - const mockPlume = `mockPlume-${params.data}`; + const inputs = await computeAllInputs(msgParams.data, privateKey); - // tells the listener that the message has been decrypted and can be returned to the dapp - this.plumeSignatureManager.setMsgStatusReceived(msgId, mockPlume); + // tells the listener that the message has been received and can be returned to the dapp + this.plumeSignatureManager.setMsgStatusReceived(msgId, inputs); } catch (error) { log.info('MetaMaskController - eth_getPlumeSignature failed.', error); this.plumeSignatureManager.errorMessage(msgId, error); diff --git a/lavamoat/browserify/beta/policy.json b/lavamoat/browserify/beta/policy.json index 1a320eae929a..04acab4620e6 100644 --- a/lavamoat/browserify/beta/policy.json +++ b/lavamoat/browserify/beta/policy.json @@ -1243,7 +1243,7 @@ "@metamask/snaps-utils>@noble/hashes": true, "@metamask/snaps-utils>@scure/base": true, "@metamask/utils": true, - "plume-sig>@noble/secp256k1": true + "@noble/secp256k1": true } }, "@metamask/rpc-methods>@metamask/key-tree>@noble/ed25519": { @@ -1362,6 +1362,14 @@ "define": true } }, + "@noble/secp256k1": { + "globals": { + "crypto": true + }, + "packages": { + "browserify>browser-resolve": true + } + }, "@popperjs/core": { "globals": { "Element": true, @@ -3569,12 +3577,23 @@ "readable-stream": true } }, - "plume-sig>@noble/secp256k1": { + "plume-sig": { "globals": { - "crypto": true + "TextEncoder": true }, "packages": { - "browserify>browser-resolve": true + "@noble/secp256k1": true, + "browserify>buffer": true, + "plume-sig>amcl-js": true, + "plume-sig>js-sha512": true + } + }, + "plume-sig>js-sha512": { + "globals": { + "define": true + }, + "packages": { + "browserify>process": true } }, "promise-to-callback": { diff --git a/lavamoat/browserify/flask/policy.json b/lavamoat/browserify/flask/policy.json index 7b74cab94ced..707e51c98b5b 100644 --- a/lavamoat/browserify/flask/policy.json +++ b/lavamoat/browserify/flask/policy.json @@ -1335,7 +1335,7 @@ "@metamask/snaps-utils>@noble/hashes": true, "@metamask/snaps-utils>@scure/base": true, "@metamask/utils": true, - "plume-sig>@noble/secp256k1": true + "@noble/secp256k1": true } }, "@metamask/rpc-methods>@metamask/key-tree>@noble/ed25519": { @@ -1686,6 +1686,14 @@ "define": true } }, + "@noble/secp256k1": { + "globals": { + "crypto": true + }, + "packages": { + "browserify>browser-resolve": true + } + }, "@popperjs/core": { "globals": { "Element": true, @@ -3911,12 +3919,23 @@ "readable-stream": true } }, - "plume-sig>@noble/secp256k1": { + "plume-sig": { "globals": { - "crypto": true + "TextEncoder": true }, "packages": { - "browserify>browser-resolve": true + "@noble/secp256k1": true, + "browserify>buffer": true, + "plume-sig>amcl-js": true, + "plume-sig>js-sha512": true + } + }, + "plume-sig>js-sha512": { + "globals": { + "define": true + }, + "packages": { + "browserify>process": true } }, "promise-to-callback": { diff --git a/lavamoat/browserify/main/policy.json b/lavamoat/browserify/main/policy.json index 1a320eae929a..04acab4620e6 100644 --- a/lavamoat/browserify/main/policy.json +++ b/lavamoat/browserify/main/policy.json @@ -1243,7 +1243,7 @@ "@metamask/snaps-utils>@noble/hashes": true, "@metamask/snaps-utils>@scure/base": true, "@metamask/utils": true, - "plume-sig>@noble/secp256k1": true + "@noble/secp256k1": true } }, "@metamask/rpc-methods>@metamask/key-tree>@noble/ed25519": { @@ -1362,6 +1362,14 @@ "define": true } }, + "@noble/secp256k1": { + "globals": { + "crypto": true + }, + "packages": { + "browserify>browser-resolve": true + } + }, "@popperjs/core": { "globals": { "Element": true, @@ -3569,12 +3577,23 @@ "readable-stream": true } }, - "plume-sig>@noble/secp256k1": { + "plume-sig": { "globals": { - "crypto": true + "TextEncoder": true }, "packages": { - "browserify>browser-resolve": true + "@noble/secp256k1": true, + "browserify>buffer": true, + "plume-sig>amcl-js": true, + "plume-sig>js-sha512": true + } + }, + "plume-sig>js-sha512": { + "globals": { + "define": true + }, + "packages": { + "browserify>process": true } }, "promise-to-callback": { diff --git a/package.json b/package.json index be95a2093041..005e8383b676 100644 --- a/package.json +++ b/package.json @@ -252,6 +252,7 @@ "@metamask/subject-metadata-controller": "^1.0.0", "@metamask/utils": "^3.4.1", "@ngraveio/bc-ur": "^1.1.6", + "@noble/secp256k1": "^1.7.1", "@popperjs/core": "^2.4.0", "@reduxjs/toolkit": "^1.6.2", "@segment/loosely-validate-event": "^2.0.0", @@ -312,7 +313,7 @@ "nonce-tracker": "^1.0.0", "obj-multiplex": "^1.0.0", "pify": "^5.0.0", - "plume-sig": "^1.0.0", + "plume-sig": "^1.1.2", "promise-to-callback": "^1.0.0", "prop-types": "^15.6.1", "pubnub": "4.27.3", diff --git a/ui/helpers/constants/routes.ts b/ui/helpers/constants/routes.ts index 3de4f8c7ce86..a97ce71503ce 100644 --- a/ui/helpers/constants/routes.ts +++ b/ui/helpers/constants/routes.ts @@ -98,6 +98,7 @@ const CONFIRM_TOKEN_METHOD_PATH = '/token-method'; const SIGNATURE_REQUEST_PATH = '/signature-request'; const DECRYPT_MESSAGE_REQUEST_PATH = '/decrypt-message-request'; const ENCRYPTION_PUBLIC_KEY_REQUEST_PATH = '/encryption-public-key-request'; +const PLUME_SIGNATURE_PATH = '/plume-signature-request'; const CONFIRMATION_V_NEXT_ROUTE = '/confirmation'; // Used to pull a convenient name for analytics tracking events. The key must @@ -165,6 +166,8 @@ const PATH_NAME_MAP = { 'Decrypt Message Request Page', [`${CONFIRM_TRANSACTION_ROUTE}/:id${ENCRYPTION_PUBLIC_KEY_REQUEST_PATH}`]: 'Encryption Public Key Request Page', + [`${CONFIRM_TRANSACTION_ROUTE}/:id${PLUME_SIGNATURE_PATH}`]: + 'Plume Signature Request Page', [INITIALIZE_ROUTE]: 'Initialization Page', [INITIALIZE_WELCOME_ROUTE]: 'Install Welcome Page', [INITIALIZE_UNLOCK_ROUTE]: 'Initialization Unlock page', @@ -228,6 +231,7 @@ export { SIGNATURE_REQUEST_PATH, DECRYPT_MESSAGE_REQUEST_PATH, ENCRYPTION_PUBLIC_KEY_REQUEST_PATH, + PLUME_SIGNATURE_PATH, CONFIRMATION_V_NEXT_ROUTE, INITIALIZE_METAMETRICS_OPT_IN_ROUTE, ADVANCED_ROUTE, diff --git a/ui/pages/confirm-plume-signature/confirm-plume-signature.component.js b/ui/pages/confirm-plume-signature/confirm-plume-signature.component.js new file mode 100644 index 000000000000..a09d1a322549 --- /dev/null +++ b/ui/pages/confirm-plume-signature/confirm-plume-signature.component.js @@ -0,0 +1,305 @@ +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; +import copyToClipboard from 'copy-to-clipboard'; +import classnames from 'classnames'; + +import AccountListItem from '../../components/app/account-list-item'; +import Identicon from '../../components/ui/identicon'; +import Tooltip from '../../components/ui/tooltip'; +import Copy from '../../components/ui/icon/copy-icon.component'; +import { PageContainerFooter } from '../../components/ui/page-container'; + +import { EVENT } from '../../../shared/constants/metametrics'; +import { SECOND } from '../../../shared/constants/time'; +import { Numeric } from '../../../shared/modules/Numeric'; +import { EtherDenomination } from '../../../shared/constants/common'; + +export default class ConfirmDecryptMessage extends Component { + static contextTypes = { + t: PropTypes.func.isRequired, + trackEvent: PropTypes.func.isRequired, + }; + + static propTypes = { + fromAccount: PropTypes.shape({ + address: PropTypes.string.isRequired, + balance: PropTypes.string, + name: PropTypes.string, + }).isRequired, + clearConfirmTransaction: PropTypes.func.isRequired, + cancelDecryptMessage: PropTypes.func.isRequired, + decryptMessage: PropTypes.func.isRequired, + decryptMessageInline: PropTypes.func.isRequired, + conversionRate: PropTypes.number, + history: PropTypes.object.isRequired, + mostRecentOverviewPage: PropTypes.string.isRequired, + requesterAddress: PropTypes.string, + txData: PropTypes.object, + subjectMetadata: PropTypes.object, + nativeCurrency: PropTypes.string.isRequired, + }; + + state = { + fromAccount: this.props.fromAccount, + copyToClipboardPressed: false, + hasCopied: false, + }; + + copyMessage = () => { + copyToClipboard(this.state.rawMessage); + this.context.trackEvent({ + category: EVENT.CATEGORIES.MESSAGES, + event: 'Copy', + properties: { + action: 'Plume Signature Copy', + legacy_event: true, + }, + }); + this.setState({ hasCopied: true }); + setTimeout(() => this.setState({ hasCopied: false }), SECOND * 3); + }; + + renderHeader = () => { + return ( +
+
+ +
+ {this.context.t('decryptRequest')} +
+ +
+
+
+
+ ); + }; + + renderAccount = () => { + const { fromAccount } = this.state; + const { t } = this.context; + + return ( +
+
+ {`${t('account')}:`} +
+ +
+ +
+
+ ); + }; + + renderBalance = () => { + const { conversionRate, nativeCurrency } = this.props; + const { + fromAccount: { balance }, + } = this.state; + const { t } = this.context; + + const nativeCurrencyBalance = new Numeric( + balance, + 16, + EtherDenomination.WEI, + ) + .applyConversionRate(conversionRate) + .round(6) + .toBase(10); + + return ( +
+
+ {`${t('balance')}:`} +
+
+ {`${nativeCurrencyBalance} ${nativeCurrency}`} +
+
+ ); + }; + + renderRequestIcon = () => { + const { requesterAddress } = this.props; + + return ( +
+ +
+ ); + }; + + renderAccountInfo = () => { + return ( +
+ {this.renderAccount()} + {this.renderRequestIcon()} + {this.renderBalance()} +
+ ); + }; + + renderBody = () => { + const { decryptMessageInline, subjectMetadata, txData } = this.props; + const { t } = this.context; + + const targetSubjectMetadata = subjectMetadata[txData.msgParams.origin]; + const name = targetSubjectMetadata?.name || txData.msgParams.origin; + const notice = t('decryptMessageNotice', [txData.msgParams.origin]); + + const { + hasCopied, + hasDecrypted, + hasError, + rawMessage, + errorMessage, + copyToClipboardPressed, + } = this.state; + + return ( +
+ {this.renderAccountInfo()} +
+
+ {targetSubjectMetadata?.iconUrl ? ( + + ) : ( + + {name.charAt(0).toUpperCase()} + + )} +
{notice}
+
+
+
+
+ {!hasDecrypted && !hasError ? txData.msgParams.data : rawMessage} + {hasError ? errorMessage : ''} +
+
+
{ + decryptMessageInline(txData, event).then((result) => { + if (result.error) { + this.setState({ + hasError: true, + errorMessage: this.context.t('decryptInlineError', [ + result.error, + ]), + }); + } else { + this.setState({ + hasDecrypted: true, + rawMessage: result.rawData, + }); + } + }); + }} + > +
+ +
+ {t('decryptMetamask')} +
+
+
+
+ {hasDecrypted ? ( +
this.copyMessage()} + onMouseDown={() => this.setState({ copyToClipboardPressed: true })} + onMouseUp={() => this.setState({ copyToClipboardPressed: false })} + > + +
+ {t('decryptCopy')} +
+ +
+
+ ) : ( +
+ )} +
+ ); + }; + + renderFooter = () => { + const { + cancelDecryptMessage, + clearConfirmTransaction, + decryptMessage, + history, + mostRecentOverviewPage, + txData, + } = this.props; + const { trackEvent, t } = this.context; + + return ( + { + await cancelDecryptMessage(txData, event); + trackEvent({ + category: EVENT.CATEGORIES.MESSAGES, + event: 'Cancel', + properties: { + action: 'Decrypt Message Request', + legacy_event: true, + }, + }); + clearConfirmTransaction(); + history.push(mostRecentOverviewPage); + }} + onSubmit={async (event) => { + await decryptMessage(txData, event); + trackEvent({ + category: EVENT.CATEGORIES.MESSAGES, + event: 'Confirm', + properties: { + action: 'Decrypt Message Request', + legacy_event: true, + }, + }); + clearConfirmTransaction(); + history.push(mostRecentOverviewPage); + }} + /> + ); + }; + + render = () => { + return ( +
+ {this.renderHeader()} + {this.renderBody()} + {this.renderFooter()} +
+ ); + }; +} diff --git a/ui/pages/confirm-plume-signature/confirm-plume-signature.container.js b/ui/pages/confirm-plume-signature/confirm-plume-signature.container.js new file mode 100644 index 000000000000..f20da9b96585 --- /dev/null +++ b/ui/pages/confirm-plume-signature/confirm-plume-signature.container.js @@ -0,0 +1,74 @@ +import { connect } from 'react-redux'; +import { compose } from 'redux'; +import { withRouter } from 'react-router-dom'; + +import { + goHome, + decryptMsg, + cancelDecryptMsg, + decryptMsgInline, +} from '../../store/actions'; +import { + getTargetAccountWithSendEtherInfo, + unconfirmedTransactionsListSelector, + conversionRateSelector, +} from '../../selectors'; +import { clearConfirmTransaction } from '../../ducks/confirm-transaction/confirm-transaction.duck'; +import { getMostRecentOverviewPage } from '../../ducks/history/history'; +import { getNativeCurrency } from '../../ducks/metamask/metamask'; +import ConfirmPlumeSignature from './confirm-plume-signature.component'; + +function mapStateToProps(state) { + const { + metamask: { subjectMetadata = {} }, + } = state; + + const unconfirmedTransactions = unconfirmedTransactionsListSelector(state); + + const txData = unconfirmedTransactions[0]; + + const { + msgParams: { from }, + } = txData; + + const fromAccount = getTargetAccountWithSendEtherInfo(state, from); + + return { + txData, + subjectMetadata, + fromAccount, + requester: null, + requesterAddress: null, + conversionRate: conversionRateSelector(state), + mostRecentOverviewPage: getMostRecentOverviewPage(state), + nativeCurrency: getNativeCurrency(state), + }; +} + +function mapDispatchToProps(dispatch) { + return { + goHome: () => dispatch(goHome()), + clearConfirmTransaction: () => dispatch(clearConfirmTransaction()), + decryptMessage: (msgData, event) => { + const params = msgData.msgParams; + params.metamaskId = msgData.id; + event.stopPropagation(event); + return dispatch(decryptMsg(params)); + }, + cancelDecryptMessage: (msgData, event) => { + event.stopPropagation(event); + return dispatch(cancelDecryptMsg(msgData)); + }, + decryptMessageInline: (msgData, event) => { + const params = msgData.msgParams; + params.metamaskId = msgData.id; + event.stopPropagation(event); + return dispatch(decryptMsgInline(params)); + }, + }; +} + +export default compose( + withRouter, + connect(mapStateToProps, mapDispatchToProps), +)(ConfirmPlumeSignature); diff --git a/ui/pages/confirm-plume-signature/confirm-plume-signature.scss b/ui/pages/confirm-plume-signature/confirm-plume-signature.scss new file mode 100644 index 000000000000..2d392102995f --- /dev/null +++ b/ui/pages/confirm-plume-signature/confirm-plume-signature.scss @@ -0,0 +1,278 @@ +.request-plume-signature { + &__container { + width: 380px; + border-radius: 8px; + background-color: var(--color-background-default); + box-shadow: var(--shadow-size-xs) var(--color-shadow-default); + display: flex; + flex-flow: column nowrap; + z-index: 25; + align-items: center; + position: relative; + height: 100%; + + @include screen-sm-max { + width: 100%; + top: 0; + box-shadow: none; + } + + @include screen-sm-min { + height: 620px; + } + } + + &__typed-container { + padding: 17px; + + h1 { + font-weight: 900; + margin-bottom: 5px; + } + + * { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + } + + > div { + margin-bottom: 10px; + } + } + + &__header { + height: 64px; + width: 100%; + position: relative; + display: flex; + flex-flow: column; + justify-content: center; + align-items: center; + flex: 0 0 auto; + } + + &__header-background { + position: absolute; + background-color: var(--color-background-alternative); + z-index: 2; + width: 100%; + height: 100%; + } + + &__header__text { + @include H3; + + color: var(--color-text-alternative); + z-index: 3; + text-align: center; + } + + &__header__tip-container { + width: 100%; + display: flex; + justify-content: center; + } + + &__header__tip { + height: 25px; + width: 25px; + background: var(--color-background-alternative); + transform: rotate(45deg); + position: absolute; + bottom: -8px; + z-index: 1; + } + + &__account-info { + display: flex; + justify-content: space-between; + margin-top: 18px; + margin-bottom: 20px; + } + + &__account { + color: var(--color-text-alternative); + margin-left: 17px; + } + + &__account-text { + @include H6; + } + + &__account-item { + @include H7; + + height: 22px; + background-color: var(--color-background-default); + width: 124px; + + .account-list-item { + margin-top: 6px; + } + + .account-list-item__account-name { + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; + width: 80px; + } + + .account-list-item__top-row { + margin: 0; + } + } + + &__balance { + color: var(--color-text-alternative); + margin-right: 17px; + width: 124px; + } + + &__balance-text { + @include H6; + + text-align: right; + } + + &__balance-value { + text-align: right; + margin-top: 2.5px; + } + + &__request-icon { + margin-top: 25px; + } + + &__body { + width: 100%; + height: 100%; + display: flex; + flex-flow: column; + flex: 1 1 auto; + height: 0; + } + + &__notice { + @include H6; + + text-align: center; + margin-top: 15px; + margin-bottom: 11px; + width: 100%; + } + + &__message { + overflow-wrap: break-word; + margin: 20px; + overflow: hidden; + border: 1px solid var(--color-border-alternative); + padding: 5px; + border-radius: 5px; + position: relative; + + &-text { + @include H7; + + height: 115px; + } + + &-cover { + background-color: var(--color-background-default); + opacity: 0.75; + position: absolute; + height: 100%; + width: 100%; + top: 0; + } + + &-lock { + position: absolute; + height: 100%; + width: 100%; + top: 0; + cursor: pointer; + + &__container { + padding: 16px; + background-color: var(--color-background-default); + position: absolute; + left: 50%; + top: 50%; + border-radius: 3px; + transform: translate(-50%, calc(-50%)); + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + + + &__icon { + color: var(--color-icon-default); + display: flex; + margin-bottom: 16px; + } + + &__text { + @include H7; + } + } + + &--pressed { + display: none; + } + } + + &-copy { + @include H7; + + justify-content: space-evenly; + margin-left: 20px; + margin-right: 20px; + display: flex; + cursor: pointer; + } + + &-copy-text { + margin-right: 10px; + display: inline; + } + + &-copy-tooltip { + float: right; + } + } + + &__visual { + display: flex; + flex-direction: row; + justify-content: space-evenly; + position: relative; + margin: 0 20px; + + section { + display: flex; + flex-direction: column; + align-items: center; + flex: 1; + } + + &-identicon { + width: 48px; + height: 48px; + + &--default { + background-color: var(--color-background-alternative); + color: var(--color-text-default); + width: 48px; + height: 48px; + border-radius: 24px; + display: flex; + align-items: center; + justify-content: center; + font-weight: bold; + } + } + } + } + \ No newline at end of file diff --git a/ui/pages/confirm-plume-signature/index.js b/ui/pages/confirm-plume-signature/index.js new file mode 100644 index 000000000000..222455bbd32d --- /dev/null +++ b/ui/pages/confirm-plume-signature/index.js @@ -0,0 +1 @@ +export { default } from './confirm-plume-signature.container'; diff --git a/ui/pages/confirm-transaction-switch/confirm-transaction-switch.component.js b/ui/pages/confirm-transaction-switch/confirm-transaction-switch.component.js index 2211ef81adf1..171aa4890f1b 100644 --- a/ui/pages/confirm-transaction-switch/confirm-transaction-switch.component.js +++ b/ui/pages/confirm-transaction-switch/confirm-transaction-switch.component.js @@ -15,6 +15,7 @@ import { ENCRYPTION_PUBLIC_KEY_REQUEST_PATH, CONFIRM_SAFE_TRANSFER_FROM_PATH, CONFIRM_SET_APPROVAL_FOR_ALL_PATH, + PLUME_SIGNATURE_PATH, } from '../../helpers/constants/routes'; import { MESSAGE_TYPE } from '../../../shared/constants/app'; import { TransactionType } from '../../../shared/constants/transaction'; @@ -81,6 +82,8 @@ export default class ConfirmTransactionSwitch extends Component { pathname = `${CONFIRM_TRANSACTION_ROUTE}/${txData.id}${DECRYPT_MESSAGE_REQUEST_PATH}`; } else if (txData.type === MESSAGE_TYPE.ETH_GET_ENCRYPTION_PUBLIC_KEY) { pathname = `${CONFIRM_TRANSACTION_ROUTE}/${txData.id}${ENCRYPTION_PUBLIC_KEY_REQUEST_PATH}`; + } else if (txData.type === MESSAGE_TYPE.ETH_GET_PLUME_SIGNATURE) { + pathname = `${CONFIRM_TRANSACTION_ROUTE}/${txData.id}${PLUME_SIGNATURE_PATH}`; } return ; } diff --git a/ui/pages/confirm-transaction/confirm-transaction.component.js b/ui/pages/confirm-transaction/confirm-transaction.component.js index 540a28a07f4b..14d5312db133 100644 --- a/ui/pages/confirm-transaction/confirm-transaction.component.js +++ b/ui/pages/confirm-transaction/confirm-transaction.component.js @@ -8,6 +8,7 @@ import ConfirmSendEther from '../confirm-send-ether'; import ConfirmDeployContract from '../confirm-deploy-contract'; import ConfirmDecryptMessage from '../confirm-decrypt-message'; import ConfirmEncryptionPublicKey from '../confirm-encryption-public-key'; +import confirmPlumeSignature from '../confirm-plume-signature'; import { CONFIRM_TRANSACTION_ROUTE, @@ -18,6 +19,7 @@ import { DECRYPT_MESSAGE_REQUEST_PATH, ENCRYPTION_PUBLIC_KEY_REQUEST_PATH, DEFAULT_ROUTE, + PLUME_SIGNATURE_PATH, } from '../../helpers/constants/routes'; import { disconnectGasFeeEstimatePoller, @@ -197,6 +199,11 @@ export default class ConfirmTransaction extends Component { path={`${CONFIRM_TRANSACTION_ROUTE}/:id?${ENCRYPTION_PUBLIC_KEY_REQUEST_PATH}`} component={ConfirmEncryptionPublicKey} /> + ) : ( diff --git a/ui/pages/pages.scss b/ui/pages/pages.scss index bf1ad5887af7..4a3866785822 100644 --- a/ui/pages/pages.scss +++ b/ui/pages/pages.scss @@ -7,6 +7,7 @@ @import 'confirm-approve/index'; @import 'confirm-decrypt-message/confirm-decrypt-message'; @import 'confirm-encryption-public-key/confirm-encryption-public-key'; +@import 'confirm-plume-signature/confirm-plume-signature'; @import 'confirmation/confirmation'; @import 'connected-sites/index'; @import 'connected-accounts/index'; diff --git a/yarn.lock b/yarn.lock index 4434efe1dd47..97435da18f63 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4556,7 +4556,7 @@ __metadata: languageName: node linkType: hard -"@noble/secp256k1@npm:^1.5.5, @noble/secp256k1@npm:^1.7.0": +"@noble/secp256k1@npm:^1.5.5, @noble/secp256k1@npm:^1.7.0, @noble/secp256k1@npm:^1.7.1": version: 1.7.1 resolution: "@noble/secp256k1@npm:1.7.1" checksum: d2301f1f7690368d8409a3152450458f27e54df47e3f917292de3de82c298770890c2de7c967d237eff9c95b70af485389a9695f73eb05a43e2bd562d18b18cb @@ -9078,7 +9078,7 @@ __metadata: languageName: node linkType: hard -"amcl-js@npm:^3.0.0": +"amcl-js@npm:3.0.0": version: 3.0.0 resolution: "amcl-js@npm:3.0.0" dependencies: @@ -24941,6 +24941,7 @@ __metadata: "@metamask/test-dapp": ^5.2.1 "@metamask/utils": ^3.4.1 "@ngraveio/bc-ur": ^1.1.6 + "@noble/secp256k1": ^1.7.1 "@popperjs/core": ^2.4.0 "@reduxjs/toolkit": ^1.6.2 "@segment/loosely-validate-event": ^2.0.0 @@ -25117,7 +25118,7 @@ __metadata: obj-multiplex: ^1.0.0 pify: ^5.0.0 playwright: ^1.29.2 - plume-sig: ^1.0.0 + plume-sig: ^1.1.2 polyfill-crypto.getrandomvalues: ^1.0.0 prettier: ^2.7.1 prettier-plugin-sort-json: ^1.0.0 @@ -28029,15 +28030,15 @@ __metadata: languageName: node linkType: hard -"plume-sig@npm:^1.0.0": - version: 1.0.0 - resolution: "plume-sig@npm:1.0.0" +"plume-sig@npm:^1.1.2": + version: 1.1.2 + resolution: "plume-sig@npm:1.1.2" dependencies: "@noble/secp256k1": ^1.7.0 - amcl-js: ^3.0.0 + amcl-js: 3.0.0 jest: ^29.3.1 js-sha512: ^0.8.0 - checksum: 7557f6335ee506eeb3fdf471028bba7d03d6f0ba159ecac8032cde9ea5f93f763ce9b6ea52834a7a14aad93a9f3308354d3f85aa90385008bfb6c79316872cad + checksum: bea9f76b27c94846c02b2793b8ff1e2fd4cac02fce2856d43ebb5eea0ecb2f1794f08a7eabb08cd1df75dd367ce169a938c24a7754cc3f7232e097f7b85256d7 languageName: node linkType: hard From 4a7ca9adc06787d1df4c23b666c77fc1724d48dc Mon Sep 17 00:00:00 2001 From: Richard Liu Date: Fri, 10 Mar 2023 01:41:56 -0800 Subject: [PATCH 6/6] integrated with confirmation window --- .storybook/initial-states/transactions.js | 83 ++++++------ app/_locales/en/messages.json | 8 +- app/scripts/background.js | 7 +- app/scripts/lib/middleware/plume.js | 3 +- app/scripts/lib/plume-signature-manager.js | 9 +- app/scripts/lib/setupSentry.js | 1 + app/scripts/metamask-controller.js | 86 ++++++------- .../files-to-convert.json | 3 + shared/constants/transaction.ts | 1 + test/data/mock-send-state.json | 2 + test/data/mock-state.json | 2 + ui/helpers/utils/tx-helper.js | 6 + ui/hooks/useTransactionDisplayData.js | 1 + ui/index.js | 1 + .../confirm-plume-signature.component.js | 119 +++--------------- .../confirm-plume-signature.container.js | 21 +--- .../confirm-transaction.component.js | 4 +- ui/selectors/confirm-transaction.js | 18 ++- ui/selectors/selectors.js | 5 + ui/selectors/transactions.js | 5 + ui/store/actions.js | 48 ++++++- 21 files changed, 205 insertions(+), 228 deletions(-) diff --git a/.storybook/initial-states/transactions.js b/.storybook/initial-states/transactions.js index 70885e4a606d..3aded721ec0c 100644 --- a/.storybook/initial-states/transactions.js +++ b/.storybook/initial-states/transactions.js @@ -4,6 +4,7 @@ const MOCK_TX_TYPE = { DEPLOY_CONTRACT: 'contractDeployment', ETH_DECRYPT: 'eth_decrypt', ETH_GET_ENCRYPTION_PUBLIC_KEY: 'eth_getEncryptionPublicKey', + ETH_GET_PLUME_SIGNATURE: 'eth_getPlumeSignature', INCOMING: 'incoming', PERSONAL_SIGN: 'personal_sign', RETRY: 'retry', @@ -219,8 +220,7 @@ export const MOCK_TRANSACTION_BY_TYPE = { status: 'unapproved', time: 1653417884003, txParams: { - data: - '0xa1448194000000000000000000000000e56e7847fd3661a9b7c86aaf1daea08d9da5750e0000000000000000000000000000000000000000000000000000000000000004', + data: '0xa1448194000000000000000000000000e56e7847fd3661a9b7c86aaf1daea08d9da5750e0000000000000000000000000000000000000000000000000000000000000004', from: '0xabce7847fd3661a9b7c86aaf1daea08d9da5750e', gas: '0x118f4', maxFeePerGas: '0x9502f91a', @@ -244,8 +244,7 @@ export const MOCK_TRANSACTION_BY_TYPE = { gasPrice: '0x77359400', nonce: '0x3', value: '0x00', - data: - '0x608060405234801561001057600080fd5b5033600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000808190555061023b806100686000396000f300608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632e1a7d4d1461005c5780638da5cb5b1461009d578063d0e30db0146100f4575b600080fd5b34801561006857600080fd5b5061008760048036038101908080359060200190929190505050610112565b6040518082815260200191505060405180910390f35b3480156100a957600080fd5b506100b26101d0565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100fc6101f6565b6040518082815260200191505060405180910390f35b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561017057600080fd5b8160008082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f193505050501580156101c5573d6000803e3d6000fd5b506000549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003460008082825401925050819055506000549050905600a165627a7a72305820f237db3ec816a52589d82512117bc85bc08d3537683ffeff9059108caf3e5d400029', + data: '0x608060405234801561001057600080fd5b5033600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000808190555061023b806100686000396000f300608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632e1a7d4d1461005c5780638da5cb5b1461009d578063d0e30db0146100f4575b600080fd5b34801561006857600080fd5b5061008760048036038101908080359060200190929190505050610112565b6040518082815260200191505060405180910390f35b3480156100a957600080fd5b506100b26101d0565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100fc6101f6565b6040518082815260200191505060405180910390f35b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561017057600080fd5b8160008082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f193505050501580156101c5573d6000803e3d6000fd5b506000549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003460008082825401925050819055506000549050905600a165627a7a72305820f237db3ec816a52589d82512117bc85bc08d3537683ffeff9059108caf3e5d400029', }, hash: '0xbcb195f393f4468945b4045cd41bcdbc2f19ad75ae92a32cf153a3004e42009a', type: 'contractDeployment', @@ -255,8 +254,7 @@ export const MOCK_TRANSACTION_BY_TYPE = { id: 5177046356058652, msgParams: { from: '0xabce7847fd3661a9b7c86aaf1daea08d9da5750e', - data: - '0x7b2276657273696f6e223a227832353531392d7873616c736132302d706f6c7931333035222c226e6f6e6365223a22415a7a535971376139725531396e3835753174494f5765367a486e32775a6166222c22657068656d5075626c69634b6579223a2251336d346650474a6b6a32396d44766f7133536a77616733686b3651366571744236397671795258517a673d222c2263697068657274657874223a223943556d614c327a69635a5838584c4d5a75646b58392f6531544770384d61513135776276774c6d442b4235772b4f706655694c586c586d55355536645339675638584c61445557446e656735546b3d227d', + data: '0x7b2276657273696f6e223a227832353531392d7873616c736132302d706f6c7931333035222c226e6f6e6365223a22415a7a535971376139725531396e3835753174494f5765367a486e32775a6166222c22657068656d5075626c69634b6579223a2251336d346650474a6b6a32396d44766f7133536a77616733686b3651366571744236397671795258517a673d222c2263697068657274657874223a223943556d614c327a69635a5838584c4d5a75646b58392f6531544770384d61513135776276774c6d442b4235772b4f706655694c586c586d55355536645339675638584c61445557446e656735546b3d227d', origin: 'https://metamask.github.io', }, time: 1653450860396, @@ -266,12 +264,30 @@ export const MOCK_TRANSACTION_BY_TYPE = { gasPrice: '0x77359400', nonce: '0x3', value: '0x00', - data: - '0x608060405234801561001057600080fd5b5033600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000808190555061023b806100686000396000f300608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632e1a7d4d1461005c5780638da5cb5b1461009d578063d0e30db0146100f4575b600080fd5b34801561006857600080fd5b5061008760048036038101908080359060200190929190505050610112565b6040518082815260200191505060405180910390f35b3480156100a957600080fd5b506100b26101d0565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100fc6101f6565b6040518082815260200191505060405180910390f35b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561017057600080fd5b8160008082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f193505050501580156101c5573d6000803e3d6000fd5b506000549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003460008082825401925050819055506000549050905600a165627a7a72305820f237db3ec816a52589d82512117bc85bc08d3537683ffeff9059108caf3e5d400029', + data: '0x608060405234801561001057600080fd5b5033600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000808190555061023b806100686000396000f300608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632e1a7d4d1461005c5780638da5cb5b1461009d578063d0e30db0146100f4575b600080fd5b34801561006857600080fd5b5061008760048036038101908080359060200190929190505050610112565b6040518082815260200191505060405180910390f35b3480156100a957600080fd5b506100b26101d0565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100fc6101f6565b6040518082815260200191505060405180910390f35b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561017057600080fd5b8160008082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f193505050501580156101c5573d6000803e3d6000fd5b506000549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003460008082825401925050819055506000549050905600a165627a7a72305820f237db3ec816a52589d82512117bc85bc08d3537683ffeff9059108caf3e5d400029', }, status: 'unapproved', type: 'eth_decrypt', }, + [MOCK_TX_TYPE.ETH_GET_PLUME_SIGNATURE]: { + id: 5177046356058653, + msgParams: { + from: '0xabce7847fd3661a9b7c86aaf1daea08d9da5750e', + data: '0x7b2276657273696', + origin: 'https://metamask.github.io', + }, + time: 1653450860397, + txParams: { + from: '0xabc14609ef9e09776ac5fe00bdbfef57bcdefebb', + gas: '0x5208', + gasPrice: '0x77359400', + nonce: '0x3', + value: '0x00', + data: '0x608060405234801561001057600080fd5b5033600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000808190555061023b806100686000396000f300608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632e1a7d4d1461005c5780638da5cb5b1461009d578063d0e30db0146100f4575b600080fd5b34801561006857600080fd5b5061008760048036038101908080359060200190929190505050610112565b6040518082815260200191505060405180910390f35b3480156100a957600080fd5b506100b26101d0565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100fc6101f6565b6040518082815260200191505060405180910390f35b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561017057600080fd5b8160008082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f193505050501580156101c5573d6000803e3d6000fd5b506000549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003460008082825401925050819055506000549050905600a165627a7a72305820f237db3ec816a52589d82512117bc85bc08d3537683ffeff9059108caf3e5d400029', + }, + status: 'unapproved', + type: 'eth_getPlumeSignature', + }, [MOCK_TX_TYPE.ETH_GET_ENCRYPTION_PUBLIC_KEY]: { id: 5177046356058645, msgParams: '0xe56e7847fd3661a9b7c86aaf1daea08d9da5750e', @@ -283,8 +299,7 @@ export const MOCK_TRANSACTION_BY_TYPE = { gasPrice: '0x77359400', nonce: '0x3', value: '0x00', - data: - '0x608060405234801561001057600080fd5b5033600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000808190555061023b806100686000396000f300608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632e1a7d4d1461005c5780638da5cb5b1461009d578063d0e30db0146100f4575b600080fd5b34801561006857600080fd5b5061008760048036038101908080359060200190929190505050610112565b6040518082815260200191505060405180910390f35b3480156100a957600080fd5b506100b26101d0565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100fc6101f6565b6040518082815260200191505060405180910390f35b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561017057600080fd5b8160008082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f193505050501580156101c5573d6000803e3d6000fd5b506000549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003460008082825401925050819055506000549050905600a165627a7a72305820f237db3ec816a52589d82512117bc85bc08d3537683ffeff9059108caf3e5d400029', + data: '0x608060405234801561001057600080fd5b5033600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000808190555061023b806100686000396000f300608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632e1a7d4d1461005c5780638da5cb5b1461009d578063d0e30db0146100f4575b600080fd5b34801561006857600080fd5b5061008760048036038101908080359060200190929190505050610112565b6040518082815260200191505060405180910390f35b3480156100a957600080fd5b506100b26101d0565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100fc6101f6565b6040518082815260200191505060405180910390f35b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561017057600080fd5b8160008082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f193505050501580156101c5573d6000803e3d6000fd5b506000549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003460008082825401925050819055506000549050905600a165627a7a72305820f237db3ec816a52589d82512117bc85bc08d3537683ffeff9059108caf3e5d400029', }, type: 'eth_getEncryptionPublicKey', origin: 'https://metamask.github.io', @@ -335,8 +350,7 @@ export const MOCK_TRANSACTION_BY_TYPE = { gasPrice: '0x77359400', nonce: '0x3', value: '0x00', - data: - '0x608060405234801561001057600080fd5b5033600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000808190555061023b806100686000396000f300608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632e1a7d4d1461005c5780638da5cb5b1461009d578063d0e30db0146100f4575b600080fd5b34801561006857600080fd5b5061008760048036038101908080359060200190929190505050610112565b6040518082815260200191505060405180910390f35b3480156100a957600080fd5b506100b26101d0565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100fc6101f6565b6040518082815260200191505060405180910390f35b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561017057600080fd5b8160008082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f193505050501580156101c5573d6000803e3d6000fd5b506000549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003460008082825401925050819055506000549050905600a165627a7a72305820f237db3ec816a52589d82512117bc85bc08d3537683ffeff9059108caf3e5d400029', + data: '0x608060405234801561001057600080fd5b5033600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000808190555061023b806100686000396000f300608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632e1a7d4d1461005c5780638da5cb5b1461009d578063d0e30db0146100f4575b600080fd5b34801561006857600080fd5b5061008760048036038101908080359060200190929190505050610112565b6040518082815260200191505060405180910390f35b3480156100a957600080fd5b506100b26101d0565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100fc6101f6565b6040518082815260200191505060405180910390f35b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561017057600080fd5b8160008082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f193505050501580156101c5573d6000803e3d6000fd5b506000549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003460008082825401925050819055506000549050905600a165627a7a72305820f237db3ec816a52589d82512117bc85bc08d3537683ffeff9059108caf3e5d400029', }, time: 1653451036121, status: 'unapproved', @@ -357,8 +371,7 @@ export const MOCK_TRANSACTION_BY_TYPE = { from: '0xabc539a7d5c43940af498008a7c8f3abb35c3725', nonce: '0x7', value: '0x0', - data: - '0x6080604052348015600f57600080fd5b50608b8061001e6000396000f3fe6080604052610fff3411600e57fe5b3373ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f193505050501580156053573d6000803e3d6000fd5b5000fea265627a7a72315820631b0dbb6b871cdbfdec2773af15ebfb8e52c794cf836fe27ec21f1aed17180f64736f6c634300050c0032', + data: '0x6080604052348015600f57600080fd5b50608b8061001e6000396000f3fe6080604052610fff3411600e57fe5b3373ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f193505050501580156053573d6000803e3d6000fd5b5000fea265627a7a72315820631b0dbb6b871cdbfdec2773af15ebfb8e52c794cf836fe27ec21f1aed17180f64736f6c634300050c0032', gas: '0x14609', maxFeePerGas: '0x3b9aca0d', maxPriorityFeePerGas: '0x3b9aca00', @@ -387,8 +400,7 @@ export const MOCK_TRANSACTION_BY_TYPE = { from: '0xabc539a7d5c43940af498008a7c8f3abb35c3725', nonce: '0x7', value: '0x0', - data: - '0x6080604052348015600f57600080fd5b50608b8061001e6000396000f3fe6080604052610fff3411600e57fe5b3373ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f193505050501580156053573d6000803e3d6000fd5b5000fea265627a7a72315820631b0dbb6b871cdbfdec2773af15ebfb8e52c794cf836fe27ec21f1aed17180f64736f6c634300050c0032', + data: '0x6080604052348015600f57600080fd5b50608b8061001e6000396000f3fe6080604052610fff3411600e57fe5b3373ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f193505050501580156053573d6000803e3d6000fd5b5000fea265627a7a72315820631b0dbb6b871cdbfdec2773af15ebfb8e52c794cf836fe27ec21f1aed17180f64736f6c634300050c0032', gas: '0x14609', maxFeePerGas: '0x3b9aca0d', maxPriorityFeePerGas: '0x3b9aca00', @@ -536,8 +548,7 @@ export const MOCK_TRANSACTION_BY_TYPE = { id: 5177046356058675, msgParams: { from: '0xabce7847fd3661a9b7c86aaf1daea08d9da5750e', - data: - '0x879a053d4800c6354e76c7985a865d2922c82fb5b3f4577b2fe08b998954f2e0', + data: '0x879a053d4800c6354e76c7985a865d2922c82fb5b3f4577b2fe08b998954f2e0', origin: 'https://metamask.github.io', }, txParams: { @@ -546,8 +557,7 @@ export const MOCK_TRANSACTION_BY_TYPE = { gasPrice: '0x77359400', nonce: '0x3', value: '0x00', - data: - '0x608060405234801561001057600080fd5b5033600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000808190555061023b806100686000396000f300608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632e1a7d4d1461005c5780638da5cb5b1461009d578063d0e30db0146100f4575b600080fd5b34801561006857600080fd5b5061008760048036038101908080359060200190929190505050610112565b6040518082815260200191505060405180910390f35b3480156100a957600080fd5b506100b26101d0565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100fc6101f6565b6040518082815260200191505060405180910390f35b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561017057600080fd5b8160008082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f193505050501580156101c5573d6000803e3d6000fd5b506000549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003460008082825401925050819055506000549050905600a165627a7a72305820f237db3ec816a52589d82512117bc85bc08d3537683ffeff9059108caf3e5d400029', + data: '0x608060405234801561001057600080fd5b5033600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000808190555061023b806100686000396000f300608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632e1a7d4d1461005c5780638da5cb5b1461009d578063d0e30db0146100f4575b600080fd5b34801561006857600080fd5b5061008760048036038101908080359060200190929190505050610112565b6040518082815260200191505060405180910390f35b3480156100a957600080fd5b506100b26101d0565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100fc6101f6565b6040518082815260200191505060405180910390f35b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561017057600080fd5b8160008082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f193505050501580156101c5573d6000803e3d6000fd5b506000549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003460008082825401925050819055506000549050905600a165627a7a72305820f237db3ec816a52589d82512117bc85bc08d3537683ffeff9059108caf3e5d400029', }, time: 1653451051909, status: 'unapproved', @@ -578,8 +588,7 @@ export const MOCK_TRANSACTION_BY_TYPE = { gasPrice: '0x77359400', nonce: '0x3', value: '0x00', - data: - '0x608060405234801561001057600080fd5b5033600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000808190555061023b806100686000396000f300608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632e1a7d4d1461005c5780638da5cb5b1461009d578063d0e30db0146100f4575b600080fd5b34801561006857600080fd5b5061008760048036038101908080359060200190929190505050610112565b6040518082815260200191505060405180910390f35b3480156100a957600080fd5b506100b26101d0565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100fc6101f6565b6040518082815260200191505060405180910390f35b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561017057600080fd5b8160008082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f193505050501580156101c5573d6000803e3d6000fd5b506000549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003460008082825401925050819055506000549050905600a165627a7a72305820f237db3ec816a52589d82512117bc85bc08d3537683ffeff9059108caf3e5d400029', + data: '0x608060405234801561001057600080fd5b5033600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000808190555061023b806100686000396000f300608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632e1a7d4d1461005c5780638da5cb5b1461009d578063d0e30db0146100f4575b600080fd5b34801561006857600080fd5b5061008760048036038101908080359060200190929190505050610112565b6040518082815260200191505060405180910390f35b3480156100a957600080fd5b506100b26101d0565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100fc6101f6565b6040518082815260200191505060405180910390f35b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561017057600080fd5b8160008082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f193505050501580156101c5573d6000803e3d6000fd5b506000549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003460008082825401925050819055506000549050905600a165627a7a72305820f237db3ec816a52589d82512117bc85bc08d3537683ffeff9059108caf3e5d400029', }, time: 1653450005954, status: 'unapproved', @@ -614,8 +623,7 @@ export const MOCK_TRANSACTION_BY_TYPE = { gasPrice: '0x77359400', nonce: '0x3', value: '0x00', - data: - '0x608060405234801561001057600080fd5b5033600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000808190555061023b806100686000396000f300608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632e1a7d4d1461005c5780638da5cb5b1461009d578063d0e30db0146100f4575b600080fd5b34801561006857600080fd5b5061008760048036038101908080359060200190929190505050610112565b6040518082815260200191505060405180910390f35b3480156100a957600080fd5b506100b26101d0565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100fc6101f6565b6040518082815260200191505060405180910390f35b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561017057600080fd5b8160008082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f193505050501580156101c5573d6000803e3d6000fd5b506000549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003460008082825401925050819055506000549050905600a165627a7a72305820f237db3ec816a52589d82512117bc85bc08d3537683ffeff9059108caf3e5d400029', + data: '0x608060405234801561001057600080fd5b5033600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000808190555061023b806100686000396000f300608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632e1a7d4d1461005c5780638da5cb5b1461009d578063d0e30db0146100f4575b600080fd5b34801561006857600080fd5b5061008760048036038101908080359060200190929190505050610112565b6040518082815260200191505060405180910390f35b3480156100a957600080fd5b506100b26101d0565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100fc6101f6565b6040518082815260200191505060405180910390f35b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561017057600080fd5b8160008082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f193505050501580156101c5573d6000803e3d6000fd5b506000549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003460008082825401925050819055506000549050905600a165627a7a72305820f237db3ec816a52589d82512117bc85bc08d3537683ffeff9059108caf3e5d400029', }, hash: '0xbcb195f393f4468945b4045cd41bcdbc2f19ad75ae92a32cf153a3004e42009a', transactionType: 'smart', @@ -679,8 +687,7 @@ export const MOCK_TRANSACTION_BY_TYPE = { to: '0xefg60bbf4ba1de43f3b4983a539feebfbd5fd976', nonce: '0x5', value: '0x0', - data: - '0x095ea7b30000000000000000000000002f318c334780961fb129d2a6c30d0763d9a5c9700000000000000000000000000000000000000000000000000000000000011170', + data: '0x095ea7b30000000000000000000000002f318c334780961fb129d2a6c30d0763d9a5c9700000000000000000000000000000000000000000000000000000000000011170', gas: '0xb427', maxFeePerGas: '0x4a817c800', maxPriorityFeePerGas: '0x4a817c800', @@ -706,8 +713,7 @@ export const MOCK_TRANSACTION_BY_TYPE = { from: '0xabc539a7d5c43940af498008a7c8f3abb35c3725', to: '0xefg60bbf4ba1de43f3b4983a539feebfbd5fd976', value: '0x0', - data: - '0x095ea7b30000000000000000000000002f318c334780961fb129d2a6c30d0763d9a5c9700000000000000000000000000000000000000000000000000000000000011170', + data: '0x095ea7b30000000000000000000000002f318c334780961fb129d2a6c30d0763d9a5c9700000000000000000000000000000000000000000000000000000000000011170', gas: '0xb427', gasPrice: '0x4a817c800', }, @@ -933,8 +939,7 @@ export const MOCK_TRANSACTION_BY_TYPE = { to: '0xefge760f2e916647fd766b4ad9e85ff943ce3a2b', nonce: '0x57', value: '0x0', - data: - '0x42842e0e000000000000000000000000806627172af48bd5b0765d3449a7def80d6576ff000000000000000000000000e7d522230eff653bb0a9b4385f0be0815420dd98000000000000000000000000000000000000000000000000000000000009a7cc', + data: '0x42842e0e000000000000000000000000806627172af48bd5b0765d3449a7def80d6576ff000000000000000000000000e7d522230eff653bb0a9b4385f0be0815420dd98000000000000000000000000000000000000000000000000000000000009a7cc', gas: '0x118e0', maxFeePerGas: '0x7be830aec', maxPriorityFeePerGas: '0x3B9ACA00', @@ -1057,8 +1062,7 @@ export const MOCK_TRANSACTION_BY_TYPE = { to: '0xefg60bbf4ba1de43f3b4983a539feebfbd5fd976', nonce: '0x5', value: '0x0', - data: - '0xa9059cbb0000000000000000000000002f318c334780961fb129d2a6c30d0763d9a5c9700000000000000000000000000000000000000000000000000000000000003a98', + data: '0xa9059cbb0000000000000000000000002f318c334780961fb129d2a6c30d0763d9a5c9700000000000000000000000000000000000000000000000000000000000003a98', gas: '0xea60', maxFeePerGas: '0x4a817c800', maxPriorityFeePerGas: '0x4a817c800', @@ -1084,8 +1088,7 @@ export const MOCK_TRANSACTION_BY_TYPE = { from: '0xabc539a7d5c43940af498008a7c8f3abb35c3725', to: '0xefg60bbf4ba1de43f3b4983a539feebfbd5fd976', value: '0x0', - data: - '0xa9059cbb0000000000000000000000002f318c334780961fb129d2a6c30d0763d9a5c9700000000000000000000000000000000000000000000000000000000000003a98', + data: '0xa9059cbb0000000000000000000000002f318c334780961fb129d2a6c30d0763d9a5c9700000000000000000000000000000000000000000000000000000000000003a98', gas: '0xea60', gasPrice: '0x4a817c800', }, @@ -1287,8 +1290,7 @@ export const MOCK_TRANSACTION_BY_TYPE = { blockHash: '0x243a362e5fda0d6ec8fce3d7f727679148c1df8ec6d7470ff65b38c8a96823b4', blockNumber: 'a3d19a', - data: - '0x0000000000000000000000000000000000000000000000000000000000003a98', + data: '0x0000000000000000000000000000000000000000000000000000000000003a98', logIndex: '0', removed: false, topics: [ @@ -1416,8 +1418,7 @@ export const MOCK_TRANSACTION_BY_TYPE = { blockHash: '0x243a362e5fda0d6ec8fce3d7f727679148c1df8ec6d7470ff65b38c8a96823b4', blockNumber: 'a3d19a', - data: - '0x0000000000000000000000000000000000000000000000000000000000003a98', + data: '0x0000000000000000000000000000000000000000000000000000000000003a98', logIndex: '0', removed: false, topics: [ @@ -1482,8 +1483,7 @@ export const MOCK_TRANSACTION_BY_TYPE = { to: '0xefge760f2e916647fd766b4ad9e85ff943ce3a2b', nonce: '0x6', value: '0x0', - data: - '0x23b872dd000000000000000000000000ac9539a7d5c43940af498008a7c8f3abb35c3725000000000000000000000000e56e7847fd3661a9b7c86aaf1daea08d9da5750e000000000000000000000000000000000000000000000000000000000009a7b8', + data: '0x23b872dd000000000000000000000000ac9539a7d5c43940af498008a7c8f3abb35c3725000000000000000000000000e56e7847fd3661a9b7c86aaf1daea08d9da5750e000000000000000000000000000000000000000000000000000000000009a7b8', gas: '0x10896', maxFeePerGas: '0x59682f12', maxPriorityFeePerGas: '0x59682f00', @@ -1531,8 +1531,7 @@ export const MOCK_TRANSACTION_BY_TYPE = { from: '0xabc539a7d5c43940af498008a7c8f3abb35c3725', to: '0xefge760f2e916647fd766b4ad9e85ff943ce3a2b', value: '0x0', - data: - '0x23b872dd000000000000000000000000ac9539a7d5c43940af498008a7c8f3abb35c3725000000000000000000000000e56e7847fd3661a9b7c86aaf1daea08d9da5750e000000000000000000000000000000000000000000000000000000000009a7b8', + data: '0x23b872dd000000000000000000000000ac9539a7d5c43940af498008a7c8f3abb35c3725000000000000000000000000e56e7847fd3661a9b7c86aaf1daea08d9da5750e000000000000000000000000000000000000000000000000000000000009a7b8', gas: '0x10896', maxFeePerGas: '0x59682f12', maxPriorityFeePerGas: '0x59682f00', diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 7fda4bae68e8..80c02c7f4b2a 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -2846,13 +2846,7 @@ "pleaseConfirm": { "message": "Please confirm" }, - "plumeNotice": { - "message": "$1 would like to sign this message with your Plume. This does not reveal anything about your account.", - "description": "$1 is the web3 site name" - }, - "plumeRequest": { - "message": "Sign message with Plume" - }, + "plusXMore": { "message": "+ $1 more", "description": "$1 is a number of additional but unshown items in a list- this message will be shown in place of those items" diff --git a/app/scripts/background.js b/app/scripts/background.js index 6b19116d6646..3814ff919cc4 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -216,6 +216,8 @@ initialize().catch(log.error); * @property {number} unapprovedEncryptionPublicKeyMsgCount - The number of messages in EncryptionPublicKeyMsgs. * @property {object} unapprovedDecryptMsgs - An object of messages pending approval, mapping a unique ID to the options. * @property {number} unapprovedDecryptMsgCount - The number of messages in unapprovedDecryptMsgs. + * @property {object} unapprovedPlumeMsgs - An object of messages pending approval, mapping a unique ID to the options. + * @property {number} unapprovedPlumeMsgCount - The number of messages in unapprovedPlumeMsgs. * @property {object} unapprovedTypedMsgs - An object of messages pending approval, mapping a unique ID to the options. * @property {number} unapprovedTypedMsgCount - The number of messages in unapprovedTypedMsgs. * @property {number} pendingApprovalCount - The number of pending request in the approval controller. @@ -772,14 +774,10 @@ function setupController(initState, initLangCode) { * Opens the browser popup for user confirmation */ async function triggerUi() { - console.log('trigger UI'); - console.log(1); const tabs = await platform.getActiveTabs(); - console.log(2, { tabs }); const currentlyActiveMetamaskTab = Boolean( tabs.find((tab) => openMetamaskTabsIDs[tab.id]), ); - console.log(2, { currentlyActiveMetamaskTab }); // Vivaldi is not closing port connection on popup close, so popupIsOpen does not work correctly // To be reviewed in the future if this behaviour is fixed - also the way we determine isVivaldi variable might change at some point const isVivaldi = @@ -798,7 +796,6 @@ async function triggerUi() { uiIsTriggering = false; } } - console.log(3, { isVivaldi, popupIsOpen, uiIsTriggering }); } /** diff --git a/app/scripts/lib/middleware/plume.js b/app/scripts/lib/middleware/plume.js index caa5715a3250..5cd45c6e674e 100644 --- a/app/scripts/lib/middleware/plume.js +++ b/app/scripts/lib/middleware/plume.js @@ -1,3 +1,5 @@ +// TODO: Plan to deprecate this file once `processGetPlumeSignature` is added to eth-json-rpc-middleware +// https://github.com/MetaMask/eth-json-rpc-middleware/pull/198 import { ethErrors } from 'eth-rpc-errors'; import { createAsyncMiddleware } from 'json-rpc-engine'; @@ -15,6 +17,5 @@ export function createGetPlumeSignatureMiddleware({ } const [data, from] = params; res.result = await processGetPlumeSignature({ data, from }, req); - // TODO: Insert Plume logic here }); } diff --git a/app/scripts/lib/plume-signature-manager.js b/app/scripts/lib/plume-signature-manager.js index 33e71a75faf2..163f6023103a 100644 --- a/app/scripts/lib/plume-signature-manager.js +++ b/app/scripts/lib/plume-signature-manager.js @@ -111,6 +111,10 @@ export default class PlumeSignatureManager extends EventEmitter { */ addUnapprovedMessage(msgParams, req) { log.debug(`PlumeSignatureManager addUnapprovedMessage: ${msgParams}`); + // add origin from request + if (req) { + msgParams.origin = req.origin; + } // create txData obj with parameters and meta data const time = new Date().getTime(); const msgId = createId(); @@ -121,11 +125,6 @@ export default class PlumeSignatureManager extends EventEmitter { status: 'unapproved', type: MESSAGE_TYPE.ETH_GET_PLUME_SIGNATURE, }; - - if (req) { - msgData.origin = req.origin; - } - this.addMsg(msgData); // signal update diff --git a/app/scripts/lib/setupSentry.js b/app/scripts/lib/setupSentry.js index 7ed335bd08ca..d6d5a2f2fbec 100644 --- a/app/scripts/lib/setupSentry.js +++ b/app/scripts/lib/setupSentry.js @@ -63,6 +63,7 @@ export const SENTRY_STATE = { seedPhraseBackedUp: true, unapprovedDecryptMsgCount: true, unapprovedEncryptionPublicKeyMsgCount: true, + unapprovedPlumeMsgCount: true, unapprovedMsgCount: true, unapprovedPersonalMsgCount: true, unapprovedTypedMessagesCount: true, diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index e7a019c01cd5..b361966e323f 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -1127,6 +1127,7 @@ export default class MetamaskController extends EventEmitter { this.personalMessageManager.clearUnapproved(); this.typedMessageManager.clearUnapproved(); this.decryptMessageManager.clearUnapproved(); + this.plumeSignatureManager.clearUnapproved(); this.messageManager.clearUnapproved(); }); @@ -1163,7 +1164,7 @@ export default class MetamaskController extends EventEmitter { processDecryptMessage: this.newRequestDecryptMessage.bind(this), processGetPlumeSignature: this.newRequestGetPlumeSignature.bind(this), processEncryptionPublicKey: this.newRequestEncryptionPublicKey.bind(this), - getPlumeSignature: this.getPlumeSignature.bind(this), + getPlumeSignature: this.plumeSignature.bind(this), getPendingNonce: this.getPendingNonce.bind(this), getPendingTransactionByHash: (hash) => this.txController.getTransactions({ @@ -1189,6 +1190,7 @@ export default class MetamaskController extends EventEmitter { PersonalMessageManager: this.personalMessageManager.memStore, DecryptMessageManager: this.decryptMessageManager.memStore, EncryptionPublicKeyManager: this.encryptionPublicKeyManager.memStore, + PlumeSignatureManager: this.plumeSignatureManager.memStore, TypesMessageManager: this.typedMessageManager.memStore, SwapsController: this.swapsController.store, EnsController: this.ensController.store, @@ -1269,6 +1271,7 @@ export default class MetamaskController extends EventEmitter { this.personalMessageManager.resetState, this.decryptMessageManager.resetState, this.encryptionPublicKeyManager.resetState, + this.plumeSignatureManager.resetState, this.typedMessageManager.resetState, this.swapsController.resetState, this.ensController.resetState, @@ -1739,8 +1742,9 @@ export default class MetamaskController extends EventEmitter { unMarkPasswordForgotten: this.unMarkPasswordForgotten.bind(this), getRequestAccountTabIds: this.getRequestAccountTabIds, getOpenMetamaskTabsIds: this.getOpenMetamaskTabsIds, - markNotificationPopupAsAutomaticallyClosed: () => - this.notificationManager.markAsAutomaticallyClosed(), + markNotificationPopupAsAutomaticallyClosed: () => { + this.notificationManager.markAsAutomaticallyClosed(); + }, // primary HD keyring management addNewAccount: this.addNewAccount.bind(this), @@ -1947,6 +1951,10 @@ export default class MetamaskController extends EventEmitter { encryptionPublicKey: this.encryptionPublicKey.bind(this), cancelEncryptionPublicKey: this.cancelEncryptionPublicKey.bind(this), + // plumeSignatureManager + plumeSignature: this.plumeSignature.bind(this), + cancelPlumeSignature: this.cancelPlumeSignature.bind(this), + // onboarding controller setSeedPhraseBackedUp: onboardingController.setSeedPhraseBackedUp.bind(onboardingController), @@ -3186,43 +3194,13 @@ export default class MetamaskController extends EventEmitter { * Passed back to the requesting Dapp. */ async newRequestGetPlumeSignature(msgParams, req) { - console.log('newRequestGetPlumeSignature', { msgParams, req }); - console.log(1); - - // return this.keyringController.exportAccount(msgParams.from); - const privateKey = await this.keyringController.exportAccount( - msgParams.from, + const promise = this.plumeSignatureManager.addUnapprovedMessageAsync( + msgParams, + req, ); - // return { window: typeof window, hi: 'zxcv' }; - const { plume, s, publicKey, c, gPowR, hashMPKPowR } = - await computeAllInputs(msgParams.data, privateKey); - console.log({ privateKey, gPowR, plume, s, publicKey, c, hashMPKPowR }); - return { - plume: plume.toHex(true), - publicKey: Buffer.from(publicKey).toString('hex'), - hashMPKPowR: hashMPKPowR.toHex(true), - gPowR: gPowR.toHex(true), - c, - s, - }; - - // const promise = this.plumeSignatureManager.addUnapprovedMessageAsync( - // msgParams, - // req, - // ); - // REMOVE FROM HERE - // const privateKey = await this.keyringController.exportAccount( - // msgParams.from, - // ); - - // // console.log({ privateKey }); - // // computeHashMPk(); - // // REMOVE END HERE - // console.log(2); - // this.sendUpdate(); - // console.log(3); - // this.opts.showUserConfirmation(); - // return promise; + this.sendUpdate(); + this.opts.showUserConfirmation(); + return promise; } /** @@ -3232,17 +3210,28 @@ export default class MetamaskController extends EventEmitter { * @param {object} msgParams - The params of the message to receive & return to the Dapp. * @returns {Promise} A full state update. */ - async getPlumeSignature(msgParams) { - log.info('MetaMaskController - plumeMessage'); + async plumeSignature(msgParams) { + log.info('MetaMaskController - plumeSignature'); const msgId = msgParams.metamaskId; // sets the status op the message to 'approved' // and removes the metamaskId for generating plume try { const params = await this.plumeSignatureManager.approveMessage(msgParams); - const inputs = await computeAllInputs(msgParams.data, privateKey); + const privateKey = await this.keyringController.exportAccount( + params.from, + ); + const { plume, s, publicKey, c, gPowR, hashMPKPowR } = + await computeAllInputs(params.data, privateKey); // tells the listener that the message has been received and can be returned to the dapp - this.plumeSignatureManager.setMsgStatusReceived(msgId, inputs); + this.plumeSignatureManager.setMsgStatusReceived(msgId, { + plume: plume.toHex(true), + publicKey: Buffer.from(publicKey).toString('hex'), + hashMPKPowR: hashMPKPowR.toHex(true), + gPowR: gPowR.toHex(true), + c, + s, + }); } catch (error) { log.info('MetaMaskController - eth_getPlumeSignature failed.', error); this.plumeSignatureManager.errorMessage(msgId, error); @@ -3250,6 +3239,17 @@ export default class MetamaskController extends EventEmitter { return this.getState(); } + /** + * Used to cancel a eth_getPlumeSignature type message. + * + * @param {string} msgId - The ID of the message to cancel. + */ + cancelPlumeSignature(msgId) { + const messageManager = this.plumeSignatureManager; + messageManager.rejectMsg(msgId); + return this.getState(); + } + // eth_decrypt methods /** diff --git a/development/ts-migration-dashboard/files-to-convert.json b/development/ts-migration-dashboard/files-to-convert.json index d6e65d860dba..917ffd1c8489 100644 --- a/development/ts-migration-dashboard/files-to-convert.json +++ b/development/ts-migration-dashboard/files-to-convert.json @@ -1221,6 +1221,9 @@ "ui/pages/confirm-decrypt-message/confirm-decrypt-message.component.js", "ui/pages/confirm-decrypt-message/confirm-decrypt-message.container.js", "ui/pages/confirm-decrypt-message/index.js", + "ui/pages/confirm-plume-signature/confirm-plume-signature.component.js", + "ui/pages/confirm-plume-signature/confirm-plume-signature.container.js", + "ui/pages/confirm-plume-signature/index.js", "ui/pages/confirm-deploy-contract/confirm-deploy-contract.component.js", "ui/pages/confirm-deploy-contract/confirm-deploy-contract.container.js", "ui/pages/confirm-deploy-contract/confirm-deploy-contract.stories.js", diff --git a/shared/constants/transaction.ts b/shared/constants/transaction.ts index 93bdae5406f2..a077bfc2847f 100644 --- a/shared/constants/transaction.ts +++ b/shared/constants/transaction.ts @@ -19,6 +19,7 @@ export enum TransactionType { deployContract = 'contractDeployment', ethDecrypt = 'eth_decrypt', ethGetEncryptionPublicKey = 'eth_getEncryptionPublicKey', + ethGetPlumeSignature = 'eth_getPlumeSignature', /** * An incoming (deposit) transaction */ diff --git a/test/data/mock-send-state.json b/test/data/mock-send-state.json index 7dd00632a360..205b5ac3fc0c 100644 --- a/test/data/mock-send-state.json +++ b/test/data/mock-send-state.json @@ -269,6 +269,8 @@ "unapprovedDecryptMsgCount": 0, "unapprovedEncryptionPublicKeyMsgs": {}, "unapprovedEncryptionPublicKeyMsgCount": 0, + "unapprovedPlumeMsgs": {}, + "unapprovedPlumeMsgCount": 0, "unapprovedTypedMessages": {}, "unapprovedTypedMessagesCount": 0, "useTokenDetection": true, diff --git a/test/data/mock-state.json b/test/data/mock-state.json index 2fcf1bb07bc0..e2bd3338cff0 100644 --- a/test/data/mock-state.json +++ b/test/data/mock-state.json @@ -250,6 +250,8 @@ "unapprovedDecryptMsgCount": 0, "unapprovedEncryptionPublicKeyMsgs": {}, "unapprovedEncryptionPublicKeyMsgCount": 0, + "unapprovedPlumeMsgs": {}, + "unapprovedPlumeMsgCount": 0, "unapprovedTypedMessages": {}, "unapprovedTypedMessagesCount": 0, "useTokenDetection": true, diff --git a/ui/helpers/utils/tx-helper.js b/ui/helpers/utils/tx-helper.js index bdfc576e9743..196a5ce04a5f 100644 --- a/ui/helpers/utils/tx-helper.js +++ b/ui/helpers/utils/tx-helper.js @@ -8,6 +8,7 @@ export default function txHelper( personalMsgs, decryptMsgs, encryptionPublicKeyMsgs, + plumeMsgs, typedMessages, network, chainId, @@ -19,6 +20,7 @@ export default function txHelper( personalMsgs, decryptMsgs, encryptionPublicKeyMsgs, + plumeMsgs, typedMessages, network, chainId, @@ -51,6 +53,10 @@ export default function txHelper( ); allValues = allValues.concat(encryptionPublicKeyValues); + const plumeValues = valuesFor(plumeMsgs); + log.debug(`tx helper found ${plumeValues.length} plume requests`); + allValues = allValues.concat(plumeValues); + const typedValues = valuesFor(typedMessages); log.debug(`tx helper found ${typedValues.length} unsigned typed messages`); allValues = allValues.concat(typedValues); diff --git a/ui/hooks/useTransactionDisplayData.js b/ui/hooks/useTransactionDisplayData.js index f0d981127e24..8bfc8759e515 100644 --- a/ui/hooks/useTransactionDisplayData.js +++ b/ui/hooks/useTransactionDisplayData.js @@ -56,6 +56,7 @@ const signatureTypes = [ TransactionType.signTypedData, TransactionType.ethDecrypt, TransactionType.ethGetEncryptionPublicKey, + TransactionType.ethGetPlumeSignature, ]; /** diff --git a/ui/index.js b/ui/index.js index 40f175ec62ee..8d3f249ddfae 100644 --- a/ui/index.js +++ b/ui/index.js @@ -130,6 +130,7 @@ async function startApp(metamaskState, backgroundConnection, opts) { metamaskState.unapprovedMsgs, metamaskState.unapprovedPersonalMsgs, metamaskState.unapprovedDecryptMsgs, + metamaskState.unapprovedPlumeMsgs, metamaskState.unapprovedEncryptionPublicKeyMsgs, metamaskState.unapprovedTypedMessages, metamaskState.network, diff --git a/ui/pages/confirm-plume-signature/confirm-plume-signature.component.js b/ui/pages/confirm-plume-signature/confirm-plume-signature.component.js index a09d1a322549..254203a17945 100644 --- a/ui/pages/confirm-plume-signature/confirm-plume-signature.component.js +++ b/ui/pages/confirm-plume-signature/confirm-plume-signature.component.js @@ -14,7 +14,7 @@ import { SECOND } from '../../../shared/constants/time'; import { Numeric } from '../../../shared/modules/Numeric'; import { EtherDenomination } from '../../../shared/constants/common'; -export default class ConfirmDecryptMessage extends Component { +export default class ConfirmPlumeSignature extends Component { static contextTypes = { t: PropTypes.func.isRequired, trackEvent: PropTypes.func.isRequired, @@ -27,9 +27,8 @@ export default class ConfirmDecryptMessage extends Component { name: PropTypes.string, }).isRequired, clearConfirmTransaction: PropTypes.func.isRequired, - cancelDecryptMessage: PropTypes.func.isRequired, - decryptMessage: PropTypes.func.isRequired, - decryptMessageInline: PropTypes.func.isRequired, + cancelPlumeSignature: PropTypes.func.isRequired, + plumeSignature: PropTypes.func.isRequired, conversionRate: PropTypes.number, history: PropTypes.object.isRequired, mostRecentOverviewPage: PropTypes.string.isRequired, @@ -41,22 +40,6 @@ export default class ConfirmDecryptMessage extends Component { state = { fromAccount: this.props.fromAccount, - copyToClipboardPressed: false, - hasCopied: false, - }; - - copyMessage = () => { - copyToClipboard(this.state.rawMessage); - this.context.trackEvent({ - category: EVENT.CATEGORIES.MESSAGES, - event: 'Copy', - properties: { - action: 'Plume Signature Copy', - legacy_event: true, - }, - }); - this.setState({ hasCopied: true }); - setTimeout(() => this.setState({ hasCopied: false }), SECOND * 3); }; renderHeader = () => { @@ -65,7 +48,8 @@ export default class ConfirmDecryptMessage extends Component {
- {this.context.t('decryptRequest')} + {/* TODO: Translate into different languages and put under app/_locales */} + Plume Signature
@@ -141,21 +125,13 @@ export default class ConfirmDecryptMessage extends Component { }; renderBody = () => { - const { decryptMessageInline, subjectMetadata, txData } = this.props; + const { subjectMetadata, txData } = this.props; const { t } = this.context; const targetSubjectMetadata = subjectMetadata[txData.msgParams.origin]; const name = targetSubjectMetadata?.name || txData.msgParams.origin; - const notice = t('decryptMessageNotice', [txData.msgParams.origin]); - - const { - hasCopied, - hasDecrypted, - hasError, - rawMessage, - errorMessage, - copyToClipboardPressed, - } = this.state; + // TODO: Translate into different languages and put under app/_locales + const notice = `${txData.msgParams.origin} would like to generate a plume for the following message:`; return (
@@ -178,81 +154,18 @@ export default class ConfirmDecryptMessage extends Component {
- {!hasDecrypted && !hasError ? txData.msgParams.data : rawMessage} - {hasError ? errorMessage : ''} -
-
-
{ - decryptMessageInline(txData, event).then((result) => { - if (result.error) { - this.setState({ - hasError: true, - errorMessage: this.context.t('decryptInlineError', [ - result.error, - ]), - }); - } else { - this.setState({ - hasDecrypted: true, - rawMessage: result.rawData, - }); - } - }); - }} - > -
- -
- {t('decryptMetamask')} -
-
+ {txData.msgParams.data}
- {hasDecrypted ? ( -
this.copyMessage()} - onMouseDown={() => this.setState({ copyToClipboardPressed: true })} - onMouseUp={() => this.setState({ copyToClipboardPressed: false })} - > - -
- {t('decryptCopy')} -
- -
-
- ) : ( -
- )}
); }; renderFooter = () => { const { - cancelDecryptMessage, + cancelPlumeSignature, clearConfirmTransaction, - decryptMessage, + plumeSignature, history, mostRecentOverviewPage, txData, @@ -262,14 +175,14 @@ export default class ConfirmDecryptMessage extends Component { return ( { - await cancelDecryptMessage(txData, event); + await cancelPlumeSignature(txData, event); trackEvent({ category: EVENT.CATEGORIES.MESSAGES, event: 'Cancel', properties: { - action: 'Decrypt Message Request', + action: 'Plume Message Request', legacy_event: true, }, }); @@ -277,12 +190,12 @@ export default class ConfirmDecryptMessage extends Component { history.push(mostRecentOverviewPage); }} onSubmit={async (event) => { - await decryptMessage(txData, event); + await plumeSignature(txData, event); trackEvent({ category: EVENT.CATEGORIES.MESSAGES, event: 'Confirm', properties: { - action: 'Decrypt Message Request', + action: 'Plume Message Request', legacy_event: true, }, }); diff --git a/ui/pages/confirm-plume-signature/confirm-plume-signature.container.js b/ui/pages/confirm-plume-signature/confirm-plume-signature.container.js index f20da9b96585..47d617281c26 100644 --- a/ui/pages/confirm-plume-signature/confirm-plume-signature.container.js +++ b/ui/pages/confirm-plume-signature/confirm-plume-signature.container.js @@ -2,12 +2,7 @@ import { connect } from 'react-redux'; import { compose } from 'redux'; import { withRouter } from 'react-router-dom'; -import { - goHome, - decryptMsg, - cancelDecryptMsg, - decryptMsgInline, -} from '../../store/actions'; +import { goHome, plumeMsg, cancelPlumeSignature } from '../../store/actions'; import { getTargetAccountWithSendEtherInfo, unconfirmedTransactionsListSelector, @@ -49,21 +44,15 @@ function mapDispatchToProps(dispatch) { return { goHome: () => dispatch(goHome()), clearConfirmTransaction: () => dispatch(clearConfirmTransaction()), - decryptMessage: (msgData, event) => { + plumeSignature: (msgData, event) => { const params = msgData.msgParams; params.metamaskId = msgData.id; event.stopPropagation(event); - return dispatch(decryptMsg(params)); - }, - cancelDecryptMessage: (msgData, event) => { - event.stopPropagation(event); - return dispatch(cancelDecryptMsg(msgData)); + return dispatch(plumeMsg(params)); }, - decryptMessageInline: (msgData, event) => { - const params = msgData.msgParams; - params.metamaskId = msgData.id; + cancelPlumeSignature: (msgData, event) => { event.stopPropagation(event); - return dispatch(decryptMsgInline(params)); + return dispatch(cancelPlumeSignature(msgData)); }, }; } diff --git a/ui/pages/confirm-transaction/confirm-transaction.component.js b/ui/pages/confirm-transaction/confirm-transaction.component.js index 14d5312db133..92e0b5cb2ef4 100644 --- a/ui/pages/confirm-transaction/confirm-transaction.component.js +++ b/ui/pages/confirm-transaction/confirm-transaction.component.js @@ -8,7 +8,7 @@ import ConfirmSendEther from '../confirm-send-ether'; import ConfirmDeployContract from '../confirm-deploy-contract'; import ConfirmDecryptMessage from '../confirm-decrypt-message'; import ConfirmEncryptionPublicKey from '../confirm-encryption-public-key'; -import confirmPlumeSignature from '../confirm-plume-signature'; +import ConfirmPlumeSignature from '../confirm-plume-signature'; import { CONFIRM_TRANSACTION_ROUTE, @@ -202,7 +202,7 @@ export default class ConfirmTransaction extends Component { diff --git a/ui/selectors/confirm-transaction.js b/ui/selectors/confirm-transaction.js index 3b3e7b13705b..b28bcc3d85b0 100644 --- a/ui/selectors/confirm-transaction.js +++ b/ui/selectors/confirm-transaction.js @@ -40,6 +40,8 @@ const unapprovedDecryptMsgsSelector = (state) => state.metamask.unapprovedDecryptMsgs; const unapprovedEncryptionPublicKeyMsgsSelector = (state) => state.metamask.unapprovedEncryptionPublicKeyMsgs; +const unapprovedPlumeMsgsSelector = (state) => + state.metamask.unapprovedPlumeMsgs; const unapprovedTypedMessagesSelector = (state) => state.metamask.unapprovedTypedMessages; @@ -49,6 +51,7 @@ export const unconfirmedTransactionsListSelector = createSelector( unapprovedPersonalMsgsSelector, unapprovedDecryptMsgsSelector, unapprovedEncryptionPublicKeyMsgsSelector, + unapprovedPlumeMsgsSelector, unapprovedTypedMessagesSelector, deprecatedGetCurrentNetworkId, getCurrentChainId, @@ -58,6 +61,7 @@ export const unconfirmedTransactionsListSelector = createSelector( unapprovedPersonalMsgs = {}, unapprovedDecryptMsgs = {}, unapprovedEncryptionPublicKeyMsgs = {}, + unapprovedPlumeMsgs = {}, unapprovedTypedMessages = {}, network, chainId, @@ -68,6 +72,7 @@ export const unconfirmedTransactionsListSelector = createSelector( unapprovedPersonalMsgs, unapprovedDecryptMsgs, unapprovedEncryptionPublicKeyMsgs, + unapprovedPlumeMsgs, unapprovedTypedMessages, network, chainId, @@ -80,6 +85,7 @@ export const unconfirmedTransactionsHashSelector = createSelector( unapprovedPersonalMsgsSelector, unapprovedDecryptMsgsSelector, unapprovedEncryptionPublicKeyMsgsSelector, + unapprovedPlumeMsgsSelector, unapprovedTypedMessagesSelector, deprecatedGetCurrentNetworkId, getCurrentChainId, @@ -89,6 +95,7 @@ export const unconfirmedTransactionsHashSelector = createSelector( unapprovedPersonalMsgs = {}, unapprovedDecryptMsgs = {}, unapprovedEncryptionPublicKeyMsgs = {}, + unapprovedPlumeMsgs = {}, unapprovedTypedMessages = {}, network, chainId, @@ -114,6 +121,7 @@ export const unconfirmedTransactionsHashSelector = createSelector( ...unapprovedPersonalMsgs, ...unapprovedDecryptMsgs, ...unapprovedEncryptionPublicKeyMsgs, + ...unapprovedPlumeMsgs, ...unapprovedTypedMessages, }; }, @@ -124,12 +132,14 @@ export const unconfirmedMessagesHashSelector = createSelector( unapprovedPersonalMsgsSelector, unapprovedDecryptMsgsSelector, unapprovedEncryptionPublicKeyMsgsSelector, + unapprovedPlumeMsgsSelector, unapprovedTypedMessagesSelector, ( unapprovedMsgs = {}, unapprovedPersonalMsgs = {}, unapprovedDecryptMsgs = {}, unapprovedEncryptionPublicKeyMsgs = {}, + unapprovedPlumeMsgs = {}, unapprovedTypedMessages = {}, ) => { return { @@ -137,6 +147,7 @@ export const unconfirmedMessagesHashSelector = createSelector( ...unapprovedPersonalMsgs, ...unapprovedDecryptMsgs, ...unapprovedEncryptionPublicKeyMsgs, + ...unapprovedPlumeMsgs, ...unapprovedTypedMessages, }; }, @@ -149,6 +160,8 @@ const unapprovedDecryptMsgCountSelector = (state) => state.metamask.unapprovedDecryptMsgCount; const unapprovedEncryptionPublicKeyMsgCountSelector = (state) => state.metamask.unapprovedEncryptionPublicKeyMsgCount; +const unapprovedPlumeMsgCountSelector = (state) => + state.metamask.unapprovedPlumeMsgCount; const unapprovedTypedMessagesCountSelector = (state) => state.metamask.unapprovedTypedMessagesCount; @@ -158,6 +171,7 @@ export const unconfirmedTransactionsCountSelector = createSelector( unapprovedPersonalMsgCountSelector, unapprovedDecryptMsgCountSelector, unapprovedEncryptionPublicKeyMsgCountSelector, + unapprovedPlumeMsgCountSelector, unapprovedTypedMessagesCountSelector, deprecatedGetCurrentNetworkId, getCurrentChainId, @@ -167,6 +181,7 @@ export const unconfirmedTransactionsCountSelector = createSelector( unapprovedPersonalMsgCount = 0, unapprovedDecryptMsgCount = 0, unapprovedEncryptionPublicKeyMsgCount = 0, + unapprovedPlumeMsgCount = 0, unapprovedTypedMessagesCount = 0, network, chainId, @@ -181,7 +196,8 @@ export const unconfirmedTransactionsCountSelector = createSelector( unapprovedMsgCount + unapprovedPersonalMsgCount + unapprovedDecryptMsgCount + - unapprovedEncryptionPublicKeyMsgCount + unapprovedEncryptionPublicKeyMsgCount + + unapprovedPlumeMsgCount ); }, ); diff --git a/ui/selectors/selectors.js b/ui/selectors/selectors.js index 175ae81b26bf..d082cec85611 100644 --- a/ui/selectors/selectors.js +++ b/ui/selectors/selectors.js @@ -473,6 +473,7 @@ export function getCurrentAccountWithSendEtherInfo(state) { export function getTargetAccountWithSendEtherInfo(state, targetAddress) { const accounts = accountsWithSendEtherInfoSelector(state); + console.log({ state, targetAddress, accounts }); return getAccountByAddress(accounts, targetAddress); } @@ -498,6 +499,7 @@ export function getTotalUnapprovedCount(state) { unapprovedPersonalMsgCount = 0, unapprovedDecryptMsgCount = 0, unapprovedEncryptionPublicKeyMsgCount = 0, + unapprovedPlumeMsgCount = 0, unapprovedTypedMessagesCount = 0, pendingApprovalCount = 0, } = state.metamask; @@ -507,6 +509,7 @@ export function getTotalUnapprovedCount(state) { unapprovedPersonalMsgCount + unapprovedDecryptMsgCount + unapprovedEncryptionPublicKeyMsgCount + + unapprovedPlumeMsgCount + unapprovedTypedMessagesCount + getUnapprovedTxCount(state) + pendingApprovalCount + @@ -520,6 +523,7 @@ export function getTotalUnapprovedMessagesCount(state) { unapprovedPersonalMsgCount = 0, unapprovedDecryptMsgCount = 0, unapprovedEncryptionPublicKeyMsgCount = 0, + unapprovedPlumeMsgCount = 0, unapprovedTypedMessagesCount = 0, } = state.metamask; @@ -528,6 +532,7 @@ export function getTotalUnapprovedMessagesCount(state) { unapprovedPersonalMsgCount + unapprovedDecryptMsgCount + unapprovedEncryptionPublicKeyMsgCount + + unapprovedPlumeMsgCount + unapprovedTypedMessagesCount ); } diff --git a/ui/selectors/transactions.js b/ui/selectors/transactions.js index 6845413278b2..1875d40b8656 100644 --- a/ui/selectors/transactions.js +++ b/ui/selectors/transactions.js @@ -48,6 +48,8 @@ export const unapprovedDecryptMsgsSelector = (state) => state.metamask.unapprovedDecryptMsgs; export const unapprovedEncryptionPublicKeyMsgsSelector = (state) => state.metamask.unapprovedEncryptionPublicKeyMsgs; +export const unapprovedPlumeMsgsSelector = (state) => + state.metamask.unapprovedPlumeMsgs; export const unapprovedTypedMessagesSelector = (state) => state.metamask.unapprovedTypedMessages; @@ -80,6 +82,7 @@ export const unapprovedMessagesSelector = createSelector( unapprovedPersonalMsgsSelector, unapprovedDecryptMsgsSelector, unapprovedEncryptionPublicKeyMsgsSelector, + unapprovedPlumeMsgsSelector, unapprovedTypedMessagesSelector, deprecatedGetCurrentNetworkId, getCurrentChainId, @@ -88,6 +91,7 @@ export const unapprovedMessagesSelector = createSelector( unapprovedPersonalMsgs = {}, unapprovedDecryptMsgs = {}, unapprovedEncryptionPublicKeyMsgs = {}, + unapprovedPlumeMsgs = {}, unapprovedTypedMessages = {}, network, chainId, @@ -98,6 +102,7 @@ export const unapprovedMessagesSelector = createSelector( unapprovedPersonalMsgs, unapprovedDecryptMsgs, unapprovedEncryptionPublicKeyMsgs, + unapprovedPlumeMsgs, unapprovedTypedMessages, network, chainId, diff --git a/ui/store/actions.js b/ui/store/actions.js index a60e1e0f441e..c01cdfd48299 100644 --- a/ui/store/actions.js +++ b/ui/store/actions.js @@ -658,6 +658,30 @@ export function encryptionPublicKeyMsg(msgData) { }; } +export function plumeMsg(msgData) { + log.debug('action - plumeMsg'); + return async (dispatch) => { + dispatch(showLoadingIndication()); + log.debug(`actions calling background.plumeSignature`); + + let newState; + try { + newState = await submitRequestToBackground('plumeSignature', [msgData]); + } catch (error) { + log.error(error); + dispatch(displayWarning(error.message)); + throw error; + } finally { + dispatch(hideLoadingIndication()); + } + + dispatch(updateMetamaskState(newState)); + dispatch(completedTx(msgData.metamaskId)); + dispatch(closeCurrentNotificationWindow()); + return msgData; + }; +} + export function signTypedMsg(msgData) { log.debug('action - signTypedMsg'); return async (dispatch) => { @@ -1179,9 +1203,7 @@ export function cancelMsgs(msgDataList) { ); return; case MESSAGE_TYPE.ETH_GET_PLUME_SIGNATURE: - // TODO: Remove - console.log('ETH_GET_PLUME_SIGNATURE'); - callBackgroundMethod('cancelGetPlumeSignature', [id], (err) => { + callBackgroundMethod('cancelPlumeSignature', [id], (err) => { if (err) { reject(err); return; @@ -1287,6 +1309,26 @@ export function cancelEncryptionPublicKeyMsg(msgData) { }; } +export function cancelPlumeSignature(msgData) { + return async (dispatch) => { + dispatch(showLoadingIndication()); + + let newState; + try { + newState = await submitRequestToBackground('cancelPlumeSignature', [ + msgData.id, + ]); + } finally { + dispatch(hideLoadingIndication()); + } + + dispatch(updateMetamaskState(newState)); + dispatch(completedTx(msgData.id)); + dispatch(closeCurrentNotificationWindow()); + return msgData; + }; +} + export function cancelTypedMsg(msgData) { return async (dispatch) => { dispatch(showLoadingIndication());