From 14904cd05489f277d71c7d6bcb6f4252f6eb1fae Mon Sep 17 00:00:00 2001 From: Cal Leung Date: Fri, 28 Apr 2023 15:48:06 -0700 Subject: [PATCH 1/4] Patch assets-controller to not use BigInt --- package.json | 1 + .../@metamask+assets-controllers+4.0.0.patch | 38 ++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c95c8b14de3..477e3d516d4 100644 --- a/package.json +++ b/package.json @@ -134,6 +134,7 @@ "@eth-optimism/contracts": "0.0.0-2021919175625", "@ethereumjs/common": "^2.3.1", "@ethereumjs/tx": "^3.2.1", + "@ethersproject/abi": "^5.7.0", "@exodus/react-native-payments": "git+https://github.com/MetaMask/react-native-payments.git#dbc8cbbed570892d2fea5e3d183bf243e062c1e5", "@keystonehq/bc-ur-registry-eth": "^0.7.7", "@keystonehq/metamask-airgapped-keyring": "^0.3.0", diff --git a/patches/@metamask+assets-controllers+4.0.0.patch b/patches/@metamask+assets-controllers+4.0.0.patch index d9917a56783..8c409700a89 100644 --- a/patches/@metamask+assets-controllers+4.0.0.patch +++ b/patches/@metamask+assets-controllers+4.0.0.patch @@ -24,10 +24,25 @@ index 332c87d..c110f41 100644 * Enumerate assets assigned to an owner. * diff --git a/node_modules/@metamask/assets-controllers/dist/Standards/ERC20Standard.js b/node_modules/@metamask/assets-controllers/dist/Standards/ERC20Standard.js -index 9ddbc28..acdc28a 100644 +index 9ddbc28..2d12e33 100644 --- a/node_modules/@metamask/assets-controllers/dist/Standards/ERC20Standard.js +++ b/node_modules/@metamask/assets-controllers/dist/Standards/ERC20Standard.js -@@ -57,6 +57,27 @@ class ERC20Standard { +@@ -13,7 +13,13 @@ exports.ERC20Standard = void 0; + const contracts_1 = require("@ethersproject/contracts"); + const metamask_eth_abis_1 = require("@metamask/metamask-eth-abis"); + const ethereumjs_util_1 = require("ethereumjs-util"); +-const abi_utils_1 = require("@metamask/abi-utils"); ++ ++// Revert to use @ethersproject/abi to fix BigInt compatibility issue ++// Issue reported here - https://github.com/MetaMask/mobile-planning/issues/913 ++// TODO - Remove patch once app is upgraded to RN 0.71.6 ++// const abi_utils_1 = require("@metamask/abi-utils"); ++const ethers_project_abi = require('@ethersproject/abi'); ++ + const controller_utils_1 = require("@metamask/controller-utils"); + const utils_1 = require("@metamask/utils"); + const assetsUtil_1 = require("../assetsUtil"); +@@ -57,6 +63,27 @@ class ERC20Standard { } }); } @@ -55,6 +70,25 @@ index 9ddbc28..acdc28a 100644 /** * Query for symbol for a given ERC20 asset. * +@@ -68,10 +95,16 @@ class ERC20Standard { + // Signature for calling `symbol()` + const payload = { to: address, data: '0x95d89b41' }; + const result = yield this.provider.call(payload); +- (0, utils_1.assertIsStrictHexString)(result); ++ ++ // TODO - Remove patch once app is upgraded to RN 0.71.6 ++ // (0, utils_1.assertIsStrictHexString)(result); ++ + // Parse as string - treat empty string as failure + try { +- const decoded = (0, abi_utils_1.decodeSingle)('string', result); ++ // TODO - Remove patch once app is upgraded to RN 0.71.6 ++ const decoded = ethers_project_abi.abiCoder.decode(['string'], result)[0]; ++ // const decoded = (0, abi_utils_1.decodeSingle)('string', result); ++ + if ((decoded === null || decoded === void 0 ? void 0 : decoded.length) > 0) { + return decoded; + } diff --git a/node_modules/@metamask/assets-controllers/dist/TokenDetectionController.js b/node_modules/@metamask/assets-controllers/dist/TokenDetectionController.js index 4ed4990..da18116 100644 --- a/node_modules/@metamask/assets-controllers/dist/TokenDetectionController.js From 8dd4024070db5f2d68be37c7b7172aa18b087e2f Mon Sep 17 00:00:00 2001 From: Cal Leung Date: Mon, 1 May 2023 09:07:24 -0700 Subject: [PATCH 2/4] Update to use public link Co-authored-by: sethkfman <10342624+sethkfman@users.noreply.github.com> --- patches/@metamask+assets-controllers+4.0.0.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches/@metamask+assets-controllers+4.0.0.patch b/patches/@metamask+assets-controllers+4.0.0.patch index 8c409700a89..554156aacd4 100644 --- a/patches/@metamask+assets-controllers+4.0.0.patch +++ b/patches/@metamask+assets-controllers+4.0.0.patch @@ -34,7 +34,7 @@ index 9ddbc28..2d12e33 100644 -const abi_utils_1 = require("@metamask/abi-utils"); + +// Revert to use @ethersproject/abi to fix BigInt compatibility issue -+// Issue reported here - https://github.com/MetaMask/mobile-planning/issues/913 ++// Issue reported here - https://github.com/MetaMask/metamask-mobile/issues/6307 +// TODO - Remove patch once app is upgraded to RN 0.71.6 +// const abi_utils_1 = require("@metamask/abi-utils"); +const ethers_project_abi = require('@ethersproject/abi'); From 07e11636f29c5275d24cfeaf3cde1fb50a6d5d73 Mon Sep 17 00:00:00 2001 From: Cal Leung Date: Mon, 1 May 2023 09:07:54 -0700 Subject: [PATCH 3/4] Update to spell out React Native Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com> --- patches/@metamask+assets-controllers+4.0.0.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches/@metamask+assets-controllers+4.0.0.patch b/patches/@metamask+assets-controllers+4.0.0.patch index 554156aacd4..98afce9609a 100644 --- a/patches/@metamask+assets-controllers+4.0.0.patch +++ b/patches/@metamask+assets-controllers+4.0.0.patch @@ -82,7 +82,7 @@ index 9ddbc28..2d12e33 100644 // Parse as string - treat empty string as failure try { - const decoded = (0, abi_utils_1.decodeSingle)('string', result); -+ // TODO - Remove patch once app is upgraded to RN 0.71.6 ++ // TODO - Remove patch once app is upgraded to React Native 0.71.6 + const decoded = ethers_project_abi.abiCoder.decode(['string'], result)[0]; + // const decoded = (0, abi_utils_1.decodeSingle)('string', result); + From 232db42d361aa49fa37bce7b9dd9b7166a691234 Mon Sep 17 00:00:00 2001 From: Cal Leung Date: Mon, 1 May 2023 09:08:05 -0700 Subject: [PATCH 4/4] Update to spell out React Native Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com> --- patches/@metamask+assets-controllers+4.0.0.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches/@metamask+assets-controllers+4.0.0.patch b/patches/@metamask+assets-controllers+4.0.0.patch index 98afce9609a..c0dbfc04147 100644 --- a/patches/@metamask+assets-controllers+4.0.0.patch +++ b/patches/@metamask+assets-controllers+4.0.0.patch @@ -35,7 +35,7 @@ index 9ddbc28..2d12e33 100644 + +// Revert to use @ethersproject/abi to fix BigInt compatibility issue +// Issue reported here - https://github.com/MetaMask/metamask-mobile/issues/6307 -+// TODO - Remove patch once app is upgraded to RN 0.71.6 ++// TODO - Remove patch once app is upgraded to React Native 0.71.6 +// const abi_utils_1 = require("@metamask/abi-utils"); +const ethers_project_abi = require('@ethersproject/abi'); +