Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add more fields to cfx_call #1421

Merged
merged 4 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .yarn/versions/9c11183a.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
releases:
"@fluent-wallet/cfx_call": patch

declined:
- helios
- helios-background
68 changes: 68 additions & 0 deletions packages/background/src/index.integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@
expect(db.findAddress({networkId})[0]).toBeDefined()
})

// test('add eth network, with cfxOnly: true, type: pub vault', async () => {

Check warning on line 538 in packages/background/src/index.integration.test.js

View workflow job for this annotation

GitHub Actions / lint (22)

Some tests seem to be commented
// await request({
// method: 'wallet_importMnemonic',
// params: {mnemonic: MNEMONIC, password},
Expand Down Expand Up @@ -820,7 +820,7 @@
expect(db.getAddress().length).toBe(4)
expect(db.getAccount({nickname: 'foo'}).length).toBe(1)
})
// test('wallet_createAccount with duplicate nickname', async function () {

Check warning on line 823 in packages/background/src/index.integration.test.js

View workflow job for this annotation

GitHub Actions / lint (22)

Some tests seem to be commented
// expect(db.getVault().length).toBe(0)

// await request({
Expand Down Expand Up @@ -903,7 +903,7 @@
expect(db.getAccount()[0].nickname).toBe('foo')
expect(db.getAccount()[0].hidden).toBe(true)
})
// test('wallet_updateAccount with duplicate nickname', async function () {

Check warning on line 906 in packages/background/src/index.integration.test.js

View workflow job for this annotation

GitHub Actions / lint (22)

Some tests seem to be commented
// await request({
// method: 'wallet_importMnemonic',
// params: {mnemonic: MNEMONIC, password, waitTillFinish: true},
Expand Down Expand Up @@ -2891,5 +2891,73 @@
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)
})
})
})
})
26 changes: 26 additions & 0 deletions packages/rpcs/cfx_call/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import {
base32ContractAddress,
Uint,
Bytes,
catn,
Hash32,
base32Address,
} from '@fluent-wallet/spec'

export const NAME = 'cfx_call'
Expand All @@ -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,
],
Expand Down
Loading