tempo.ts 0.0.0 → 0.0.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 +92 -0
- package/dist/chains.d.ts +1477 -0
- package/dist/chains.d.ts.map +1 -0
- package/dist/chains.js +43 -0
- package/dist/chains.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/types.d.ts +284 -0
- package/dist/internal/types.d.ts.map +1 -0
- package/dist/internal/types.js +2 -0
- package/dist/internal/types.js.map +1 -0
- package/dist/ox/TokenId.d.ts +18 -0
- package/dist/ox/TokenId.d.ts.map +1 -0
- package/dist/ox/TokenId.js +29 -0
- package/dist/ox/TokenId.js.map +1 -0
- package/dist/ox/TokenRole.d.ts +11 -0
- package/dist/ox/TokenRole.d.ts.map +1 -0
- package/dist/ox/TokenRole.js +22 -0
- package/dist/ox/TokenRole.js.map +1 -0
- package/dist/ox/Transaction.d.ts +161 -0
- package/dist/ox/Transaction.d.ts.map +1 -0
- package/dist/ox/Transaction.js +117 -0
- package/dist/ox/Transaction.js.map +1 -0
- package/dist/ox/TransactionEnvelopeFeeToken.d.ts +393 -0
- package/dist/ox/TransactionEnvelopeFeeToken.d.ts.map +1 -0
- package/dist/ox/TransactionEnvelopeFeeToken.js +452 -0
- package/dist/ox/TransactionEnvelopeFeeToken.js.map +1 -0
- package/dist/ox/TransactionRequest.d.ts +62 -0
- package/dist/ox/TransactionRequest.d.ts.map +1 -0
- package/dist/ox/TransactionRequest.js +66 -0
- package/dist/ox/TransactionRequest.js.map +1 -0
- package/dist/ox/index.d.ts +5 -0
- package/dist/ox/index.d.ts.map +1 -0
- package/dist/ox/index.js +5 -0
- package/dist/ox/index.js.map +1 -0
- package/dist/prool/Instance.d.ts +92 -0
- package/dist/prool/Instance.d.ts.map +1 -0
- package/dist/prool/Instance.js +96 -0
- package/dist/prool/Instance.js.map +1 -0
- package/dist/prool/index.d.ts +2 -0
- package/dist/prool/index.d.ts.map +1 -0
- package/dist/prool/index.js +2 -0
- package/dist/prool/index.js.map +1 -0
- package/dist/viem/abis.d.ts +2058 -0
- package/dist/viem/abis.d.ts.map +1 -0
- package/dist/viem/abis.js +1599 -0
- package/dist/viem/abis.js.map +1 -0
- package/dist/viem/actions/amm.d.ts +2091 -0
- package/dist/viem/actions/amm.d.ts.map +1 -0
- package/dist/viem/actions/amm.js +876 -0
- package/dist/viem/actions/amm.js.map +1 -0
- package/dist/viem/actions/fee.d.ts +727 -0
- package/dist/viem/actions/fee.d.ts.map +1 -0
- package/dist/viem/actions/fee.js +230 -0
- package/dist/viem/actions/fee.js.map +1 -0
- package/dist/viem/actions/index.d.ts +5 -0
- package/dist/viem/actions/index.d.ts.map +1 -0
- package/dist/viem/actions/index.js +5 -0
- package/dist/viem/actions/index.js.map +1 -0
- package/dist/viem/actions/policy.d.ts +1900 -0
- package/dist/viem/actions/policy.d.ts.map +1 -0
- package/dist/viem/actions/policy.js +841 -0
- package/dist/viem/actions/policy.js.map +1 -0
- package/dist/viem/actions/token.d.ts +13759 -0
- package/dist/viem/actions/token.d.ts.map +1 -0
- package/dist/viem/actions/token.js +2579 -0
- package/dist/viem/actions/token.js.map +1 -0
- package/dist/viem/addresses.d.ts +8 -0
- package/dist/viem/addresses.d.ts.map +1 -0
- package/dist/viem/addresses.js +8 -0
- package/dist/viem/addresses.js.map +1 -0
- package/dist/viem/chain.d.ts +341 -0
- package/dist/viem/chain.d.ts.map +1 -0
- package/dist/viem/chain.js +22 -0
- package/dist/viem/chain.js.map +1 -0
- package/dist/viem/client.d.ts +27 -0
- package/dist/viem/client.d.ts.map +1 -0
- package/dist/viem/client.js +28 -0
- package/dist/viem/client.js.map +1 -0
- package/dist/viem/decorator.d.ts +1636 -0
- package/dist/viem/decorator.d.ts.map +1 -0
- package/dist/viem/decorator.js +95 -0
- package/dist/viem/decorator.js.map +1 -0
- package/dist/viem/formatters.d.ts +4 -0
- package/dist/viem/formatters.d.ts.map +1 -0
- package/dist/viem/formatters.js +69 -0
- package/dist/viem/formatters.js.map +1 -0
- package/dist/viem/index.d.ts +9 -0
- package/dist/viem/index.d.ts.map +1 -0
- package/dist/viem/index.js +9 -0
- package/dist/viem/index.js.map +1 -0
- package/dist/viem/transaction.d.ts +54 -0
- package/dist/viem/transaction.d.ts.map +1 -0
- package/dist/viem/transaction.js +108 -0
- package/dist/viem/transaction.js.map +1 -0
- package/dist/viem/transport.d.ts +16 -0
- package/dist/viem/transport.d.ts.map +1 -0
- package/dist/viem/transport.js +33 -0
- package/dist/viem/transport.js.map +1 -0
- package/dist/viem/types.d.ts +10 -0
- package/dist/viem/types.d.ts.map +1 -0
- package/dist/viem/types.js +2 -0
- package/dist/viem/types.js.map +1 -0
- package/dist/viem/utils.d.ts +8 -0
- package/dist/viem/utils.d.ts.map +1 -0
- package/dist/viem/utils.js +9 -0
- package/dist/viem/utils.js.map +1 -0
- package/package.json +100 -2
- package/src/chains.ts +46 -0
- package/src/index.ts +1 -0
- package/src/internal/types.ts +414 -0
- package/src/ox/TokenId.test.ts +29 -0
- package/src/ox/TokenId.ts +35 -0
- package/src/ox/TokenRole.test.ts +20 -0
- package/src/ox/TokenRole.ts +27 -0
- package/src/ox/Transaction.test.ts +257 -0
- package/src/ox/Transaction.ts +247 -0
- package/src/ox/TransactionEnvelopeFeeToken.test.ts +1215 -0
- package/src/ox/TransactionEnvelopeFeeToken.ts +717 -0
- package/src/ox/TransactionRequest.ts +100 -0
- package/src/ox/index.ts +4 -0
- package/src/prool/Instance.test.ts +43 -0
- package/src/prool/Instance.ts +190 -0
- package/src/prool/index.ts +1 -0
- package/src/prool/internal/chain.json +106 -0
- package/src/prool/internal/consensus.toml +32 -0
- package/src/viem/abis.ts +1606 -0
- package/src/viem/actions/amm.test.ts +425 -0
- package/src/viem/actions/amm.ts +1308 -0
- package/src/viem/actions/fee.test.ts +281 -0
- package/src/viem/actions/fee.ts +362 -0
- package/src/viem/actions/index.ts +4 -0
- package/src/viem/actions/policy.test.ts +514 -0
- package/src/viem/actions/policy.ts +1284 -0
- package/src/viem/actions/token.test.ts +2172 -0
- package/src/viem/actions/token.ts +3830 -0
- package/src/viem/addresses.ts +10 -0
- package/src/viem/chain.ts +27 -0
- package/src/viem/client.bench-d.ts +8 -0
- package/src/viem/client.test.ts +152 -0
- package/src/viem/client.ts +91 -0
- package/src/viem/decorator.bench-d.ts +11 -0
- package/src/viem/decorator.test.ts +35 -0
- package/src/viem/decorator.ts +1914 -0
- package/src/viem/e2e.test.ts +410 -0
- package/src/viem/formatters.ts +100 -0
- package/src/viem/index.ts +8 -0
- package/src/viem/transaction.ts +253 -0
- package/src/viem/transport.ts +47 -0
- package/src/viem/types.ts +55 -0
- package/src/viem/utils.ts +37 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { Transaction } from 'tempo.ts/ox'
|
|
2
|
+
import { describe, expect, test } from 'vitest'
|
|
3
|
+
|
|
4
|
+
describe('fromRpc', () => {
|
|
5
|
+
test('default', () => {
|
|
6
|
+
const transaction = Transaction.fromRpc({
|
|
7
|
+
accessList: [],
|
|
8
|
+
authorizationList: [],
|
|
9
|
+
maxFeePerGas: '0x2',
|
|
10
|
+
maxPriorityFeePerGas: '0x1',
|
|
11
|
+
hash: '0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0',
|
|
12
|
+
nonce: '0x357',
|
|
13
|
+
blockHash:
|
|
14
|
+
'0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b',
|
|
15
|
+
blockNumber: '0x12f296f',
|
|
16
|
+
transactionIndex: '0x2',
|
|
17
|
+
feeToken: '0x20c0000000000000000000000000000000000000',
|
|
18
|
+
from: '0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6',
|
|
19
|
+
to: '0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad',
|
|
20
|
+
value: '0x9b6e64a8ec60000',
|
|
21
|
+
gas: '0x43f5d',
|
|
22
|
+
gasPrice: '0x2ca6ae494',
|
|
23
|
+
input:
|
|
24
|
+
'0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000006643504700000000000000000000000000000000000000000000000000000000000000040b080604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec600000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec60000000000000000000000000000000000000000000000000000019124bb5ae978c000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b80000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b8000000000000000000000000000000fee13a103a10d593b9ae06b3e05f2e7e1c00000000000000000000000000000000000000000000000000000000000000190000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b800000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000190240001b9872b',
|
|
25
|
+
r: '0x635dc2033e60185bb36709c29c75d64ea51dfbd91c32ef4be198e4ceb169fb4d',
|
|
26
|
+
s: '0x50c2667ac4c771072746acfdcf1f1483336dcca8bd2df47cd83175dbe60f0540',
|
|
27
|
+
v: '0x0',
|
|
28
|
+
yParity: '0x0',
|
|
29
|
+
chainId: '0x1',
|
|
30
|
+
type: '0x77',
|
|
31
|
+
})
|
|
32
|
+
expect(transaction).toMatchInlineSnapshot(`
|
|
33
|
+
{
|
|
34
|
+
"accessList": [],
|
|
35
|
+
"authorizationList": [],
|
|
36
|
+
"blockHash": "0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b",
|
|
37
|
+
"blockNumber": 19868015n,
|
|
38
|
+
"chainId": 1,
|
|
39
|
+
"data": "0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000006643504700000000000000000000000000000000000000000000000000000000000000040b080604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec600000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec60000000000000000000000000000000000000000000000000000019124bb5ae978c000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b80000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b8000000000000000000000000000000fee13a103a10d593b9ae06b3e05f2e7e1c00000000000000000000000000000000000000000000000000000000000000190000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b800000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000190240001b9872b",
|
|
40
|
+
"feeToken": "0x20c0000000000000000000000000000000000000",
|
|
41
|
+
"from": "0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6",
|
|
42
|
+
"gas": 278365n,
|
|
43
|
+
"gasPrice": 11985937556n,
|
|
44
|
+
"hash": "0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0",
|
|
45
|
+
"input": "0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000006643504700000000000000000000000000000000000000000000000000000000000000040b080604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec600000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec60000000000000000000000000000000000000000000000000000019124bb5ae978c000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b80000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b8000000000000000000000000000000fee13a103a10d593b9ae06b3e05f2e7e1c00000000000000000000000000000000000000000000000000000000000000190000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b800000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000190240001b9872b",
|
|
46
|
+
"maxFeePerGas": 2n,
|
|
47
|
+
"maxPriorityFeePerGas": 1n,
|
|
48
|
+
"nonce": 855n,
|
|
49
|
+
"r": 44944627813007772897391531230081695102703289123332187696115181104739239197517n,
|
|
50
|
+
"s": 36528503505192438307355164441104001310566505351980369085208178712678799181120n,
|
|
51
|
+
"to": "0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad",
|
|
52
|
+
"transactionIndex": 2,
|
|
53
|
+
"type": "feeToken",
|
|
54
|
+
"v": 27,
|
|
55
|
+
"value": 700000000000000000n,
|
|
56
|
+
"yParity": 0,
|
|
57
|
+
}
|
|
58
|
+
`)
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
test('with feePayerSignature', () => {
|
|
62
|
+
const transaction = Transaction.fromRpc({
|
|
63
|
+
accessList: [],
|
|
64
|
+
authorizationList: [],
|
|
65
|
+
maxFeePerGas: '0x2',
|
|
66
|
+
maxPriorityFeePerGas: '0x1',
|
|
67
|
+
hash: '0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0',
|
|
68
|
+
nonce: '0x357',
|
|
69
|
+
blockHash:
|
|
70
|
+
'0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b',
|
|
71
|
+
blockNumber: '0x12f296f',
|
|
72
|
+
transactionIndex: '0x2',
|
|
73
|
+
feeToken: '0x20c0000000000000000000000000000000000000',
|
|
74
|
+
feePayerSignature: {
|
|
75
|
+
r: '0x12f4d9e9924f62b19de816252efc125006298f43e62d394151e62600e2c2f91e',
|
|
76
|
+
s: '0x31daa78bb3e95dd22f6370e59617c60d109bf28e55c92b25994ddbed420e2a80',
|
|
77
|
+
v: '0x0',
|
|
78
|
+
yParity: '0x0',
|
|
79
|
+
},
|
|
80
|
+
from: '0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6',
|
|
81
|
+
to: '0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad',
|
|
82
|
+
value: '0x9b6e64a8ec60000',
|
|
83
|
+
gas: '0x43f5d',
|
|
84
|
+
gasPrice: '0x2ca6ae494',
|
|
85
|
+
input:
|
|
86
|
+
'0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000006643504700000000000000000000000000000000000000000000000000000000000000040b080604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec600000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec60000000000000000000000000000000000000000000000000000019124bb5ae978c000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b80000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b8000000000000000000000000000000fee13a103a10d593b9ae06b3e05f2e7e1c00000000000000000000000000000000000000000000000000000000000000190000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b800000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000190240001b9872b',
|
|
87
|
+
r: '0x635dc2033e60185bb36709c29c75d64ea51dfbd91c32ef4be198e4ceb169fb4d',
|
|
88
|
+
s: '0x50c2667ac4c771072746acfdcf1f1483336dcca8bd2df47cd83175dbe60f0540',
|
|
89
|
+
v: '0x0',
|
|
90
|
+
yParity: '0x0',
|
|
91
|
+
chainId: '0x1',
|
|
92
|
+
type: '0x77',
|
|
93
|
+
})
|
|
94
|
+
expect(transaction).toMatchInlineSnapshot(`
|
|
95
|
+
{
|
|
96
|
+
"accessList": [],
|
|
97
|
+
"authorizationList": [],
|
|
98
|
+
"blockHash": "0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b",
|
|
99
|
+
"blockNumber": 19868015n,
|
|
100
|
+
"chainId": 1,
|
|
101
|
+
"data": "0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000006643504700000000000000000000000000000000000000000000000000000000000000040b080604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec600000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec60000000000000000000000000000000000000000000000000000019124bb5ae978c000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b80000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b8000000000000000000000000000000fee13a103a10d593b9ae06b3e05f2e7e1c00000000000000000000000000000000000000000000000000000000000000190000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b800000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000190240001b9872b",
|
|
102
|
+
"feePayer": "0x65c6b18ab472711077b9860bd00a835d51a30380",
|
|
103
|
+
"feePayerSignature": {
|
|
104
|
+
"r": 8574245934337799659042750864278046211314109527666697413298781631396794530078n,
|
|
105
|
+
"s": 22549658598721143185960614158212618570884225122794367192341714237232002247296n,
|
|
106
|
+
"v": 27,
|
|
107
|
+
"yParity": 0,
|
|
108
|
+
},
|
|
109
|
+
"feeToken": "0x20c0000000000000000000000000000000000000",
|
|
110
|
+
"from": "0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6",
|
|
111
|
+
"gas": 278365n,
|
|
112
|
+
"gasPrice": 11985937556n,
|
|
113
|
+
"hash": "0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0",
|
|
114
|
+
"input": "0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000006643504700000000000000000000000000000000000000000000000000000000000000040b080604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec600000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec60000000000000000000000000000000000000000000000000000019124bb5ae978c000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b80000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b8000000000000000000000000000000fee13a103a10d593b9ae06b3e05f2e7e1c00000000000000000000000000000000000000000000000000000000000000190000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b800000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000190240001b9872b",
|
|
115
|
+
"maxFeePerGas": 2n,
|
|
116
|
+
"maxPriorityFeePerGas": 1n,
|
|
117
|
+
"nonce": 855n,
|
|
118
|
+
"r": 44944627813007772897391531230081695102703289123332187696115181104739239197517n,
|
|
119
|
+
"s": 36528503505192438307355164441104001310566505351980369085208178712678799181120n,
|
|
120
|
+
"to": "0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad",
|
|
121
|
+
"transactionIndex": 2,
|
|
122
|
+
"type": "feeToken",
|
|
123
|
+
"v": 27,
|
|
124
|
+
"value": 700000000000000000n,
|
|
125
|
+
"yParity": 0,
|
|
126
|
+
}
|
|
127
|
+
`)
|
|
128
|
+
})
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
describe('toRpc', () => {
|
|
132
|
+
test('default', () => {
|
|
133
|
+
const transaction = Transaction.toRpc({
|
|
134
|
+
accessList: [],
|
|
135
|
+
authorizationList: [],
|
|
136
|
+
blockHash:
|
|
137
|
+
'0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b',
|
|
138
|
+
blockNumber: 19868015n,
|
|
139
|
+
chainId: 1,
|
|
140
|
+
data: '0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000006643504700000000000000000000000000000000000000000000000000000000000000040b080604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec600000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec60000000000000000000000000000000000000000000000000000019124bb5ae978c000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b80000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b8000000000000000000000000000000fee13a103a10d593b9ae06b3e05f2e7e1c00000000000000000000000000000000000000000000000000000000000000190000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b800000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000190240001b9872b',
|
|
141
|
+
feeToken: '0x20c0000000000000000000000000000000000000',
|
|
142
|
+
from: '0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6',
|
|
143
|
+
gas: 278365n,
|
|
144
|
+
gasPrice: 11985937556n,
|
|
145
|
+
hash: '0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0',
|
|
146
|
+
input:
|
|
147
|
+
'0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000006643504700000000000000000000000000000000000000000000000000000000000000040b080604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec600000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec60000000000000000000000000000000000000000000000000000019124bb5ae978c000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b80000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b8000000000000000000000000000000fee13a103a10d593b9ae06b3e05f2e7e1c00000000000000000000000000000000000000000000000000000000000000190000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b800000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000190240001b9872b',
|
|
148
|
+
maxFeePerGas: 2n,
|
|
149
|
+
maxPriorityFeePerGas: 1n,
|
|
150
|
+
nonce: 855n,
|
|
151
|
+
r: 44944627813007772897391531230081695102703289123332187696115181104739239197517n,
|
|
152
|
+
s: 36528503505192438307355164441104001310566505351980369085208178712678799181120n,
|
|
153
|
+
to: '0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad',
|
|
154
|
+
transactionIndex: 2,
|
|
155
|
+
type: 'feeToken',
|
|
156
|
+
v: 27,
|
|
157
|
+
value: 700000000000000000n,
|
|
158
|
+
yParity: 0,
|
|
159
|
+
})
|
|
160
|
+
expect(transaction).toMatchInlineSnapshot(`
|
|
161
|
+
{
|
|
162
|
+
"accessList": [],
|
|
163
|
+
"authorizationList": [],
|
|
164
|
+
"blockHash": "0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b",
|
|
165
|
+
"blockNumber": "0x12f296f",
|
|
166
|
+
"chainId": "0x1",
|
|
167
|
+
"feeToken": "0x20c0000000000000000000000000000000000000",
|
|
168
|
+
"from": "0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6",
|
|
169
|
+
"gas": "0x43f5d",
|
|
170
|
+
"gasPrice": "0x2ca6ae494",
|
|
171
|
+
"hash": "0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0",
|
|
172
|
+
"input": "0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000006643504700000000000000000000000000000000000000000000000000000000000000040b080604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec600000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec60000000000000000000000000000000000000000000000000000019124bb5ae978c000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b80000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b8000000000000000000000000000000fee13a103a10d593b9ae06b3e05f2e7e1c00000000000000000000000000000000000000000000000000000000000000190000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b800000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000190240001b9872b",
|
|
173
|
+
"maxFeePerGas": "0x2",
|
|
174
|
+
"maxPriorityFeePerGas": "0x1",
|
|
175
|
+
"nonce": "0x357",
|
|
176
|
+
"r": "0x635dc2033e60185bb36709c29c75d64ea51dfbd91c32ef4be198e4ceb169fb4d",
|
|
177
|
+
"s": "0x50c2667ac4c771072746acfdcf1f1483336dcca8bd2df47cd83175dbe60f0540",
|
|
178
|
+
"to": "0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad",
|
|
179
|
+
"transactionIndex": "0x2",
|
|
180
|
+
"type": "0x77",
|
|
181
|
+
"v": "0x1b",
|
|
182
|
+
"value": "0x9b6e64a8ec60000",
|
|
183
|
+
"yParity": "0x0",
|
|
184
|
+
}
|
|
185
|
+
`)
|
|
186
|
+
})
|
|
187
|
+
|
|
188
|
+
test('default', () => {
|
|
189
|
+
const transaction = Transaction.toRpc({
|
|
190
|
+
accessList: [],
|
|
191
|
+
authorizationList: [],
|
|
192
|
+
blockHash:
|
|
193
|
+
'0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b',
|
|
194
|
+
blockNumber: 19868015n,
|
|
195
|
+
chainId: 1,
|
|
196
|
+
data: '0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000006643504700000000000000000000000000000000000000000000000000000000000000040b080604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec600000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec60000000000000000000000000000000000000000000000000000019124bb5ae978c000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b80000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b8000000000000000000000000000000fee13a103a10d593b9ae06b3e05f2e7e1c00000000000000000000000000000000000000000000000000000000000000190000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b800000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000190240001b9872b',
|
|
197
|
+
feePayer: '0x18ff045b61748c6f0e6a0412a6ccc8690e5bf9aa',
|
|
198
|
+
feePayerSignature: {
|
|
199
|
+
r: 8574245934337799659042750864278046211314109527666697413298781631396794530078n,
|
|
200
|
+
s: 22549658598721143185960614158212618570884225122794367192341714237232002247296n,
|
|
201
|
+
v: 27,
|
|
202
|
+
yParity: 0,
|
|
203
|
+
},
|
|
204
|
+
feeToken: '0x20c0000000000000000000000000000000000000',
|
|
205
|
+
from: '0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6',
|
|
206
|
+
gas: 278365n,
|
|
207
|
+
gasPrice: 11985937556n,
|
|
208
|
+
hash: '0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0',
|
|
209
|
+
input:
|
|
210
|
+
'0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000006643504700000000000000000000000000000000000000000000000000000000000000040b080604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec600000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec60000000000000000000000000000000000000000000000000000019124bb5ae978c000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b80000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b8000000000000000000000000000000fee13a103a10d593b9ae06b3e05f2e7e1c00000000000000000000000000000000000000000000000000000000000000190000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b800000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000190240001b9872b',
|
|
211
|
+
maxFeePerGas: 2n,
|
|
212
|
+
maxPriorityFeePerGas: 1n,
|
|
213
|
+
nonce: 855n,
|
|
214
|
+
r: 44944627813007772897391531230081695102703289123332187696115181104739239197517n,
|
|
215
|
+
s: 36528503505192438307355164441104001310566505351980369085208178712678799181120n,
|
|
216
|
+
to: '0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad',
|
|
217
|
+
transactionIndex: 2,
|
|
218
|
+
type: 'feeToken',
|
|
219
|
+
v: 27,
|
|
220
|
+
value: 700000000000000000n,
|
|
221
|
+
yParity: 0,
|
|
222
|
+
})
|
|
223
|
+
expect(transaction).toMatchInlineSnapshot(`
|
|
224
|
+
{
|
|
225
|
+
"accessList": [],
|
|
226
|
+
"authorizationList": [],
|
|
227
|
+
"blockHash": "0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b",
|
|
228
|
+
"blockNumber": "0x12f296f",
|
|
229
|
+
"chainId": "0x1",
|
|
230
|
+
"feePayer": "0x18ff045b61748c6f0e6a0412a6ccc8690e5bf9aa",
|
|
231
|
+
"feePayerSignature": {
|
|
232
|
+
"r": "0x12f4d9e9924f62b19de816252efc125006298f43e62d394151e62600e2c2f91e",
|
|
233
|
+
"s": "0x31daa78bb3e95dd22f6370e59617c60d109bf28e55c92b25994ddbed420e2a80",
|
|
234
|
+
"v": "0x1b",
|
|
235
|
+
"yParity": "0x0",
|
|
236
|
+
},
|
|
237
|
+
"feeToken": "0x20c0000000000000000000000000000000000000",
|
|
238
|
+
"from": "0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6",
|
|
239
|
+
"gas": "0x43f5d",
|
|
240
|
+
"gasPrice": "0x2ca6ae494",
|
|
241
|
+
"hash": "0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0",
|
|
242
|
+
"input": "0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000006643504700000000000000000000000000000000000000000000000000000000000000040b080604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec600000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec60000000000000000000000000000000000000000000000000000019124bb5ae978c000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b80000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b8000000000000000000000000000000fee13a103a10d593b9ae06b3e05f2e7e1c00000000000000000000000000000000000000000000000000000000000000190000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b800000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000190240001b9872b",
|
|
243
|
+
"maxFeePerGas": "0x2",
|
|
244
|
+
"maxPriorityFeePerGas": "0x1",
|
|
245
|
+
"nonce": "0x357",
|
|
246
|
+
"r": "0x635dc2033e60185bb36709c29c75d64ea51dfbd91c32ef4be198e4ceb169fb4d",
|
|
247
|
+
"s": "0x50c2667ac4c771072746acfdcf1f1483336dcca8bd2df47cd83175dbe60f0540",
|
|
248
|
+
"to": "0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad",
|
|
249
|
+
"transactionIndex": "0x2",
|
|
250
|
+
"type": "0x77",
|
|
251
|
+
"v": "0x1b",
|
|
252
|
+
"value": "0x9b6e64a8ec60000",
|
|
253
|
+
"yParity": "0x0",
|
|
254
|
+
}
|
|
255
|
+
`)
|
|
256
|
+
})
|
|
257
|
+
})
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import type * as AccessList from 'ox/AccessList'
|
|
2
|
+
import type * as Address from 'ox/Address'
|
|
3
|
+
import type * as Authorization from 'ox/Authorization'
|
|
4
|
+
import type * as Errors from 'ox/Errors'
|
|
5
|
+
import * as Hex from 'ox/Hex'
|
|
6
|
+
import * as Secp256k1 from 'ox/Secp256k1'
|
|
7
|
+
import * as Signature from 'ox/Signature'
|
|
8
|
+
import * as ox_Transaction from 'ox/Transaction'
|
|
9
|
+
import type { Compute, OneOf, UnionCompute } from '../internal/types.js'
|
|
10
|
+
import * as TransactionEnvelopeFeeToken from './TransactionEnvelopeFeeToken.js'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A Transaction as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/transaction.yaml).
|
|
14
|
+
*/
|
|
15
|
+
export type Transaction<
|
|
16
|
+
pending extends boolean = false,
|
|
17
|
+
bigintType = bigint,
|
|
18
|
+
numberType = number,
|
|
19
|
+
> = UnionCompute<
|
|
20
|
+
OneOf<
|
|
21
|
+
| FeeToken<pending, bigintType, numberType>
|
|
22
|
+
| ox_Transaction.Transaction<pending, bigintType, numberType>
|
|
23
|
+
>
|
|
24
|
+
>
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* An RPC Transaction as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/transaction.yaml).
|
|
28
|
+
*/
|
|
29
|
+
export type Rpc<pending extends boolean = false> = UnionCompute<
|
|
30
|
+
OneOf<FeeTokenRpc<pending> | ox_Transaction.Rpc<pending>>
|
|
31
|
+
>
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Fee token transaction.
|
|
35
|
+
*/
|
|
36
|
+
export type FeeToken<
|
|
37
|
+
pending extends boolean = false,
|
|
38
|
+
bigintType = bigint,
|
|
39
|
+
numberType = number,
|
|
40
|
+
type extends string = 'feeToken',
|
|
41
|
+
> = Compute<
|
|
42
|
+
ox_Transaction.Base<type, pending, bigintType, numberType> & {
|
|
43
|
+
/** EIP-2930 Access List. */
|
|
44
|
+
accessList: AccessList.AccessList
|
|
45
|
+
/** EIP-7702 Authorization list for the transaction. */
|
|
46
|
+
authorizationList: Authorization.ListSigned<bigintType, numberType>
|
|
47
|
+
/** Fee token preference. */
|
|
48
|
+
feeToken: Address.Address
|
|
49
|
+
/** Fee payer address. */
|
|
50
|
+
feePayer?: Address.Address | undefined
|
|
51
|
+
/** Fee payer signature. */
|
|
52
|
+
feePayerSignature?:
|
|
53
|
+
| {
|
|
54
|
+
/** ECDSA signature r. */
|
|
55
|
+
r: bigintType
|
|
56
|
+
/** ECDSA signature s. */
|
|
57
|
+
s: bigintType
|
|
58
|
+
/** ECDSA signature yParity. */
|
|
59
|
+
yParity: numberType
|
|
60
|
+
/** @deprecated ECDSA signature v (for backwards compatibility). */
|
|
61
|
+
v?: numberType | undefined
|
|
62
|
+
}
|
|
63
|
+
| undefined
|
|
64
|
+
/** Effective gas price paid by the sender in wei. */
|
|
65
|
+
gasPrice?: bigintType | undefined
|
|
66
|
+
/** Total fee per gas in wei (gasPrice/baseFeePerGas + maxPriorityFeePerGas). */
|
|
67
|
+
maxFeePerGas: bigintType
|
|
68
|
+
/** Max priority fee per gas (in wei). */
|
|
69
|
+
maxPriorityFeePerGas: bigintType
|
|
70
|
+
}
|
|
71
|
+
>
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Fee token transaction in RPC format.
|
|
75
|
+
*/
|
|
76
|
+
export type FeeTokenRpc<pending extends boolean = false> = Compute<
|
|
77
|
+
FeeToken<pending, Hex.Hex, Hex.Hex, ToRpcType['feeToken']>
|
|
78
|
+
>
|
|
79
|
+
|
|
80
|
+
/** Type to RPC Type mapping. */
|
|
81
|
+
export const toRpcType = {
|
|
82
|
+
...ox_Transaction.toRpcType,
|
|
83
|
+
feeToken: '0x77',
|
|
84
|
+
} as const
|
|
85
|
+
|
|
86
|
+
/** Type to RPC Type mapping. */
|
|
87
|
+
export type ToRpcType = typeof toRpcType & {
|
|
88
|
+
[type: string]: `0x${string}`
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** RPC Type to Type mapping. */
|
|
92
|
+
export const fromRpcType = {
|
|
93
|
+
...ox_Transaction.fromRpcType,
|
|
94
|
+
'0x77': 'feeToken',
|
|
95
|
+
} as const
|
|
96
|
+
|
|
97
|
+
/** RPC Type to Type mapping. */
|
|
98
|
+
|
|
99
|
+
export type FromRpcType = typeof fromRpcType & {
|
|
100
|
+
[type: `0x${string}`]: string
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Converts an {@link ox#Transaction.Rpc} to an {@link ox#Transaction.Transaction}.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts twoslash
|
|
108
|
+
* import { Transaction } from 'ox/tempo'
|
|
109
|
+
*
|
|
110
|
+
* const transaction = Transaction.fromRpc({
|
|
111
|
+
* hash: '0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0',
|
|
112
|
+
* nonce: '0x357',
|
|
113
|
+
* blockHash:
|
|
114
|
+
* '0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b',
|
|
115
|
+
* blockNumber: '0x12f296f',
|
|
116
|
+
* feeToken: '0x20c0000000000000000000000000000000000000',
|
|
117
|
+
* transactionIndex: '0x2',
|
|
118
|
+
* from: '0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6',
|
|
119
|
+
* to: '0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad',
|
|
120
|
+
* value: '0x9b6e64a8ec60000',
|
|
121
|
+
* gas: '0x43f5d',
|
|
122
|
+
* maxFeePerGas: '0x2ca6ae494',
|
|
123
|
+
* maxPriorityFeePerGas: '0x41cc3c0',
|
|
124
|
+
* input:
|
|
125
|
+
* '0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000006643504700000000000000000000000000000000000000000000000000000000000000040b080604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec600000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec60000000000000000000000000000000000000000000000000000019124bb5ae978c000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b80000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b8000000000000000000000000000000fee13a103a10d593b9ae06b3e05f2e7e1c00000000000000000000000000000000000000000000000000000000000000190000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b800000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000190240001b9872b',
|
|
126
|
+
* r: '0x635dc2033e60185bb36709c29c75d64ea51dfbd91c32ef4be198e4ceb169fb4d',
|
|
127
|
+
* s: '0x50c2667ac4c771072746acfdcf1f1483336dcca8bd2df47cd83175dbe60f0540',
|
|
128
|
+
* yParity: '0x0',
|
|
129
|
+
* chainId: '0x1',
|
|
130
|
+
* accessList: [],
|
|
131
|
+
* type: '0x77',
|
|
132
|
+
* })
|
|
133
|
+
* ```
|
|
134
|
+
*
|
|
135
|
+
* @param transaction - The RPC transaction to convert.
|
|
136
|
+
* @returns An instantiated {@link ox#Transaction.Transaction}.
|
|
137
|
+
*/
|
|
138
|
+
export function fromRpc<
|
|
139
|
+
const transaction extends Rpc | null,
|
|
140
|
+
pending extends boolean = false,
|
|
141
|
+
>(
|
|
142
|
+
transaction: transaction | Rpc<pending> | null,
|
|
143
|
+
_options: fromRpc.Options<pending> = {},
|
|
144
|
+
): transaction extends Rpc<pending> ? Transaction<pending> : null {
|
|
145
|
+
if (!transaction) return null as never
|
|
146
|
+
|
|
147
|
+
const transaction_ = ox_Transaction.fromRpc(
|
|
148
|
+
transaction as ox_Transaction.Rpc<pending>,
|
|
149
|
+
) as Transaction<pending>
|
|
150
|
+
|
|
151
|
+
transaction_.type = fromRpcType[transaction.type as keyof typeof fromRpcType]
|
|
152
|
+
if (transaction.feePayerSignature) {
|
|
153
|
+
transaction_.feePayerSignature = Signature.fromRpc(
|
|
154
|
+
transaction.feePayerSignature,
|
|
155
|
+
)
|
|
156
|
+
;(transaction_.feePayerSignature as any).v = Signature.yParityToV(
|
|
157
|
+
transaction_.feePayerSignature.yParity,
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
// TODO: remove once `feePayer` returned on `eth_getTxBy*`.
|
|
161
|
+
transaction_.feePayer = Secp256k1.recoverAddress({
|
|
162
|
+
payload: TransactionEnvelopeFeeToken.getFeePayerSignPayload(
|
|
163
|
+
transaction_ as never,
|
|
164
|
+
{ sender: transaction.from },
|
|
165
|
+
),
|
|
166
|
+
signature: transaction_.feePayerSignature,
|
|
167
|
+
})
|
|
168
|
+
}
|
|
169
|
+
if (transaction.feeToken) transaction_.feeToken = transaction.feeToken
|
|
170
|
+
|
|
171
|
+
return transaction_ as never
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export declare namespace fromRpc {
|
|
175
|
+
type Options<pending extends boolean = false> = {
|
|
176
|
+
pending?: pending | boolean | undefined
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
type ErrorType = ox_Transaction.fromRpc.ErrorType | Errors.GlobalErrorType
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Converts an {@link ox#Transaction.Transaction} to an {@link ox#Transaction.Rpc}.
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```ts twoslash
|
|
187
|
+
* import { Transaction } from 'ox/tempo'
|
|
188
|
+
*
|
|
189
|
+
* const transaction = Transaction.toRpc({
|
|
190
|
+
* accessList: [],
|
|
191
|
+
* blockHash:
|
|
192
|
+
* '0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b',
|
|
193
|
+
* blockNumber: 19868015n,
|
|
194
|
+
* chainId: 1,
|
|
195
|
+
* feeToken: '0x20c0000000000000000000000000000000000000',
|
|
196
|
+
* from: '0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6',
|
|
197
|
+
* gas: 278365n,
|
|
198
|
+
* hash: '0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0',
|
|
199
|
+
* input:
|
|
200
|
+
* '0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000006643504700000000000000000000000000000000000000000000000000000000000000040b080604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec600000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec60000000000000000000000000000000000000000000000000000019124bb5ae978c000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b80000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b8000000000000000000000000000000fee13a103a10d593b9ae06b3e05f2e7e1c00000000000000000000000000000000000000000000000000000000000000190000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b800000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000190240001b9872b',
|
|
201
|
+
* maxFeePerGas: 11985937556n,
|
|
202
|
+
* maxPriorityFeePerGas: 68993984n,
|
|
203
|
+
* nonce: 855n,
|
|
204
|
+
* r: 44944627813007772897391531230081695102703289123332187696115181104739239197517n,
|
|
205
|
+
* s: 36528503505192438307355164441104001310566505351980369085208178712678799181120n,
|
|
206
|
+
* to: '0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad',
|
|
207
|
+
* transactionIndex: 2,
|
|
208
|
+
* type: 'feeToken',
|
|
209
|
+
* v: 27,
|
|
210
|
+
* value: 700000000000000000n,
|
|
211
|
+
* yParity: 0,
|
|
212
|
+
* })
|
|
213
|
+
* ```
|
|
214
|
+
*
|
|
215
|
+
* @param transaction - The transaction to convert.
|
|
216
|
+
* @returns An RPC-formatted transaction.
|
|
217
|
+
*/
|
|
218
|
+
export function toRpc<pending extends boolean = false>(
|
|
219
|
+
transaction: Transaction<pending>,
|
|
220
|
+
_options?: toRpc.Options<pending>,
|
|
221
|
+
): Rpc<pending> {
|
|
222
|
+
const rpc = ox_Transaction.toRpc(
|
|
223
|
+
transaction as ox_Transaction.Transaction<pending>,
|
|
224
|
+
) as Rpc<pending>
|
|
225
|
+
|
|
226
|
+
rpc.type = toRpcType[transaction.type as keyof typeof toRpcType]
|
|
227
|
+
if (transaction.feeToken) rpc.feeToken = transaction.feeToken
|
|
228
|
+
if (transaction.feePayerSignature) {
|
|
229
|
+
rpc.feePayerSignature = Signature.toRpc(
|
|
230
|
+
transaction.feePayerSignature,
|
|
231
|
+
) as any
|
|
232
|
+
;(rpc.feePayerSignature as any).v = Hex.fromNumber(
|
|
233
|
+
Signature.yParityToV(transaction.feePayerSignature?.yParity),
|
|
234
|
+
)
|
|
235
|
+
rpc.feePayer = transaction.feePayer
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return rpc as Rpc<pending>
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export declare namespace toRpc {
|
|
242
|
+
type Options<pending extends boolean = false> = {
|
|
243
|
+
pending?: pending | boolean | undefined
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
type ErrorType = ox_Transaction.toRpc.ErrorType | Errors.GlobalErrorType
|
|
247
|
+
}
|