diff --git a/.yarn/versions/9c11183a.yml b/.yarn/versions/9c11183a.yml new file mode 100644 index 000000000..11a659095 --- /dev/null +++ b/.yarn/versions/9c11183a.yml @@ -0,0 +1,6 @@ +releases: + "@fluent-wallet/cfx_call": patch + +declined: + - helios + - helios-background diff --git a/packages/background/src/index.integration.test.js b/packages/background/src/index.integration.test.js index f243fb735..d202ba1c7 100644 --- a/packages/background/src/index.integration.test.js +++ b/packages/background/src/index.integration.test.js @@ -2891,5 +2891,73 @@ describe('integration test', () => { expect(res.result.startsWith('0x')).toBe(true) }) }) + + describe('cfx_call', async () => { + test('cfx_call', async () => { + const {token1} = await deployCRC20() + await request({ + method: 'wallet_importMnemonic', + params: {mnemonic: MNEMONIC, password}, + }) + expect( + ( + await request({ + method: 'cfx_call', + params: [ + { + to: token1.contractAddress, + data: '0x06fdde03', + }, + ], + }) + ).result.startsWith('0x'), + ).toBe(true) + expect( + ( + await request({ + method: 'cfx_call', + params: [ + { + to: token1.contractAddress, + data: '0x06fdde03', + maxPriorityFeePerGas: '0x4a817c800', + }, + ], + }) + ).result.startsWith('0x'), + ).toBe(true) + expect( + ( + await request({ + method: 'cfx_call', + params: [ + { + to: token1.contractAddress, + data: '0x06fdde03', + maxPriorityFeePerGas: '0x4a817c800', + maxFeePerGas: '0x4a817c800', + }, + ], + }) + ).result.startsWith('0x'), + ).toBe(true) + expect( + ( + await request({ + method: 'cfx_call', + params: [ + { + to: token1.contractAddress, + data: '0x06fdde03', + maxPriorityFeePerGas: '0x4a817c800', + maxFeePerGas: '0x4a817c800', + type: '0x2', + }, + ], + }) + ).result.startsWith('0x'), + ).toBe(true) + }) + }) }) }) diff --git a/packages/rpcs/cfx_call/index.js b/packages/rpcs/cfx_call/index.js index 0f77299f9..aeb44350b 100644 --- a/packages/rpcs/cfx_call/index.js +++ b/packages/rpcs/cfx_call/index.js @@ -6,6 +6,9 @@ import { base32ContractAddress, Uint, Bytes, + catn, + Hash32, + base32Address, } from '@fluent-wallet/spec' export const NAME = 'cfx_call' @@ -32,6 +35,29 @@ export const schemas = { ['value', {optional: true}, Uint], ['data', {optional: true}, Bytes], ['nonce', {optional: true}, Uint], + ['type', {optional: true}, Uint], + ['maxPriorityFeePerGas', {optional: true}, Uint], + ['maxFeePerGas', {optional: true}, Uint], + [ + 'accessList', + {optional: true}, + [ + catn, + [ + 'AccessListEntry', + [ + map, + {closed: true}, + ['address', {optional: true}, base32Address], + [ + 'storageKeys', + {optional: true}, + [catn, ['32BtyeHexValue', Hash32]], + ], + ], + ], + ], + ], ], epochRef, ],