From b7b9efbd38a04af0de33b9dcaa4cc0bc7c167fd6 Mon Sep 17 00:00:00 2001 From: iosh Date: Thu, 26 Sep 2024 16:49:34 +0800 Subject: [PATCH 1/4] chore: add more fields to cfx_call --- .../background/src/index.integration.test.js | 52 +++++++++++++++++++ packages/rpcs/cfx_call/index.js | 26 ++++++++++ 2 files changed, 78 insertions(+) diff --git a/packages/background/src/index.integration.test.js b/packages/background/src/index.integration.test.js index f243fb735..bd486fce8 100644 --- a/packages/background/src/index.integration.test.js +++ b/packages/background/src/index.integration.test.js @@ -2891,5 +2891,57 @@ 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) + }) + }) }) }) 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, ], From fce35be58872c609c1709a0c4319946bf7594a84 Mon Sep 17 00:00:00 2001 From: iosh Date: Thu, 26 Sep 2024 16:52:11 +0800 Subject: [PATCH 2/4] chore: add test --- .../background/src/index.integration.test.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/background/src/index.integration.test.js b/packages/background/src/index.integration.test.js index bd486fce8..d202ba1c7 100644 --- a/packages/background/src/index.integration.test.js +++ b/packages/background/src/index.integration.test.js @@ -2941,6 +2941,22 @@ describe('integration test', () => { }) ).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) }) }) }) From 33818cd66e8e52bcbe689054430021c6db846f94 Mon Sep 17 00:00:00 2001 From: iosh Date: Thu, 26 Sep 2024 16:54:46 +0800 Subject: [PATCH 3/4] chore: add version change --- .yarn/versions/9c11183a.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .yarn/versions/9c11183a.yml diff --git a/.yarn/versions/9c11183a.yml b/.yarn/versions/9c11183a.yml new file mode 100644 index 000000000..26b1c19cb --- /dev/null +++ b/.yarn/versions/9c11183a.yml @@ -0,0 +1,5 @@ +releases: + "@fluent-wallet/cfx_call": patch + +declined: + - helios-background From f53136b952fad7705a0bd42f6f8ec641683e79fe Mon Sep 17 00:00:00 2001 From: iosh Date: Thu, 26 Sep 2024 16:56:36 +0800 Subject: [PATCH 4/4] chore: add version change --- .yarn/versions/9c11183a.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.yarn/versions/9c11183a.yml b/.yarn/versions/9c11183a.yml index 26b1c19cb..11a659095 100644 --- a/.yarn/versions/9c11183a.yml +++ b/.yarn/versions/9c11183a.yml @@ -2,4 +2,5 @@ releases: "@fluent-wallet/cfx_call": patch declined: + - helios - helios-background