From 2dc8cb71365b423dbccbd413eea7f1a479abf414 Mon Sep 17 00:00:00 2001 From: MetaMask Bot Date: Fri, 6 Jan 2023 20:08:14 +0000 Subject: [PATCH 1/6] Version v10.23.3 --- CHANGELOG.md | 5 ++++- package.json | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 30f18d6c7..2ceda35af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [10.23.3] + ## [10.23.2] ### Fixed - Improve performance on signature request screens ([#17052](https://github.com/MetaMask/metamask-extension/pull/17052)) @@ -3344,7 +3346,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Uncategorized - Added the ability to restore accounts from seed words. -[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v10.23.2...HEAD +[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v10.23.3...HEAD +[10.23.3]: https://github.com/MetaMask/metamask-extension/compare/v10.23.2...v10.23.3 [10.23.2]: https://github.com/MetaMask/metamask-extension/compare/v10.23.1...v10.23.2 [10.23.1]: https://github.com/MetaMask/metamask-extension/compare/v10.23.0...v10.23.1 [10.23.0]: https://github.com/MetaMask/metamask-extension/compare/v10.22.3...v10.23.0 diff --git a/package.json b/package.json index da038edc0..e974f4665 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "metamask-crx", - "version": "10.23.2", + "version": "10.23.3", "private": true, "repository": { "type": "git", From 5672f24c9f6fe656e3f6d749fa445f4ad1b1b3cc Mon Sep 17 00:00:00 2001 From: PeterYinusa Date: Thu, 5 Jan 2023 11:41:59 +0000 Subject: [PATCH 2/6] fix audit failure (#17079) --- .iyarc | 10 ++++++++++ lavamoat/browserify/beta/policy.json | 5 +---- lavamoat/browserify/flask/policy.json | 5 +---- lavamoat/browserify/main/policy.json | 5 +---- package.json | 2 +- patches/fast-json-patch+2.2.1.patch | 13 ------------- yarn.lock | 7 ++++++- 7 files changed, 20 insertions(+), 27 deletions(-) delete mode 100644 patches/fast-json-patch+2.2.1.patch diff --git a/.iyarc b/.iyarc index 316510d7d..1d0f2111f 100644 --- a/.iyarc +++ b/.iyarc @@ -1,2 +1,12 @@ # improved-yarn-audit advisory exclusions GHSA-257v-vj4p-3w2h + +# yarn npm audit reports on a fast-json-patch version < 3.1.1 but due to patch +# resolution, the only version of fast-json-patch that we use is 3.1.1. We also +# have 2.2.1 installed but it is a dev only dependency. The "violation" reports +# smart-transacton-controller as the culprit but if you run +# `yarn info -A -R dependents fast-json-patch` you can see that only 2.2.1 and +# 3.3.1 are installed and that smart-transaction-controller resolves to the +# patched version of 3.3.1. We can remove this once the +# smart-transaction-controller updates its dependency. +GHSA-8gh8-hqwg-xf34 diff --git a/lavamoat/browserify/beta/policy.json b/lavamoat/browserify/beta/policy.json index e7f71c17f..de032a2d2 100644 --- a/lavamoat/browserify/beta/policy.json +++ b/lavamoat/browserify/beta/policy.json @@ -1291,7 +1291,7 @@ "@metamask/controllers>@ethersproject/providers": true, "@metamask/controllers>isomorphic-fetch": true, "@metamask/smart-transactions-controller>bignumber.js": true, - "@metamask/smart-transactions-controller>fast-json-patch": true, + "fast-json-patch": true, "lodash": true } }, @@ -4471,9 +4471,6 @@ "clearTimeout": true, "removeEventListener": true, "setTimeout": true - }, - "packages": { - "fast-json-patch>fast-deep-equal": true } }, "fuse.js": { diff --git a/lavamoat/browserify/flask/policy.json b/lavamoat/browserify/flask/policy.json index 8864f057d..79c338ab4 100644 --- a/lavamoat/browserify/flask/policy.json +++ b/lavamoat/browserify/flask/policy.json @@ -1536,7 +1536,7 @@ "@metamask/controllers>@ethersproject/providers": true, "@metamask/controllers>isomorphic-fetch": true, "@metamask/smart-transactions-controller>bignumber.js": true, - "@metamask/smart-transactions-controller>fast-json-patch": true, + "fast-json-patch": true, "lodash": true } }, @@ -4992,9 +4992,6 @@ "clearTimeout": true, "removeEventListener": true, "setTimeout": true - }, - "packages": { - "fast-json-patch>fast-deep-equal": true } }, "fuse.js": { diff --git a/lavamoat/browserify/main/policy.json b/lavamoat/browserify/main/policy.json index e7f71c17f..de032a2d2 100644 --- a/lavamoat/browserify/main/policy.json +++ b/lavamoat/browserify/main/policy.json @@ -1291,7 +1291,7 @@ "@metamask/controllers>@ethersproject/providers": true, "@metamask/controllers>isomorphic-fetch": true, "@metamask/smart-transactions-controller>bignumber.js": true, - "@metamask/smart-transactions-controller>fast-json-patch": true, + "fast-json-patch": true, "lodash": true } }, @@ -4471,9 +4471,6 @@ "clearTimeout": true, "removeEventListener": true, "setTimeout": true - }, - "packages": { - "fast-json-patch>fast-deep-equal": true } }, "fuse.js": { diff --git a/package.json b/package.json index e974f4665..06690c623 100644 --- a/package.json +++ b/package.json @@ -174,7 +174,7 @@ "ethjs-contract": "^0.2.3", "ethjs-query": "^0.3.4", "extension-port-stream": "^2.0.0", - "fast-json-patch": "^2.2.1", + "fast-json-patch": "^3.1.1", "fuse.js": "^3.2.0", "globalthis": "^1.0.1", "human-standard-token-abi": "^2.0.0", diff --git a/patches/fast-json-patch+2.2.1.patch b/patches/fast-json-patch+2.2.1.patch deleted file mode 100644 index d8f7b20f8..000000000 --- a/patches/fast-json-patch+2.2.1.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/node_modules/fast-json-patch/lib/helpers.js b/node_modules/fast-json-patch/lib/helpers.js -index 0ac28b4..d048c0a 100644 ---- a/node_modules/fast-json-patch/lib/helpers.js -+++ b/node_modules/fast-json-patch/lib/helpers.js -@@ -21,7 +21,7 @@ var _hasOwnProperty = Object.prototype.hasOwnProperty; - function hasOwnProperty(obj, key) { - return _hasOwnProperty.call(obj, key); - } --exports.hasOwnProperty = hasOwnProperty; -+Object.defineProperty(exports, "hasOwnProperty", { value: hasOwnProperty }); - function _objectKeys(obj) { - if (Array.isArray(obj)) { - var keys = new Array(obj.length); \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 8d84807d1..04cafe80d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12112,7 +12112,7 @@ fast-json-parse@^1.0.3: resolved "https://registry.yarnpkg.com/fast-json-parse/-/fast-json-parse-1.0.3.tgz#43e5c61ee4efa9265633046b770fb682a7577c4d" integrity sha512-FRWsaZRWEJ1ESVNbDWmsAlqDk96gPQezzLghafp5J4GUKjbCz3OkAHuZs5TuPEtkbVQERysLp9xv6c24fBm8Aw== -fast-json-patch@^2.0.6, fast-json-patch@^2.2.1: +fast-json-patch@^2.0.6: version "2.2.1" resolved "https://registry.yarnpkg.com/fast-json-patch/-/fast-json-patch-2.2.1.tgz#18150d36c9ab65c7209e7d4eb113f4f8eaabe6d9" integrity sha512-4j5uBaTnsYAV5ebkidvxiLUYOwjQ+JSFljeqfTxCrH9bDmlCQaOJFS84oDJ2rAXZq2yskmk3ORfoP9DCwqFNig== @@ -12124,6 +12124,11 @@ fast-json-patch@^3.1.0: resolved "https://registry.yarnpkg.com/fast-json-patch/-/fast-json-patch-3.1.0.tgz#ec8cd9b9c4c564250ec8b9140ef7a55f70acaee6" integrity sha512-IhpytlsVTRndz0hU5t0/MGzS/etxLlfrpG5V5M9mVbuj9TrJLWaMfsox9REM5rkuGX0T+5qjpe8XA1o0gZ42nA== +fast-json-patch@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/fast-json-patch/-/fast-json-patch-3.1.1.tgz#85064ea1b1ebf97a3f7ad01e23f9337e72c66947" + integrity sha512-vf6IHUX2SBcA+5/+4883dsIjpBTqmfBjmYiWK1savxQmFk4JfBMLa7ynTYOs1Rolp/T1betJxHiGD3g1Mn8lUQ== + fast-json-stable-stringify@^2.0.0, fast-json-stable-stringify@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" From 53604b14dd86c398d012a8113fd459d9087d8ea2 Mon Sep 17 00:00:00 2001 From: PeterYinusa Date: Thu, 5 Jan 2023 20:27:06 +0000 Subject: [PATCH 3/6] Update policies policy updates Remove fast-json-patch exclusion run lavamoat:auto --- .iyarc | 10 ---------- lavamoat/browserify/beta/policy.json | 8 -------- lavamoat/browserify/flask/policy.json | 8 -------- lavamoat/browserify/main/policy.json | 8 -------- ...sactions-controller++fast-json-patch+3.1.0.patch | 13 ------------- patches/fast-json-patch+3.1.1.patch | 13 +++++++++++++ yarn.lock | 7 +------ 7 files changed, 14 insertions(+), 53 deletions(-) delete mode 100644 patches/@metamask+smart-transactions-controller++fast-json-patch+3.1.0.patch create mode 100644 patches/fast-json-patch+3.1.1.patch diff --git a/.iyarc b/.iyarc index 1d0f2111f..316510d7d 100644 --- a/.iyarc +++ b/.iyarc @@ -1,12 +1,2 @@ # improved-yarn-audit advisory exclusions GHSA-257v-vj4p-3w2h - -# yarn npm audit reports on a fast-json-patch version < 3.1.1 but due to patch -# resolution, the only version of fast-json-patch that we use is 3.1.1. We also -# have 2.2.1 installed but it is a dev only dependency. The "violation" reports -# smart-transacton-controller as the culprit but if you run -# `yarn info -A -R dependents fast-json-patch` you can see that only 2.2.1 and -# 3.3.1 are installed and that smart-transaction-controller resolves to the -# patched version of 3.3.1. We can remove this once the -# smart-transaction-controller updates its dependency. -GHSA-8gh8-hqwg-xf34 diff --git a/lavamoat/browserify/beta/policy.json b/lavamoat/browserify/beta/policy.json index de032a2d2..5d249535f 100644 --- a/lavamoat/browserify/beta/policy.json +++ b/lavamoat/browserify/beta/policy.json @@ -1306,14 +1306,6 @@ "define": true } }, - "@metamask/smart-transactions-controller>fast-json-patch": { - "globals": { - "addEventListener": true, - "clearTimeout": true, - "removeEventListener": true, - "setTimeout": true - } - }, "@metamask/snap-controllers>nanoid": { "globals": { "crypto.getRandomValues": true diff --git a/lavamoat/browserify/flask/policy.json b/lavamoat/browserify/flask/policy.json index 79c338ab4..1c77e477d 100644 --- a/lavamoat/browserify/flask/policy.json +++ b/lavamoat/browserify/flask/policy.json @@ -1551,14 +1551,6 @@ "define": true } }, - "@metamask/smart-transactions-controller>fast-json-patch": { - "globals": { - "addEventListener": true, - "clearTimeout": true, - "removeEventListener": true, - "setTimeout": true - } - }, "@metamask/snap-controllers": { "globals": { "URL": true, diff --git a/lavamoat/browserify/main/policy.json b/lavamoat/browserify/main/policy.json index de032a2d2..5d249535f 100644 --- a/lavamoat/browserify/main/policy.json +++ b/lavamoat/browserify/main/policy.json @@ -1306,14 +1306,6 @@ "define": true } }, - "@metamask/smart-transactions-controller>fast-json-patch": { - "globals": { - "addEventListener": true, - "clearTimeout": true, - "removeEventListener": true, - "setTimeout": true - } - }, "@metamask/snap-controllers>nanoid": { "globals": { "crypto.getRandomValues": true diff --git a/patches/@metamask+smart-transactions-controller++fast-json-patch+3.1.0.patch b/patches/@metamask+smart-transactions-controller++fast-json-patch+3.1.0.patch deleted file mode 100644 index 97762d5a9..000000000 --- a/patches/@metamask+smart-transactions-controller++fast-json-patch+3.1.0.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/node_modules/@metamask/smart-transactions-controller/node_modules/fast-json-patch/commonjs/helpers.js b/node_modules/@metamask/smart-transactions-controller/node_modules/fast-json-patch/commonjs/helpers.js -index 0ac28b4..d048c0a 100644 ---- a/node_modules/@metamask/smart-transactions-controller/node_modules/fast-json-patch/commonjs/helpers.js -+++ b/node_modules/@metamask/smart-transactions-controller/node_modules/fast-json-patch/commonjs/helpers.js -@@ -21,7 +21,7 @@ var _hasOwnProperty = Object.prototype.hasOwnProperty; - function hasOwnProperty(obj, key) { - return _hasOwnProperty.call(obj, key); - } --exports.hasOwnProperty = hasOwnProperty; -+Object.defineProperty(exports, "hasOwnProperty", { value: hasOwnProperty }); - function _objectKeys(obj) { - if (Array.isArray(obj)) { - var keys = new Array(obj.length); diff --git a/patches/fast-json-patch+3.1.1.patch b/patches/fast-json-patch+3.1.1.patch new file mode 100644 index 000000000..9a481f0cd --- /dev/null +++ b/patches/fast-json-patch+3.1.1.patch @@ -0,0 +1,13 @@ +diff --git a/node_modules/fast-json-patch/commonjs/helpers.js b/node_modules/fast-json-patch/commonjs/helpers.js +index 5f2350e..8894686 100644 +--- a/node_modules/fast-json-patch/commonjs/helpers.js ++++ b/node_modules/fast-json-patch/commonjs/helpers.js +@@ -21,7 +21,7 @@ var _hasOwnProperty = Object.prototype.hasOwnProperty; + function hasOwnProperty(obj, key) { + return _hasOwnProperty.call(obj, key); + } +-exports.hasOwnProperty = hasOwnProperty; ++Object.defineProperty(exports, "hasOwnProperty", { value: hasOwnProperty }); + function _objectKeys(obj) { + if (Array.isArray(obj)) { + var keys_1 = new Array(obj.length); diff --git a/yarn.lock b/yarn.lock index 04cafe80d..ca67a7279 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12119,12 +12119,7 @@ fast-json-patch@^2.0.6: dependencies: fast-deep-equal "^2.0.1" -fast-json-patch@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/fast-json-patch/-/fast-json-patch-3.1.0.tgz#ec8cd9b9c4c564250ec8b9140ef7a55f70acaee6" - integrity sha512-IhpytlsVTRndz0hU5t0/MGzS/etxLlfrpG5V5M9mVbuj9TrJLWaMfsox9REM5rkuGX0T+5qjpe8XA1o0gZ42nA== - -fast-json-patch@^3.1.1: +fast-json-patch@^3.1.0, fast-json-patch@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/fast-json-patch/-/fast-json-patch-3.1.1.tgz#85064ea1b1ebf97a3f7ad01e23f9337e72c66947" integrity sha512-vf6IHUX2SBcA+5/+4883dsIjpBTqmfBjmYiWK1savxQmFk4JfBMLa7ynTYOs1Rolp/T1betJxHiGD3g1Mn8lUQ== From da18f15950b2394558b72c090d7343f495594698 Mon Sep 17 00:00:00 2001 From: PeterYinusa Date: Mon, 9 Jan 2023 19:26:21 +0000 Subject: [PATCH 4/6] fix audit failure for luxon by upgrading (#17106) --- package.json | 2 +- patches/luxon+3.1.0.patch | 22 --------------------- patches/luxon+3.2.1.patch | 40 +++++++++++++++++++++++++++++++++++++++ yarn.lock | 8 ++++---- 4 files changed, 45 insertions(+), 27 deletions(-) delete mode 100644 patches/luxon+3.1.0.patch create mode 100644 patches/luxon+3.2.1.patch diff --git a/package.json b/package.json index 06690c623..91e274a5e 100644 --- a/package.json +++ b/package.json @@ -188,7 +188,7 @@ "localforage": "^1.9.0", "lodash": "^4.17.21", "loglevel": "^1.4.1", - "luxon": "^3.1.0", + "luxon": "^3.2.1", "nanoid": "^2.1.6", "nonce-tracker": "^1.0.0", "obj-multiplex": "^1.0.0", diff --git a/patches/luxon+3.1.0.patch b/patches/luxon+3.1.0.patch deleted file mode 100644 index 0cb7a6e65..000000000 --- a/patches/luxon+3.1.0.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff --git a/node_modules/luxon/build/cjs-browser/luxon.js b/node_modules/luxon/build/cjs-browser/luxon.js -index 9ab2b9f..14c2891 100644 ---- a/node_modules/luxon/build/cjs-browser/luxon.js -+++ b/node_modules/luxon/build/cjs-browser/luxon.js -@@ -7373,7 +7373,7 @@ var DateTime = /*#__PURE__*/function () { - */ - ; - -- _proto.toLocaleString = function toLocaleString(formatOpts, opts) { -+ Reflect.defineProperty(_proto, 'toLocaleString', { value: function toLocaleString(formatOpts, opts) { - if (formatOpts === void 0) { - formatOpts = DATE_SHORT; - } -@@ -7383,7 +7383,7 @@ var DateTime = /*#__PURE__*/function () { - } - - return this.isValid ? Formatter.create(this.loc.clone(opts), formatOpts).formatDateTime(this) : INVALID; -- } -+ }}) - /** - * Returns an array of format "parts", meaning individual tokens along with metadata. This is allows callers to post-process individual sections of the formatted output. - * Defaults to the system's locale if no locale has been specified diff --git a/patches/luxon+3.2.1.patch b/patches/luxon+3.2.1.patch new file mode 100644 index 000000000..c3b672663 --- /dev/null +++ b/patches/luxon+3.2.1.patch @@ -0,0 +1,40 @@ +diff --git a/node_modules/luxon/build/cjs-browser/luxon.js b/node_modules/luxon/build/cjs-browser/luxon.js +index 776c38a..c0f0c21 100644 +--- a/node_modules/luxon/build/cjs-browser/luxon.js ++++ b/node_modules/luxon/build/cjs-browser/luxon.js +@@ -4226,7 +4226,7 @@ var Interval = /*#__PURE__*/function () { + * @example Interval.fromISO('2022-11-07T17:00Z/2022-11-07T19:00Z').toLocaleString({ weekday: 'short', month: 'short', day: '2-digit', hour: '2-digit', minute: '2-digit' }); //=> Mon, Nov 07, 6:00 – 8:00 p + * @return {string} + */; +- _proto.toLocaleString = function toLocaleString(formatOpts, opts) { ++ Reflect.defineProperty(_proto, 'toLocaleString', { value: function toLocaleString(formatOpts, opts) { + if (formatOpts === void 0) { + formatOpts = DATE_SHORT; + } +@@ -4234,7 +4234,7 @@ var Interval = /*#__PURE__*/function () { + opts = {}; + } + return this.isValid ? Formatter.create(this.s.loc.clone(opts), formatOpts).formatInterval(this) : INVALID$1; +- } ++ }}) + + /** + * Returns an ISO 8601-compliant string representation of this Interval. +@@ -6598,7 +6598,7 @@ var DateTime = /*#__PURE__*/function () { + * @example DateTime.now().toLocaleString({ hour: '2-digit', minute: '2-digit', hourCycle: 'h23' }); //=> '11:32' + * @return {string} + */; +- _proto.toLocaleString = function toLocaleString(formatOpts, opts) { ++ Reflect.defineProperty(_proto, 'toLocaleString', { value: function toLocaleString(formatOpts, opts) { + if (formatOpts === void 0) { + formatOpts = DATE_SHORT; + } +@@ -6606,7 +6606,7 @@ var DateTime = /*#__PURE__*/function () { + opts = {}; + } + return this.isValid ? Formatter.create(this.loc.clone(opts), formatOpts).formatDateTime(this) : INVALID; +- } ++ }}) + + /** + * Returns an array of format "parts", meaning individual tokens along with metadata. This is allows callers to post-process individual sections of the formatted output. diff --git a/yarn.lock b/yarn.lock index ca67a7279..e275846a6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -16914,10 +16914,10 @@ ltgt@~2.2.0: resolved "https://registry.yarnpkg.com/ltgt/-/ltgt-2.2.1.tgz#f35ca91c493f7b73da0e07495304f17b31f87ee5" integrity sha1-81ypHEk/e3PaDgdJUwTxezH4fuU= -luxon@^3.0.1, luxon@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/luxon/-/luxon-3.1.0.tgz#9ac33d7142b7ea18d4ec8583cdeb0b079abef60d" - integrity sha512-7w6hmKC0/aoWnEsmPCu5Br54BmbmUp5GfcqBxQngRcXJ+q5fdfjEzn7dxmJh2YdDhgW8PccYtlWKSv4tQkrTQg== +luxon@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/luxon/-/luxon-3.2.1.tgz#14f1af209188ad61212578ea7e3d518d18cee45f" + integrity sha512-QrwPArQCNLAKGO/C+ZIilgIuDnEnKx5QYODdDtbFaxzsbZcc/a7WFq7MhsVYgRlwawLtvOUESTlfJ+hc/USqPg== madge@^5.0.1: version "5.0.1" From 6ac899b96ae3126ea48255c4771c1c4fd7c9d3c8 Mon Sep 17 00:00:00 2001 From: Brad Decker Date: Thu, 5 Jan 2023 09:49:55 -0500 Subject: [PATCH 5/6] add an extra identifier on anonymized duplicate events (#17080) --- app/scripts/controllers/metametrics.js | 14 +- app/scripts/controllers/metametrics.test.js | 192 ++++++++++++++++++++ 2 files changed, 201 insertions(+), 5 deletions(-) diff --git a/app/scripts/controllers/metametrics.js b/app/scripts/controllers/metametrics.js index f52d2cd76..fbf29b41d 100644 --- a/app/scripts/controllers/metametrics.js +++ b/app/scripts/controllers/metametrics.js @@ -35,15 +35,18 @@ const defaultCaptureException = (err) => { // The function is used to build a unique messageId for segment messages // It uses actionId and uniqueIdentifier from event if present const buildUniqueMessageId = (args) => { - let messageId = ''; + const messageIdParts = []; if (args.uniqueIdentifier) { - messageId += `${args.uniqueIdentifier}-`; + messageIdParts.push(args.uniqueIdentifier); } if (args.actionId) { - messageId += args.actionId; + messageIdParts.push(args.actionId); } - if (messageId.length) { - return messageId; + if (messageIdParts.length && args.isDuplicateAnonymizedEvent) { + messageIdParts.push('0x000'); + } + if (messageIdParts.length) { + return messageIdParts.join('-'); } return generateRandomId(); }; @@ -536,6 +539,7 @@ export default class MetaMetricsController { this._buildEventPayload({ ...payload, properties: combinedProperties, + isDuplicateAnonymizedEvent: true, }), { ...options, excludeMetaMetricsId: true }, ), diff --git a/app/scripts/controllers/metametrics.test.js b/app/scripts/controllers/metametrics.test.js index e164f5461..6204a3708 100644 --- a/app/scripts/controllers/metametrics.test.js +++ b/app/scripts/controllers/metametrics.test.js @@ -159,6 +159,7 @@ describe('MetaMetricsController', function () { clock = sinon.useFakeTimers(now.getTime()); sinon.stub(Utils, 'generateRandomId').returns('DUMMY_RANDOM_ID'); }); + describe('constructor', function () { it('should properly initialize', function () { const mock = sinon.mock(segment); @@ -681,6 +682,197 @@ describe('MetaMetricsController', function () { }); }); + describe('deterministic messageId', function () { + it('should use the actionId as messageId when provided', function () { + const metaMetricsController = getMetaMetricsController(); + const spy = sinon.spy(segment, 'track'); + metaMetricsController.submitEvent({ + event: 'Fake Event', + category: 'Unit Test', + properties: { foo: 'bar' }, + actionId: '0x001', + }); + assert.ok(spy.calledOnce); + assert.ok( + spy.calledWith({ + event: 'Fake Event', + userId: TEST_META_METRICS_ID, + context: DEFAULT_TEST_CONTEXT, + properties: { + foo: 'bar', + ...DEFAULT_EVENT_PROPERTIES, + }, + messageId: '0x001', + timestamp: new Date(), + }), + ); + }); + + it('should append 0x000 to the actionId of anonymized event when tracking sensitiveProperties', function () { + const metaMetricsController = getMetaMetricsController(); + const spy = sinon.spy(segment, 'track'); + metaMetricsController.submitEvent({ + event: 'Fake Event', + category: 'Unit Test', + sensitiveProperties: { foo: 'bar' }, + actionId: '0x001', + }); + assert.ok(spy.calledTwice); + + assert.ok( + spy.calledWith({ + event: 'Fake Event', + anonymousId: METAMETRICS_ANONYMOUS_ID, + context: DEFAULT_TEST_CONTEXT, + properties: { + foo: 'bar', + ...DEFAULT_EVENT_PROPERTIES, + }, + messageId: '0x001-0x000', + timestamp: new Date(), + }), + ); + assert.ok( + spy.calledWith({ + event: 'Fake Event', + userId: TEST_META_METRICS_ID, + context: DEFAULT_TEST_CONTEXT, + properties: { + ...DEFAULT_EVENT_PROPERTIES, + }, + messageId: '0x001', + timestamp: new Date(), + }), + ); + }); + + it('should use the uniqueIdentifier as messageId when provided', function () { + const metaMetricsController = getMetaMetricsController(); + const spy = sinon.spy(segment, 'track'); + metaMetricsController.submitEvent({ + event: 'Fake Event', + category: 'Unit Test', + properties: { foo: 'bar' }, + uniqueIdentifier: 'transaction-submitted-0000', + }); + assert.ok(spy.calledOnce); + assert.ok( + spy.calledWith({ + event: 'Fake Event', + userId: TEST_META_METRICS_ID, + context: DEFAULT_TEST_CONTEXT, + properties: { + foo: 'bar', + ...DEFAULT_EVENT_PROPERTIES, + }, + messageId: 'transaction-submitted-0000', + timestamp: new Date(), + }), + ); + }); + + it('should append 0x000 to the uniqueIdentifier of anonymized event when tracking sensitiveProperties', function () { + const metaMetricsController = getMetaMetricsController(); + const spy = sinon.spy(segment, 'track'); + metaMetricsController.submitEvent({ + event: 'Fake Event', + category: 'Unit Test', + sensitiveProperties: { foo: 'bar' }, + uniqueIdentifier: 'transaction-submitted-0000', + }); + assert.ok(spy.calledTwice); + assert.ok( + spy.calledWith({ + event: 'Fake Event', + anonymousId: METAMETRICS_ANONYMOUS_ID, + context: DEFAULT_TEST_CONTEXT, + properties: { + foo: 'bar', + ...DEFAULT_EVENT_PROPERTIES, + }, + messageId: 'transaction-submitted-0000-0x000', + timestamp: new Date(), + }), + ); + assert.ok( + spy.calledWith({ + event: 'Fake Event', + userId: TEST_META_METRICS_ID, + context: DEFAULT_TEST_CONTEXT, + properties: { + ...DEFAULT_EVENT_PROPERTIES, + }, + messageId: 'transaction-submitted-0000', + timestamp: new Date(), + }), + ); + }); + + it('should combine the uniqueIdentifier and actionId as messageId when both provided', function () { + const metaMetricsController = getMetaMetricsController(); + const spy = sinon.spy(segment, 'track'); + metaMetricsController.submitEvent({ + event: 'Fake Event', + category: 'Unit Test', + properties: { foo: 'bar' }, + actionId: '0x001', + uniqueIdentifier: 'transaction-submitted-0000', + }); + assert.ok(spy.calledOnce); + assert.ok( + spy.calledWith({ + event: 'Fake Event', + userId: TEST_META_METRICS_ID, + context: DEFAULT_TEST_CONTEXT, + properties: { + foo: 'bar', + ...DEFAULT_EVENT_PROPERTIES, + }, + messageId: 'transaction-submitted-0000-0x001', + timestamp: new Date(), + }), + ); + }); + + it('should append 0x000 to the combined uniqueIdentifier and actionId of anonymized event when tracking sensitiveProperties', function () { + const metaMetricsController = getMetaMetricsController(); + const spy = sinon.spy(segment, 'track'); + metaMetricsController.submitEvent({ + event: 'Fake Event', + category: 'Unit Test', + sensitiveProperties: { foo: 'bar' }, + actionId: '0x001', + uniqueIdentifier: 'transaction-submitted-0000', + }); + assert.ok(spy.calledTwice); + assert.ok( + spy.calledWith({ + event: 'Fake Event', + anonymousId: METAMETRICS_ANONYMOUS_ID, + context: DEFAULT_TEST_CONTEXT, + properties: { + foo: 'bar', + ...DEFAULT_EVENT_PROPERTIES, + }, + messageId: 'transaction-submitted-0000-0x001-0x000', + timestamp: new Date(), + }), + ); + assert.ok( + spy.calledWith({ + event: 'Fake Event', + userId: TEST_META_METRICS_ID, + context: DEFAULT_TEST_CONTEXT, + properties: { + ...DEFAULT_EVENT_PROPERTIES, + }, + messageId: 'transaction-submitted-0000-0x001', + timestamp: new Date(), + }), + ); + }); + }); + describe('_buildUserTraitsObject', function () { it('should return full user traits object on first call', function () { const MOCK_ALL_TOKENS = { From bbd76bcb38da9918d85f0f616143a8960fce1159 Mon Sep 17 00:00:00 2001 From: Alaa Hadad Date: Mon, 9 Jan 2023 21:14:13 +0400 Subject: [PATCH 6/6] soft disable onramp provider wyre (#17102) --- ui/components/app/deposit-popover/deposit-popover.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ui/components/app/deposit-popover/deposit-popover.js b/ui/components/app/deposit-popover/deposit-popover.js index 81f1715dc..b0128a5f1 100644 --- a/ui/components/app/deposit-popover/deposit-popover.js +++ b/ui/components/app/deposit-popover/deposit-popover.js @@ -24,7 +24,6 @@ import { getSelectedAddress, getIsBuyableTransakChain, getIsBuyableMoonPayChain, - getIsBuyableWyreChain, getIsBuyableCoinbasePayChain, getIsBuyableCoinbasePayToken, getIsBuyableTransakToken, @@ -46,7 +45,7 @@ const DepositPopover = ({ onClose, token }) => { const address = useSelector(getSelectedAddress); const isBuyableTransakChain = useSelector(getIsBuyableTransakChain); const isBuyableMoonPayChain = useSelector(getIsBuyableMoonPayChain); - const isBuyableWyreChain = useSelector(getIsBuyableWyreChain); + const isBuyableWyreChain = false; const isBuyableCoinbasePayChain = useSelector(getIsBuyableCoinbasePayChain); const isTokenBuyableCoinbasePay = useSelector((state) =>