tempo.ts 0.1.5 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -2
- package/dist/chains.d.ts +509 -115
- package/dist/chains.d.ts.map +1 -1
- package/dist/chains.js +20 -9
- package/dist/chains.js.map +1 -1
- package/dist/ox/Order.d.ts +92 -0
- package/dist/ox/Order.d.ts.map +1 -0
- package/dist/ox/Order.js +88 -0
- package/dist/ox/Order.js.map +1 -0
- package/dist/ox/OrdersFilters.d.ts +72 -0
- package/dist/ox/OrdersFilters.d.ts.map +1 -0
- package/dist/ox/OrdersFilters.js +100 -0
- package/dist/ox/OrdersFilters.js.map +1 -0
- package/dist/ox/Pagination.d.ts +128 -0
- package/dist/ox/Pagination.d.ts.map +1 -0
- package/dist/ox/Pagination.js +78 -0
- package/dist/ox/Pagination.js.map +1 -0
- package/dist/ox/PoolId.d.ts +18 -0
- package/dist/ox/PoolId.d.ts.map +1 -0
- package/dist/ox/PoolId.js +13 -0
- package/dist/ox/PoolId.js.map +1 -0
- package/dist/ox/RpcSchema.d.ts +32 -0
- package/dist/ox/RpcSchema.d.ts.map +1 -0
- package/dist/ox/RpcSchema.js +2 -0
- package/dist/ox/RpcSchema.js.map +1 -0
- package/dist/ox/SignatureEnvelope.d.ts +1 -1
- package/dist/ox/SignatureEnvelope.d.ts.map +1 -1
- package/dist/ox/SignatureEnvelope.js.map +1 -1
- package/dist/{viem → ox}/Tick.d.ts +4 -0
- package/dist/ox/Tick.d.ts.map +1 -0
- package/dist/ox/Tick.js.map +1 -0
- package/dist/ox/Transaction.d.ts.map +1 -1
- package/dist/ox/Transaction.js +2 -1
- package/dist/ox/Transaction.js.map +1 -1
- package/dist/ox/TransactionEnvelopeAA.d.ts +6 -6
- package/dist/ox/TransactionEnvelopeAA.d.ts.map +1 -1
- package/dist/ox/TransactionEnvelopeAA.js +4 -2
- package/dist/ox/TransactionEnvelopeAA.js.map +1 -1
- package/dist/ox/TransactionRequest.d.ts +4 -0
- package/dist/ox/TransactionRequest.d.ts.map +1 -1
- package/dist/ox/TransactionRequest.js.map +1 -1
- package/dist/ox/index.d.ts +6 -0
- package/dist/ox/index.d.ts.map +1 -1
- package/dist/ox/index.js +6 -0
- package/dist/ox/index.js.map +1 -1
- package/dist/prool/Instance.d.ts.map +1 -1
- package/dist/prool/Instance.js +20 -4
- package/dist/prool/Instance.js.map +1 -1
- package/dist/viem/Abis.d.ts +1469 -1082
- package/dist/viem/Abis.d.ts.map +1 -1
- package/dist/viem/Abis.js +932 -671
- package/dist/viem/Abis.js.map +1 -1
- package/dist/viem/Account.d.ts +150 -0
- package/dist/viem/Account.d.ts.map +1 -0
- package/dist/viem/Account.js +221 -0
- package/dist/viem/Account.js.map +1 -0
- package/dist/viem/Actions/amm.d.ts +144 -161
- package/dist/viem/Actions/amm.d.ts.map +1 -1
- package/dist/viem/Actions/amm.js +109 -163
- package/dist/viem/Actions/amm.js.map +1 -1
- package/dist/viem/Actions/dex.d.ts +920 -664
- package/dist/viem/Actions/dex.d.ts.map +1 -1
- package/dist/viem/Actions/dex.js +129 -30
- package/dist/viem/Actions/dex.js.map +1 -1
- package/dist/viem/Actions/faucet.d.ts +34 -0
- package/dist/viem/Actions/faucet.d.ts.map +1 -0
- package/dist/viem/Actions/faucet.js +33 -0
- package/dist/viem/Actions/faucet.js.map +1 -0
- package/dist/viem/Actions/fee.d.ts +16 -30
- package/dist/viem/Actions/fee.d.ts.map +1 -1
- package/dist/viem/Actions/fee.js +13 -13
- package/dist/viem/Actions/fee.js.map +1 -1
- package/dist/viem/Actions/index.d.ts +2 -0
- package/dist/viem/Actions/index.d.ts.map +1 -1
- package/dist/viem/Actions/index.js +2 -0
- package/dist/viem/Actions/index.js.map +1 -1
- package/dist/viem/Actions/policy.d.ts +46 -46
- package/dist/viem/Actions/policy.js +46 -46
- package/dist/viem/Actions/reward.d.ts +3236 -0
- package/dist/viem/Actions/reward.d.ts.map +1 -0
- package/dist/viem/Actions/reward.js +725 -0
- package/dist/viem/Actions/reward.js.map +1 -0
- package/dist/viem/Actions/token.d.ts +4399 -2750
- package/dist/viem/Actions/token.d.ts.map +1 -1
- package/dist/viem/Actions/token.js +361 -482
- package/dist/viem/Actions/token.js.map +1 -1
- package/dist/viem/Addresses.d.ts +1 -2
- package/dist/viem/Addresses.d.ts.map +1 -1
- package/dist/viem/Addresses.js +1 -2
- package/dist/viem/Addresses.js.map +1 -1
- package/dist/viem/Chain.d.ts +38 -12
- package/dist/viem/Chain.d.ts.map +1 -1
- package/dist/viem/Chain.js +27 -18
- package/dist/viem/Chain.js.map +1 -1
- package/dist/viem/Decorator.d.ts +1009 -428
- package/dist/viem/Decorator.d.ts.map +1 -1
- package/dist/viem/Decorator.js +17 -5
- package/dist/viem/Decorator.js.map +1 -1
- package/dist/viem/Formatters.d.ts +8 -1
- package/dist/viem/Formatters.d.ts.map +1 -1
- package/dist/viem/Formatters.js +17 -0
- package/dist/viem/Formatters.js.map +1 -1
- package/dist/viem/P256.d.ts +2 -0
- package/dist/viem/P256.d.ts.map +1 -0
- package/dist/viem/P256.js +2 -0
- package/dist/viem/P256.js.map +1 -0
- package/dist/viem/Secp256k1.d.ts +2 -0
- package/dist/viem/Secp256k1.d.ts.map +1 -0
- package/dist/viem/Secp256k1.js +2 -0
- package/dist/viem/Secp256k1.js.map +1 -0
- package/dist/viem/TokenIds.d.ts +1 -2
- package/dist/viem/TokenIds.d.ts.map +1 -1
- package/dist/viem/TokenIds.js +1 -2
- package/dist/viem/TokenIds.js.map +1 -1
- package/dist/viem/Transaction.d.ts +1 -1
- package/dist/viem/Transaction.d.ts.map +1 -1
- package/dist/viem/Transaction.js +46 -5
- package/dist/viem/Transaction.js.map +1 -1
- package/dist/viem/WebAuthnP256.d.ts +79 -0
- package/dist/viem/WebAuthnP256.d.ts.map +1 -0
- package/dist/viem/WebAuthnP256.js +95 -0
- package/dist/viem/WebAuthnP256.js.map +1 -0
- package/dist/viem/WebCryptoP256.d.ts +2 -0
- package/dist/viem/WebCryptoP256.d.ts.map +1 -0
- package/dist/viem/WebCryptoP256.js +2 -0
- package/dist/viem/WebCryptoP256.js.map +1 -0
- package/dist/viem/index.d.ts +6 -3
- package/dist/viem/index.d.ts.map +1 -1
- package/dist/viem/index.js +6 -3
- package/dist/viem/index.js.map +1 -1
- package/dist/viem/internal/account.d.ts +24 -0
- package/dist/viem/internal/account.d.ts.map +1 -0
- package/dist/viem/internal/account.js +68 -0
- package/dist/viem/internal/account.js.map +1 -0
- package/dist/viem/internal/types.d.ts +10 -0
- package/dist/viem/internal/types.d.ts.map +1 -1
- package/dist/wagmi/Actions/amm.d.ts +428 -0
- package/dist/wagmi/Actions/amm.d.ts.map +1 -0
- package/dist/wagmi/Actions/amm.js +472 -0
- package/dist/wagmi/Actions/amm.js.map +1 -0
- package/dist/wagmi/Actions/dex.d.ts +908 -0
- package/dist/wagmi/Actions/dex.d.ts.map +1 -0
- package/dist/wagmi/Actions/dex.js +1023 -0
- package/dist/wagmi/Actions/dex.js.map +1 -0
- package/dist/wagmi/Actions/faucet.d.ts +35 -0
- package/dist/wagmi/Actions/faucet.d.ts.map +1 -0
- package/dist/wagmi/Actions/faucet.js +33 -0
- package/dist/wagmi/Actions/faucet.js.map +1 -0
- package/dist/wagmi/Actions/fee.d.ts +111 -0
- package/dist/wagmi/Actions/fee.d.ts.map +1 -0
- package/dist/wagmi/Actions/fee.js +126 -0
- package/dist/wagmi/Actions/fee.js.map +1 -0
- package/dist/wagmi/Actions/index.d.ts +7 -0
- package/dist/wagmi/Actions/index.d.ts.map +1 -0
- package/dist/wagmi/Actions/index.js +7 -0
- package/dist/wagmi/Actions/index.js.map +1 -0
- package/dist/wagmi/Actions/reward.d.ts +348 -0
- package/dist/wagmi/Actions/reward.d.ts.map +1 -0
- package/dist/wagmi/Actions/reward.js +388 -0
- package/dist/wagmi/Actions/reward.js.map +1 -0
- package/dist/wagmi/Actions/token.d.ts +1546 -0
- package/dist/wagmi/Actions/token.d.ts.map +1 -0
- package/dist/wagmi/Actions/token.js +1712 -0
- package/dist/wagmi/Actions/token.js.map +1 -0
- package/dist/wagmi/Connector.d.ts +81 -0
- package/dist/wagmi/Connector.d.ts.map +1 -0
- package/dist/wagmi/Connector.js +261 -0
- package/dist/wagmi/Connector.js.map +1 -0
- package/dist/wagmi/Hooks/amm.d.ts +421 -0
- package/dist/wagmi/Hooks/amm.d.ts.map +1 -0
- package/dist/wagmi/Hooks/amm.js +504 -0
- package/dist/wagmi/Hooks/amm.js.map +1 -0
- package/dist/wagmi/Hooks/dex.d.ts +816 -0
- package/dist/wagmi/Hooks/dex.d.ts.map +1 -0
- package/dist/wagmi/Hooks/dex.js +973 -0
- package/dist/wagmi/Hooks/dex.js.map +1 -0
- package/dist/wagmi/Hooks/faucet.d.ts +39 -0
- package/dist/wagmi/Hooks/faucet.d.ts.map +1 -0
- package/dist/wagmi/Hooks/faucet.js +40 -0
- package/dist/wagmi/Hooks/faucet.js.map +1 -0
- package/dist/wagmi/Hooks/fee.d.ts +97 -0
- package/dist/wagmi/Hooks/fee.d.ts.map +1 -0
- package/dist/wagmi/Hooks/fee.js +109 -0
- package/dist/wagmi/Hooks/fee.js.map +1 -0
- package/dist/wagmi/Hooks/index.d.ts +7 -0
- package/dist/wagmi/Hooks/index.d.ts.map +1 -0
- package/dist/wagmi/Hooks/index.js +7 -0
- package/dist/wagmi/Hooks/index.js.map +1 -0
- package/dist/wagmi/Hooks/reward.d.ts +307 -0
- package/dist/wagmi/Hooks/reward.d.ts.map +1 -0
- package/dist/wagmi/Hooks/reward.js +349 -0
- package/dist/wagmi/Hooks/reward.js.map +1 -0
- package/dist/wagmi/Hooks/token.d.ts +1388 -0
- package/dist/wagmi/Hooks/token.d.ts.map +1 -0
- package/dist/wagmi/Hooks/token.js +1657 -0
- package/dist/wagmi/Hooks/token.js.map +1 -0
- package/dist/wagmi/index.d.ts +4 -0
- package/dist/wagmi/index.d.ts.map +1 -0
- package/dist/wagmi/index.js +4 -0
- package/dist/wagmi/index.js.map +1 -0
- package/package.json +54 -10
- package/src/chains.ts +21 -9
- package/src/ox/Order.test.ts +78 -0
- package/src/ox/Order.ts +125 -0
- package/src/ox/OrdersFilters.test.ts +182 -0
- package/src/ox/OrdersFilters.ts +125 -0
- package/src/ox/Pagination.test.ts +162 -0
- package/src/ox/Pagination.ts +164 -0
- package/src/ox/PoolId.test.ts +33 -0
- package/src/ox/PoolId.ts +27 -0
- package/src/ox/RpcSchema.ts +35 -0
- package/src/ox/SignatureEnvelope.ts +3 -1
- package/src/{viem → ox}/Tick.test.ts +1 -1
- package/src/{viem → ox}/Tick.ts +5 -0
- package/src/ox/Transaction.test.ts +1 -1
- package/src/ox/Transaction.ts +2 -1
- package/src/ox/TransactionEnvelopeAA.test.ts +239 -96
- package/src/ox/TransactionEnvelopeAA.ts +9 -7
- package/src/ox/TransactionRequest.ts +4 -0
- package/src/ox/index.ts +6 -0
- package/src/prool/Instance.ts +51 -37
- package/src/prool/internal/chain.json +104 -52
- package/src/tsconfig.json +9 -0
- package/src/viem/Abis.ts +972 -710
- package/src/viem/Account.ts +279 -0
- package/src/viem/Actions/__snapshots__/dex.test.ts.snap +850 -0
- package/src/viem/Actions/amm.test.ts +173 -169
- package/src/viem/Actions/amm.ts +131 -203
- package/src/viem/Actions/dex.test.ts +563 -484
- package/src/viem/Actions/dex.ts +203 -30
- package/src/viem/Actions/faucet.ts +50 -0
- package/src/viem/Actions/fee.test.ts +23 -34
- package/src/viem/Actions/fee.ts +20 -13
- package/src/viem/Actions/index.ts +2 -0
- package/src/viem/Actions/policy.test.ts +19 -33
- package/src/viem/Actions/policy.ts +46 -46
- package/src/viem/Actions/reward.test.ts +457 -0
- package/src/viem/Actions/reward.ts +999 -0
- package/src/viem/Actions/token.test.ts +453 -287
- package/src/viem/Actions/token.ts +605 -693
- package/src/viem/Addresses.ts +1 -2
- package/src/viem/Chain.bench-d.ts +12 -0
- package/src/viem/Chain.ts +70 -20
- package/src/viem/Decorator.bench-d.ts +1 -1
- package/src/viem/Decorator.test.ts +3 -1
- package/src/viem/Decorator.ts +1049 -442
- package/src/viem/Formatters.ts +31 -5
- package/src/viem/P256.ts +1 -0
- package/src/viem/Secp256k1.ts +1 -0
- package/src/viem/TokenIds.ts +1 -2
- package/src/viem/Transaction.ts +53 -7
- package/src/viem/WebAuthnP256.ts +140 -0
- package/src/viem/WebCryptoP256.ts +1 -0
- package/src/viem/e2e.test.ts +1126 -297
- package/src/viem/index.ts +6 -3
- package/src/viem/internal/account.ts +107 -0
- package/src/viem/internal/types.ts +9 -0
- package/src/wagmi/Actions/__snapshots__/dex.test.ts.snap +310 -0
- package/src/wagmi/Actions/amm.test.ts +198 -0
- package/src/wagmi/Actions/amm.ts +691 -0
- package/src/wagmi/Actions/dex.test.ts +1507 -0
- package/src/wagmi/Actions/dex.ts +1640 -0
- package/src/wagmi/Actions/faucet.ts +46 -0
- package/src/wagmi/Actions/fee.test.ts +63 -0
- package/src/wagmi/Actions/fee.ts +208 -0
- package/src/wagmi/Actions/index.ts +6 -0
- package/src/wagmi/Actions/reward.test.ts +210 -0
- package/src/wagmi/Actions/reward.ts +632 -0
- package/src/wagmi/Actions/token.test.ts +1308 -0
- package/src/wagmi/Actions/token.ts +2613 -0
- package/src/wagmi/Connector.test.ts +53 -0
- package/src/wagmi/Connector.ts +390 -0
- package/src/wagmi/Hooks/__snapshots__/dex.test.ts.snap +457 -0
- package/src/wagmi/Hooks/amm.test.ts +424 -0
- package/src/wagmi/Hooks/amm.ts +806 -0
- package/src/wagmi/Hooks/dex.test.ts +1017 -0
- package/src/wagmi/Hooks/dex.ts +1685 -0
- package/src/wagmi/Hooks/faucet.ts +76 -0
- package/src/wagmi/Hooks/fee.test.ts +166 -0
- package/src/wagmi/Hooks/fee.ts +206 -0
- package/src/wagmi/Hooks/index.ts +6 -0
- package/src/wagmi/Hooks/reward.test.ts +219 -0
- package/src/wagmi/Hooks/reward.ts +672 -0
- package/src/wagmi/Hooks/token.test.ts +1670 -0
- package/src/wagmi/Hooks/token.ts +2906 -0
- package/src/wagmi/index.ts +3 -0
- package/src/wagmi/internal/types.ts +16 -0
- package/dist/viem/Client.d.ts +0 -27
- package/dist/viem/Client.d.ts.map +0 -1
- package/dist/viem/Client.js +0 -28
- package/dist/viem/Client.js.map +0 -1
- package/dist/viem/Tick.d.ts.map +0 -1
- package/dist/viem/Tick.js.map +0 -1
- package/src/viem/Client.bench-d.ts +0 -8
- package/src/viem/Client.test.ts +0 -178
- package/src/viem/Client.ts +0 -91
- /package/dist/{viem → ox}/Tick.js +0 -0
package/src/viem/e2e.test.ts
CHANGED
|
@@ -1,238 +1,867 @@
|
|
|
1
1
|
import * as Http from 'node:http'
|
|
2
2
|
import { createRequestListener } from '@remix-run/node-fetch-server'
|
|
3
|
-
import { RpcRequest, RpcResponse } from 'ox'
|
|
4
|
-
import { Transaction } from 'tempo.ts/viem'
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
import { RpcRequest, RpcResponse, WebCryptoP256 } from 'ox'
|
|
4
|
+
import { Account, Transaction } from 'tempo.ts/viem'
|
|
5
|
+
import {
|
|
6
|
+
createClient,
|
|
7
|
+
http,
|
|
8
|
+
parseUnits,
|
|
9
|
+
publicActions,
|
|
10
|
+
walletActions,
|
|
11
|
+
} from 'viem'
|
|
12
|
+
import { privateKeyToAccount } from 'viem/accounts'
|
|
13
|
+
import { afterAll, afterEach, beforeAll, describe, expect, test } from 'vitest'
|
|
14
|
+
import {
|
|
15
|
+
accounts,
|
|
16
|
+
addresses,
|
|
17
|
+
rpcUrl,
|
|
18
|
+
tempoTest,
|
|
19
|
+
} from '../../test/viem/config.js'
|
|
9
20
|
import * as actions from './Actions/index.js'
|
|
10
21
|
import { tempoActions } from './index.js'
|
|
11
22
|
import { withFeePayer } from './Transport.js'
|
|
12
23
|
|
|
24
|
+
const client = createClient({
|
|
25
|
+
chain: tempoTest({ feeToken: 1n }),
|
|
26
|
+
transport: http(),
|
|
27
|
+
})
|
|
28
|
+
.extend(publicActions)
|
|
29
|
+
.extend(walletActions)
|
|
30
|
+
.extend(tempoActions())
|
|
31
|
+
|
|
13
32
|
describe('sendTransaction', () => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
account
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
33
|
+
describe('secp256k1', () => {
|
|
34
|
+
test('default', async () => {
|
|
35
|
+
const account = accounts[0]
|
|
36
|
+
|
|
37
|
+
const hash = await client.sendTransaction({
|
|
38
|
+
account,
|
|
39
|
+
data: '0xdeadbeef',
|
|
40
|
+
feeToken: '0x20c0000000000000000000000000000000000001',
|
|
41
|
+
to: '0x0000000000000000000000000000000000000000',
|
|
42
|
+
})
|
|
43
|
+
await client.waitForTransactionReceipt({ hash })
|
|
44
|
+
|
|
45
|
+
const {
|
|
46
|
+
blockHash: _,
|
|
47
|
+
blockNumber: __,
|
|
48
|
+
...transaction
|
|
49
|
+
} = await client.getTransaction({ hash })
|
|
50
|
+
|
|
51
|
+
expect(transaction).toMatchInlineSnapshot(`
|
|
52
|
+
{
|
|
53
|
+
"aaAuthorizationList": [],
|
|
54
|
+
"accessList": [],
|
|
55
|
+
"authorizationList": undefined,
|
|
56
|
+
"calls": [
|
|
57
|
+
{
|
|
58
|
+
"data": "0xdeadbeef",
|
|
59
|
+
"to": "0x0000000000000000000000000000000000000000",
|
|
60
|
+
"value": 0n,
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
"chainId": 1337,
|
|
64
|
+
"data": undefined,
|
|
65
|
+
"feePayerSignature": undefined,
|
|
66
|
+
"feeToken": "0x20c0000000000000000000000000000000000001",
|
|
67
|
+
"from": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
|
|
68
|
+
"gas": 24002n,
|
|
69
|
+
"gasPrice": 10000000000n,
|
|
70
|
+
"hash": "0x19ffdd8817d0180edc18be1ab5001445eaf267713e8d5f9e87e9b481413aca46",
|
|
71
|
+
"maxFeePerBlobGas": undefined,
|
|
72
|
+
"maxFeePerGas": 12000000000n,
|
|
73
|
+
"maxPriorityFeePerGas": 0n,
|
|
74
|
+
"nonce": 0,
|
|
75
|
+
"nonceKey": 0n,
|
|
76
|
+
"signature": {
|
|
77
|
+
"signature": {
|
|
78
|
+
"r": 18480044007397695090640579354047056183881606998783899463314972543335313635471n,
|
|
79
|
+
"s": 7944214793912353709460484452936700808754473617494909879093391150696529863949n,
|
|
80
|
+
"yParity": 1,
|
|
81
|
+
},
|
|
82
|
+
"type": "secp256k1",
|
|
83
|
+
},
|
|
84
|
+
"to": null,
|
|
85
|
+
"transactionIndex": 1,
|
|
86
|
+
"type": "aa",
|
|
87
|
+
"typeHex": "0x76",
|
|
88
|
+
"v": undefined,
|
|
89
|
+
"validAfter": null,
|
|
90
|
+
"validBefore": null,
|
|
91
|
+
"value": 0n,
|
|
92
|
+
"yParity": undefined,
|
|
93
|
+
}
|
|
94
|
+
`)
|
|
21
95
|
})
|
|
22
|
-
.extend(publicActions)
|
|
23
|
-
.extend(walletActions)
|
|
24
96
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
97
|
+
test('with calls', async () => {
|
|
98
|
+
const hash = await client.sendTransaction({
|
|
99
|
+
account: accounts[0],
|
|
100
|
+
calls: [
|
|
101
|
+
actions.token.create.call({
|
|
102
|
+
admin: accounts[0].address,
|
|
103
|
+
currency: 'USD',
|
|
104
|
+
name: 'Test Token 3',
|
|
105
|
+
symbol: 'TEST3',
|
|
106
|
+
}),
|
|
107
|
+
],
|
|
108
|
+
})
|
|
109
|
+
await client.waitForTransactionReceipt({ hash })
|
|
110
|
+
|
|
111
|
+
const transaction = await client.getTransaction({ hash })
|
|
112
|
+
expect({
|
|
113
|
+
...transaction,
|
|
114
|
+
blockHash: undefined,
|
|
115
|
+
blockNumber: undefined,
|
|
116
|
+
}).toMatchInlineSnapshot(`
|
|
117
|
+
{
|
|
118
|
+
"aaAuthorizationList": [],
|
|
119
|
+
"accessList": [],
|
|
120
|
+
"authorizationList": undefined,
|
|
121
|
+
"blockHash": undefined,
|
|
122
|
+
"blockNumber": undefined,
|
|
123
|
+
"calls": [
|
|
124
|
+
{
|
|
125
|
+
"data": "0xb395b9ac00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000020c0000000000000000000000000000000000000000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266000000000000000000000000000000000000000000000000000000000000000c5465737420546f6b656e203300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005544553543300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000035553440000000000000000000000000000000000000000000000000000000000",
|
|
126
|
+
"to": "0x20fc000000000000000000000000000000000000",
|
|
127
|
+
"value": 0n,
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
"chainId": 1337,
|
|
131
|
+
"data": undefined,
|
|
132
|
+
"feePayerSignature": undefined,
|
|
133
|
+
"feeToken": null,
|
|
134
|
+
"from": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
|
|
135
|
+
"gas": 239290n,
|
|
136
|
+
"gasPrice": 10000000000n,
|
|
137
|
+
"hash": "0x1b62b8248f353290df1c914ee4aaf37c5ece8d020e1ac171cf78906612d7bc5a",
|
|
138
|
+
"maxFeePerBlobGas": undefined,
|
|
139
|
+
"maxFeePerGas": 12000000000n,
|
|
140
|
+
"maxPriorityFeePerGas": 0n,
|
|
141
|
+
"nonce": 1,
|
|
142
|
+
"nonceKey": 0n,
|
|
143
|
+
"signature": {
|
|
144
|
+
"signature": {
|
|
145
|
+
"r": 78503646767442786974432974752095559477349685648765578842048507711761355176107n,
|
|
146
|
+
"s": 57178559224012078251730091306310112266493733814812722813686070134939395899608n,
|
|
147
|
+
"yParity": 0,
|
|
148
|
+
},
|
|
149
|
+
"type": "secp256k1",
|
|
150
|
+
},
|
|
151
|
+
"to": null,
|
|
152
|
+
"transactionIndex": 1,
|
|
153
|
+
"type": "aa",
|
|
154
|
+
"typeHex": "0x76",
|
|
155
|
+
"v": undefined,
|
|
156
|
+
"validAfter": null,
|
|
157
|
+
"validBefore": null,
|
|
158
|
+
"value": 0n,
|
|
159
|
+
"yParity": undefined,
|
|
160
|
+
}
|
|
161
|
+
`)
|
|
29
162
|
})
|
|
30
|
-
await client.waitForTransactionReceipt({ hash })
|
|
31
163
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
164
|
+
test('with feePayer', async () => {
|
|
165
|
+
const account = privateKeyToAccount(
|
|
166
|
+
// unfunded PK
|
|
167
|
+
'0xecc3fe55647412647e5c6b657c496803b08ef956f927b7a821da298cfbdd9666',
|
|
168
|
+
)
|
|
169
|
+
const feePayer = accounts[0]
|
|
37
170
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
171
|
+
const hash = await client.sendTransaction({
|
|
172
|
+
account,
|
|
173
|
+
feePayer,
|
|
174
|
+
to: '0x0000000000000000000000000000000000000000',
|
|
175
|
+
})
|
|
176
|
+
await client.waitForTransactionReceipt({ hash })
|
|
177
|
+
|
|
178
|
+
const {
|
|
179
|
+
blockHash: _,
|
|
180
|
+
blockNumber: __,
|
|
181
|
+
...transaction
|
|
182
|
+
} = await client.getTransaction({ hash })
|
|
183
|
+
|
|
184
|
+
expect(transaction).toMatchInlineSnapshot(`
|
|
185
|
+
{
|
|
186
|
+
"aaAuthorizationList": [],
|
|
187
|
+
"accessList": [],
|
|
188
|
+
"authorizationList": undefined,
|
|
189
|
+
"calls": [
|
|
190
|
+
{
|
|
191
|
+
"data": "0x",
|
|
192
|
+
"to": "0x0000000000000000000000000000000000000000",
|
|
193
|
+
"value": 0n,
|
|
194
|
+
},
|
|
195
|
+
],
|
|
196
|
+
"chainId": 1337,
|
|
197
|
+
"data": undefined,
|
|
198
|
+
"feePayer": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
|
|
199
|
+
"feePayerSignature": {
|
|
200
|
+
"r": "0x8f719d9463938d85897ee74b518c4121995791c59873199e2bbc1d9d69a458b6",
|
|
201
|
+
"s": "0x45c622bec0e381c5a06cfe7c5397cace1f7972137cefd1eba87174d7936a689c",
|
|
202
|
+
"v": 27n,
|
|
203
|
+
"yParity": 0,
|
|
47
204
|
},
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"maxFeePerGas": 52n,
|
|
59
|
-
"maxPriorityFeePerGas": 0n,
|
|
60
|
-
"nonce": 0,
|
|
61
|
-
"nonceKey": 0n,
|
|
62
|
-
"signature": {
|
|
205
|
+
"feeToken": null,
|
|
206
|
+
"from": "0x740474977e01d056f04a314b5537e4dd88f35952",
|
|
207
|
+
"gas": 23938n,
|
|
208
|
+
"gasPrice": 10000000000n,
|
|
209
|
+
"hash": "0x5aae48907ceccf3331f634bf9a76fe51f52576000e4becac929ed04d953fb0bb",
|
|
210
|
+
"maxFeePerBlobGas": undefined,
|
|
211
|
+
"maxFeePerGas": 12000000000n,
|
|
212
|
+
"maxPriorityFeePerGas": 0n,
|
|
213
|
+
"nonce": 0,
|
|
214
|
+
"nonceKey": 0n,
|
|
63
215
|
"signature": {
|
|
64
|
-
"
|
|
65
|
-
|
|
66
|
-
|
|
216
|
+
"signature": {
|
|
217
|
+
"r": 65079212976636076484448674374308068589367423744201870901549594095730781246312n,
|
|
218
|
+
"s": 36138663572355181246084885182221172668063229180861599797673217267233822764445n,
|
|
219
|
+
"yParity": 1,
|
|
220
|
+
},
|
|
221
|
+
"type": "secp256k1",
|
|
67
222
|
},
|
|
68
|
-
"
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
`)
|
|
223
|
+
"to": null,
|
|
224
|
+
"transactionIndex": 1,
|
|
225
|
+
"type": "aa",
|
|
226
|
+
"typeHex": "0x76",
|
|
227
|
+
"v": undefined,
|
|
228
|
+
"validAfter": null,
|
|
229
|
+
"validBefore": null,
|
|
230
|
+
"value": 0n,
|
|
231
|
+
"yParity": undefined,
|
|
232
|
+
}
|
|
233
|
+
`)
|
|
234
|
+
})
|
|
81
235
|
})
|
|
82
236
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
account
|
|
86
|
-
'
|
|
87
|
-
)
|
|
88
|
-
chain: tempoTest,
|
|
89
|
-
transport: http(),
|
|
90
|
-
})
|
|
91
|
-
.extend(publicActions)
|
|
92
|
-
.extend(walletActions)
|
|
93
|
-
|
|
94
|
-
const hash = await client.sendTransaction({
|
|
95
|
-
calls: [
|
|
96
|
-
actions.token.create.call({
|
|
97
|
-
admin: client.account.address,
|
|
98
|
-
currency: 'USD',
|
|
99
|
-
name: 'Test Token 3',
|
|
100
|
-
symbol: 'TEST3',
|
|
101
|
-
}),
|
|
102
|
-
],
|
|
103
|
-
})
|
|
104
|
-
await client.waitForTransactionReceipt({ hash })
|
|
237
|
+
describe('p256', () => {
|
|
238
|
+
test('default', async () => {
|
|
239
|
+
const account = Account.fromP256(
|
|
240
|
+
'0x6a3086fb3f2f95a3f36ef5387d18151ff51dc98a1e0eb987b159ba196beb0c99',
|
|
241
|
+
)
|
|
105
242
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
243
|
+
// fund account
|
|
244
|
+
await client.token.transferSync({
|
|
245
|
+
account: accounts[0],
|
|
246
|
+
token: addresses.alphaUsd,
|
|
247
|
+
to: account.address,
|
|
248
|
+
amount: parseUnits('10000', 6),
|
|
249
|
+
})
|
|
250
|
+
|
|
251
|
+
const receipt = await client.sendTransactionSync({
|
|
252
|
+
account,
|
|
253
|
+
data: '0xdeadbeef',
|
|
254
|
+
to: '0x0000000000000000000000000000000000000000',
|
|
255
|
+
})
|
|
256
|
+
|
|
257
|
+
const transaction = await client.getTransaction({
|
|
258
|
+
hash: receipt.transactionHash,
|
|
259
|
+
})
|
|
260
|
+
expect({
|
|
261
|
+
...transaction,
|
|
262
|
+
blockHash: undefined,
|
|
263
|
+
blockNumber: undefined,
|
|
264
|
+
}).toMatchInlineSnapshot(`
|
|
265
|
+
{
|
|
266
|
+
"aaAuthorizationList": [],
|
|
267
|
+
"accessList": [],
|
|
268
|
+
"authorizationList": undefined,
|
|
269
|
+
"blockHash": undefined,
|
|
270
|
+
"blockNumber": undefined,
|
|
271
|
+
"calls": [
|
|
272
|
+
{
|
|
273
|
+
"data": "0xdeadbeef",
|
|
274
|
+
"to": "0x0000000000000000000000000000000000000000",
|
|
275
|
+
"value": 0n,
|
|
276
|
+
},
|
|
277
|
+
],
|
|
278
|
+
"chainId": 1337,
|
|
279
|
+
"data": undefined,
|
|
280
|
+
"feePayerSignature": undefined,
|
|
281
|
+
"feeToken": null,
|
|
282
|
+
"from": "0xfc39755d501fa7b79164f74efb906e87ecde342c",
|
|
283
|
+
"gas": 29012n,
|
|
284
|
+
"gasPrice": 10000000000n,
|
|
285
|
+
"hash": "0x13ed96d72f7b21a19f30b734575004fb34cd0694b54d6833cc88e3de37d61d58",
|
|
286
|
+
"maxFeePerBlobGas": undefined,
|
|
287
|
+
"maxFeePerGas": 12000000000n,
|
|
288
|
+
"maxPriorityFeePerGas": 0n,
|
|
289
|
+
"nonce": 0,
|
|
290
|
+
"nonceKey": 0n,
|
|
291
|
+
"signature": {
|
|
292
|
+
"prehash": undefined,
|
|
293
|
+
"publicKey": {
|
|
294
|
+
"prefix": 4,
|
|
295
|
+
"x": 76851314197341596384765982852901663495246887984601955818013524729577854391357n,
|
|
296
|
+
"y": 28479403900638612718017087999484027026245572142646745985103165612268853186552n,
|
|
297
|
+
},
|
|
298
|
+
"signature": {
|
|
299
|
+
"r": 82730263136973498533190232493673429238005086892575761509437404111798066703019n,
|
|
300
|
+
"s": 44946766134305303588824367771503538281500341815262656891619888686974098389980n,
|
|
301
|
+
},
|
|
302
|
+
"type": "p256",
|
|
122
303
|
},
|
|
304
|
+
"to": null,
|
|
305
|
+
"transactionIndex": 1,
|
|
306
|
+
"type": "aa",
|
|
307
|
+
"typeHex": "0x76",
|
|
308
|
+
"v": undefined,
|
|
309
|
+
"validAfter": null,
|
|
310
|
+
"validBefore": null,
|
|
311
|
+
"value": 0n,
|
|
312
|
+
"yParity": undefined,
|
|
313
|
+
}
|
|
314
|
+
`)
|
|
315
|
+
})
|
|
316
|
+
|
|
317
|
+
test('with calls', async () => {
|
|
318
|
+
const account = Account.fromP256(
|
|
319
|
+
'0x6a3086fb3f2f95a3f36ef5387d18151ff51dc98a1e0eb987b159ba196beb0c99',
|
|
320
|
+
)
|
|
321
|
+
|
|
322
|
+
// fund account
|
|
323
|
+
await client.token.transferSync({
|
|
324
|
+
account: accounts[0],
|
|
325
|
+
token: addresses.alphaUsd,
|
|
326
|
+
to: account.address,
|
|
327
|
+
amount: parseUnits('10000', 6),
|
|
328
|
+
})
|
|
329
|
+
|
|
330
|
+
const receipt = await client.sendTransactionSync({
|
|
331
|
+
account,
|
|
332
|
+
calls: [
|
|
333
|
+
actions.token.create.call({
|
|
334
|
+
admin: account.address,
|
|
335
|
+
currency: 'USD',
|
|
336
|
+
name: 'Test Token 4',
|
|
337
|
+
symbol: 'TEST4',
|
|
338
|
+
}),
|
|
123
339
|
],
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
340
|
+
// TODO: remove once `eth_estimateGas` supports passing key type.
|
|
341
|
+
gas: 100_000n,
|
|
342
|
+
})
|
|
343
|
+
|
|
344
|
+
const transaction = await client.getTransaction({
|
|
345
|
+
hash: receipt.transactionHash,
|
|
346
|
+
})
|
|
347
|
+
expect({
|
|
348
|
+
...transaction,
|
|
349
|
+
blockHash: undefined,
|
|
350
|
+
blockNumber: undefined,
|
|
351
|
+
}).toMatchInlineSnapshot(`
|
|
352
|
+
{
|
|
353
|
+
"aaAuthorizationList": [],
|
|
354
|
+
"accessList": [],
|
|
355
|
+
"authorizationList": undefined,
|
|
356
|
+
"blockHash": undefined,
|
|
357
|
+
"blockNumber": undefined,
|
|
358
|
+
"calls": [
|
|
359
|
+
{
|
|
360
|
+
"data": "0xb395b9ac00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000020c0000000000000000000000000000000000000000000000000000000000000fc39755d501fa7b79164f74efb906e87ecde342c000000000000000000000000000000000000000000000000000000000000000c5465737420546f6b656e203400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005544553543400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000035553440000000000000000000000000000000000000000000000000000000000",
|
|
361
|
+
"to": "0x20fc000000000000000000000000000000000000",
|
|
362
|
+
"value": 0n,
|
|
363
|
+
},
|
|
364
|
+
],
|
|
365
|
+
"chainId": 1337,
|
|
366
|
+
"data": undefined,
|
|
367
|
+
"feePayerSignature": undefined,
|
|
368
|
+
"feeToken": null,
|
|
369
|
+
"from": "0xfc39755d501fa7b79164f74efb906e87ecde342c",
|
|
370
|
+
"gas": 100000n,
|
|
371
|
+
"gasPrice": 10000000000n,
|
|
372
|
+
"hash": "0x47d30679625b66e09219f73c11e657a8950259e814ec9bef0a8054bc418ce138",
|
|
373
|
+
"maxFeePerBlobGas": undefined,
|
|
374
|
+
"maxFeePerGas": 12000000000n,
|
|
375
|
+
"maxPriorityFeePerGas": 0n,
|
|
376
|
+
"nonce": 1,
|
|
377
|
+
"nonceKey": 0n,
|
|
138
378
|
"signature": {
|
|
139
|
-
"
|
|
140
|
-
"
|
|
379
|
+
"prehash": undefined,
|
|
380
|
+
"publicKey": {
|
|
381
|
+
"prefix": 4,
|
|
382
|
+
"x": 76851314197341596384765982852901663495246887984601955818013524729577854391357n,
|
|
383
|
+
"y": 28479403900638612718017087999484027026245572142646745985103165612268853186552n,
|
|
384
|
+
},
|
|
385
|
+
"signature": {
|
|
386
|
+
"r": 113341784972223677657638155264375724813412569467929323654477865838324981972769n,
|
|
387
|
+
"s": 42271961989228659763384216377289107353157423528268870961696295632380366334643n,
|
|
388
|
+
},
|
|
389
|
+
"type": "p256",
|
|
390
|
+
},
|
|
391
|
+
"to": null,
|
|
392
|
+
"transactionIndex": 1,
|
|
393
|
+
"type": "aa",
|
|
394
|
+
"typeHex": "0x76",
|
|
395
|
+
"v": undefined,
|
|
396
|
+
"validAfter": null,
|
|
397
|
+
"validBefore": null,
|
|
398
|
+
"value": 0n,
|
|
399
|
+
"yParity": undefined,
|
|
400
|
+
}
|
|
401
|
+
`)
|
|
402
|
+
})
|
|
403
|
+
|
|
404
|
+
test('with feePayer', async () => {
|
|
405
|
+
const account = Account.fromP256(
|
|
406
|
+
// unfunded account with different key
|
|
407
|
+
'0x1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b',
|
|
408
|
+
)
|
|
409
|
+
const feePayer = accounts[0]
|
|
410
|
+
|
|
411
|
+
const hash = await client.sendTransaction({
|
|
412
|
+
account,
|
|
413
|
+
feePayer,
|
|
414
|
+
to: '0x0000000000000000000000000000000000000000',
|
|
415
|
+
})
|
|
416
|
+
await client.waitForTransactionReceipt({ hash })
|
|
417
|
+
|
|
418
|
+
const {
|
|
419
|
+
blockHash: _,
|
|
420
|
+
blockNumber: __,
|
|
421
|
+
...transaction
|
|
422
|
+
} = await client.getTransaction({ hash })
|
|
423
|
+
|
|
424
|
+
expect(transaction).toMatchInlineSnapshot(`
|
|
425
|
+
{
|
|
426
|
+
"aaAuthorizationList": [],
|
|
427
|
+
"accessList": [],
|
|
428
|
+
"authorizationList": undefined,
|
|
429
|
+
"calls": [
|
|
430
|
+
{
|
|
431
|
+
"data": "0x",
|
|
432
|
+
"to": "0x0000000000000000000000000000000000000000",
|
|
433
|
+
"value": 0n,
|
|
434
|
+
},
|
|
435
|
+
],
|
|
436
|
+
"chainId": 1337,
|
|
437
|
+
"data": undefined,
|
|
438
|
+
"feePayer": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
|
|
439
|
+
"feePayerSignature": {
|
|
440
|
+
"r": "0x9d9e74278c306658fff5cca2a736f07c475d3dbe4b931ba73be8543d522b5430",
|
|
441
|
+
"s": "0x2224242aaf6fa17b8f2266bea1ad501837c2c2ad13e0d96b9ed29ecb60ba1ac4",
|
|
442
|
+
"v": 27n,
|
|
141
443
|
"yParity": 0,
|
|
142
444
|
},
|
|
143
|
-
"
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
445
|
+
"feeToken": null,
|
|
446
|
+
"from": "0x5f704c6c7075acd14ee36527f03b5b5dcb4a966f",
|
|
447
|
+
"gas": 28947n,
|
|
448
|
+
"gasPrice": 10000000000n,
|
|
449
|
+
"hash": "0x77ce7f3b60540465d681b360293aaafca496c0a2ff2a4f5f146f144206a487dd",
|
|
450
|
+
"maxFeePerBlobGas": undefined,
|
|
451
|
+
"maxFeePerGas": 12000000000n,
|
|
452
|
+
"maxPriorityFeePerGas": 0n,
|
|
453
|
+
"nonce": 0,
|
|
454
|
+
"nonceKey": 0n,
|
|
455
|
+
"signature": {
|
|
456
|
+
"prehash": undefined,
|
|
457
|
+
"publicKey": {
|
|
458
|
+
"prefix": 4,
|
|
459
|
+
"x": 89768657165983002447270155621964907577955735922001002175265262336201091268103n,
|
|
460
|
+
"y": 21692506528696391747937034302216251793515398807520467579078748804389014172835n,
|
|
461
|
+
},
|
|
462
|
+
"signature": {
|
|
463
|
+
"r": 6861653902973636215987311933940928353425544366774814432483697786223275705586n,
|
|
464
|
+
"s": 7277254520198161524871116736077233939785567558470334763663181456500888822079n,
|
|
465
|
+
},
|
|
466
|
+
"type": "p256",
|
|
467
|
+
},
|
|
468
|
+
"to": null,
|
|
469
|
+
"transactionIndex": 1,
|
|
470
|
+
"type": "aa",
|
|
471
|
+
"typeHex": "0x76",
|
|
472
|
+
"v": undefined,
|
|
473
|
+
"validAfter": null,
|
|
474
|
+
"validBefore": null,
|
|
475
|
+
"value": 0n,
|
|
476
|
+
"yParity": undefined,
|
|
477
|
+
}
|
|
478
|
+
`)
|
|
479
|
+
})
|
|
156
480
|
})
|
|
157
481
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
)
|
|
163
|
-
const feePayer = mnemonicToAccount(
|
|
164
|
-
'test test test test test test test test test test test junk',
|
|
165
|
-
)
|
|
482
|
+
describe('webcrypto', () => {
|
|
483
|
+
test('default', async () => {
|
|
484
|
+
const keyPair = await WebCryptoP256.createKeyPair()
|
|
485
|
+
const account = Account.fromWebCryptoP256(keyPair)
|
|
166
486
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
487
|
+
// fund account
|
|
488
|
+
await client.token.transferSync({
|
|
489
|
+
account: accounts[0],
|
|
490
|
+
token: addresses.alphaUsd,
|
|
491
|
+
to: account.address,
|
|
492
|
+
amount: parseUnits('10000', 6),
|
|
493
|
+
})
|
|
494
|
+
|
|
495
|
+
const receipt = await client.sendTransactionSync({
|
|
496
|
+
account,
|
|
497
|
+
data: '0xdeadbeef',
|
|
498
|
+
to: '0x0000000000000000000000000000000000000000',
|
|
499
|
+
})
|
|
500
|
+
|
|
501
|
+
const transaction = await client.getTransaction({
|
|
502
|
+
hash: receipt.transactionHash,
|
|
503
|
+
})
|
|
504
|
+
expect({
|
|
505
|
+
...transaction,
|
|
506
|
+
blockHash: undefined,
|
|
507
|
+
blockNumber: undefined,
|
|
508
|
+
from: undefined,
|
|
509
|
+
hash: undefined,
|
|
510
|
+
signature: undefined,
|
|
511
|
+
}).toMatchInlineSnapshot(`
|
|
512
|
+
{
|
|
513
|
+
"aaAuthorizationList": [],
|
|
514
|
+
"accessList": [],
|
|
515
|
+
"authorizationList": undefined,
|
|
516
|
+
"blockHash": undefined,
|
|
517
|
+
"blockNumber": undefined,
|
|
518
|
+
"calls": [
|
|
519
|
+
{
|
|
520
|
+
"data": "0xdeadbeef",
|
|
521
|
+
"to": "0x0000000000000000000000000000000000000000",
|
|
522
|
+
"value": 0n,
|
|
523
|
+
},
|
|
524
|
+
],
|
|
525
|
+
"chainId": 1337,
|
|
526
|
+
"data": undefined,
|
|
527
|
+
"feePayerSignature": undefined,
|
|
528
|
+
"feeToken": null,
|
|
529
|
+
"from": undefined,
|
|
530
|
+
"gas": 29012n,
|
|
531
|
+
"gasPrice": 10000000000n,
|
|
532
|
+
"hash": undefined,
|
|
533
|
+
"maxFeePerBlobGas": undefined,
|
|
534
|
+
"maxFeePerGas": 12000000000n,
|
|
535
|
+
"maxPriorityFeePerGas": 0n,
|
|
536
|
+
"nonce": 0,
|
|
537
|
+
"nonceKey": 0n,
|
|
538
|
+
"signature": undefined,
|
|
539
|
+
"to": null,
|
|
540
|
+
"transactionIndex": 1,
|
|
541
|
+
"type": "aa",
|
|
542
|
+
"typeHex": "0x76",
|
|
543
|
+
"v": undefined,
|
|
544
|
+
"validAfter": null,
|
|
545
|
+
"validBefore": null,
|
|
546
|
+
"value": 0n,
|
|
547
|
+
"yParity": undefined,
|
|
548
|
+
}
|
|
549
|
+
`)
|
|
171
550
|
})
|
|
172
|
-
.extend(publicActions)
|
|
173
|
-
.extend(walletActions)
|
|
174
551
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
552
|
+
test('with calls', async () => {
|
|
553
|
+
const keyPair = await WebCryptoP256.createKeyPair()
|
|
554
|
+
const account = Account.fromWebCryptoP256(keyPair)
|
|
555
|
+
|
|
556
|
+
// fund account
|
|
557
|
+
await client.token.transferSync({
|
|
558
|
+
account: accounts[0],
|
|
559
|
+
token: addresses.alphaUsd,
|
|
560
|
+
to: account.address,
|
|
561
|
+
amount: parseUnits('10000', 6),
|
|
562
|
+
})
|
|
563
|
+
|
|
564
|
+
const receipt = await client.sendTransactionSync({
|
|
565
|
+
account,
|
|
566
|
+
calls: [
|
|
567
|
+
actions.token.create.call({
|
|
568
|
+
admin: account.address,
|
|
569
|
+
currency: 'USD',
|
|
570
|
+
name: 'Test Token 5',
|
|
571
|
+
symbol: 'TEST5',
|
|
572
|
+
}),
|
|
573
|
+
],
|
|
574
|
+
// TODO: remove once `eth_estimateGas` supports passing key type.
|
|
575
|
+
gas: 100_000n,
|
|
576
|
+
})
|
|
577
|
+
|
|
578
|
+
const transaction = await client.getTransaction({
|
|
579
|
+
hash: receipt.transactionHash,
|
|
580
|
+
})
|
|
581
|
+
expect(transaction).toBeDefined()
|
|
178
582
|
})
|
|
179
|
-
await client.waitForTransactionReceipt({ hash })
|
|
180
583
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
} = await client.getTransaction({ hash })
|
|
584
|
+
test('with feePayer', async () => {
|
|
585
|
+
const keyPair = await WebCryptoP256.createKeyPair()
|
|
586
|
+
const account = Account.fromWebCryptoP256(keyPair)
|
|
587
|
+
const feePayer = accounts[0]
|
|
186
588
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
589
|
+
const hash = await client.sendTransaction({
|
|
590
|
+
account,
|
|
591
|
+
feePayer,
|
|
592
|
+
to: '0x0000000000000000000000000000000000000000',
|
|
593
|
+
})
|
|
594
|
+
await client.waitForTransactionReceipt({ hash })
|
|
595
|
+
|
|
596
|
+
const transaction = await client.getTransaction({ hash })
|
|
597
|
+
expect(transaction).toBeDefined()
|
|
598
|
+
})
|
|
599
|
+
})
|
|
600
|
+
|
|
601
|
+
describe('webAuthn', () => {
|
|
602
|
+
test('default', async () => {
|
|
603
|
+
const account = Account.fromHeadlessWebAuthn(
|
|
604
|
+
'0x6a3086fb3f2f95a3f36ef5387d18151ff51dc98a1e0eb987b159ba196beb0c99',
|
|
605
|
+
{
|
|
606
|
+
rpId: 'localhost',
|
|
607
|
+
origin: 'http://localhost',
|
|
608
|
+
},
|
|
609
|
+
)
|
|
610
|
+
|
|
611
|
+
// fund account
|
|
612
|
+
await client.token.transferSync({
|
|
613
|
+
account: accounts[0],
|
|
614
|
+
token: addresses.alphaUsd,
|
|
615
|
+
to: account.address,
|
|
616
|
+
amount: parseUnits('10000', 6),
|
|
617
|
+
})
|
|
618
|
+
|
|
619
|
+
const receipt = await client.sendTransactionSync({
|
|
620
|
+
account,
|
|
621
|
+
data: '0xdeadbeef',
|
|
622
|
+
to: '0x0000000000000000000000000000000000000000',
|
|
623
|
+
})
|
|
624
|
+
|
|
625
|
+
const transaction = await client.getTransaction({
|
|
626
|
+
hash: receipt.transactionHash,
|
|
627
|
+
})
|
|
628
|
+
expect({
|
|
629
|
+
...transaction,
|
|
630
|
+
blockHash: undefined,
|
|
631
|
+
blockNumber: undefined,
|
|
632
|
+
}).toMatchInlineSnapshot(`
|
|
633
|
+
{
|
|
634
|
+
"aaAuthorizationList": [],
|
|
635
|
+
"accessList": [],
|
|
636
|
+
"authorizationList": undefined,
|
|
637
|
+
"blockHash": undefined,
|
|
638
|
+
"blockNumber": undefined,
|
|
639
|
+
"calls": [
|
|
640
|
+
{
|
|
641
|
+
"data": "0xdeadbeef",
|
|
642
|
+
"to": "0x0000000000000000000000000000000000000000",
|
|
643
|
+
"value": 0n,
|
|
644
|
+
},
|
|
645
|
+
],
|
|
646
|
+
"chainId": 1337,
|
|
647
|
+
"data": undefined,
|
|
648
|
+
"feePayerSignature": undefined,
|
|
649
|
+
"feeToken": null,
|
|
650
|
+
"from": "0xfc39755d501fa7b79164f74efb906e87ecde342c",
|
|
651
|
+
"gas": 41404n,
|
|
652
|
+
"gasPrice": 10000000000n,
|
|
653
|
+
"hash": "0x1b56e02e48a5c39478bcc7f912108892a8fa0302747c6928260fc89cd8729499",
|
|
654
|
+
"maxFeePerBlobGas": undefined,
|
|
655
|
+
"maxFeePerGas": 12000000000n,
|
|
656
|
+
"maxPriorityFeePerGas": 0n,
|
|
657
|
+
"nonce": 2,
|
|
658
|
+
"nonceKey": 0n,
|
|
659
|
+
"signature": {
|
|
660
|
+
"metadata": {
|
|
661
|
+
"authenticatorData": "0x49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630500000000",
|
|
662
|
+
"clientDataJSON": "{"type":"webauthn.get","challenge":"YHxXuO3IIuui0Kz1A5bvEMnEwcV1jXHGgH4s_DEFq0Q","origin":"http://localhost","crossOrigin":false}",
|
|
663
|
+
},
|
|
664
|
+
"publicKey": {
|
|
665
|
+
"prefix": 4,
|
|
666
|
+
"x": 76851314197341596384765982852901663495246887984601955818013524729577854391357n,
|
|
667
|
+
"y": 28479403900638612718017087999484027026245572142646745985103165612268853186552n,
|
|
668
|
+
},
|
|
669
|
+
"signature": {
|
|
670
|
+
"r": 20513840452271821919896541370744222233657684228117041709895363014729132314467n,
|
|
671
|
+
"s": 27363596257739130609932989541270702074673583176160656328016769892248487926140n,
|
|
672
|
+
},
|
|
673
|
+
"type": "webAuthn",
|
|
196
674
|
},
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
"
|
|
203
|
-
"
|
|
204
|
-
"
|
|
205
|
-
"yParity":
|
|
675
|
+
"to": null,
|
|
676
|
+
"transactionIndex": 1,
|
|
677
|
+
"type": "aa",
|
|
678
|
+
"typeHex": "0x76",
|
|
679
|
+
"v": undefined,
|
|
680
|
+
"validAfter": null,
|
|
681
|
+
"validBefore": null,
|
|
682
|
+
"value": 0n,
|
|
683
|
+
"yParity": undefined,
|
|
684
|
+
}
|
|
685
|
+
`)
|
|
686
|
+
})
|
|
687
|
+
|
|
688
|
+
test('with calls', async () => {
|
|
689
|
+
const account = Account.fromHeadlessWebAuthn(
|
|
690
|
+
'0x6a3086fb3f2f95a3f36ef5387d18151ff51dc98a1e0eb987b159ba196beb0c99',
|
|
691
|
+
{
|
|
692
|
+
rpId: 'localhost',
|
|
693
|
+
origin: 'http://localhost',
|
|
206
694
|
},
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
695
|
+
)
|
|
696
|
+
|
|
697
|
+
// fund account
|
|
698
|
+
await client.token.transferSync({
|
|
699
|
+
account: accounts[0],
|
|
700
|
+
token: addresses.alphaUsd,
|
|
701
|
+
to: account.address,
|
|
702
|
+
amount: parseUnits('10000', 6),
|
|
703
|
+
})
|
|
704
|
+
|
|
705
|
+
const receipt = await client.sendTransactionSync({
|
|
706
|
+
account,
|
|
707
|
+
calls: [
|
|
708
|
+
actions.token.create.call({
|
|
709
|
+
admin: account.address,
|
|
710
|
+
currency: 'USD',
|
|
711
|
+
name: 'Test Token 6',
|
|
712
|
+
symbol: 'TEST6',
|
|
713
|
+
}),
|
|
714
|
+
],
|
|
715
|
+
// TODO: remove once `eth_estimateGas` supports passing key type.
|
|
716
|
+
gas: 100_000n,
|
|
717
|
+
})
|
|
718
|
+
|
|
719
|
+
const transaction = await client.getTransaction({
|
|
720
|
+
hash: receipt.transactionHash,
|
|
721
|
+
})
|
|
722
|
+
expect({
|
|
723
|
+
...transaction,
|
|
724
|
+
blockHash: undefined,
|
|
725
|
+
blockNumber: undefined,
|
|
726
|
+
}).toMatchInlineSnapshot(`
|
|
727
|
+
{
|
|
728
|
+
"aaAuthorizationList": [],
|
|
729
|
+
"accessList": [],
|
|
730
|
+
"authorizationList": undefined,
|
|
731
|
+
"blockHash": undefined,
|
|
732
|
+
"blockNumber": undefined,
|
|
733
|
+
"calls": [
|
|
734
|
+
{
|
|
735
|
+
"data": "0xb395b9ac00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000020c0000000000000000000000000000000000000000000000000000000000000fc39755d501fa7b79164f74efb906e87ecde342c000000000000000000000000000000000000000000000000000000000000000c5465737420546f6b656e203600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005544553543600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000035553440000000000000000000000000000000000000000000000000000000000",
|
|
736
|
+
"to": "0x20fc000000000000000000000000000000000000",
|
|
737
|
+
"value": 0n,
|
|
738
|
+
},
|
|
739
|
+
],
|
|
740
|
+
"chainId": 1337,
|
|
741
|
+
"data": undefined,
|
|
742
|
+
"feePayerSignature": undefined,
|
|
743
|
+
"feeToken": null,
|
|
744
|
+
"from": "0xfc39755d501fa7b79164f74efb906e87ecde342c",
|
|
745
|
+
"gas": 100000n,
|
|
746
|
+
"gasPrice": 10000000000n,
|
|
747
|
+
"hash": "0x6520a97076d29b5e1bc76cb4dcd813e5b2a1bdbf1bba622e542bab3de9ea4a9f",
|
|
748
|
+
"maxFeePerBlobGas": undefined,
|
|
749
|
+
"maxFeePerGas": 12000000000n,
|
|
750
|
+
"maxPriorityFeePerGas": 0n,
|
|
751
|
+
"nonce": 3,
|
|
752
|
+
"nonceKey": 0n,
|
|
218
753
|
"signature": {
|
|
219
|
-
"
|
|
220
|
-
|
|
221
|
-
|
|
754
|
+
"metadata": {
|
|
755
|
+
"authenticatorData": "0x49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630500000000",
|
|
756
|
+
"clientDataJSON": "{"type":"webauthn.get","challenge":"PqvaeGCzQHEM5f8UU4LbjCY97K8kfxlwFl4VpOfQy9U","origin":"http://localhost","crossOrigin":false}",
|
|
757
|
+
},
|
|
758
|
+
"publicKey": {
|
|
759
|
+
"prefix": 4,
|
|
760
|
+
"x": 76851314197341596384765982852901663495246887984601955818013524729577854391357n,
|
|
761
|
+
"y": 28479403900638612718017087999484027026245572142646745985103165612268853186552n,
|
|
762
|
+
},
|
|
763
|
+
"signature": {
|
|
764
|
+
"r": 90764526189385409482244930589827202930214636605680311984211069314044601874317n,
|
|
765
|
+
"s": 54909273314024796243497246034814125113763800884613983294394271661966971076442n,
|
|
766
|
+
},
|
|
767
|
+
"type": "webAuthn",
|
|
222
768
|
},
|
|
223
|
-
"
|
|
769
|
+
"to": null,
|
|
770
|
+
"transactionIndex": 1,
|
|
771
|
+
"type": "aa",
|
|
772
|
+
"typeHex": "0x76",
|
|
773
|
+
"v": undefined,
|
|
774
|
+
"validAfter": null,
|
|
775
|
+
"validBefore": null,
|
|
776
|
+
"value": 0n,
|
|
777
|
+
"yParity": undefined,
|
|
778
|
+
}
|
|
779
|
+
`)
|
|
780
|
+
})
|
|
781
|
+
|
|
782
|
+
test('with feePayer', async () => {
|
|
783
|
+
const account = Account.fromHeadlessWebAuthn(
|
|
784
|
+
// unfunded account with different key
|
|
785
|
+
'0x1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b',
|
|
786
|
+
{
|
|
787
|
+
rpId: 'localhost',
|
|
788
|
+
origin: 'http://localhost',
|
|
224
789
|
},
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
790
|
+
)
|
|
791
|
+
const feePayer = accounts[0]
|
|
792
|
+
|
|
793
|
+
const hash = await client.sendTransaction({
|
|
794
|
+
account,
|
|
795
|
+
feePayer,
|
|
796
|
+
to: '0x0000000000000000000000000000000000000000',
|
|
797
|
+
})
|
|
798
|
+
await client.waitForTransactionReceipt({ hash })
|
|
799
|
+
|
|
800
|
+
const {
|
|
801
|
+
blockHash: _,
|
|
802
|
+
blockNumber: __,
|
|
803
|
+
...transaction
|
|
804
|
+
} = await client.getTransaction({ hash })
|
|
805
|
+
|
|
806
|
+
expect(transaction).toMatchInlineSnapshot(`
|
|
807
|
+
{
|
|
808
|
+
"aaAuthorizationList": [],
|
|
809
|
+
"accessList": [],
|
|
810
|
+
"authorizationList": undefined,
|
|
811
|
+
"calls": [
|
|
812
|
+
{
|
|
813
|
+
"data": "0x",
|
|
814
|
+
"to": "0x0000000000000000000000000000000000000000",
|
|
815
|
+
"value": 0n,
|
|
816
|
+
},
|
|
817
|
+
],
|
|
818
|
+
"chainId": 1337,
|
|
819
|
+
"data": undefined,
|
|
820
|
+
"feePayer": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
|
|
821
|
+
"feePayerSignature": {
|
|
822
|
+
"r": "0x90b71f46a775d5ca06725fcef4fe4763b4dce34bb72cde30a527ec26407baa84",
|
|
823
|
+
"s": "0x398d0192f02d503b5463b1f886790eee882f2329e7af44b8106f27930735041d",
|
|
824
|
+
"v": 28n,
|
|
825
|
+
"yParity": 1,
|
|
826
|
+
},
|
|
827
|
+
"feeToken": null,
|
|
828
|
+
"from": "0x5f704c6c7075acd14ee36527f03b5b5dcb4a966f",
|
|
829
|
+
"gas": 41340n,
|
|
830
|
+
"gasPrice": 10000000000n,
|
|
831
|
+
"hash": "0x6f6801526c00fba8e107e5064758bd20a978f3952b144f6c52bab1abfc913143",
|
|
832
|
+
"maxFeePerBlobGas": undefined,
|
|
833
|
+
"maxFeePerGas": 12000000000n,
|
|
834
|
+
"maxPriorityFeePerGas": 0n,
|
|
835
|
+
"nonce": 1,
|
|
836
|
+
"nonceKey": 0n,
|
|
837
|
+
"signature": {
|
|
838
|
+
"metadata": {
|
|
839
|
+
"authenticatorData": "0x49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630500000000",
|
|
840
|
+
"clientDataJSON": "{"type":"webauthn.get","challenge":"dVrVJFewcT_ifvpphKoheG6VSAQJ_74h6g3O32Rri2Q","origin":"http://localhost","crossOrigin":false}",
|
|
841
|
+
},
|
|
842
|
+
"publicKey": {
|
|
843
|
+
"prefix": 4,
|
|
844
|
+
"x": 89768657165983002447270155621964907577955735922001002175265262336201091268103n,
|
|
845
|
+
"y": 21692506528696391747937034302216251793515398807520467579078748804389014172835n,
|
|
846
|
+
},
|
|
847
|
+
"signature": {
|
|
848
|
+
"r": 72341690970159629319932745028286754044171557161564831284038819357806396549916n,
|
|
849
|
+
"s": 47900412910547062549030763809045404303050255516583713899170528571925897239021n,
|
|
850
|
+
},
|
|
851
|
+
"type": "webAuthn",
|
|
852
|
+
},
|
|
853
|
+
"to": null,
|
|
854
|
+
"transactionIndex": 1,
|
|
855
|
+
"type": "aa",
|
|
856
|
+
"typeHex": "0x76",
|
|
857
|
+
"v": undefined,
|
|
858
|
+
"validAfter": null,
|
|
859
|
+
"validBefore": null,
|
|
860
|
+
"value": 0n,
|
|
861
|
+
"yParity": undefined,
|
|
862
|
+
}
|
|
863
|
+
`)
|
|
864
|
+
})
|
|
236
865
|
})
|
|
237
866
|
})
|
|
238
867
|
|
|
@@ -242,19 +871,10 @@ describe('signTransaction', () => {
|
|
|
242
871
|
// unfunded PK
|
|
243
872
|
'0xecc3fe55647412647e5c6b657c496803b08ef956f927b7a821da298cfbdd9666',
|
|
244
873
|
)
|
|
245
|
-
const feePayer =
|
|
246
|
-
'test test test test test test test test test test test junk',
|
|
247
|
-
)
|
|
248
|
-
|
|
249
|
-
const client = createClient({
|
|
250
|
-
account,
|
|
251
|
-
chain: tempoTest,
|
|
252
|
-
transport: http(),
|
|
253
|
-
})
|
|
254
|
-
.extend(walletActions)
|
|
255
|
-
.extend(publicActions)
|
|
874
|
+
const feePayer = accounts[0]
|
|
256
875
|
|
|
257
876
|
const request = await client.prepareTransactionRequest({
|
|
877
|
+
account,
|
|
258
878
|
data: '0xdeadbeef',
|
|
259
879
|
feePayer: true,
|
|
260
880
|
to: '0xcafebabecafebabecafebabecafebabecafebabe',
|
|
@@ -263,6 +883,7 @@ describe('signTransaction', () => {
|
|
|
263
883
|
|
|
264
884
|
transaction = await client.signTransaction({
|
|
265
885
|
...Transaction.deserialize(transaction),
|
|
886
|
+
account,
|
|
266
887
|
feePayer,
|
|
267
888
|
})
|
|
268
889
|
const hash = await client.sendRawTransaction({
|
|
@@ -279,6 +900,7 @@ describe('signTransaction', () => {
|
|
|
279
900
|
|
|
280
901
|
expect(transaction2).toMatchInlineSnapshot(`
|
|
281
902
|
{
|
|
903
|
+
"aaAuthorizationList": [],
|
|
282
904
|
"accessList": [],
|
|
283
905
|
"authorizationList": undefined,
|
|
284
906
|
"calls": [
|
|
@@ -292,31 +914,31 @@ describe('signTransaction', () => {
|
|
|
292
914
|
"data": undefined,
|
|
293
915
|
"feePayer": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
|
|
294
916
|
"feePayerSignature": {
|
|
295
|
-
"r": "
|
|
296
|
-
"s": "
|
|
297
|
-
"v":
|
|
298
|
-
"yParity":
|
|
917
|
+
"r": "0x669793cc2483931ffe3141aab062c7f69d3d16d15003c1192ca944b019ef445a",
|
|
918
|
+
"s": "0x037cce00c3e94063ef98c4a55e9b11cdfc826ddae125d42cf679a6fcd1c8fef9",
|
|
919
|
+
"v": 28n,
|
|
920
|
+
"yParity": 1,
|
|
299
921
|
},
|
|
300
922
|
"feeToken": null,
|
|
301
923
|
"from": "0x740474977e01d056f04a314b5537e4dd88f35952",
|
|
302
|
-
"gas":
|
|
303
|
-
"gasPrice":
|
|
304
|
-
"hash": "
|
|
924
|
+
"gas": 24002n,
|
|
925
|
+
"gasPrice": 10000000000n,
|
|
926
|
+
"hash": "0xb0abd89951c7d053af43c7684859a604b381680dc8521e41e57a2412cef13211",
|
|
305
927
|
"maxFeePerBlobGas": undefined,
|
|
306
|
-
"maxFeePerGas":
|
|
928
|
+
"maxFeePerGas": 12000000000n,
|
|
307
929
|
"maxPriorityFeePerGas": 0n,
|
|
308
|
-
"nonce":
|
|
930
|
+
"nonce": 1,
|
|
309
931
|
"nonceKey": 0n,
|
|
310
932
|
"signature": {
|
|
311
933
|
"signature": {
|
|
312
|
-
"r":
|
|
313
|
-
"s":
|
|
314
|
-
"yParity":
|
|
934
|
+
"r": 67093125285953111322286487053649634901104592648978739500209237696329559594663n,
|
|
935
|
+
"s": 23307791115004510736003345595881666676393686556128238040992902553893261582309n,
|
|
936
|
+
"yParity": 0,
|
|
315
937
|
},
|
|
316
938
|
"type": "secp256k1",
|
|
317
939
|
},
|
|
318
940
|
"to": null,
|
|
319
|
-
"transactionIndex":
|
|
941
|
+
"transactionIndex": 1,
|
|
320
942
|
"type": "aa",
|
|
321
943
|
"typeHex": "0x76",
|
|
322
944
|
"v": undefined,
|
|
@@ -330,16 +952,25 @@ describe('signTransaction', () => {
|
|
|
330
952
|
})
|
|
331
953
|
|
|
332
954
|
describe('relay', () => {
|
|
955
|
+
const client = createClient({
|
|
956
|
+
chain: tempoTest({ feeToken: 1n }),
|
|
957
|
+
transport: withFeePayer(http(), http('http://localhost:3000')),
|
|
958
|
+
})
|
|
959
|
+
.extend(tempoActions())
|
|
960
|
+
.extend(walletActions)
|
|
961
|
+
.extend(publicActions)
|
|
333
962
|
let server: Http.Server
|
|
334
963
|
|
|
964
|
+
afterEach(async () => {
|
|
965
|
+
await fetch(`${rpcUrl}/restart`)
|
|
966
|
+
})
|
|
967
|
+
|
|
335
968
|
beforeAll(async () => {
|
|
336
969
|
server = Http.createServer(
|
|
337
970
|
createRequestListener(async (r) => {
|
|
338
971
|
const client = createClient({
|
|
339
|
-
account:
|
|
340
|
-
|
|
341
|
-
),
|
|
342
|
-
chain: tempoTest,
|
|
972
|
+
account: accounts[0],
|
|
973
|
+
chain: tempoTest({ feeToken: 1n }),
|
|
343
974
|
transport: http(),
|
|
344
975
|
}).extend(walletActions)
|
|
345
976
|
|
|
@@ -401,86 +1032,284 @@ describe('relay', () => {
|
|
|
401
1032
|
})
|
|
402
1033
|
})
|
|
403
1034
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
account
|
|
1035
|
+
describe('secp256k1', () => {
|
|
1036
|
+
test('default', async () => {
|
|
1037
|
+
const account = privateKeyToAccount(
|
|
407
1038
|
// unfunded PK
|
|
408
1039
|
'0xecc3fe55647412647e5c6b657c496803b08ef956f927b7a821da298cfbdd9666',
|
|
409
|
-
)
|
|
410
|
-
chain: tempoTest,
|
|
411
|
-
transport: withFeePayer(http(), http('http://localhost:3000')),
|
|
412
|
-
})
|
|
413
|
-
.extend(tempoActions())
|
|
414
|
-
.extend(walletActions)
|
|
415
|
-
.extend(publicActions)
|
|
1040
|
+
)
|
|
416
1041
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
1042
|
+
const { receipt } = await client.fee.setUserTokenSync({
|
|
1043
|
+
account,
|
|
1044
|
+
feePayer: true,
|
|
1045
|
+
token: 1n,
|
|
1046
|
+
})
|
|
421
1047
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
1048
|
+
const userToken = await client.fee.getUserToken({ account })
|
|
1049
|
+
expect(userToken).toMatchInlineSnapshot(`
|
|
1050
|
+
{
|
|
1051
|
+
"address": "0x20C0000000000000000000000000000000000001",
|
|
1052
|
+
"id": 1n,
|
|
1053
|
+
}
|
|
1054
|
+
`)
|
|
429
1055
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
1056
|
+
const {
|
|
1057
|
+
blockHash: _,
|
|
1058
|
+
blockNumber: __,
|
|
1059
|
+
...transaction
|
|
1060
|
+
} = await client.getTransaction({ hash: receipt.transactionHash })
|
|
435
1061
|
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
1062
|
+
expect(transaction).toMatchInlineSnapshot(`
|
|
1063
|
+
{
|
|
1064
|
+
"aaAuthorizationList": [],
|
|
1065
|
+
"accessList": [],
|
|
1066
|
+
"authorizationList": undefined,
|
|
1067
|
+
"calls": [
|
|
1068
|
+
{
|
|
1069
|
+
"data": "0xe789744400000000000000000000000020c0000000000000000000000000000000000001",
|
|
1070
|
+
"to": "0xfeec000000000000000000000000000000000000",
|
|
1071
|
+
"value": 0n,
|
|
1072
|
+
},
|
|
1073
|
+
],
|
|
1074
|
+
"chainId": 1337,
|
|
1075
|
+
"data": undefined,
|
|
1076
|
+
"feePayer": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
|
|
1077
|
+
"feePayerSignature": {
|
|
1078
|
+
"r": "0x57f6f6777f1689f87c333d1fa37207cf668b2c2d7321dcd5c63a2e6a7108077e",
|
|
1079
|
+
"s": "0x3c4270f67d8add0b5e7a9de6fee2b915cd754e1c0495ee88a1b78fd7568e6619",
|
|
1080
|
+
"v": 28n,
|
|
1081
|
+
"yParity": 1,
|
|
445
1082
|
},
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
"
|
|
452
|
-
"
|
|
453
|
-
"
|
|
454
|
-
"
|
|
455
|
-
|
|
456
|
-
"feeToken": null,
|
|
457
|
-
"from": "0x740474977e01d056f04a314b5537e4dd88f35952",
|
|
458
|
-
"gas": 53793n,
|
|
459
|
-
"gasPrice": 44n,
|
|
460
|
-
"hash": "0xcb8f0e58ddb27f9fb3cbf200ec3023dffd43ced39c2e187c7907373082707420",
|
|
461
|
-
"maxFeePerBlobGas": undefined,
|
|
462
|
-
"maxFeePerGas": 52n,
|
|
463
|
-
"maxPriorityFeePerGas": 0n,
|
|
464
|
-
"nonce": 0,
|
|
465
|
-
"nonceKey": 0n,
|
|
466
|
-
"signature": {
|
|
1083
|
+
"feeToken": null,
|
|
1084
|
+
"from": "0x740474977e01d056f04a314b5537e4dd88f35952",
|
|
1085
|
+
"gas": 47825n,
|
|
1086
|
+
"gasPrice": 10000000000n,
|
|
1087
|
+
"hash": "0xd8429515914095d1093e6cd0cace8a06890ed5a2e4e3c775f3196ec78b4fa75d",
|
|
1088
|
+
"maxFeePerBlobGas": undefined,
|
|
1089
|
+
"maxFeePerGas": 12000000000n,
|
|
1090
|
+
"maxPriorityFeePerGas": 0n,
|
|
1091
|
+
"nonce": 2,
|
|
1092
|
+
"nonceKey": 0n,
|
|
467
1093
|
"signature": {
|
|
468
|
-
"
|
|
469
|
-
|
|
1094
|
+
"signature": {
|
|
1095
|
+
"r": 3978685029830144709654747044848526179202245954092725489802520292215589805538n,
|
|
1096
|
+
"s": 13481864494883849326291583961518021266257348574613329487348338733748737047938n,
|
|
1097
|
+
"yParity": 1,
|
|
1098
|
+
},
|
|
1099
|
+
"type": "secp256k1",
|
|
1100
|
+
},
|
|
1101
|
+
"to": null,
|
|
1102
|
+
"transactionIndex": 1,
|
|
1103
|
+
"type": "aa",
|
|
1104
|
+
"typeHex": "0x76",
|
|
1105
|
+
"v": undefined,
|
|
1106
|
+
"validAfter": null,
|
|
1107
|
+
"validBefore": null,
|
|
1108
|
+
"value": 0n,
|
|
1109
|
+
"yParity": undefined,
|
|
1110
|
+
}
|
|
1111
|
+
`)
|
|
1112
|
+
})
|
|
1113
|
+
})
|
|
1114
|
+
|
|
1115
|
+
describe('p256', () => {
|
|
1116
|
+
test('default', async () => {
|
|
1117
|
+
const account = Account.fromP256(
|
|
1118
|
+
'0x1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b',
|
|
1119
|
+
)
|
|
1120
|
+
|
|
1121
|
+
const { receipt } = await client.fee.setUserTokenSync({
|
|
1122
|
+
account,
|
|
1123
|
+
feePayer: true,
|
|
1124
|
+
token: 1n,
|
|
1125
|
+
})
|
|
1126
|
+
|
|
1127
|
+
const userToken = await client.fee.getUserToken({ account })
|
|
1128
|
+
expect(userToken).toMatchInlineSnapshot(`
|
|
1129
|
+
{
|
|
1130
|
+
"address": "0x20C0000000000000000000000000000000000001",
|
|
1131
|
+
"id": 1n,
|
|
1132
|
+
}
|
|
1133
|
+
`)
|
|
1134
|
+
|
|
1135
|
+
const {
|
|
1136
|
+
blockHash: _,
|
|
1137
|
+
blockNumber: __,
|
|
1138
|
+
...transaction
|
|
1139
|
+
} = await client.getTransaction({ hash: receipt.transactionHash })
|
|
1140
|
+
|
|
1141
|
+
expect(transaction).toMatchInlineSnapshot(`
|
|
1142
|
+
{
|
|
1143
|
+
"aaAuthorizationList": [],
|
|
1144
|
+
"accessList": [],
|
|
1145
|
+
"authorizationList": undefined,
|
|
1146
|
+
"calls": [
|
|
1147
|
+
{
|
|
1148
|
+
"data": "0xe789744400000000000000000000000020c0000000000000000000000000000000000001",
|
|
1149
|
+
"to": "0xfeec000000000000000000000000000000000000",
|
|
1150
|
+
"value": 0n,
|
|
1151
|
+
},
|
|
1152
|
+
],
|
|
1153
|
+
"chainId": 1337,
|
|
1154
|
+
"data": undefined,
|
|
1155
|
+
"feePayer": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
|
|
1156
|
+
"feePayerSignature": {
|
|
1157
|
+
"r": "0x44507c3e9e4df1dff5f54ca012c69b2556e5395d9166b3b4594181e4e656a1cc",
|
|
1158
|
+
"s": "0x5ba80c21e194089173ffaed7c12a627f611d5fba846c84e2f6f83d55353f01d2",
|
|
1159
|
+
"v": 28n,
|
|
470
1160
|
"yParity": 1,
|
|
471
1161
|
},
|
|
472
|
-
"
|
|
1162
|
+
"feeToken": null,
|
|
1163
|
+
"from": "0x5f704c6c7075acd14ee36527f03b5b5dcb4a966f",
|
|
1164
|
+
"gas": 53231n,
|
|
1165
|
+
"gasPrice": 10000000000n,
|
|
1166
|
+
"hash": "0xb6848050598c30b26855673a029127a5532885dd44719894f0ac1c6ce380cffe",
|
|
1167
|
+
"maxFeePerBlobGas": undefined,
|
|
1168
|
+
"maxFeePerGas": 12000000000n,
|
|
1169
|
+
"maxPriorityFeePerGas": 0n,
|
|
1170
|
+
"nonce": 0,
|
|
1171
|
+
"nonceKey": 0n,
|
|
1172
|
+
"signature": {
|
|
1173
|
+
"prehash": undefined,
|
|
1174
|
+
"publicKey": {
|
|
1175
|
+
"prefix": 4,
|
|
1176
|
+
"x": 89768657165983002447270155621964907577955735922001002175265262336201091268103n,
|
|
1177
|
+
"y": 21692506528696391747937034302216251793515398807520467579078748804389014172835n,
|
|
1178
|
+
},
|
|
1179
|
+
"signature": {
|
|
1180
|
+
"r": 50668837405839025212455471714452555085562104168132337639876146018573466159747n,
|
|
1181
|
+
"s": 27497318506208669156329628613746311078142570431871623594260715714766657455474n,
|
|
1182
|
+
},
|
|
1183
|
+
"type": "p256",
|
|
1184
|
+
},
|
|
1185
|
+
"to": null,
|
|
1186
|
+
"transactionIndex": 1,
|
|
1187
|
+
"type": "aa",
|
|
1188
|
+
"typeHex": "0x76",
|
|
1189
|
+
"v": undefined,
|
|
1190
|
+
"validAfter": null,
|
|
1191
|
+
"validBefore": null,
|
|
1192
|
+
"value": 0n,
|
|
1193
|
+
"yParity": undefined,
|
|
1194
|
+
}
|
|
1195
|
+
`)
|
|
1196
|
+
})
|
|
1197
|
+
})
|
|
1198
|
+
|
|
1199
|
+
describe('webcrypto', () => {
|
|
1200
|
+
test('default', async () => {
|
|
1201
|
+
const keyPair = await WebCryptoP256.createKeyPair()
|
|
1202
|
+
const account = Account.fromWebCryptoP256(keyPair)
|
|
1203
|
+
|
|
1204
|
+
const { receipt } = await client.fee.setUserTokenSync({
|
|
1205
|
+
account,
|
|
1206
|
+
feePayer: true,
|
|
1207
|
+
token: 1n,
|
|
1208
|
+
})
|
|
1209
|
+
|
|
1210
|
+
const userToken = await client.fee.getUserToken({ account })
|
|
1211
|
+
expect(userToken).toMatchInlineSnapshot(`
|
|
1212
|
+
{
|
|
1213
|
+
"address": "0x20C0000000000000000000000000000000000001",
|
|
1214
|
+
"id": 1n,
|
|
1215
|
+
}
|
|
1216
|
+
`)
|
|
1217
|
+
|
|
1218
|
+
const transaction = await client.getTransaction({
|
|
1219
|
+
hash: receipt.transactionHash,
|
|
1220
|
+
})
|
|
1221
|
+
expect(transaction).toBeDefined()
|
|
1222
|
+
})
|
|
1223
|
+
})
|
|
1224
|
+
|
|
1225
|
+
describe('webAuthn', () => {
|
|
1226
|
+
test('default', async () => {
|
|
1227
|
+
const account = Account.fromHeadlessWebAuthn(
|
|
1228
|
+
'0x1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b',
|
|
1229
|
+
{
|
|
1230
|
+
rpId: 'localhost',
|
|
1231
|
+
origin: 'http://localhost',
|
|
473
1232
|
},
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
1233
|
+
)
|
|
1234
|
+
|
|
1235
|
+
const { receipt } = await client.fee.setUserTokenSync({
|
|
1236
|
+
account,
|
|
1237
|
+
feePayer: true,
|
|
1238
|
+
token: 1n,
|
|
1239
|
+
})
|
|
1240
|
+
|
|
1241
|
+
const userToken = await client.fee.getUserToken({ account })
|
|
1242
|
+
expect(userToken).toMatchInlineSnapshot(`
|
|
1243
|
+
{
|
|
1244
|
+
"address": "0x20C0000000000000000000000000000000000001",
|
|
1245
|
+
"id": 1n,
|
|
1246
|
+
}
|
|
1247
|
+
`)
|
|
1248
|
+
|
|
1249
|
+
const {
|
|
1250
|
+
blockHash: _,
|
|
1251
|
+
blockNumber: __,
|
|
1252
|
+
...transaction
|
|
1253
|
+
} = await client.getTransaction({ hash: receipt.transactionHash })
|
|
1254
|
+
|
|
1255
|
+
expect(transaction).toMatchInlineSnapshot(`
|
|
1256
|
+
{
|
|
1257
|
+
"aaAuthorizationList": [],
|
|
1258
|
+
"accessList": [],
|
|
1259
|
+
"authorizationList": undefined,
|
|
1260
|
+
"calls": [
|
|
1261
|
+
{
|
|
1262
|
+
"data": "0xe789744400000000000000000000000020c0000000000000000000000000000000000001",
|
|
1263
|
+
"to": "0xfeec000000000000000000000000000000000000",
|
|
1264
|
+
"value": 0n,
|
|
1265
|
+
},
|
|
1266
|
+
],
|
|
1267
|
+
"chainId": 1337,
|
|
1268
|
+
"data": undefined,
|
|
1269
|
+
"feePayer": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
|
|
1270
|
+
"feePayerSignature": {
|
|
1271
|
+
"r": "0xc4446d8fe8fa3341d1f004cf5d54fd30ce3079909d26d8a2878ba95b7b9eec2d",
|
|
1272
|
+
"s": "0x3dbe6bcd56aafcff58b0faad331ac8339389cad60b42e82cdccd23f67e1f82c8",
|
|
1273
|
+
"v": 27n,
|
|
1274
|
+
"yParity": 0,
|
|
1275
|
+
},
|
|
1276
|
+
"feeToken": null,
|
|
1277
|
+
"from": "0x5f704c6c7075acd14ee36527f03b5b5dcb4a966f",
|
|
1278
|
+
"gas": 65648n,
|
|
1279
|
+
"gasPrice": 10000000000n,
|
|
1280
|
+
"hash": "0x279ae834209d6df5bded3c96bf5c74671cb34ef7b041b262cab97085d471f6f4",
|
|
1281
|
+
"maxFeePerBlobGas": undefined,
|
|
1282
|
+
"maxFeePerGas": 12000000000n,
|
|
1283
|
+
"maxPriorityFeePerGas": 0n,
|
|
1284
|
+
"nonce": 0,
|
|
1285
|
+
"nonceKey": 0n,
|
|
1286
|
+
"signature": {
|
|
1287
|
+
"metadata": {
|
|
1288
|
+
"authenticatorData": "0x49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630500000000",
|
|
1289
|
+
"clientDataJSON": "{"type":"webauthn.get","challenge":"v8tl8bzz9Csc1GJFeUfNTnjOLM03xPTSseTVmPjPgGU","origin":"http://localhost","crossOrigin":false}",
|
|
1290
|
+
},
|
|
1291
|
+
"publicKey": {
|
|
1292
|
+
"prefix": 4,
|
|
1293
|
+
"x": 89768657165983002447270155621964907577955735922001002175265262336201091268103n,
|
|
1294
|
+
"y": 21692506528696391747937034302216251793515398807520467579078748804389014172835n,
|
|
1295
|
+
},
|
|
1296
|
+
"signature": {
|
|
1297
|
+
"r": 58941397289082666235265603710597281523077712128054003324346038713355012809744n,
|
|
1298
|
+
"s": 40774536608463041714947524596466110685374802167796811824221384869265764799570n,
|
|
1299
|
+
},
|
|
1300
|
+
"type": "webAuthn",
|
|
1301
|
+
},
|
|
1302
|
+
"to": null,
|
|
1303
|
+
"transactionIndex": 1,
|
|
1304
|
+
"type": "aa",
|
|
1305
|
+
"typeHex": "0x76",
|
|
1306
|
+
"v": undefined,
|
|
1307
|
+
"validAfter": null,
|
|
1308
|
+
"validBefore": null,
|
|
1309
|
+
"value": 0n,
|
|
1310
|
+
"yParity": undefined,
|
|
1311
|
+
}
|
|
1312
|
+
`)
|
|
1313
|
+
})
|
|
485
1314
|
})
|
|
486
1315
|
})
|