From 2852ddf453376edd9df58631f83929a24270daaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Van=20Eyck?= Date: Fri, 18 Oct 2024 17:21:57 +0200 Subject: [PATCH] feat(9544): clean unused test signing related changes --- .yarnrc.yml | 64 +++++++++++++++++-- app/scripts/lib/metaRPCClientFactory.js | 1 - app/scripts/metamask-controller.js | 2 - package.json | 6 +- test/e2e/seeder/ganache.ts | 28 ++++---- .../hardware-wallets/trezor-account.spec.js | 1 - test/stub/keyring-bridge.js | 33 ---------- test/stub/keyring-utils.js | 8 --- 8 files changed, 73 insertions(+), 70 deletions(-) diff --git a/.yarnrc.yml b/.yarnrc.yml index c7f5d0bcd407..f4d8fc7fa471 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -13,21 +13,73 @@ logFilters: nodeLinker: node-modules npmAuditIgnoreAdvisories: + ### Advisories: + + # Issue: yargs-parser Vulnerable to Prototype Pollution + # URL - https://github.com/advisories/GHSA-p9pc-299p-vxgp + # The affected version (<5.0.0) is only included via @ensdomains/ens via + # 'solc' which is not used in the imports we use from this package. - 1088783 + + # Issue: protobufjs Prototype Pollution vulnerability + # URL - https://github.com/advisories/GHSA-h755-8qp9-cq85 + # Not easily patched. Minimally effects the extension due to usage of + # LavaMoat lockdown. Additional id added that resolves to the same advisory + # but has a different entry due to it being a new dependency of + # @trezor/connect-web. Upgrading - 1092429 - 1095136 + + # Issue: Regular Expression Denial of Service (ReDOS) + # URL: https://github.com/advisories/GHSA-257v-vj4p-3w2h + # color-string is listed as a dependency of 'color' which is brought in by + # @metamask/jazzicon v2.0.0 but there is work done on that repository to + # remove the color dependency. We should upgrade - 1089718 + + # Issue: semver vulnerable to Regular Expression Denial of Service + # URL: https://github.com/advisories/GHSA-c2qf-rxjj-qqgw + # semver is used in the solidity compiler portion of @truffle/codec that does + # not appear to be used. - 1092461 - - ts-custom-error (deprecation) - - text-encoding (deprecation) - - popper.js (deprecation) - - mini-create-react-context (deprecation) - - uuid (deprecation) + + # Temp fix for https://github.com/MetaMask/metamask-extension/pull/16920 for the sake of 11.7.1 hotfix + # This will be removed in this ticket https://github.com/MetaMask/metamask-extension/issues/22299 + - 'ts-custom-error (deprecation)' + - 'text-encoding (deprecation)' + + ### Package Deprecations: + + # React-tippy brings in popper.js and react-tippy has not been updated in + # three years. + - 'popper.js (deprecation)' + + # React-router is out of date and brings in the following deprecated package + - 'mini-create-react-context (deprecation)' + + # The affected version, which is less than 7.0.0, is brought in by + # ethereumjs-wallet version 0.6.5 used in the extension but only in a single + # file app/scripts/account-import-strategies/index.js, which may be easy to + # upgrade. + - 'uuid (deprecation)' + + # @npmcli/move-file is brought in via CopyWebpackPlugin used in the storybook + # main.js file, which can be upgraded to remove this dependency in favor of + # @npmcli/fs - '@npmcli/move-file (deprecation)' - - core-js (deprecation) + + # Upgrading babel will result in the following deprecated packages being + # updated: + - 'core-js (deprecation)' + + # Material UI dependencies are planned for removal - '@material-ui/core (deprecation)' - '@material-ui/styles (deprecation)' - '@material-ui/system (deprecation)' + + # @ensdomains/ens should be explored for upgrade. The following packages are + # deprecated and would be resolved by upgrading to newer versions of + # ensdomains packages: - '@ensdomains/ens (deprecation)' - '@ensdomains/resolver (deprecation)' - 'testrpc (deprecation)' diff --git a/app/scripts/lib/metaRPCClientFactory.js b/app/scripts/lib/metaRPCClientFactory.js index 4822ef549fb5..2451189836e9 100644 --- a/app/scripts/lib/metaRPCClientFactory.js +++ b/app/scripts/lib/metaRPCClientFactory.js @@ -60,7 +60,6 @@ class MetaRPCClient { } handleResponse(data) { - console.log('==============> data', data); const { id, result, error, method, params } = data; const isNotification = id === undefined && error === undefined; const cb = this.requests.get(id); diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index a39d227e7ebc..176c7aea10e5 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -4641,7 +4641,6 @@ export default class MetamaskController extends EventEmitter { */ async connectHardware(deviceName, page, hdPath) { const keyring = await this.getKeyringForDevice(deviceName, hdPath); - console.log('============> keyring', keyring); if (deviceName === HardwareDeviceNames.ledger) { await this.setLedgerTransportPreference(keyring); @@ -4662,7 +4661,6 @@ export default class MetamaskController extends EventEmitter { // Merge with existing accounts // and make sure addresses are not repeated const oldAccounts = await this.keyringController.getAccounts(); - console.log('================> accounts', accounts); const accountsToTrack = [ ...new Set( diff --git a/package.json b/package.json index a856df4009b1..fca1780d3300 100644 --- a/package.json +++ b/package.json @@ -271,7 +271,6 @@ "@blockaid/ppom_release": "^1.5.3", "@ensdomains/content-hash": "^2.5.7", "@ethereumjs/tx": "^4.1.1", - "@ethereumjs/util": "^9.0.3", "@ethersproject/abi": "^5.6.4", "@ethersproject/bignumber": "^5.7.0", "@ethersproject/bytes": "^5.7.0", @@ -764,10 +763,7 @@ "core-js-pure": true, "resolve-url-loader>es6-iterator>d>es5-ext": false, "resolve-url-loader>es6-iterator>d>es5-ext>esniff>es5-ext": false, - "level>classic-level": false, - "@ledgerhq/hw-app-eth>@ledgerhq/domain-service>eip55>keccak": false, - "@lavamoat/allow-scripts>@lavamoat/preinstall-always-fail": false, - "@metamask/notification-services-controller>firebase>@firebase/firestore>@grpc/proto-loader>protobufjs": false + "level>classic-level": false } }, "packageManager": "yarn@4.4.1" diff --git a/test/e2e/seeder/ganache.ts b/test/e2e/seeder/ganache.ts index 8a0814849c64..7fa3d1ab0238 100644 --- a/test/e2e/seeder/ganache.ts +++ b/test/e2e/seeder/ganache.ts @@ -8,7 +8,7 @@ const defaultOptions = { port: 8545, vmErrorsOnRPCResponse: false, hardfork: 'muirGlacier', - verbose: true, + quiet: true, }; export class Ganache { @@ -34,14 +34,24 @@ export class Ganache { }); } - async getAddressBalance(address: string) { + async getBalance(address = null): Promise { const provider = await this.getProvider(); + if (!provider) { - throw new Error('No provider found'); + console.log('No provider found'); + return 0; } + + const accountToUse = address || (await this.getAccounts())?.[0]; + + if (!accountToUse) { + console.log('No accounts found'); + return 0; + } + const balanceHex = await provider.request({ method: 'eth_getBalance', - params: [address, 'latest'], + params: [accountToUse, 'latest'], }); const balanceInt = parseInt(balanceHex, 16) / 10 ** 18; @@ -51,16 +61,6 @@ export class Ganache { return Number(balanceFormatted); } - async getBalance(accountIndex: number = 0): Promise { - const accounts = await this.getAccounts(); - - if (!accounts?.[accountIndex]) { - throw new Error('Account not found'); - } - - return this.getAddressBalance(accounts?.[accountIndex]); - } - async getFiatBalance(): Promise { const balance = await this.getBalance(); const currencyConversionRate = 1700.0; diff --git a/test/e2e/tests/hardware-wallets/trezor-account.spec.js b/test/e2e/tests/hardware-wallets/trezor-account.spec.js index fb7ab3ca91ac..9abf6e67974d 100644 --- a/test/e2e/tests/hardware-wallets/trezor-account.spec.js +++ b/test/e2e/tests/hardware-wallets/trezor-account.spec.js @@ -40,7 +40,6 @@ describe('Trezor Hardware', function () { async ({ driver }) => { await unlockWallet(driver); await connectTrezor(driver); - await driver.delay(100000); // Check that the first page of accounts is correct for (const { address, index } of KNOWN_PUBLIC_KEY_ADDRESSES.slice( diff --git a/test/stub/keyring-bridge.js b/test/stub/keyring-bridge.js index 1da7064378b3..64950e2f8b85 100644 --- a/test/stub/keyring-bridge.js +++ b/test/stub/keyring-bridge.js @@ -151,37 +151,4 @@ export class FakeLedgerBridge extends FakeKeyringBridge { updateTransportMethod() { return true; } - - // async deviceSignTransaction({ tx }) { - // return ecsign(tx, Buffer.from(KNOWN_PRIVATE_KEYS[0], 'hex')); - // } - - async deviceSignTransaction({ tx }) { - // chainId hardcoded for now - const chainId = 1337; - const common = Common.custom({ - chain: { - name: 'localhost', - chainId, - networkId: chainId, - }, - chainId, - hardfork: 'istanbul', - }); - - // return Transaction.fromTxData(tx, { - // common, - // }).sign(Buffer.from(KNOWN_PRIVATE_KEYS[0], 'hex')); - - const txBuffer = Buffer.from(tx, 'hex'); - return Transaction.fromSerializedTx(txBuffer, { - common, - }).sign(Buffer.from(KNOWN_PRIVATE_KEYS[0], 'hex')); - } - - // async deviceSignTypedData(params) { - // console.log('=============> params', params); - // const { tx } = params; - // return ecsign(tx, Buffer.from(KNOWN_PRIVATE_KEYS[0], 'hex')); - // } } diff --git a/test/stub/keyring-utils.js b/test/stub/keyring-utils.js index 181df26e5180..2990e63dc26d 100644 --- a/test/stub/keyring-utils.js +++ b/test/stub/keyring-utils.js @@ -68,14 +68,6 @@ export class Common { chainId() { return BigInt(this.chain.chainId); } - - isActivatedEIP() { - return true; - } - - param() { - return BigInt(0); - } } /**