diff --git a/.yarn/versions/4e981df6.yml b/.yarn/versions/4e981df6.yml new file mode 100644 index 000000000..20d56e825 --- /dev/null +++ b/.yarn/versions/4e981df6.yml @@ -0,0 +1,6 @@ +releases: + "@fluent-wallet/cfx_estimate-gas-and-collateral": patch + +declined: + - helios + - helios-background diff --git a/packages/background/src/index.integration.test.js b/packages/background/src/index.integration.test.js index d202ba1c7..db893effb 100644 --- a/packages/background/src/index.integration.test.js +++ b/packages/background/src/index.integration.test.js @@ -279,8 +279,40 @@ describe('integration test', () => { ).toBe('1337') }) }) + + 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', + maxPriorityFeePerGas: '0x4a817c800', + maxFeePerGas: '0x4a817c800', + type: '0x2', + }, + ], + }) + ).result.startsWith('0x'), + ).toBe(true) + }) + }) + describe('cfx_estimateGasAndCollateral', () => { test('cfx_estimateGasAndCollateral', async () => { + const {token1} = await deployCRC20() + await request({ + method: 'wallet_importMnemonic', + params: {mnemonic: MNEMONIC, password}, + }) res = await request({ method: 'cfx_estimateGasAndCollateral', params: [{}], @@ -289,6 +321,23 @@ describe('integration test', () => { expect(res.result.gasLimit).toBeDefined() expect(res.result.gasUsed).toBeDefined() expect(res.result.storageCollateralized).toBeDefined() + + const estimateRes = await request({ + method: 'cfx_estimateGasAndCollateral', + params: [ + { + type: '0x2', + to: token1.contractAddress, + data: '0x06fdde03', + maxPriorityFeePerGas: '0x4a817c800', + maxFeePerGas: '0x4a817c800', + }, + ], + }) + expect(estimateRes?.result).toBeDefined() + expect(estimateRes.result.gasLimit).toBeDefined() + expect(estimateRes.result.gasUsed).toBeDefined() + expect(estimateRes.result.storageCollateralized).toBeDefined() }) }) describe('eth_estimateGas', () => { @@ -2891,73 +2940,5 @@ 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_estimateGasAndCollateral/index.js b/packages/rpcs/cfx_estimateGasAndCollateral/index.js index e932039a5..5109fd4b0 100644 --- a/packages/rpcs/cfx_estimateGasAndCollateral/index.js +++ b/packages/rpcs/cfx_estimateGasAndCollateral/index.js @@ -7,6 +7,8 @@ import { Bytes, epochRefNoMined, chainId, + catn, + Hash32, } from '@fluent-wallet/spec' export const NAME = 'cfx_estimateGasAndCollateral' @@ -35,6 +37,29 @@ export const schemas = { ['nonce', {optional: true, doc: 'default to 0x0'}, Uint], ['storageLimit', {optional: true}, Uint], ['epochHeight', {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]], + ], + ], + ], + ], + ], ], epochRefNoMined, ],