diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md index 8977793b5..9c88d8943 100644 --- a/DEPLOYMENT.md +++ b/DEPLOYMENT.md @@ -43,3 +43,7 @@ If you're running in prerelease mode, make sure you're also pushing the release ```bash git push --follow-tags ``` + +8. Run `pnpm build` again + +9. Commit lockfile diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 13bcf49d4..aada3eba7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -73,8 +73,8 @@ importers: specifier: 8.1.0 version: 8.1.0 '@synthetixio/synpress-tsconfig': - specifier: 0.0.3 - version: 0.0.3 + specifier: 0.0.4 + version: 0.0.4 '@types/node': specifier: 20.11.17 version: 20.11.17 @@ -104,8 +104,8 @@ importers: specifier: 8.1.0 version: 8.1.0 '@synthetixio/synpress-tsconfig': - specifier: 0.0.3 - version: 0.0.3 + specifier: 0.0.4 + version: 0.0.4 '@types/node': specifier: 20.11.17 version: 20.11.17 @@ -159,8 +159,8 @@ importers: version: 3.22.4 devDependencies: '@synthetixio/synpress-tsconfig': - specifier: 0.0.3 - version: 0.0.3 + specifier: 0.0.4 + version: 0.0.4 '@types/archiver': specifier: 6.0.2 version: 6.0.2 @@ -208,8 +208,8 @@ importers: version: 1.48.2 devDependencies: '@synthetixio/synpress-tsconfig': - specifier: 0.0.3 - version: 0.0.3 + specifier: 0.0.4 + version: 0.0.4 '@types/node': specifier: 20.11.17 version: 20.11.17 @@ -234,18 +234,18 @@ importers: specifier: workspace:* version: link:../wallets/ethereum-wallet-mock '@synthetixio/synpress-cache': - specifier: 0.0.3 - version: 0.0.3(playwright-core@1.48.2)(postcss@8.4.41)(typescript@5.3.3) + specifier: 0.0.4 + version: 0.0.4(playwright-core@1.48.2)(postcss@8.4.41)(typescript@5.3.3) '@synthetixio/synpress-core': - specifier: 0.0.3 - version: 0.0.3(@playwright/test@1.48.2) + specifier: 0.0.4 + version: 0.0.4(@playwright/test@1.48.2) '@synthetixio/synpress-metamask': specifier: workspace:* version: link:../wallets/metamask devDependencies: '@synthetixio/synpress-tsconfig': - specifier: 0.0.3 - version: 0.0.3 + specifier: 0.0.4 + version: 0.0.4 '@types/node': specifier: 20.11.17 version: 20.11.17 @@ -263,10 +263,10 @@ importers: dependencies: '@depay/web3-client': specifier: 10.18.6 - version: 10.18.6(@depay/solana-web3.js@1.26.0)(@depay/web3-blockchains@9.4.4)(ethers@5.7.2) + version: 10.18.6(@depay/solana-web3.js@1.26.0)(@depay/web3-blockchains@9.7.5)(ethers@5.7.2) '@depay/web3-mock': - specifier: 14.17.0 - version: 14.17.0 + specifier: 14.19.1 + version: 14.19.1 '@depay/web3-mock-evm': specifier: ^14.17.0 version: 14.18.0 @@ -274,15 +274,15 @@ importers: specifier: 1.48.2 version: 1.48.2 '@synthetixio/synpress-core': - specifier: 0.0.3 - version: 0.0.3(@playwright/test@1.48.2) + specifier: 0.0.4 + version: 0.0.4(@playwright/test@1.48.2) viem: specifier: 2.9.9 version: 2.9.9(typescript@5.3.3)(zod@3.22.4) devDependencies: '@synthetixio/synpress-tsconfig': - specifier: 0.0.3 - version: 0.0.3 + specifier: 0.0.4 + version: 0.0.4 '@types/node': specifier: 20.11.17 version: 20.11.17 @@ -324,8 +324,8 @@ importers: version: 3.22.4 devDependencies: '@synthetixio/synpress-tsconfig': - specifier: 0.0.3 - version: 0.0.3 + specifier: 0.0.4 + version: 0.0.4 '@types/fs-extra': specifier: 11.0.4 version: 11.0.4 @@ -581,6 +581,10 @@ packages: resolution: {integrity: sha512-z/L7QjtGCavkNOt+gzZbg44aILazzjQKK+ZAniNCy+DeT1HRNbBC3HXAfprb6GNiBaZBk6rmsLf8o1GsYQMa8g==} engines: {node: '>=10'} + '@depay/web3-blockchains@9.7.5': + resolution: {integrity: sha512-Nhte6p1mYolqe58JS3Gt3ebn1/xsMMzytNhHk6BK/rpCeqTwX2WyeaYeTAHXNn0sm99hlZM4Qf2Vo4BeZUKOLw==} + engines: {node: '>=18'} + '@depay/web3-client@10.18.6': resolution: {integrity: sha512-JeUAZ04/dsIra1ao3mvqAdVhRf4U1YxSoH0mE+XxhcXPgLC7KQTzH6oCLp07tAmoxholEL2cf5Oo20n6q1fZ/w==} engines: {node: '>=16'} @@ -593,8 +597,8 @@ packages: resolution: {integrity: sha512-St3Pzhw2zi5io+u+R48iKTTryZg9Dzsy+zGxBMMCd28rc/sSJGla5e/FjieMYjPtJaRGXX/jVJoEhOdB2BHH9Q==} engines: {node: '>=16'} - '@depay/web3-mock@14.17.0': - resolution: {integrity: sha512-0WCIpHqGUTPmOb5l3iN+4wCY+P3nHnGWd3uyWB+Wrt5DygS6MWI2b50gwtSCgYUCfgmEv9KlRuCnHDC4TDKCeA==} + '@depay/web3-mock@14.19.1': + resolution: {integrity: sha512-bBM1J0EWDWXJKVPtzo8YrX7fbGwUATYWN8kaJniQU2z5V+UK3kVhjQi+en0JMF9cCjinkERK7MqoZLaYR+cb+Q==} engines: {node: '>=16'} '@docsearch/css@3.6.1': @@ -1401,19 +1405,19 @@ packages: resolution: {integrity: sha512-TV7t8GKYaJWsn00tFDqBw8+Uqmr8A0fRU1tvTQhyZzGv0sJCGRQL3JGMI3ucuKo3XIZdUP+Lx7/gh2t3lewy7g==} engines: {node: '>=14.16'} - '@synthetixio/synpress-cache@0.0.3': - resolution: {integrity: sha512-TbbCBft7lst8onYa2GpyG51w036F+iXe0h09ooFUEF6BrHdkgk6yw+12mzpeeOI9sQB/YYjsqSUmd+EK9wtetA==} + '@synthetixio/synpress-cache@0.0.4': + resolution: {integrity: sha512-G1qF0XgMyRDjQjTYFniuFvPaY6+AuSvcEi2bkdcMmKCD0NK+Zw/PLEk0wRy1r1LN1F4HLdXrjittiKU6mh5PLA==} hasBin: true peerDependencies: playwright-core: 1.48.2 - '@synthetixio/synpress-core@0.0.3': - resolution: {integrity: sha512-DmtCiCFsTiSadISlhCz9nOYRCqoDcULVbiR7UOtsaz07H4sSjPzKJqWXlLrVD2wgFLRBRF8HbJbgV9kaeBNoXg==} + '@synthetixio/synpress-core@0.0.4': + resolution: {integrity: sha512-3zO8PGigi9sjdG359pZ0EB3BiBPweZVOyiobCopNDykKI/EoWNYY05bOttOG+/Wg0HynMzGTPTRwpJ0+a+k2Sg==} peerDependencies: '@playwright/test': 1.48.2 - '@synthetixio/synpress-tsconfig@0.0.3': - resolution: {integrity: sha512-f8tqG2rhXntUZjVzmgYwjZVT9GQbIALLnBvwqBihK9CXitWpPqBl+erAYHo7Vga1EqXfHsdleMUqywIPLRGxCw==} + '@synthetixio/synpress-tsconfig@0.0.4': + resolution: {integrity: sha512-hbCj7Tr3fFt1oJ1ceu8aQeUgG8I8SHOUxM6V2sHHSK9+2caEKxg1ehqVBObY7Tt2X4WyZerJa92WPVpX/TKSRA==} '@szmarczak/http-timer@5.0.1': resolution: {integrity: sha512-+PmQX0PiAYPMeVYe237LJAYvOMYW1j2rH5YROyS3b4CTVJum34HfRvKvAzozHAQG0TnHNdUfY9nCeUyRAs//cw==} @@ -5426,10 +5430,12 @@ snapshots: '@depay/web3-blockchains@9.4.4': {} - '@depay/web3-client@10.18.6(@depay/solana-web3.js@1.26.0)(@depay/web3-blockchains@9.4.4)(ethers@5.7.2)': + '@depay/web3-blockchains@9.7.5': {} + + '@depay/web3-client@10.18.6(@depay/solana-web3.js@1.26.0)(@depay/web3-blockchains@9.7.5)(ethers@5.7.2)': dependencies: '@depay/solana-web3.js': 1.26.0 - '@depay/web3-blockchains': 9.4.4 + '@depay/web3-blockchains': 9.7.5 ethers: 5.7.2 '@depay/web3-mock-evm@14.18.0': @@ -5440,10 +5446,10 @@ snapshots: - bufferutil - utf-8-validate - '@depay/web3-mock@14.17.0': + '@depay/web3-mock@14.19.1': dependencies: '@depay/solana-web3.js': 1.26.0 - '@depay/web3-blockchains': 9.4.4 + '@depay/web3-blockchains': 9.7.5 ethers: 5.7.2 transitivePeerDependencies: - bufferutil @@ -6225,7 +6231,7 @@ snapshots: '@sindresorhus/is@5.6.0': {} - '@synthetixio/synpress-cache@0.0.3(playwright-core@1.48.2)(postcss@8.4.41)(typescript@5.3.3)': + '@synthetixio/synpress-cache@0.0.4(playwright-core@1.48.2)(postcss@8.4.41)(typescript@5.3.3)': dependencies: axios: 1.6.7 chalk: 5.3.0 @@ -6248,11 +6254,11 @@ snapshots: - ts-node - typescript - '@synthetixio/synpress-core@0.0.3(@playwright/test@1.48.2)': + '@synthetixio/synpress-core@0.0.4(@playwright/test@1.48.2)': dependencies: '@playwright/test': 1.48.2 - '@synthetixio/synpress-tsconfig@0.0.3': {} + '@synthetixio/synpress-tsconfig@0.0.4': {} '@szmarczak/http-timer@5.0.1': dependencies: diff --git a/wallets/ethereum-wallet-mock/package.json b/wallets/ethereum-wallet-mock/package.json index 15fadaf7d..c53611897 100644 --- a/wallets/ethereum-wallet-mock/package.json +++ b/wallets/ethereum-wallet-mock/package.json @@ -35,13 +35,13 @@ }, "dependencies": { "@depay/web3-client": "10.18.6", - "@depay/web3-mock": "14.17.0", + "@depay/web3-mock": "14.19.1", "@depay/web3-mock-evm": "^14.17.0", "@synthetixio/synpress-core": "0.0.4", "viem": "2.9.9" }, "devDependencies": { - "@depay/web3-mock": "14.17.0", + "@depay/web3-mock": "14.19.1", "@synthetixio/synpress-tsconfig": "0.0.4", "@types/node": "20.11.17", "@vitest/coverage-v8": "1.2.2", diff --git a/wallets/ethereum-wallet-mock/src/playwright/EthereumWalletMock.ts b/wallets/ethereum-wallet-mock/src/playwright/EthereumWalletMock.ts index 8f058b42e..9a7be2d9f 100644 --- a/wallets/ethereum-wallet-mock/src/playwright/EthereumWalletMock.ts +++ b/wallets/ethereum-wallet-mock/src/playwright/EthereumWalletMock.ts @@ -5,6 +5,7 @@ import { EthereumWalletMockAbstract } from '../type/EthereumWalletMockAbstract' import type { Network } from '../type/Network' import type { WalletMock } from '../type/WalletMock' import { DEFAULT_NETWORK_ID } from './utils' +import { mockTransaction, sendTransaction } from './utils' /** * Mock implementation of an Ethereum wallet for testing purposes. @@ -230,4 +231,26 @@ export default class EthereumWalletMock extends EthereumWalletMockAbstract { [BLOCKCHAIN, [ACCOUNT_MOCK], wallet] ) } + + /** + * Sends a transaction. + * @param to - Recipient address. + * @param value - Transaction value in wei. + * @returns Promise that resolves to the transaction hash. + */ + async sendTransaction(to: string, value: string): Promise { + // Mock the transaction + await mockTransaction(this.page, [ + to, + ACCOUNT_MOCK, // from address + value + ]) + + // Send the transaction + return this.page.evaluate(sendTransaction, { + to, + from: ACCOUNT_MOCK, + value + }) + } } diff --git a/wallets/ethereum-wallet-mock/src/playwright/utils/index.ts b/wallets/ethereum-wallet-mock/src/playwright/utils/index.ts index 77d5358b2..f58b0b85d 100644 --- a/wallets/ethereum-wallet-mock/src/playwright/utils/index.ts +++ b/wallets/ethereum-wallet-mock/src/playwright/utils/index.ts @@ -1,2 +1,4 @@ export { default as mockEthereum } from './mockEthereum' +export * from './mockTransaction' +export * from './sendTransaction' export * from '../constants' diff --git a/wallets/ethereum-wallet-mock/src/playwright/utils/mockTransaction.ts b/wallets/ethereum-wallet-mock/src/playwright/utils/mockTransaction.ts new file mode 100644 index 000000000..c81c6ade4 --- /dev/null +++ b/wallets/ethereum-wallet-mock/src/playwright/utils/mockTransaction.ts @@ -0,0 +1,23 @@ +import type { Page } from '@playwright/test' + +/** + * Mocks an Ethereum transaction using Web3Mock + * @param page - Playwright page instance + * @param params - Array of transaction parameters [to, from, value] + * @returns Promise that resolves to the Web3Mock mock result + */ +export const mockTransaction = async (page: Page, params: [string, string, string]) => { + return page.evaluate( + ([params]) => { + return Web3Mock.mock({ + blockchain: 'ethereum', + transaction: { + to: params?.[0], + from: params?.[1], + value: params?.[2] + } + }) + }, + [params] + ) +} diff --git a/wallets/ethereum-wallet-mock/src/playwright/utils/sendTransaction.ts b/wallets/ethereum-wallet-mock/src/playwright/utils/sendTransaction.ts new file mode 100644 index 000000000..8f74dfa44 --- /dev/null +++ b/wallets/ethereum-wallet-mock/src/playwright/utils/sendTransaction.ts @@ -0,0 +1,17 @@ +interface SendTransactionParams { + to: string + from: string + value: string +} + +/** + * Sends an Ethereum transaction using Web3Mock + * @param params - Transaction parameters {to: string, from: string, value: string} + * @returns Promise that resolves to the transaction hash + */ +export const sendTransaction = (params: SendTransactionParams): Promise => { + return window.ethereum.request({ + method: 'eth_sendTransaction', + params: [params] + }) +} diff --git a/wallets/ethereum-wallet-mock/test/playwright/mock/sendTransaction.spec.ts b/wallets/ethereum-wallet-mock/test/playwright/mock/sendTransaction.spec.ts new file mode 100644 index 000000000..32a9001b2 --- /dev/null +++ b/wallets/ethereum-wallet-mock/test/playwright/mock/sendTransaction.spec.ts @@ -0,0 +1,57 @@ +import { ACCOUNT_MOCK } from '../../../src/constants' +import test from '../../../src/playwright/synpress' + +const { expect } = test + +const TO_ADDRESS = '0x5Af489c8786A018EC4814194dC8048be1007e390' +const VALUE = '2000000000000000000' // 2 ETH + +test('should mock and send transaction', async ({ ethereumWalletMock }) => { + // Connect wallet first + await ethereumWalletMock.connectToDapp() + + // Send the transaction + const txHash = await ethereumWalletMock.sendTransaction(TO_ADDRESS, VALUE) + + // Verify transaction hash format + expect(txHash).toMatch(/^0x[a-fA-F0-9]{64}$/) +}) + +test('should mock and send transaction with zero value', async ({ ethereumWalletMock }) => { + await ethereumWalletMock.connectToDapp() + + const txHash = await ethereumWalletMock.sendTransaction(TO_ADDRESS, '0') + + expect(txHash).toMatch(/^0x[a-fA-F0-9]{64}$/) +}) + +test('should mock and send transaction to same address', async ({ ethereumWalletMock }) => { + await ethereumWalletMock.connectToDapp() + + const txHash = await ethereumWalletMock.sendTransaction(ACCOUNT_MOCK, VALUE) + + expect(txHash).toMatch(/^0x[a-fA-F0-9]{64}$/) +}) + +test('should mock and send multiple transactions', async ({ ethereumWalletMock }) => { + await ethereumWalletMock.connectToDapp() + + const transactions = [ + { to: TO_ADDRESS, value: '1000000000000000000' }, // 1 ETH + { to: TO_ADDRESS, value: '3000000000000000000' }, // 3 ETH + { to: TO_ADDRESS, value: '500000000000000000' } // 0.5 ETH + ] + + for (const tx of transactions) { + const txHash = await ethereumWalletMock.sendTransaction(tx.to, tx.value) + expect(txHash).toMatch(/^0x[a-fA-F0-9]{64}$/) + } +}) + +test('should fail with invalid value', async ({ ethereumWalletMock }) => { + await ethereumWalletMock.connectToDapp() + + const invalidValue = 'invalid' + + await expect(ethereumWalletMock.sendTransaction(TO_ADDRESS, invalidValue)).rejects.toThrow() +})