From 276fbf20878f6abd815e8e190d07963bf124e5e2 Mon Sep 17 00:00:00 2001 From: matstyler Date: Mon, 8 Apr 2024 21:07:04 +0200 Subject: [PATCH 1/5] =?UTF-8?q?=E2=9C=A8=20feat:=20Synpress=20with=20metam?= =?UTF-8?q?ask=20mock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/new-dawn/test/e2e/00_mock.spec.ts | 20 + packages/tsconfig/base.json | 2 +- pnpm-lock.yaml | 632 ++++++++++++++++++ release/package.json | 3 +- release/src/index.ts | 31 +- wallets/metamask-mock/environment.d.ts | 18 + wallets/metamask-mock/package.json | 46 ++ wallets/metamask-mock/playwright.config.ts | 50 ++ wallets/metamask-mock/src/index.ts | 3 + wallets/metamask-mock/src/metamask-mock.ts | 191 ++++++ wallets/metamask-mock/src/network/Network.ts | 11 + .../metamask-mock/src/testWithMetaMaskMock.ts | 64 ++ wallets/metamask-mock/src/utils/index.ts | 1 + .../metamask-mock/src/utils/mockEthereum.ts | 10 + .../test/e2e/metamask/addNewAccount.spec.ts | 18 + .../importWalletFromPrivateKey.spec.ts | 16 + .../e2e/metamask/mock/mockEthereum.spec.ts | 25 + .../test/e2e/metamask/switchAccount.spec.ts | 16 + .../test/e2e/metamask/switchNetwork.spec.ts | 23 + wallets/metamask-mock/tsconfig.build.json | 12 + wallets/metamask-mock/tsconfig.json | 10 + wallets/metamask-mock/tsup.config.ts | 12 + wallets/metamask-mock/vitest.config.ts | 7 + 23 files changed, 1215 insertions(+), 6 deletions(-) create mode 100644 examples/new-dawn/test/e2e/00_mock.spec.ts create mode 100644 wallets/metamask-mock/environment.d.ts create mode 100644 wallets/metamask-mock/package.json create mode 100644 wallets/metamask-mock/playwright.config.ts create mode 100644 wallets/metamask-mock/src/index.ts create mode 100644 wallets/metamask-mock/src/metamask-mock.ts create mode 100644 wallets/metamask-mock/src/network/Network.ts create mode 100644 wallets/metamask-mock/src/testWithMetaMaskMock.ts create mode 100644 wallets/metamask-mock/src/utils/index.ts create mode 100644 wallets/metamask-mock/src/utils/mockEthereum.ts create mode 100644 wallets/metamask-mock/test/e2e/metamask/addNewAccount.spec.ts create mode 100644 wallets/metamask-mock/test/e2e/metamask/importWalletFromPrivateKey.spec.ts create mode 100644 wallets/metamask-mock/test/e2e/metamask/mock/mockEthereum.spec.ts create mode 100644 wallets/metamask-mock/test/e2e/metamask/switchAccount.spec.ts create mode 100644 wallets/metamask-mock/test/e2e/metamask/switchNetwork.spec.ts create mode 100644 wallets/metamask-mock/tsconfig.build.json create mode 100644 wallets/metamask-mock/tsconfig.json create mode 100644 wallets/metamask-mock/tsup.config.ts create mode 100644 wallets/metamask-mock/vitest.config.ts diff --git a/examples/new-dawn/test/e2e/00_mock.spec.ts b/examples/new-dawn/test/e2e/00_mock.spec.ts new file mode 100644 index 000000000..774435d00 --- /dev/null +++ b/examples/new-dawn/test/e2e/00_mock.spec.ts @@ -0,0 +1,20 @@ +import { testWithMetaMaskMock, MetaMaskMock } from "@synthetixio/synpress"; + +const test = testWithMetaMaskMock; + +const { expect } = test; + +test("should work to the MetaMask Test Dapp", async ({ page }) => { + const metamask = new MetaMaskMock(page); + + await page.goto("/"); + + await expect(page.locator("#accounts")).toHaveText( + "0xd73b04b0e696b0945283defa3eee453814758f1a" + ); + + await page.locator("#getAccounts").click(); + await expect(page.locator("#getAccountsResult")).toHaveText( + "0xd73b04b0e696b0945283defa3eee453814758f1a" + ); +}); diff --git a/packages/tsconfig/base.json b/packages/tsconfig/base.json index a71b7913f..fc85922e5 100644 --- a/packages/tsconfig/base.json +++ b/packages/tsconfig/base.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/tsconfig", "compilerOptions": { "target": "ES2022", - "lib": ["ES2022"], + "lib": ["ES2022", "DOM"], "moduleResolution": "bundler", "module": "ES2022", "verbatimModuleSyntax": true, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5820709bb..ca1d2d4cb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -220,6 +220,9 @@ importers: '@synthetixio/synpress-metamask': specifier: 0.0.1-alpha.3 version: link:../wallets/metamask + '@synthetixio/synpress-metamask-mock': + specifier: 0.0.1-alpha.3 + version: link:../wallets/metamask-mock devDependencies: '@synthetixio/synpress-tsconfig': specifier: 0.0.1-alpha.3 @@ -274,8 +277,64 @@ importers: specifier: 1.2.2 version: 1.2.2(@types/node@20.11.17) + wallets/metamask-mock: + dependencies: + '@depay/web3-blockchains': + specifier: 9.3.4 + version: 9.3.4 + '@depay/web3-mock': + specifier: 14.17.0 + version: 14.17.0 + '@playwright/test': + specifier: 1.41.2 + version: 1.41.2 + '@synthetixio/synpress-core': + specifier: 0.0.1-alpha.3 + version: link:../../packages/core + '@synthetixio/synpress-fixtures': + specifier: 0.0.1-alpha.3 + version: link:../../packages/fixtures + '@synthetixio/synpress-metamask': + specifier: 0.0.1-alpha.3 + version: link:../metamask + path: + specifier: 0.12.7 + version: 0.12.7 + viem: + specifier: 2.9.9 + version: 2.9.9(typescript@5.3.3)(zod@3.22.4) + zod: + specifier: 3.22.4 + version: 3.22.4 + devDependencies: + '@synthetixio/synpress-tsconfig': + specifier: 0.0.1-alpha.3 + version: link:../../packages/tsconfig + '@types/node': + specifier: 20.11.17 + version: 20.11.17 + '@vitest/coverage-v8': + specifier: 1.2.2 + version: 1.2.2(vitest@1.2.2) + rimraf: + specifier: 5.0.5 + version: 5.0.5 + tsup: + specifier: 8.0.2 + version: 8.0.2(typescript@5.3.3) + typescript: + specifier: 5.3.3 + version: 5.3.3 + vitest: + specifier: 1.2.2 + version: 1.2.2(@types/node@20.11.17) + packages: + /@adraffy/ens-normalize@1.10.0: + resolution: {integrity: sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q==} + dev: false + /@algolia/autocomplete-core@1.9.3(@algolia/client-search@4.22.1)(algoliasearch@4.22.1)(search-insights@2.13.0): resolution: {integrity: sha512-009HdfugtGCdC4JdXUbVJClA0q0zh24yyePn+KUGk3rP7j8FEe/m5Yo/z65gn6nP/cM39PxpzqKrL7A6fP6PPw==} dependencies: @@ -750,6 +809,29 @@ packages: chalk: 4.1.2 dev: true + /@depay/solana-web3.js@1.26.0: + resolution: {integrity: sha512-aAhDxfNGraE8VBwM5g/BhHnNCENlLSKDJ3yIh2EZd4mfmKM/4utv0cNUhTEytUAvvFoaMcOXXQ5U5sE1IMXFrQ==} + dependencies: + bs58: 5.0.0 + dev: false + + /@depay/web3-blockchains@9.3.4: + resolution: {integrity: sha512-iw22WSFrQXQ6UUoegqJBhurb/jT13ELa0cht7FKcdQeC8d7Cyj5dV4Qky0rmjITi+ZHx4v/ui+NJwCtzbTFdmg==} + engines: {node: '>=10'} + dev: false + + /@depay/web3-mock@14.17.0: + resolution: {integrity: sha512-0WCIpHqGUTPmOb5l3iN+4wCY+P3nHnGWd3uyWB+Wrt5DygS6MWI2b50gwtSCgYUCfgmEv9KlRuCnHDC4TDKCeA==} + engines: {node: '>=16'} + dependencies: + '@depay/solana-web3.js': 1.26.0 + '@depay/web3-blockchains': 9.3.4 + ethers: 5.7.2 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + dev: false + /@docsearch/css@3.5.2: resolution: {integrity: sha512-SPiDHaWKQZpwR2siD0KQUwlStvIAnEyK6tAE2h2Wuoq8ue9skzhlyVQ1ddzOxX6khULnAALDiR/isSF3bnuciA==} dev: true @@ -1184,6 +1266,321 @@ packages: dev: false optional: true + /@ethersproject/abi@5.7.0: + resolution: {integrity: sha512-351ktp42TiRcYB3H1OP8yajPeAQstMW/yCFokj/AthP9bLHzQFPlOrxOcwYEDkUAICmOHljvN4K39OMTMUa9RA==} + dependencies: + '@ethersproject/address': 5.7.0 + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/constants': 5.7.0 + '@ethersproject/hash': 5.7.0 + '@ethersproject/keccak256': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/properties': 5.7.0 + '@ethersproject/strings': 5.7.0 + dev: false + + /@ethersproject/abstract-provider@5.7.0: + resolution: {integrity: sha512-R41c9UkchKCpAqStMYUpdunjo3pkEvZC3FAwZn5S5MGbXoMQOHIdHItezTETxAO5bevtMApSyEhn9+CHcDsWBw==} + dependencies: + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/networks': 5.7.1 + '@ethersproject/properties': 5.7.0 + '@ethersproject/transactions': 5.7.0 + '@ethersproject/web': 5.7.1 + dev: false + + /@ethersproject/abstract-signer@5.7.0: + resolution: {integrity: sha512-a16V8bq1/Cz+TGCkE2OPMTOUDLS3grCpdjoJCYNnVBbdYEMSgKrU0+B90s8b6H+ByYTBZN7a3g76jdIJi7UfKQ==} + dependencies: + '@ethersproject/abstract-provider': 5.7.0 + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/properties': 5.7.0 + dev: false + + /@ethersproject/address@5.7.0: + resolution: {integrity: sha512-9wYhYt7aghVGo758POM5nqcOMaE168Q6aRLJZwUmiqSrAungkG74gSSeKEIR7ukixesdRZGPgVqme6vmxs1fkA==} + dependencies: + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/keccak256': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/rlp': 5.7.0 + dev: false + + /@ethersproject/base64@5.7.0: + resolution: {integrity: sha512-Dr8tcHt2mEbsZr/mwTPIQAf3Ai0Bks/7gTw9dSqk1mQvhW3XvRlmDJr/4n+wg1JmCl16NZue17CDh8xb/vZ0sQ==} + dependencies: + '@ethersproject/bytes': 5.7.0 + dev: false + + /@ethersproject/basex@5.7.0: + resolution: {integrity: sha512-ywlh43GwZLv2Voc2gQVTKBoVQ1mti3d8HK5aMxsfu/nRDnMmNqaSJ3r3n85HBByT8OpoY96SXM1FogC533T4zw==} + dependencies: + '@ethersproject/bytes': 5.7.0 + '@ethersproject/properties': 5.7.0 + dev: false + + /@ethersproject/bignumber@5.7.0: + resolution: {integrity: sha512-n1CAdIHRWjSucQO3MC1zPSVgV/6dy/fjL9pMrPP9peL+QxEg9wOsVqwD4+818B6LUEtaXzVHQiuivzRoxPxUGw==} + dependencies: + '@ethersproject/bytes': 5.7.0 + '@ethersproject/logger': 5.7.0 + bn.js: 5.2.1 + dev: false + + /@ethersproject/bytes@5.7.0: + resolution: {integrity: sha512-nsbxwgFXWh9NyYWo+U8atvmMsSdKJprTcICAkvbBffT75qDocbuggBU0SJiVK2MuTrp0q+xvLkTnGMPK1+uA9A==} + dependencies: + '@ethersproject/logger': 5.7.0 + dev: false + + /@ethersproject/constants@5.7.0: + resolution: {integrity: sha512-DHI+y5dBNvkpYUMiRQyxRBYBefZkJfo70VUkUAsRjcPs47muV9evftfZ0PJVCXYbAiCgght0DtcF9srFQmIgWA==} + dependencies: + '@ethersproject/bignumber': 5.7.0 + dev: false + + /@ethersproject/contracts@5.7.0: + resolution: {integrity: sha512-5GJbzEU3X+d33CdfPhcyS+z8MzsTrBGk/sc+G+59+tPa9yFkl6HQ9D6L0QMgNTA9q8dT0XKxxkyp883XsQvbbg==} + dependencies: + '@ethersproject/abi': 5.7.0 + '@ethersproject/abstract-provider': 5.7.0 + '@ethersproject/abstract-signer': 5.7.0 + '@ethersproject/address': 5.7.0 + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/constants': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/properties': 5.7.0 + '@ethersproject/transactions': 5.7.0 + dev: false + + /@ethersproject/hash@5.7.0: + resolution: {integrity: sha512-qX5WrQfnah1EFnO5zJv1v46a8HW0+E5xuBBDTwMFZLuVTx0tbU2kkx15NqdjxecrLGatQN9FGQKpb1FKdHCt+g==} + dependencies: + '@ethersproject/abstract-signer': 5.7.0 + '@ethersproject/address': 5.7.0 + '@ethersproject/base64': 5.7.0 + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/keccak256': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/properties': 5.7.0 + '@ethersproject/strings': 5.7.0 + dev: false + + /@ethersproject/hdnode@5.7.0: + resolution: {integrity: sha512-OmyYo9EENBPPf4ERhR7oj6uAtUAhYGqOnIS+jE5pTXvdKBS99ikzq1E7Iv0ZQZ5V36Lqx1qZLeak0Ra16qpeOg==} + dependencies: + '@ethersproject/abstract-signer': 5.7.0 + '@ethersproject/basex': 5.7.0 + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/pbkdf2': 5.7.0 + '@ethersproject/properties': 5.7.0 + '@ethersproject/sha2': 5.7.0 + '@ethersproject/signing-key': 5.7.0 + '@ethersproject/strings': 5.7.0 + '@ethersproject/transactions': 5.7.0 + '@ethersproject/wordlists': 5.7.0 + dev: false + + /@ethersproject/json-wallets@5.7.0: + resolution: {integrity: sha512-8oee5Xgu6+RKgJTkvEMl2wDgSPSAQ9MB/3JYjFV9jlKvcYHUXZC+cQp0njgmxdHkYWn8s6/IqIZYm0YWCjO/0g==} + dependencies: + '@ethersproject/abstract-signer': 5.7.0 + '@ethersproject/address': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/hdnode': 5.7.0 + '@ethersproject/keccak256': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/pbkdf2': 5.7.0 + '@ethersproject/properties': 5.7.0 + '@ethersproject/random': 5.7.0 + '@ethersproject/strings': 5.7.0 + '@ethersproject/transactions': 5.7.0 + aes-js: 3.0.0 + scrypt-js: 3.0.1 + dev: false + + /@ethersproject/keccak256@5.7.0: + resolution: {integrity: sha512-2UcPboeL/iW+pSg6vZ6ydF8tCnv3Iu/8tUmLLzWWGzxWKFFqOBQFLo6uLUv6BDrLgCDfN28RJ/wtByx+jZ4KBg==} + dependencies: + '@ethersproject/bytes': 5.7.0 + js-sha3: 0.8.0 + dev: false + + /@ethersproject/logger@5.7.0: + resolution: {integrity: sha512-0odtFdXu/XHtjQXJYA3u9G0G8btm0ND5Cu8M7i5vhEcE8/HmF4Lbdqanwyv4uQTr2tx6b7fQRmgLrsnpQlmnig==} + dev: false + + /@ethersproject/networks@5.7.1: + resolution: {integrity: sha512-n/MufjFYv3yFcUyfhnXotyDlNdFb7onmkSy8aQERi2PjNcnWQ66xXxa3XlS8nCcA8aJKJjIIMNJTC7tu80GwpQ==} + dependencies: + '@ethersproject/logger': 5.7.0 + dev: false + + /@ethersproject/pbkdf2@5.7.0: + resolution: {integrity: sha512-oR/dBRZR6GTyaofd86DehG72hY6NpAjhabkhxgr3X2FpJtJuodEl2auADWBZfhDHgVCbu3/H/Ocq2uC6dpNjjw==} + dependencies: + '@ethersproject/bytes': 5.7.0 + '@ethersproject/sha2': 5.7.0 + dev: false + + /@ethersproject/properties@5.7.0: + resolution: {integrity: sha512-J87jy8suntrAkIZtecpxEPxY//szqr1mlBaYlQ0r4RCaiD2hjheqF9s1LVE8vVuJCXisjIP+JgtK/Do54ej4Sw==} + dependencies: + '@ethersproject/logger': 5.7.0 + dev: false + + /@ethersproject/providers@5.7.2: + resolution: {integrity: sha512-g34EWZ1WWAVgr4aptGlVBF8mhl3VWjv+8hoAnzStu8Ah22VHBsuGzP17eb6xDVRzw895G4W7vvx60lFFur/1Rg==} + dependencies: + '@ethersproject/abstract-provider': 5.7.0 + '@ethersproject/abstract-signer': 5.7.0 + '@ethersproject/address': 5.7.0 + '@ethersproject/base64': 5.7.0 + '@ethersproject/basex': 5.7.0 + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/constants': 5.7.0 + '@ethersproject/hash': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/networks': 5.7.1 + '@ethersproject/properties': 5.7.0 + '@ethersproject/random': 5.7.0 + '@ethersproject/rlp': 5.7.0 + '@ethersproject/sha2': 5.7.0 + '@ethersproject/strings': 5.7.0 + '@ethersproject/transactions': 5.7.0 + '@ethersproject/web': 5.7.1 + bech32: 1.1.4 + ws: 7.4.6 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + dev: false + + /@ethersproject/random@5.7.0: + resolution: {integrity: sha512-19WjScqRA8IIeWclFme75VMXSBvi4e6InrUNuaR4s5pTF2qNhcGdCUwdxUVGtDDqC00sDLCO93jPQoDUH4HVmQ==} + dependencies: + '@ethersproject/bytes': 5.7.0 + '@ethersproject/logger': 5.7.0 + dev: false + + /@ethersproject/rlp@5.7.0: + resolution: {integrity: sha512-rBxzX2vK8mVF7b0Tol44t5Tb8gomOHkj5guL+HhzQ1yBh/ydjGnpw6at+X6Iw0Kp3OzzzkcKp8N9r0W4kYSs9w==} + dependencies: + '@ethersproject/bytes': 5.7.0 + '@ethersproject/logger': 5.7.0 + dev: false + + /@ethersproject/sha2@5.7.0: + resolution: {integrity: sha512-gKlH42riwb3KYp0reLsFTokByAKoJdgFCwI+CCiX/k+Jm2mbNs6oOaCjYQSlI1+XBVejwH2KrmCbMAT/GnRDQw==} + dependencies: + '@ethersproject/bytes': 5.7.0 + '@ethersproject/logger': 5.7.0 + hash.js: 1.1.7 + dev: false + + /@ethersproject/signing-key@5.7.0: + resolution: {integrity: sha512-MZdy2nL3wO0u7gkB4nA/pEf8lu1TlFswPNmy8AiYkfKTdO6eXBJyUdmHO/ehm/htHw9K/qF8ujnTyUAD+Ry54Q==} + dependencies: + '@ethersproject/bytes': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/properties': 5.7.0 + bn.js: 5.2.1 + elliptic: 6.5.4 + hash.js: 1.1.7 + dev: false + + /@ethersproject/solidity@5.7.0: + resolution: {integrity: sha512-HmabMd2Dt/raavyaGukF4XxizWKhKQ24DoLtdNbBmNKUOPqwjsKQSdV9GQtj9CBEea9DlzETlVER1gYeXXBGaA==} + dependencies: + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/keccak256': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/sha2': 5.7.0 + '@ethersproject/strings': 5.7.0 + dev: false + + /@ethersproject/strings@5.7.0: + resolution: {integrity: sha512-/9nu+lj0YswRNSH0NXYqrh8775XNyEdUQAuf3f+SmOrnVewcJ5SBNAjF7lpgehKi4abvNNXyf+HX86czCdJ8Mg==} + dependencies: + '@ethersproject/bytes': 5.7.0 + '@ethersproject/constants': 5.7.0 + '@ethersproject/logger': 5.7.0 + dev: false + + /@ethersproject/transactions@5.7.0: + resolution: {integrity: sha512-kmcNicCp1lp8qanMTC3RIikGgoJ80ztTyvtsFvCYpSCfkjhD0jZ2LOrnbcuxuToLIUYYf+4XwD1rP+B/erDIhQ==} + dependencies: + '@ethersproject/address': 5.7.0 + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/constants': 5.7.0 + '@ethersproject/keccak256': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/properties': 5.7.0 + '@ethersproject/rlp': 5.7.0 + '@ethersproject/signing-key': 5.7.0 + dev: false + + /@ethersproject/units@5.7.0: + resolution: {integrity: sha512-pD3xLMy3SJu9kG5xDGI7+xhTEmGXlEqXU4OfNapmfnxLVY4EMSSRp7j1k7eezutBPH7RBN/7QPnwR7hzNlEFeg==} + dependencies: + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/constants': 5.7.0 + '@ethersproject/logger': 5.7.0 + dev: false + + /@ethersproject/wallet@5.7.0: + resolution: {integrity: sha512-MhmXlJXEJFBFVKrDLB4ZdDzxcBxQ3rLyCkhNqVu3CDYvR97E+8r01UgrI+TI99Le+aYm/in/0vp86guJuM7FCA==} + dependencies: + '@ethersproject/abstract-provider': 5.7.0 + '@ethersproject/abstract-signer': 5.7.0 + '@ethersproject/address': 5.7.0 + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/hash': 5.7.0 + '@ethersproject/hdnode': 5.7.0 + '@ethersproject/json-wallets': 5.7.0 + '@ethersproject/keccak256': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/properties': 5.7.0 + '@ethersproject/random': 5.7.0 + '@ethersproject/signing-key': 5.7.0 + '@ethersproject/transactions': 5.7.0 + '@ethersproject/wordlists': 5.7.0 + dev: false + + /@ethersproject/web@5.7.1: + resolution: {integrity: sha512-Gueu8lSvyjBWL4cYsWsjh6MtMwM0+H4HvqFPZfB6dV8ctbP9zFAO73VG1cMWae0FLPCtz0peKPpZY8/ugJJX2w==} + dependencies: + '@ethersproject/base64': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/properties': 5.7.0 + '@ethersproject/strings': 5.7.0 + dev: false + + /@ethersproject/wordlists@5.7.0: + resolution: {integrity: sha512-S2TFNJNfHWVHNE6cNDjbVlZ6MgE17MIxMbMg2zv3wn+3XSJGosL1m9ZVv3GXCf/2ymSsQ+hRI5IzoMJTG6aoVA==} + dependencies: + '@ethersproject/bytes': 5.7.0 + '@ethersproject/hash': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/properties': 5.7.0 + '@ethersproject/strings': 5.7.0 + dev: false + /@gar/promisify@1.1.3: resolution: {integrity: sha512-k2Ty1JcVojjJFwrg/ThKi2ujJ7XNLYaFGNB/bWT9wGR+oSMJHMa5w+CUq6p/pVrKeNNgA7pCqEcjSnHVoqJQFw==} dev: true @@ -1328,6 +1725,17 @@ packages: strict-event-emitter: 0.5.1 dev: true + /@noble/curves@1.2.0: + resolution: {integrity: sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==} + dependencies: + '@noble/hashes': 1.3.2 + dev: false + + /@noble/hashes@1.3.2: + resolution: {integrity: sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==} + engines: {node: '>= 16'} + dev: false + /@nodelib/fs.scandir@2.1.5: resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -1562,6 +1970,25 @@ packages: requiresBuild: true optional: true + /@scure/base@1.1.6: + resolution: {integrity: sha512-ok9AWwhcgYuGG3Zfhyqg+zwl+Wn5uE+dwC0NV/2qQkx4dABbb/bx96vWu8NSj+BNjjSjno+JRYRjle1jV08k3g==} + dev: false + + /@scure/bip32@1.3.2: + resolution: {integrity: sha512-N1ZhksgwD3OBlwTv3R6KFEcPojl/W4ElJOeCZdi+vuI5QmTFwLq3OFf2zd2ROpKvxFdgZ6hUpb0dx9bVNEwYCA==} + dependencies: + '@noble/curves': 1.2.0 + '@noble/hashes': 1.3.2 + '@scure/base': 1.1.6 + dev: false + + /@scure/bip39@1.2.1: + resolution: {integrity: sha512-Z3/Fsz1yr904dduJD0NpiyRHhRYHdcnyh73FZWiV+/qhWi83wNJ3NWolYqCEN+ZWsUz2TWwajJggcRE9r1zUYg==} + dependencies: + '@noble/hashes': 1.3.2 + '@scure/base': 1.1.6 + dev: false + /@shikijs/core@1.1.2: resolution: {integrity: sha512-ERVzNQz88ZkDqUpWeC57Kp+Kmx5RjqeDBR1M8AGWGom4yrkITiTfXCGmjchlDSw12MhDTuPYR4HVFW8uT61RaQ==} dev: true @@ -2024,6 +2451,21 @@ packages: resolution: {integrity: sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==} dev: true + /abitype@1.0.0(typescript@5.3.3)(zod@3.22.4): + resolution: {integrity: sha512-NMeMah//6bJ56H5XRj8QCV4AwuW6hB6zqz2LnhhLdcWVQOsXki6/Pn3APeqxCma62nXIcmZWdu1DlHWS74umVQ==} + peerDependencies: + typescript: '>=5.0.4' + zod: ^3 >=3.22.0 + peerDependenciesMeta: + typescript: + optional: true + zod: + optional: true + dependencies: + typescript: 5.3.3 + zod: 3.22.4 + dev: false + /accepts@1.3.8: resolution: {integrity: sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==} engines: {node: '>= 0.6'} @@ -2043,6 +2485,10 @@ packages: hasBin: true dev: true + /aes-js@3.0.0: + resolution: {integrity: sha512-H7wUZRn8WpTq9jocdxQ2c8x2sKo9ZVmzfRE13GiNJXfp7NcKYEdvl3vspKjXox6RIG2VtaRe4JFvxG4rqp2Zuw==} + dev: false + /agent-base@6.0.2: resolution: {integrity: sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==} engines: {node: '>= 6.0.0'} @@ -2292,6 +2738,14 @@ packages: /balanced-match@1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} + /base-x@4.0.0: + resolution: {integrity: sha512-FuwxlW4H5kh37X/oW59pwTzzTKRzfrrQwhmyspRM7swOEZcHtDZSCt45U6oKgtuFE+WYPblePMVIPR4RZrh/hw==} + dev: false + + /bech32@1.1.4: + resolution: {integrity: sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ==} + dev: false + /better-path-resolve@1.0.0: resolution: {integrity: sha512-pbnl5XzGBdrFU/wT4jqmJVPn2B6UHPBOhzMQkY/SPUPB6QtUXtmBHBIwCbXJol93mOpGMnQyP/+BB19q04xj7g==} engines: {node: '>=4'} @@ -2319,6 +2773,14 @@ packages: resolution: {integrity: sha512-iD3898SR7sWVRHbiQv+sHUtHnMvC1o3nW5rAcqnq3uOn07DSAppZYUkIGslDz6gXC7HfunPe7YVBgoEJASPcHA==} dev: false + /bn.js@4.12.0: + resolution: {integrity: sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==} + dev: false + + /bn.js@5.2.1: + resolution: {integrity: sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==} + dev: false + /boxen@7.0.0: resolution: {integrity: sha512-j//dBVuyacJbvW+tvZ9HuH03fZ46QcaKvvhZickZqtB271DxJ7SNRSNxrV/dZX0085m7hISRZWbzWlJvx/rHSg==} engines: {node: '>=14.16'} @@ -2370,6 +2832,16 @@ packages: wcwidth: 1.0.1 dev: true + /brorand@1.1.0: + resolution: {integrity: sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==} + dev: false + + /bs58@5.0.0: + resolution: {integrity: sha512-r+ihvQJvahgYT50JD05dyJNKlmmSlMoOGwn1lCcEzanPglg7TxYjioQUYehQ9mAR/+hOSd2jRc/Z2y5UxBymvQ==} + dependencies: + base-x: 4.0.0 + dev: false + /buffer-crc32@0.2.13: resolution: {integrity: sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==} dev: true @@ -3008,6 +3480,18 @@ packages: /eastasianwidth@0.2.0: resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} + /elliptic@6.5.4: + resolution: {integrity: sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==} + dependencies: + bn.js: 4.12.0 + brorand: 1.1.0 + hash.js: 1.1.7 + hmac-drbg: 1.0.1 + inherits: 2.0.4 + minimalistic-assert: 1.0.1 + minimalistic-crypto-utils: 1.0.1 + dev: false + /emoji-regex@10.3.0: resolution: {integrity: sha512-QpLs9D9v9kArv4lfDEgg1X/gN5XLnf/A6l9cs8SPZLRZR3ZkY9+kwIQTxm+fsSej5UMYGE8fdoaZVIBlqG0XTw==} dev: true @@ -3215,6 +3699,44 @@ packages: '@types/estree': 1.0.5 dev: true + /ethers@5.7.2: + resolution: {integrity: sha512-wswUsmWo1aOK8rR7DIKiWSw9DbLWe6x98Jrn8wcTflTVvaXhAMaB5zGAXy0GYQEQp9iO1iSHWVyARQm11zUtyg==} + dependencies: + '@ethersproject/abi': 5.7.0 + '@ethersproject/abstract-provider': 5.7.0 + '@ethersproject/abstract-signer': 5.7.0 + '@ethersproject/address': 5.7.0 + '@ethersproject/base64': 5.7.0 + '@ethersproject/basex': 5.7.0 + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/constants': 5.7.0 + '@ethersproject/contracts': 5.7.0 + '@ethersproject/hash': 5.7.0 + '@ethersproject/hdnode': 5.7.0 + '@ethersproject/json-wallets': 5.7.0 + '@ethersproject/keccak256': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/networks': 5.7.1 + '@ethersproject/pbkdf2': 5.7.0 + '@ethersproject/properties': 5.7.0 + '@ethersproject/providers': 5.7.2 + '@ethersproject/random': 5.7.0 + '@ethersproject/rlp': 5.7.0 + '@ethersproject/sha2': 5.7.0 + '@ethersproject/signing-key': 5.7.0 + '@ethersproject/solidity': 5.7.0 + '@ethersproject/strings': 5.7.0 + '@ethersproject/transactions': 5.7.0 + '@ethersproject/units': 5.7.0 + '@ethersproject/wallet': 5.7.0 + '@ethersproject/web': 5.7.1 + '@ethersproject/wordlists': 5.7.0 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + dev: false + /eventemitter3@4.0.7: resolution: {integrity: sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==} dev: false @@ -3740,6 +4262,13 @@ packages: engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} dev: true + /hash.js@1.1.7: + resolution: {integrity: sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==} + dependencies: + inherits: 2.0.4 + minimalistic-assert: 1.0.1 + dev: false + /hasown@2.0.0: resolution: {integrity: sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==} engines: {node: '>= 0.4'} @@ -3751,6 +4280,14 @@ packages: resolution: {integrity: sha512-EWGTfnTqAO2L/j5HZgoM/3z82L7necsJ0pO9Tp0X1wil3PDLrkypTBRgVO2ExehEEvUycejZD3FuRaXpZZc3kw==} dev: true + /hmac-drbg@1.0.1: + resolution: {integrity: sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==} + dependencies: + hash.js: 1.1.7 + minimalistic-assert: 1.0.1 + minimalistic-crypto-utils: 1.0.1 + dev: false + /hookable@5.5.3: resolution: {integrity: sha512-Yc+BQe8SvoXH1643Qez1zqLRmbA5rCL+sSmk6TVos0LWVfNIB7PGncdlId77WzLGSIB5KaWgTaNTs2lNVEI6VQ==} dev: true @@ -3908,6 +4445,10 @@ packages: once: 1.4.0 wrappy: 1.0.2 + /inherits@2.0.3: + resolution: {integrity: sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==} + dev: false + /inherits@2.0.4: resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} @@ -4176,6 +4717,14 @@ packages: /isexe@2.0.0: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} + /isows@1.0.3(ws@8.13.0): + resolution: {integrity: sha512-2cKei4vlmg2cxEjm3wVSqn8pcoRF/LX/wpifuuNquFO4SQmPwarClT+SUCA2lt+l581tTeZIPIZuIDo2jWN1fg==} + peerDependencies: + ws: '*' + dependencies: + ws: 8.13.0 + dev: false + /istanbul-lib-coverage@3.2.2: resolution: {integrity: sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==} engines: {node: '>=8'} @@ -4225,6 +4774,10 @@ packages: resolution: {integrity: sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==} engines: {node: '>=10'} + /js-sha3@0.8.0: + resolution: {integrity: sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==} + dev: false + /js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} dev: true @@ -4672,6 +5225,14 @@ packages: engines: {node: '>=4'} dev: true + /minimalistic-assert@1.0.1: + resolution: {integrity: sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==} + dev: false + + /minimalistic-crypto-utils@1.0.1: + resolution: {integrity: sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==} + dev: false + /minimatch@3.1.2: resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==} dependencies: @@ -5285,6 +5846,13 @@ packages: resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} engines: {node: '>=8'} + /path@0.12.7: + resolution: {integrity: sha512-aXXC6s+1w7otVF9UletFkFcDsJeO7lSZBPUQhtb5O0xJe8LtYhj/GxldoL09bBj9+ZmE2hNoHqQSFMN5fikh4Q==} + dependencies: + process: 0.11.10 + util: 0.10.4 + dev: false + /pathe@1.1.2: resolution: {integrity: sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==} dev: true @@ -5418,6 +5986,11 @@ packages: /process-nextick-args@2.0.1: resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==} + /process@0.11.10: + resolution: {integrity: sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==} + engines: {node: '>= 0.6.0'} + dev: false + /progress@2.0.3: resolution: {integrity: sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==} engines: {node: '>=0.4.0'} @@ -5816,6 +6389,10 @@ packages: resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==} dev: true + /scrypt-js@3.0.1: + resolution: {integrity: sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA==} + dev: false + /search-insights@2.13.0: resolution: {integrity: sha512-Orrsjf9trHHxFRuo9/rzm0KIWmgzE8RMlZMzuhZOJ01Rnz3D0YBAe+V6473t6/H6c7irs6Lt48brULAiRWb3Vw==} dev: true @@ -6806,6 +7383,12 @@ packages: /util-deprecate@1.0.2: resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} + /util@0.10.4: + resolution: {integrity: sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==} + dependencies: + inherits: 2.0.3 + dev: false + /v8-to-istanbul@9.2.0: resolution: {integrity: sha512-/EH/sDgxU2eGxajKdwLCDmQ4FWq+kpi3uCmBGpw1xJtnAxEjlD8j8PEiGWpCIMIs3ciNAgH0d3TTJiUkYzyZjA==} engines: {node: '>=10.12.0'} @@ -6834,6 +7417,29 @@ packages: engines: {node: '>= 0.8'} dev: true + /viem@2.9.9(typescript@5.3.3)(zod@3.22.4): + resolution: {integrity: sha512-SUIHBL6M5IIlqDCMEQwAAvHzeglaM4FEqM6bCI+srLXtFYmrpV4tWhnpobQRNwh4f7HIksmKLLZ+cytv8FfnJQ==} + peerDependencies: + typescript: '>=5.0.4' + peerDependenciesMeta: + typescript: + optional: true + dependencies: + '@adraffy/ens-normalize': 1.10.0 + '@noble/curves': 1.2.0 + '@noble/hashes': 1.3.2 + '@scure/bip32': 1.3.2 + '@scure/bip39': 1.2.1 + abitype: 1.0.0(typescript@5.3.3)(zod@3.22.4) + isows: 1.0.3(ws@8.13.0) + typescript: 5.3.3 + ws: 8.13.0 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + - zod + dev: false + /vite-node@1.2.2(@types/node@20.11.17): resolution: {integrity: sha512-1as4rDTgVWJO3n1uHmUYqq7nsFgINQ9u+mRcXpjeOMJUmviqNKjcZB7UfRZrlM7MjYXMKpuWp5oGkjaFLnjawg==} engines: {node: ^18.0.0 || >=20.0.0} @@ -7181,6 +7787,32 @@ packages: typedarray-to-buffer: 3.1.5 dev: true + /ws@7.4.6: + resolution: {integrity: sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==} + engines: {node: '>=8.3.0'} + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: ^5.0.2 + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + dev: false + + /ws@8.13.0: + resolution: {integrity: sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==} + engines: {node: '>=10.0.0'} + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: '>=5.0.2' + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + dev: false + /ws@8.16.0: resolution: {integrity: sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ==} engines: {node: '>=10.0.0'} diff --git a/release/package.json b/release/package.json index f38fd2af9..37240e689 100644 --- a/release/package.json +++ b/release/package.json @@ -28,7 +28,8 @@ "dependencies": { "@synthetixio/synpress-core": "0.0.1-alpha.3", "@synthetixio/synpress-fixtures": "0.0.1-alpha.3", - "@synthetixio/synpress-metamask": "0.0.1-alpha.3" + "@synthetixio/synpress-metamask": "0.0.1-alpha.3", + "@synthetixio/synpress-metamask-mock": "0.0.1-alpha.3" }, "devDependencies": { "@synthetixio/synpress-tsconfig": "0.0.1-alpha.3", diff --git a/release/src/index.ts b/release/src/index.ts index c1ed62865..59fd1c8a3 100644 --- a/release/src/index.ts +++ b/release/src/index.ts @@ -1,5 +1,28 @@ -import { defineWalletSetup } from '@synthetixio/synpress-core' -import { getExtensionId, testWithSynpress } from '@synthetixio/synpress-fixtures' -import { MetaMask, homePageSelectors, unlockForFixture } from '@synthetixio/synpress-metamask' +import { defineWalletSetup } from "@synthetixio/synpress-core"; +import { + getExtensionId, + testWithSynpress, +} from "@synthetixio/synpress-fixtures"; +import { + MetaMask, + homePageSelectors, + unlockForFixture, +} from "@synthetixio/synpress-metamask"; +import { + testWithMetaMaskMock, + MetaMaskMock, +} from "@synthetixio/synpress-metamask-mock"; -export { defineWalletSetup, testWithSynpress, getExtensionId, MetaMask, unlockForFixture, homePageSelectors } +export { + // Framework fixtures + testWithSynpress, + testWithMetaMaskMock, + // API + MetaMask, + MetaMaskMock, + // Helpers + defineWalletSetup, + getExtensionId, + unlockForFixture, + homePageSelectors, +}; diff --git a/wallets/metamask-mock/environment.d.ts b/wallets/metamask-mock/environment.d.ts new file mode 100644 index 000000000..3da96a469 --- /dev/null +++ b/wallets/metamask-mock/environment.d.ts @@ -0,0 +1,18 @@ +declare global { + namespace NodeJS { + interface ProcessEnv { + CI: boolean; + HEADLESS: boolean; + } + } +} + +declare global { + interface Window { + ethereum: any; + } + + const Web3Mock: any; +} + +export {}; diff --git a/wallets/metamask-mock/package.json b/wallets/metamask-mock/package.json new file mode 100644 index 000000000..3ef8081fb --- /dev/null +++ b/wallets/metamask-mock/package.json @@ -0,0 +1,46 @@ +{ + "name": "@synthetixio/synpress-metamask-mock", + "version": "0.0.1-alpha.3", + "type": "module", + "exports": { + "types": "./types/index.d.ts", + "default": "./dist/index.js" + }, + "main": "./dist/index.js", + "types": "./types/index.d.ts", + "files": [ + "dist", + "src", + "types" + ], + "scripts": { + "build": "pnpm run clean && pnpm run build:dist && pnpm run build:types", + "build:dist": "tsup --tsconfig tsconfig.build.json", + "build:types": "tsc --emitDeclarationOnly --project tsconfig.build.json", + "clean": "rimraf dist types", + "test": "vitest run", + "test:coverage": "vitest run --coverage", + "test:e2e:headful": "playwright test", + "test:e2e:headless": "HEADLESS=true playwright test", + "test:e2e:headless:ui": "HEADLESS=true playwright test --ui", + "test:watch": "vitest watch", + "types:check": "tsc --noEmit" + }, + "dependencies": { + "@depay/web3-mock": "14.17.0", + "viem": "2.9.9" + }, + "devDependencies": { + "@depay/web3-mock": "14.17.0", + "@synthetixio/synpress-tsconfig": "0.0.1-alpha.3", + "@types/node": "20.11.17", + "@vitest/coverage-v8": "1.2.2", + "rimraf": "5.0.5", + "tsup": "8.0.2", + "typescript": "5.3.3", + "vitest": "1.2.2" + }, + "peerDependencies": { + "@playwright/test": "1.41.2" + } +} diff --git a/wallets/metamask-mock/playwright.config.ts b/wallets/metamask-mock/playwright.config.ts new file mode 100644 index 000000000..0994ed0a0 --- /dev/null +++ b/wallets/metamask-mock/playwright.config.ts @@ -0,0 +1,50 @@ +import { defineConfig, devices } from '@playwright/test' + +/** + * See https://playwright.dev/docs/test-configuration. + */ +export default defineConfig({ + // Look for test files in the "test/e2e" directory, relative to this configuration file. + testDir: './test/e2e', + + // We're increasing the timeout to 60 seconds to allow all traces to be recorded. + // Sometimes it threw an error saying that traces were not recorded in the 30 seconds timeout limit. + timeout: 60_000, + + // Run all tests in parallel. + fullyParallel: true, + + // Fail the build on CI if you accidentally left test.only in the source code. + forbidOnly: !!process.env.CI, + + // Fail all remaining tests on CI after the first failure. We want to reduce the feedback loop on CI to minimum. + maxFailures: process.env.CI ? 1 : 0, + + // Opt out of parallel tests on CI since it supports only 1 worker. + workers: process.env.CI ? 1 : undefined, + + // Concise 'dot' for CI, default 'html' when running locally. + // See https://playwright.dev/docs/test-reporters. + reporter: process.env.CI + ? [['html', { open: 'never', outputFolder: `playwright-report-${process.env.HEADLESS ? 'headless' : 'headful'}` }]] + : 'html', + + // Shared settings for all the projects below. + // See https://playwright.dev/docs/api/class-testoptions. + use: { + // We are using locally deployed MetaMask Test Dapp. + baseURL: 'http://localhost:9999', + + // Collect all traces on CI, and only traces for failed tests when running locally. + // See https://playwright.dev/docs/trace-viewer. + trace: process.env.CI ? 'on' : 'retain-on-failure' + }, + + // Configure projects for major browsers. + projects: [ + { + name: 'chromium', + use: { ...devices['Desktop Chrome'] } + } + ] +}) diff --git a/wallets/metamask-mock/src/index.ts b/wallets/metamask-mock/src/index.ts new file mode 100644 index 000000000..1377df821 --- /dev/null +++ b/wallets/metamask-mock/src/index.ts @@ -0,0 +1,3 @@ +export * from "./metamask-mock"; +export * from "./utils"; +export * from "./testWithMetaMaskMock"; diff --git a/wallets/metamask-mock/src/metamask-mock.ts b/wallets/metamask-mock/src/metamask-mock.ts new file mode 100644 index 000000000..6c1c1e0c4 --- /dev/null +++ b/wallets/metamask-mock/src/metamask-mock.ts @@ -0,0 +1,191 @@ +import { mnemonicToAccount, privateKeyToAccount } from "viem/accounts"; +// @ts-ignore +import { connect } from "@depay/web3-mock"; +import type { Page } from "@playwright/test"; +import type { Network } from "./network/Network"; + +export const blockchain = "ethereum"; +export const wallet = "metamask"; + +const networkConfig = { + blockchain, + wallet, +}; + +const BSC_NETWORK_ID = "0x38"; + +export const SEED_PHRASE = + "test test test test test test test test test test test junk"; + +export const PRIVATE_KEY = + "ea084c575a01e2bbefcca3db101eaeab1d8af15554640a510c73692db24d0a6a"; + +/** + * This class is the heart of Synpress's MetaMask API. + */ +export class MetaMaskMock { + seedPhrase = ""; + + constructor( + /** + * The MetaMask tab page. + */ + readonly page: Page + ) { + this.page = page; + } + + /** + * Imports a wallet using the given seed phrase. + * + * @param seedPhrase - The seed phrase to import. + */ + importWallet(seedPhrase: string) { + this.seedPhrase = seedPhrase; + } + + /** + * Retrieves the current account address. + */ + async getAllAccounts(): Promise { + return this.page.evaluate(() => { + return window.ethereum.request({ method: "eth_requestAccounts" }); + }); + } + + /** + * Adds a new account. This account is based on the initially imported seed phrase. + */ + async addNewAccount() { + const accounts = await this.getAllAccounts(); + + const newAccount = mnemonicToAccount(this.seedPhrase, { + accountIndex: accounts.length, + }); + + return this.page.evaluate( + ([networkConfig, accounts]) => { + return Web3Mock.mock({ + ...networkConfig, + accounts: { + return: accounts, + }, + }); + }, + [networkConfig, [newAccount.address, ...accounts]] + ); + } + + /** + * Imports a wallet using the given private key. + * + * @param privateKey - The private key to import. + */ + async importWalletFromPrivateKey(privateKey: `0x${string}`) { + const newAccount = privateKeyToAccount(privateKey); + + return this.page.evaluate( + ([networkConfig, account]) => { + return Web3Mock.mock({ + ...networkConfig, + accounts: { + return: account, + }, + }); + }, + [networkConfig, [newAccount.address]] + ); + } + + /** + * Switches to the account with the given name. + * + * @param accountAddress - The name of the account to switch to. + */ + async switchAccount(accountAddress: string) { + return this.page.evaluate( + ([networkConfig, accountAddress]) => { + return Web3Mock.mock({ + // @ts-ignore + ...networkConfig, + accounts: { + return: [accountAddress], + }, + }); + }, + [networkConfig, accountAddress] + ); + } + + /** + * Adds a new network. + * + * @param network - The network object to use for adding the new network. + * @param network.name - The name of the network. + * @param network.rpcUrl - The RPC URL of the network. + * @param network.chainId - The chain ID of the network. + * @param network.symbol - The currency symbol of the network. + * @param network.blockExplorerUrl - The block explorer URL of the network. + */ + async addNetwork(network: Network) { + const networkInfo = { + chainId: network.chainId, + chainName: network.name, + nativeCurrency: network.nativeCurrency, + rpcUrls: [network.rpcUrl], + blockExplorerUrls: [network.blockExplorerUrl], + }; + + return this.page.evaluate( + ([networkConfig, networkInfo]) => { + return Web3Mock.mock({ + ...networkConfig, + network: { + add: networkInfo, + }, + }); + }, + [networkConfig, networkInfo] + ); + } + + /** + * Retrieves the current account address. + */ + async getAccountAddress() { + return (await this.getAllAccounts())[0]; + } + + /** + * Switches to the network with the given name. + * + * @param networkName - The name of the network to switch to. + */ + async switchNetwork(networkName: string) { + return this.page.evaluate( + ([networkConfig, networkName, chainId]) => { + Web3Mock.mock({ + // @ts-ignore + ...networkConfig, + network: { + switchTo: networkName, + }, + }); + + window.ethereum.request({ + method: "wallet_switchEthereumChain", + // Mock do not support custom network IDs + params: [{ chainId }], + }); + }, + [networkConfig, networkName, BSC_NETWORK_ID] + ); + } + + /** + * Connects to the dapp using the currently selected account. + */ + async connectToDapp(network: string) { + connect(network); + } +} diff --git a/wallets/metamask-mock/src/network/Network.ts b/wallets/metamask-mock/src/network/Network.ts new file mode 100644 index 000000000..cbed8bb09 --- /dev/null +++ b/wallets/metamask-mock/src/network/Network.ts @@ -0,0 +1,11 @@ +export type Network = { + name: string; + rpcUrl: string; + chainId: number; + blockExplorerUrl?: string; + nativeCurrency?: { + name: string; + symbol: string; + decimals: number; + }; +}; diff --git a/wallets/metamask-mock/src/testWithMetaMaskMock.ts b/wallets/metamask-mock/src/testWithMetaMaskMock.ts new file mode 100644 index 000000000..6495a0053 --- /dev/null +++ b/wallets/metamask-mock/src/testWithMetaMaskMock.ts @@ -0,0 +1,64 @@ +import { readFileSync } from "fs"; +import { test as base } from "@playwright/test"; +import { MetaMaskMock, SEED_PHRASE } from "./metamask-mock"; +import type { Network } from "./network/Network"; +import { mockEthereum } from "./utils"; +import { createRequire } from "node:module"; + +const ANVIL_CHAIN_ID = 31337; +const ANVIL_URL_URL = "http://anvil:5000"; + +const require = createRequire(import.meta.url); +// Relative path to the web3-mock bundle +const web3MockPath = require.resolve( + "@depay/web3-mock/dist/umd/index.bundle.js" +); + +export const testWithMetaMaskMock = base.extend<{ + metamask: MetaMaskMock; + createAnvilNetwork: () => Network; + deployToken: () => Promise; +}>({ + context: async ({ context }, use) => { + // Dependency and mock function has to be added at the same time - https://playwright.dev/docs/api/class-browsercontext#browser-context-add-init-script + await context.addInitScript({ + content: + readFileSync(web3MockPath, "utf-8") + + "\n" + + `(${mockEthereum.toString()})();`, + }); + + await use(context); + + await context.close(); + }, + page: async ({ context }, use) => { + const page = await context.newPage(); + + await page.goto("/"); + + await use(page); + }, + metamask: async ({ page }, use) => { + const metamask = new MetaMaskMock(page); + + metamask.importWallet(SEED_PHRASE); + + await use(metamask); + }, + createAnvilNetwork: async ({ context: _ }, use) => { + await use(() => { + return { + name: "Anvil", + rpcUrl: ANVIL_URL_URL, + chainId: ANVIL_CHAIN_ID, + blockExplorerUrl: "https://etherscan.io/", + nativeCurrency: { + decimals: 18, + name: "Anvil", + symbol: "ETH", + }, + }; + }); + }, +}); diff --git a/wallets/metamask-mock/src/utils/index.ts b/wallets/metamask-mock/src/utils/index.ts new file mode 100644 index 000000000..92fd67110 --- /dev/null +++ b/wallets/metamask-mock/src/utils/index.ts @@ -0,0 +1 @@ +export { default as mockEthereum } from "./mockEthereum"; diff --git a/wallets/metamask-mock/src/utils/mockEthereum.ts b/wallets/metamask-mock/src/utils/mockEthereum.ts new file mode 100644 index 000000000..db665f526 --- /dev/null +++ b/wallets/metamask-mock/src/utils/mockEthereum.ts @@ -0,0 +1,10 @@ +export default function mockEthereum() { + // @ts-ignore + Web3Mock.mock({ + blockchain: "ethereum", + wallet: "metamask", + accounts: { + return: ["0xd73b04b0e696b0945283defa3eee453814758f1a"], + }, + }); +} diff --git a/wallets/metamask-mock/test/e2e/metamask/addNewAccount.spec.ts b/wallets/metamask-mock/test/e2e/metamask/addNewAccount.spec.ts new file mode 100644 index 000000000..2e6c4bfc7 --- /dev/null +++ b/wallets/metamask-mock/test/e2e/metamask/addNewAccount.spec.ts @@ -0,0 +1,18 @@ +import { testWithMetaMaskMock } from "../../../src"; + +const test = testWithMetaMaskMock; + +const { expect } = test; + +test("should add a new account with specified name", async ({ metamask }) => { + expect(await metamask.getAllAccounts()).toHaveLength(1); + + await metamask.addNewAccount(); + + expect(await metamask.getAllAccounts()).toHaveLength(2); + + await metamask.addNewAccount(); + await metamask.addNewAccount(); + + expect(await metamask.getAllAccounts()).toHaveLength(4); +}); diff --git a/wallets/metamask-mock/test/e2e/metamask/importWalletFromPrivateKey.spec.ts b/wallets/metamask-mock/test/e2e/metamask/importWalletFromPrivateKey.spec.ts new file mode 100644 index 000000000..620f3abee --- /dev/null +++ b/wallets/metamask-mock/test/e2e/metamask/importWalletFromPrivateKey.spec.ts @@ -0,0 +1,16 @@ +import { testWithMetaMaskMock } from "../../../src"; + +const test = testWithMetaMaskMock; + +const { expect } = test; + +test("should import account using private key", async ({ page, metamask }) => { + await metamask.importWalletFromPrivateKey( + "0xea084c575a01e2bbefcca3db101eaeab1d8af15554640a510c73692db24d0a6a" + ); + + await page.locator("#getAccounts").click(); + await expect(page.locator("#getAccountsResult")).toHaveText( + "0xa2ce797cA71d0EaE1be5a7EffD27Fd6C38126801" + ); +}); diff --git a/wallets/metamask-mock/test/e2e/metamask/mock/mockEthereum.spec.ts b/wallets/metamask-mock/test/e2e/metamask/mock/mockEthereum.spec.ts new file mode 100644 index 000000000..8790f3e99 --- /dev/null +++ b/wallets/metamask-mock/test/e2e/metamask/mock/mockEthereum.spec.ts @@ -0,0 +1,25 @@ +import { testWithMetaMaskMock } from "../../../../src"; + +const test = testWithMetaMaskMock; + +const { expect } = test; + +test("should be able to access ethereum API", async ({ page }) => { + const ethereum = await page.evaluate(() => window.ethereum); + expect(ethereum).toBeTruthy(); +}); + +test("should be connected to metamask", async ({ page }) => { + const ethereum = await page.evaluate(() => window.ethereum); + expect(ethereum.isMetaMask).toBe(true); +}); + +test("should connect to ethereum", async ({ page }) => { + const currentChainId = await page.evaluate(() => + window.ethereum.request({ + method: "eth_chainId", + }) + ); + + expect(currentChainId).toEqual("0x1"); +}); diff --git a/wallets/metamask-mock/test/e2e/metamask/switchAccount.spec.ts b/wallets/metamask-mock/test/e2e/metamask/switchAccount.spec.ts new file mode 100644 index 000000000..1e3f2fe1e --- /dev/null +++ b/wallets/metamask-mock/test/e2e/metamask/switchAccount.spec.ts @@ -0,0 +1,16 @@ +import { testWithMetaMaskMock } from "../../../src"; + +const test = testWithMetaMaskMock; + +const { expect } = test; + +test("should switch account", async ({ page, metamask }) => { + await metamask.switchAccount( + "0x4444797cA71d0EaE1be5a7EffD27Fd6C38126801" + ); + + await page.locator("#getAccounts").click(); + await expect(page.locator("#getAccountsResult")).toHaveText( + "0x4444797cA71d0EaE1be5a7EffD27Fd6C38126801" + ); +}); diff --git a/wallets/metamask-mock/test/e2e/metamask/switchNetwork.spec.ts b/wallets/metamask-mock/test/e2e/metamask/switchNetwork.spec.ts new file mode 100644 index 000000000..70dbf7e3c --- /dev/null +++ b/wallets/metamask-mock/test/e2e/metamask/switchNetwork.spec.ts @@ -0,0 +1,23 @@ +import { testWithMetaMaskMock } from "../../../src"; + +const test = testWithMetaMaskMock; + +const { expect } = test; + +test("should switch network", async ({ + createAnvilNetwork, + metamask, + page, +}) => { + const network = createAnvilNetwork(); + + await metamask.addNetwork(network); + + await metamask.switchNetwork(network.name); + + const chainId = await page.evaluate(async () => { + return await window.ethereum.request({ method: "eth_chainId" }); + }); + + expect(chainId).toBe("0x38"); +}); diff --git a/wallets/metamask-mock/tsconfig.build.json b/wallets/metamask-mock/tsconfig.build.json new file mode 100644 index 000000000..9af73f809 --- /dev/null +++ b/wallets/metamask-mock/tsconfig.build.json @@ -0,0 +1,12 @@ +{ + "extends": "@synthetixio/synpress-tsconfig/base.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "types", + "declaration": true, + "sourceMap": true, + "declarationMap": true + }, + "include": ["src"], + "files": ["environment.d.ts"] +} diff --git a/wallets/metamask-mock/tsconfig.json b/wallets/metamask-mock/tsconfig.json new file mode 100644 index 000000000..f36ef006c --- /dev/null +++ b/wallets/metamask-mock/tsconfig.json @@ -0,0 +1,10 @@ +{ + "type": "commonjs", + "extends": "./tsconfig.build.json", + "compilerOptions": { + "rootDir": ".", + "exactOptionalPropertyTypes": false // Allows for `undefined` in `playwright.config.ts` + }, + "include": ["src", "test"], + "files": ["environment.d.ts", "playwright.config.ts", "vitest.config.ts"] +} diff --git a/wallets/metamask-mock/tsup.config.ts b/wallets/metamask-mock/tsup.config.ts new file mode 100644 index 000000000..63ed05775 --- /dev/null +++ b/wallets/metamask-mock/tsup.config.ts @@ -0,0 +1,12 @@ +import { defineConfig } from 'tsup' + +export default defineConfig({ + name: 'metamask', + entry: ['src/index.ts'], + outDir: 'dist', + format: 'esm', + splitting: false, + treeshake: true, + sourcemap: true, + external: ['@playwright/test'] +}) diff --git a/wallets/metamask-mock/vitest.config.ts b/wallets/metamask-mock/vitest.config.ts new file mode 100644 index 000000000..42ec65bf9 --- /dev/null +++ b/wallets/metamask-mock/vitest.config.ts @@ -0,0 +1,7 @@ +import { defineConfig } from 'vitest/config' + +export default defineConfig({ + test: { + dir: 'test/unit' + } +}) From 1b41be1f5f83086305daa1845fe649cf1b7fe6d1 Mon Sep 17 00:00:00 2001 From: matstyler Date: Mon, 8 Apr 2024 21:22:13 +0200 Subject: [PATCH 2/5] fix: cleanup --- examples/new-dawn/test/e2e/00_mock.spec.ts | 24 ++--- release/src/index.ts | 22 ++--- wallets/metamask-mock/environment.d.ts | 11 ++- wallets/metamask-mock/src/index.ts | 6 +- wallets/metamask-mock/src/metamask-mock.ts | 96 +++++++++---------- wallets/metamask-mock/src/network/Network.ts | 18 ++-- .../metamask-mock/src/testWithMetaMaskMock.ts | 69 +++++++------ wallets/metamask-mock/src/utils/index.ts | 2 +- .../metamask-mock/src/utils/mockEthereum.ts | 11 +-- .../test/e2e/metamask/addNewAccount.spec.ts | 22 ++--- .../importWalletFromPrivateKey.spec.ts | 20 ++-- .../e2e/metamask/mock/mockEthereum.spec.ts | 32 +++---- .../test/e2e/metamask/switchAccount.spec.ts | 20 ++-- .../test/e2e/metamask/switchNetwork.spec.ts | 26 +++-- 14 files changed, 173 insertions(+), 206 deletions(-) diff --git a/examples/new-dawn/test/e2e/00_mock.spec.ts b/examples/new-dawn/test/e2e/00_mock.spec.ts index 774435d00..8fcb14679 100644 --- a/examples/new-dawn/test/e2e/00_mock.spec.ts +++ b/examples/new-dawn/test/e2e/00_mock.spec.ts @@ -1,20 +1,16 @@ -import { testWithMetaMaskMock, MetaMaskMock } from "@synthetixio/synpress"; +import { MetaMaskMock, testWithMetaMaskMock } from '@synthetixio/synpress' -const test = testWithMetaMaskMock; +const test = testWithMetaMaskMock -const { expect } = test; +const { expect } = test -test("should work to the MetaMask Test Dapp", async ({ page }) => { - const metamask = new MetaMaskMock(page); +test('should work to the MetaMask Test Dapp', async ({ page }) => { + const metamask = new MetaMaskMock(page) - await page.goto("/"); + await page.goto('/') - await expect(page.locator("#accounts")).toHaveText( - "0xd73b04b0e696b0945283defa3eee453814758f1a" - ); + await expect(page.locator('#accounts')).toHaveText('0xd73b04b0e696b0945283defa3eee453814758f1a') - await page.locator("#getAccounts").click(); - await expect(page.locator("#getAccountsResult")).toHaveText( - "0xd73b04b0e696b0945283defa3eee453814758f1a" - ); -}); + await page.locator('#getAccounts').click() + await expect(page.locator('#getAccountsResult')).toHaveText('0xd73b04b0e696b0945283defa3eee453814758f1a') +}) diff --git a/release/src/index.ts b/release/src/index.ts index 59fd1c8a3..75bd9686d 100644 --- a/release/src/index.ts +++ b/release/src/index.ts @@ -1,17 +1,7 @@ -import { defineWalletSetup } from "@synthetixio/synpress-core"; -import { - getExtensionId, - testWithSynpress, -} from "@synthetixio/synpress-fixtures"; -import { - MetaMask, - homePageSelectors, - unlockForFixture, -} from "@synthetixio/synpress-metamask"; -import { - testWithMetaMaskMock, - MetaMaskMock, -} from "@synthetixio/synpress-metamask-mock"; +import { defineWalletSetup } from '@synthetixio/synpress-core' +import { getExtensionId, testWithSynpress } from '@synthetixio/synpress-fixtures' +import { MetaMask, homePageSelectors, unlockForFixture } from '@synthetixio/synpress-metamask' +import { MetaMaskMock, testWithMetaMaskMock } from '@synthetixio/synpress-metamask-mock' export { // Framework fixtures @@ -24,5 +14,5 @@ export { defineWalletSetup, getExtensionId, unlockForFixture, - homePageSelectors, -}; + homePageSelectors +} diff --git a/wallets/metamask-mock/environment.d.ts b/wallets/metamask-mock/environment.d.ts index 3da96a469..fed78f861 100644 --- a/wallets/metamask-mock/environment.d.ts +++ b/wallets/metamask-mock/environment.d.ts @@ -1,18 +1,19 @@ declare global { namespace NodeJS { interface ProcessEnv { - CI: boolean; - HEADLESS: boolean; + CI: boolean + HEADLESS: boolean } } } declare global { interface Window { - ethereum: any; + ethereum: import('ethers').Eip1193Provider } - const Web3Mock: any; + // biome-ignore lint/suspicious/noExplicitAny: Web3Mock is a mock object + const Web3Mock: any } -export {}; +export {} diff --git a/wallets/metamask-mock/src/index.ts b/wallets/metamask-mock/src/index.ts index 1377df821..94d5183c1 100644 --- a/wallets/metamask-mock/src/index.ts +++ b/wallets/metamask-mock/src/index.ts @@ -1,3 +1,3 @@ -export * from "./metamask-mock"; -export * from "./utils"; -export * from "./testWithMetaMaskMock"; +export * from './metamask-mock' +export * from './utils' +export * from './testWithMetaMaskMock' diff --git a/wallets/metamask-mock/src/metamask-mock.ts b/wallets/metamask-mock/src/metamask-mock.ts index 6c1c1e0c4..798277a1c 100644 --- a/wallets/metamask-mock/src/metamask-mock.ts +++ b/wallets/metamask-mock/src/metamask-mock.ts @@ -1,30 +1,28 @@ -import { mnemonicToAccount, privateKeyToAccount } from "viem/accounts"; // @ts-ignore -import { connect } from "@depay/web3-mock"; -import type { Page } from "@playwright/test"; -import type { Network } from "./network/Network"; +import { connect } from '@depay/web3-mock' +import type { Page } from '@playwright/test' +import { mnemonicToAccount, privateKeyToAccount } from 'viem/accounts' +import type { Network } from './network/Network' -export const blockchain = "ethereum"; -export const wallet = "metamask"; +export const blockchain = 'ethereum' +export const wallet = 'metamask' const networkConfig = { blockchain, - wallet, -}; + wallet +} -const BSC_NETWORK_ID = "0x38"; +const BSC_NETWORK_ID = '0x38' -export const SEED_PHRASE = - "test test test test test test test test test test test junk"; +export const SEED_PHRASE = 'test test test test test test test test test test test junk' -export const PRIVATE_KEY = - "ea084c575a01e2bbefcca3db101eaeab1d8af15554640a510c73692db24d0a6a"; +export const PRIVATE_KEY = 'ea084c575a01e2bbefcca3db101eaeab1d8af15554640a510c73692db24d0a6a' /** * This class is the heart of Synpress's MetaMask API. */ export class MetaMaskMock { - seedPhrase = ""; + seedPhrase = '' constructor( /** @@ -32,7 +30,7 @@ export class MetaMaskMock { */ readonly page: Page ) { - this.page = page; + this.page = page } /** @@ -41,7 +39,7 @@ export class MetaMaskMock { * @param seedPhrase - The seed phrase to import. */ importWallet(seedPhrase: string) { - this.seedPhrase = seedPhrase; + this.seedPhrase = seedPhrase } /** @@ -49,31 +47,31 @@ export class MetaMaskMock { */ async getAllAccounts(): Promise { return this.page.evaluate(() => { - return window.ethereum.request({ method: "eth_requestAccounts" }); - }); + return window.ethereum.request({ method: 'eth_requestAccounts' }) + }) } /** * Adds a new account. This account is based on the initially imported seed phrase. */ async addNewAccount() { - const accounts = await this.getAllAccounts(); + const accounts = await this.getAllAccounts() const newAccount = mnemonicToAccount(this.seedPhrase, { - accountIndex: accounts.length, - }); + accountIndex: accounts.length + }) return this.page.evaluate( ([networkConfig, accounts]) => { return Web3Mock.mock({ ...networkConfig, accounts: { - return: accounts, - }, - }); + return: accounts + } + }) }, [networkConfig, [newAccount.address, ...accounts]] - ); + ) } /** @@ -82,19 +80,19 @@ export class MetaMaskMock { * @param privateKey - The private key to import. */ async importWalletFromPrivateKey(privateKey: `0x${string}`) { - const newAccount = privateKeyToAccount(privateKey); + const newAccount = privateKeyToAccount(privateKey) return this.page.evaluate( ([networkConfig, account]) => { return Web3Mock.mock({ ...networkConfig, accounts: { - return: account, - }, - }); + return: account + } + }) }, [networkConfig, [newAccount.address]] - ); + ) } /** @@ -109,12 +107,12 @@ export class MetaMaskMock { // @ts-ignore ...networkConfig, accounts: { - return: [accountAddress], - }, - }); + return: [accountAddress] + } + }) }, [networkConfig, accountAddress] - ); + ) } /** @@ -133,27 +131,27 @@ export class MetaMaskMock { chainName: network.name, nativeCurrency: network.nativeCurrency, rpcUrls: [network.rpcUrl], - blockExplorerUrls: [network.blockExplorerUrl], - }; + blockExplorerUrls: [network.blockExplorerUrl] + } return this.page.evaluate( ([networkConfig, networkInfo]) => { return Web3Mock.mock({ ...networkConfig, network: { - add: networkInfo, - }, - }); + add: networkInfo + } + }) }, [networkConfig, networkInfo] - ); + ) } /** * Retrieves the current account address. */ async getAccountAddress() { - return (await this.getAllAccounts())[0]; + return (await this.getAllAccounts())[0] } /** @@ -168,24 +166,24 @@ export class MetaMaskMock { // @ts-ignore ...networkConfig, network: { - switchTo: networkName, - }, - }); + switchTo: networkName + } + }) window.ethereum.request({ - method: "wallet_switchEthereumChain", + method: 'wallet_switchEthereumChain', // Mock do not support custom network IDs - params: [{ chainId }], - }); + params: [{ chainId }] + }) }, [networkConfig, networkName, BSC_NETWORK_ID] - ); + ) } /** * Connects to the dapp using the currently selected account. */ async connectToDapp(network: string) { - connect(network); + connect(network) } } diff --git a/wallets/metamask-mock/src/network/Network.ts b/wallets/metamask-mock/src/network/Network.ts index cbed8bb09..23b839e84 100644 --- a/wallets/metamask-mock/src/network/Network.ts +++ b/wallets/metamask-mock/src/network/Network.ts @@ -1,11 +1,11 @@ export type Network = { - name: string; - rpcUrl: string; - chainId: number; - blockExplorerUrl?: string; + name: string + rpcUrl: string + chainId: number + blockExplorerUrl?: string nativeCurrency?: { - name: string; - symbol: string; - decimals: number; - }; -}; + name: string + symbol: string + decimals: number + } +} diff --git a/wallets/metamask-mock/src/testWithMetaMaskMock.ts b/wallets/metamask-mock/src/testWithMetaMaskMock.ts index 6495a0053..f6bd28f93 100644 --- a/wallets/metamask-mock/src/testWithMetaMaskMock.ts +++ b/wallets/metamask-mock/src/testWithMetaMaskMock.ts @@ -1,64 +1,59 @@ -import { readFileSync } from "fs"; -import { test as base } from "@playwright/test"; -import { MetaMaskMock, SEED_PHRASE } from "./metamask-mock"; -import type { Network } from "./network/Network"; -import { mockEthereum } from "./utils"; -import { createRequire } from "node:module"; +import { readFileSync } from 'fs' +import { createRequire } from 'node:module' +import { test as base } from '@playwright/test' +import { MetaMaskMock, SEED_PHRASE } from './metamask-mock' +import type { Network } from './network/Network' +import { mockEthereum } from './utils' -const ANVIL_CHAIN_ID = 31337; -const ANVIL_URL_URL = "http://anvil:5000"; +const ANVIL_CHAIN_ID = 31337 +const ANVIL_URL_URL = 'http://anvil:5000' -const require = createRequire(import.meta.url); +const require = createRequire(import.meta.url) // Relative path to the web3-mock bundle -const web3MockPath = require.resolve( - "@depay/web3-mock/dist/umd/index.bundle.js" -); +const web3MockPath = require.resolve('@depay/web3-mock/dist/umd/index.bundle.js') export const testWithMetaMaskMock = base.extend<{ - metamask: MetaMaskMock; - createAnvilNetwork: () => Network; - deployToken: () => Promise; + metamask: MetaMaskMock + createAnvilNetwork: () => Network + deployToken: () => Promise }>({ context: async ({ context }, use) => { // Dependency and mock function has to be added at the same time - https://playwright.dev/docs/api/class-browsercontext#browser-context-add-init-script await context.addInitScript({ - content: - readFileSync(web3MockPath, "utf-8") + - "\n" + - `(${mockEthereum.toString()})();`, - }); + content: `${readFileSync(web3MockPath, 'utf-8')}\n(${mockEthereum.toString()})();` + }) - await use(context); + await use(context) - await context.close(); + await context.close() }, page: async ({ context }, use) => { - const page = await context.newPage(); + const page = await context.newPage() - await page.goto("/"); + await page.goto('/') - await use(page); + await use(page) }, metamask: async ({ page }, use) => { - const metamask = new MetaMaskMock(page); + const metamask = new MetaMaskMock(page) - metamask.importWallet(SEED_PHRASE); + metamask.importWallet(SEED_PHRASE) - await use(metamask); + await use(metamask) }, createAnvilNetwork: async ({ context: _ }, use) => { await use(() => { return { - name: "Anvil", + name: 'Anvil', rpcUrl: ANVIL_URL_URL, chainId: ANVIL_CHAIN_ID, - blockExplorerUrl: "https://etherscan.io/", + blockExplorerUrl: 'https://etherscan.io/', nativeCurrency: { decimals: 18, - name: "Anvil", - symbol: "ETH", - }, - }; - }); - }, -}); + name: 'Anvil', + symbol: 'ETH' + } + } + }) + } +}) diff --git a/wallets/metamask-mock/src/utils/index.ts b/wallets/metamask-mock/src/utils/index.ts index 92fd67110..8fe4e82ee 100644 --- a/wallets/metamask-mock/src/utils/index.ts +++ b/wallets/metamask-mock/src/utils/index.ts @@ -1 +1 @@ -export { default as mockEthereum } from "./mockEthereum"; +export { default as mockEthereum } from './mockEthereum' diff --git a/wallets/metamask-mock/src/utils/mockEthereum.ts b/wallets/metamask-mock/src/utils/mockEthereum.ts index db665f526..5c500f5f7 100644 --- a/wallets/metamask-mock/src/utils/mockEthereum.ts +++ b/wallets/metamask-mock/src/utils/mockEthereum.ts @@ -1,10 +1,9 @@ export default function mockEthereum() { - // @ts-ignore Web3Mock.mock({ - blockchain: "ethereum", - wallet: "metamask", + blockchain: 'ethereum', + wallet: 'metamask', accounts: { - return: ["0xd73b04b0e696b0945283defa3eee453814758f1a"], - }, - }); + return: ['0xd73b04b0e696b0945283defa3eee453814758f1a'] + } + }) } diff --git a/wallets/metamask-mock/test/e2e/metamask/addNewAccount.spec.ts b/wallets/metamask-mock/test/e2e/metamask/addNewAccount.spec.ts index 2e6c4bfc7..66d501321 100644 --- a/wallets/metamask-mock/test/e2e/metamask/addNewAccount.spec.ts +++ b/wallets/metamask-mock/test/e2e/metamask/addNewAccount.spec.ts @@ -1,18 +1,18 @@ -import { testWithMetaMaskMock } from "../../../src"; +import { testWithMetaMaskMock } from '../../../src' -const test = testWithMetaMaskMock; +const test = testWithMetaMaskMock -const { expect } = test; +const { expect } = test -test("should add a new account with specified name", async ({ metamask }) => { - expect(await metamask.getAllAccounts()).toHaveLength(1); +test('should add a new account with specified name', async ({ metamask }) => { + expect(await metamask.getAllAccounts()).toHaveLength(1) - await metamask.addNewAccount(); + await metamask.addNewAccount() - expect(await metamask.getAllAccounts()).toHaveLength(2); + expect(await metamask.getAllAccounts()).toHaveLength(2) - await metamask.addNewAccount(); - await metamask.addNewAccount(); + await metamask.addNewAccount() + await metamask.addNewAccount() - expect(await metamask.getAllAccounts()).toHaveLength(4); -}); + expect(await metamask.getAllAccounts()).toHaveLength(4) +}) diff --git a/wallets/metamask-mock/test/e2e/metamask/importWalletFromPrivateKey.spec.ts b/wallets/metamask-mock/test/e2e/metamask/importWalletFromPrivateKey.spec.ts index 620f3abee..8d699d21c 100644 --- a/wallets/metamask-mock/test/e2e/metamask/importWalletFromPrivateKey.spec.ts +++ b/wallets/metamask-mock/test/e2e/metamask/importWalletFromPrivateKey.spec.ts @@ -1,16 +1,12 @@ -import { testWithMetaMaskMock } from "../../../src"; +import { testWithMetaMaskMock } from '../../../src' -const test = testWithMetaMaskMock; +const test = testWithMetaMaskMock -const { expect } = test; +const { expect } = test -test("should import account using private key", async ({ page, metamask }) => { - await metamask.importWalletFromPrivateKey( - "0xea084c575a01e2bbefcca3db101eaeab1d8af15554640a510c73692db24d0a6a" - ); +test('should import account using private key', async ({ page, metamask }) => { + await metamask.importWalletFromPrivateKey('0xea084c575a01e2bbefcca3db101eaeab1d8af15554640a510c73692db24d0a6a') - await page.locator("#getAccounts").click(); - await expect(page.locator("#getAccountsResult")).toHaveText( - "0xa2ce797cA71d0EaE1be5a7EffD27Fd6C38126801" - ); -}); + await page.locator('#getAccounts').click() + await expect(page.locator('#getAccountsResult')).toHaveText('0xa2ce797cA71d0EaE1be5a7EffD27Fd6C38126801') +}) diff --git a/wallets/metamask-mock/test/e2e/metamask/mock/mockEthereum.spec.ts b/wallets/metamask-mock/test/e2e/metamask/mock/mockEthereum.spec.ts index 8790f3e99..70fb1be59 100644 --- a/wallets/metamask-mock/test/e2e/metamask/mock/mockEthereum.spec.ts +++ b/wallets/metamask-mock/test/e2e/metamask/mock/mockEthereum.spec.ts @@ -1,25 +1,25 @@ -import { testWithMetaMaskMock } from "../../../../src"; +import { testWithMetaMaskMock } from '../../../../src' -const test = testWithMetaMaskMock; +const test = testWithMetaMaskMock -const { expect } = test; +const { expect } = test -test("should be able to access ethereum API", async ({ page }) => { - const ethereum = await page.evaluate(() => window.ethereum); - expect(ethereum).toBeTruthy(); -}); +test('should be able to access ethereum API', async ({ page }) => { + const ethereum = await page.evaluate(() => window.ethereum) + expect(ethereum).toBeTruthy() +}) -test("should be connected to metamask", async ({ page }) => { - const ethereum = await page.evaluate(() => window.ethereum); - expect(ethereum.isMetaMask).toBe(true); -}); +test('should be connected to metamask', async ({ page }) => { + const ethereum = await page.evaluate(() => window.ethereum) + expect(ethereum.isMetaMask).toBe(true) +}) -test("should connect to ethereum", async ({ page }) => { +test('should connect to ethereum', async ({ page }) => { const currentChainId = await page.evaluate(() => window.ethereum.request({ - method: "eth_chainId", + method: 'eth_chainId' }) - ); + ) - expect(currentChainId).toEqual("0x1"); -}); + expect(currentChainId).toEqual('0x1') +}) diff --git a/wallets/metamask-mock/test/e2e/metamask/switchAccount.spec.ts b/wallets/metamask-mock/test/e2e/metamask/switchAccount.spec.ts index 1e3f2fe1e..b3570e38d 100644 --- a/wallets/metamask-mock/test/e2e/metamask/switchAccount.spec.ts +++ b/wallets/metamask-mock/test/e2e/metamask/switchAccount.spec.ts @@ -1,16 +1,12 @@ -import { testWithMetaMaskMock } from "../../../src"; +import { testWithMetaMaskMock } from '../../../src' -const test = testWithMetaMaskMock; +const test = testWithMetaMaskMock -const { expect } = test; +const { expect } = test -test("should switch account", async ({ page, metamask }) => { - await metamask.switchAccount( - "0x4444797cA71d0EaE1be5a7EffD27Fd6C38126801" - ); +test('should switch account', async ({ page, metamask }) => { + await metamask.switchAccount('0x4444797cA71d0EaE1be5a7EffD27Fd6C38126801') - await page.locator("#getAccounts").click(); - await expect(page.locator("#getAccountsResult")).toHaveText( - "0x4444797cA71d0EaE1be5a7EffD27Fd6C38126801" - ); -}); + await page.locator('#getAccounts').click() + await expect(page.locator('#getAccountsResult')).toHaveText('0x4444797cA71d0EaE1be5a7EffD27Fd6C38126801') +}) diff --git a/wallets/metamask-mock/test/e2e/metamask/switchNetwork.spec.ts b/wallets/metamask-mock/test/e2e/metamask/switchNetwork.spec.ts index 70dbf7e3c..d04a2f238 100644 --- a/wallets/metamask-mock/test/e2e/metamask/switchNetwork.spec.ts +++ b/wallets/metamask-mock/test/e2e/metamask/switchNetwork.spec.ts @@ -1,23 +1,19 @@ -import { testWithMetaMaskMock } from "../../../src"; +import { testWithMetaMaskMock } from '../../../src' -const test = testWithMetaMaskMock; +const test = testWithMetaMaskMock -const { expect } = test; +const { expect } = test -test("should switch network", async ({ - createAnvilNetwork, - metamask, - page, -}) => { - const network = createAnvilNetwork(); +test('should switch network', async ({ createAnvilNetwork, metamask, page }) => { + const network = createAnvilNetwork() - await metamask.addNetwork(network); + await metamask.addNetwork(network) - await metamask.switchNetwork(network.name); + await metamask.switchNetwork(network.name) const chainId = await page.evaluate(async () => { - return await window.ethereum.request({ method: "eth_chainId" }); - }); + return await window.ethereum.request({ method: 'eth_chainId' }) + }) - expect(chainId).toBe("0x38"); -}); + expect(chainId).toBe('0x38') +}) From 3f76c0748380c069b73a9fb3253aed005139b571 Mon Sep 17 00:00:00 2001 From: matstyler Date: Mon, 8 Apr 2024 21:30:26 +0200 Subject: [PATCH 3/5] fix: dependencies --- examples/new-dawn/test/e2e/00_mock.spec.ts | 13 ++++-- pnpm-lock.yaml | 52 ++-------------------- wallets/metamask-mock/package.json | 5 +-- 3 files changed, 15 insertions(+), 55 deletions(-) diff --git a/examples/new-dawn/test/e2e/00_mock.spec.ts b/examples/new-dawn/test/e2e/00_mock.spec.ts index 8fcb14679..ebcbf11fa 100644 --- a/examples/new-dawn/test/e2e/00_mock.spec.ts +++ b/examples/new-dawn/test/e2e/00_mock.spec.ts @@ -4,9 +4,7 @@ const test = testWithMetaMaskMock const { expect } = test -test('should work to the MetaMask Test Dapp', async ({ page }) => { - const metamask = new MetaMaskMock(page) - +test('should mock MetaMask in the Test Dapp', async ({ page }) => { await page.goto('/') await expect(page.locator('#accounts')).toHaveText('0xd73b04b0e696b0945283defa3eee453814758f1a') @@ -14,3 +12,12 @@ test('should work to the MetaMask Test Dapp', async ({ page }) => { await page.locator('#getAccounts').click() await expect(page.locator('#getAccountsResult')).toHaveText('0xd73b04b0e696b0945283defa3eee453814758f1a') }) + +test('should add new account using MetaMask mock', async ({ page }) => { + const metamask = new MetaMaskMock(page) + + metamask.importWallet('candy maple cake sugar pudding cream honey rich smooth crumble sweet treat') + await metamask.addNewAccount() + + await expect(page.locator('#accounts')).toHaveText('0xd73b04b0e696b0945283defa3eee453814758f1a') +}) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ca1d2d4cb..711978ab3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -279,33 +279,15 @@ importers: wallets/metamask-mock: dependencies: - '@depay/web3-blockchains': - specifier: 9.3.4 - version: 9.3.4 '@depay/web3-mock': specifier: 14.17.0 version: 14.17.0 '@playwright/test': specifier: 1.41.2 version: 1.41.2 - '@synthetixio/synpress-core': - specifier: 0.0.1-alpha.3 - version: link:../../packages/core - '@synthetixio/synpress-fixtures': - specifier: 0.0.1-alpha.3 - version: link:../../packages/fixtures - '@synthetixio/synpress-metamask': - specifier: 0.0.1-alpha.3 - version: link:../metamask - path: - specifier: 0.12.7 - version: 0.12.7 viem: specifier: 2.9.9 - version: 2.9.9(typescript@5.3.3)(zod@3.22.4) - zod: - specifier: 3.22.4 - version: 3.22.4 + version: 2.9.9(typescript@5.3.3) devDependencies: '@synthetixio/synpress-tsconfig': specifier: 0.0.1-alpha.3 @@ -325,9 +307,6 @@ importers: typescript: specifier: 5.3.3 version: 5.3.3 - vitest: - specifier: 1.2.2 - version: 1.2.2(@types/node@20.11.17) packages: @@ -2451,7 +2430,7 @@ packages: resolution: {integrity: sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==} dev: true - /abitype@1.0.0(typescript@5.3.3)(zod@3.22.4): + /abitype@1.0.0(typescript@5.3.3): resolution: {integrity: sha512-NMeMah//6bJ56H5XRj8QCV4AwuW6hB6zqz2LnhhLdcWVQOsXki6/Pn3APeqxCma62nXIcmZWdu1DlHWS74umVQ==} peerDependencies: typescript: '>=5.0.4' @@ -2463,7 +2442,6 @@ packages: optional: true dependencies: typescript: 5.3.3 - zod: 3.22.4 dev: false /accepts@1.3.8: @@ -4445,10 +4423,6 @@ packages: once: 1.4.0 wrappy: 1.0.2 - /inherits@2.0.3: - resolution: {integrity: sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==} - dev: false - /inherits@2.0.4: resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} @@ -5846,13 +5820,6 @@ packages: resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} engines: {node: '>=8'} - /path@0.12.7: - resolution: {integrity: sha512-aXXC6s+1w7otVF9UletFkFcDsJeO7lSZBPUQhtb5O0xJe8LtYhj/GxldoL09bBj9+ZmE2hNoHqQSFMN5fikh4Q==} - dependencies: - process: 0.11.10 - util: 0.10.4 - dev: false - /pathe@1.1.2: resolution: {integrity: sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==} dev: true @@ -5986,11 +5953,6 @@ packages: /process-nextick-args@2.0.1: resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==} - /process@0.11.10: - resolution: {integrity: sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==} - engines: {node: '>= 0.6.0'} - dev: false - /progress@2.0.3: resolution: {integrity: sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==} engines: {node: '>=0.4.0'} @@ -7383,12 +7345,6 @@ packages: /util-deprecate@1.0.2: resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} - /util@0.10.4: - resolution: {integrity: sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==} - dependencies: - inherits: 2.0.3 - dev: false - /v8-to-istanbul@9.2.0: resolution: {integrity: sha512-/EH/sDgxU2eGxajKdwLCDmQ4FWq+kpi3uCmBGpw1xJtnAxEjlD8j8PEiGWpCIMIs3ciNAgH0d3TTJiUkYzyZjA==} engines: {node: '>=10.12.0'} @@ -7417,7 +7373,7 @@ packages: engines: {node: '>= 0.8'} dev: true - /viem@2.9.9(typescript@5.3.3)(zod@3.22.4): + /viem@2.9.9(typescript@5.3.3): resolution: {integrity: sha512-SUIHBL6M5IIlqDCMEQwAAvHzeglaM4FEqM6bCI+srLXtFYmrpV4tWhnpobQRNwh4f7HIksmKLLZ+cytv8FfnJQ==} peerDependencies: typescript: '>=5.0.4' @@ -7430,7 +7386,7 @@ packages: '@noble/hashes': 1.3.2 '@scure/bip32': 1.3.2 '@scure/bip39': 1.2.1 - abitype: 1.0.0(typescript@5.3.3)(zod@3.22.4) + abitype: 1.0.0(typescript@5.3.3) isows: 1.0.3(ws@8.13.0) typescript: 5.3.3 ws: 8.13.0 diff --git a/wallets/metamask-mock/package.json b/wallets/metamask-mock/package.json index 3ef8081fb..12baa8293 100644 --- a/wallets/metamask-mock/package.json +++ b/wallets/metamask-mock/package.json @@ -18,8 +18,6 @@ "build:dist": "tsup --tsconfig tsconfig.build.json", "build:types": "tsc --emitDeclarationOnly --project tsconfig.build.json", "clean": "rimraf dist types", - "test": "vitest run", - "test:coverage": "vitest run --coverage", "test:e2e:headful": "playwright test", "test:e2e:headless": "HEADLESS=true playwright test", "test:e2e:headless:ui": "HEADLESS=true playwright test --ui", @@ -37,8 +35,7 @@ "@vitest/coverage-v8": "1.2.2", "rimraf": "5.0.5", "tsup": "8.0.2", - "typescript": "5.3.3", - "vitest": "1.2.2" + "typescript": "5.3.3" }, "peerDependencies": { "@playwright/test": "1.41.2" From 184a135142028a3819cb8a6e716e32c650a8fd94 Mon Sep 17 00:00:00 2001 From: matstyler Date: Mon, 8 Apr 2024 22:17:10 +0200 Subject: [PATCH 4/5] fix: e2e test --- wallets/metamask/test/e2e/metamask/connectToDapp.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wallets/metamask/test/e2e/metamask/connectToDapp.spec.ts b/wallets/metamask/test/e2e/metamask/connectToDapp.spec.ts index 0a9e56292..52c6439fd 100644 --- a/wallets/metamask/test/e2e/metamask/connectToDapp.spec.ts +++ b/wallets/metamask/test/e2e/metamask/connectToDapp.spec.ts @@ -32,6 +32,6 @@ test('should connect multiple wallets to dapp', async ({ context, page, metamask await metamask.connectToDapp(['Account x2', 'Account 1']) await expect(page.locator('#accounts')).toHaveText( - '0x70997970c51812dc3a010c7d01b50e0d17dc79c8,0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266' + '0x976ea74026e726554db657fa54763abd0c3a0aa9,0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266' ) }) From ec073a0eac714c6ebef92901fb42db32bc65a1b7 Mon Sep 17 00:00:00 2001 From: matstyler Date: Mon, 8 Apr 2024 23:42:57 +0200 Subject: [PATCH 5/5] fix: refreshed PPOM testing scenarios --- wallets/metamask/test/e2e/metamask/PPOM.spec.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wallets/metamask/test/e2e/metamask/PPOM.spec.ts b/wallets/metamask/test/e2e/metamask/PPOM.spec.ts index 37e2ca036..664cb308f 100644 --- a/wallets/metamask/test/e2e/metamask/PPOM.spec.ts +++ b/wallets/metamask/test/e2e/metamask/PPOM.spec.ts @@ -20,7 +20,7 @@ describe('using PPOM security mechanism', () => { ) }) - test('should prevent malicious ERC20 transfer', async ({ context, page, metamask }) => { + test.skip('should prevent malicious ERC20 transfer', async ({ context, page, metamask }) => { await page.locator('#maliciousERC20TransferButton').click() const notificationPage = await getNotificationPageAndWaitForLoad(context, metamask.extensionId || '') @@ -36,7 +36,7 @@ describe('using PPOM security mechanism', () => { const notificationPage = await getNotificationPageAndWaitForLoad(context, metamask.extensionId || '') await expect(notificationPage.locator(createDataTestSelector('security-provider-banner-alert'))).toContainText( - PPOM_WARNING + PPOM_ERROR ) }) @@ -46,7 +46,7 @@ describe('using PPOM security mechanism', () => { const notificationPage = await getNotificationPageAndWaitForLoad(context, metamask.extensionId || '') await expect(notificationPage.locator(createDataTestSelector('security-provider-banner-alert'))).toContainText( - PPOM_WARNING + PPOM_ERROR ) })