ox 0.9.16 → 0.10.0

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.
Files changed (216) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +4 -4
  3. package/TxEnvelope/package.json +6 -0
  4. package/TxEnvelopeEip1559/package.json +6 -0
  5. package/TxEnvelopeEip2930/package.json +6 -0
  6. package/TxEnvelopeEip4844/package.json +6 -0
  7. package/TxEnvelopeEip7702/package.json +6 -0
  8. package/TxEnvelopeLegacy/package.json +6 -0
  9. package/_cjs/core/{TransactionEnvelope.js → TxEnvelope.js} +1 -1
  10. package/_cjs/core/TxEnvelope.js.map +1 -0
  11. package/_cjs/core/{TransactionEnvelopeEip1559.js → TxEnvelopeEip1559.js} +2 -2
  12. package/_cjs/core/TxEnvelopeEip1559.js.map +1 -0
  13. package/_cjs/core/{TransactionEnvelopeEip2930.js → TxEnvelopeEip2930.js} +2 -2
  14. package/_cjs/core/TxEnvelopeEip2930.js.map +1 -0
  15. package/_cjs/core/{TransactionEnvelopeEip4844.js → TxEnvelopeEip4844.js} +4 -4
  16. package/_cjs/core/TxEnvelopeEip4844.js.map +1 -0
  17. package/_cjs/core/{TransactionEnvelopeEip7702.js → TxEnvelopeEip7702.js} +4 -4
  18. package/_cjs/core/TxEnvelopeEip7702.js.map +1 -0
  19. package/_cjs/core/{TransactionEnvelopeLegacy.js → TxEnvelopeLegacy.js} +2 -2
  20. package/_cjs/core/TxEnvelopeLegacy.js.map +1 -0
  21. package/_cjs/core/WebAuthnP256.js +1 -1
  22. package/_cjs/core/WebAuthnP256.js.map +1 -1
  23. package/_cjs/erc8021/Attribution.js +36 -6
  24. package/_cjs/erc8021/Attribution.js.map +1 -1
  25. package/_cjs/index.docs.js +1 -0
  26. package/_cjs/index.docs.js.map +1 -1
  27. package/_cjs/index.js +7 -7
  28. package/_cjs/index.js.map +1 -1
  29. package/_cjs/tempo/AuthorizationTempo.js +101 -0
  30. package/_cjs/tempo/AuthorizationTempo.js.map +1 -0
  31. package/_cjs/tempo/KeyAuthorization.js +123 -0
  32. package/_cjs/tempo/KeyAuthorization.js.map +1 -0
  33. package/_cjs/tempo/PoolId.js +10 -0
  34. package/_cjs/tempo/PoolId.js.map +1 -0
  35. package/_cjs/tempo/SignatureEnvelope.js +394 -0
  36. package/_cjs/tempo/SignatureEnvelope.js.map +1 -0
  37. package/_cjs/tempo/Tick.js +77 -0
  38. package/_cjs/tempo/Tick.js.map +1 -0
  39. package/_cjs/tempo/TokenId.js +28 -0
  40. package/_cjs/tempo/TokenId.js.map +1 -0
  41. package/_cjs/tempo/TokenRole.js +26 -0
  42. package/_cjs/tempo/TokenRole.js.map +1 -0
  43. package/_cjs/tempo/Transaction.js +80 -0
  44. package/_cjs/tempo/Transaction.js.map +1 -0
  45. package/_cjs/tempo/TransactionReceipt.js +26 -0
  46. package/_cjs/tempo/TransactionReceipt.js.map +1 -0
  47. package/_cjs/tempo/TransactionRequest.js +53 -0
  48. package/_cjs/tempo/TransactionRequest.js.map +1 -0
  49. package/_cjs/tempo/TxEnvelopeTempo.js +267 -0
  50. package/_cjs/tempo/TxEnvelopeTempo.js.map +1 -0
  51. package/_cjs/tempo/index.js +15 -0
  52. package/_cjs/tempo/index.js.map +1 -0
  53. package/_cjs/version.js +1 -1
  54. package/_esm/core/Blobs.js +8 -8
  55. package/_esm/core/{TransactionEnvelope.js → TxEnvelope.js} +11 -11
  56. package/_esm/core/TxEnvelope.js.map +1 -0
  57. package/_esm/core/{TransactionEnvelopeEip1559.js → TxEnvelopeEip1559.js} +42 -42
  58. package/_esm/core/TxEnvelopeEip1559.js.map +1 -0
  59. package/_esm/core/{TransactionEnvelopeEip2930.js → TxEnvelopeEip2930.js} +43 -43
  60. package/_esm/core/TxEnvelopeEip2930.js.map +1 -0
  61. package/_esm/core/{TransactionEnvelopeEip4844.js → TxEnvelopeEip4844.js} +42 -42
  62. package/_esm/core/TxEnvelopeEip4844.js.map +1 -0
  63. package/_esm/core/{TransactionEnvelopeEip7702.js → TxEnvelopeEip7702.js} +40 -40
  64. package/_esm/core/TxEnvelopeEip7702.js.map +1 -0
  65. package/_esm/core/{TransactionEnvelopeLegacy.js → TxEnvelopeLegacy.js} +42 -42
  66. package/_esm/core/TxEnvelopeLegacy.js.map +1 -0
  67. package/_esm/core/WebAuthnP256.js +1 -1
  68. package/_esm/core/WebAuthnP256.js.map +1 -1
  69. package/_esm/erc8021/Attribution.js +58 -13
  70. package/_esm/erc8021/Attribution.js.map +1 -1
  71. package/_esm/index.docs.js +1 -0
  72. package/_esm/index.docs.js.map +1 -1
  73. package/_esm/index.js +192 -192
  74. package/_esm/index.js.map +1 -1
  75. package/_esm/tempo/AuthorizationTempo.js +664 -0
  76. package/_esm/tempo/AuthorizationTempo.js.map +1 -0
  77. package/_esm/tempo/KeyAuthorization.js +426 -0
  78. package/_esm/tempo/KeyAuthorization.js.map +1 -0
  79. package/_esm/tempo/PoolId.js +28 -0
  80. package/_esm/tempo/PoolId.js.map +1 -0
  81. package/_esm/tempo/SignatureEnvelope.js +660 -0
  82. package/_esm/tempo/SignatureEnvelope.js.map +1 -0
  83. package/_esm/tempo/Tick.js +147 -0
  84. package/_esm/tempo/Tick.js.map +1 -0
  85. package/_esm/tempo/TokenId.js +71 -0
  86. package/_esm/tempo/TokenId.js.map +1 -0
  87. package/_esm/tempo/TokenRole.js +40 -0
  88. package/_esm/tempo/TokenRole.js.map +1 -0
  89. package/_esm/tempo/Transaction.js +167 -0
  90. package/_esm/tempo/Transaction.js.map +1 -0
  91. package/_esm/tempo/TransactionReceipt.js +138 -0
  92. package/_esm/tempo/TransactionReceipt.js.map +1 -0
  93. package/_esm/tempo/TransactionRequest.js +99 -0
  94. package/_esm/tempo/TransactionRequest.js.map +1 -0
  95. package/_esm/tempo/TxEnvelopeTempo.js +607 -0
  96. package/_esm/tempo/TxEnvelopeTempo.js.map +1 -0
  97. package/_esm/tempo/index.js +298 -0
  98. package/_esm/tempo/index.js.map +1 -0
  99. package/_esm/version.js +1 -1
  100. package/_types/core/Blobs.d.ts +8 -8
  101. package/_types/core/{TransactionEnvelope.d.ts → TxEnvelope.d.ts} +11 -11
  102. package/_types/core/TxEnvelope.d.ts.map +1 -0
  103. package/_types/core/{TransactionEnvelopeEip1559.d.ts → TxEnvelopeEip1559.d.ts} +54 -54
  104. package/_types/core/TxEnvelopeEip1559.d.ts.map +1 -0
  105. package/_types/core/{TransactionEnvelopeEip2930.d.ts → TxEnvelopeEip2930.d.ts} +55 -55
  106. package/_types/core/TxEnvelopeEip2930.d.ts.map +1 -0
  107. package/_types/core/{TransactionEnvelopeEip4844.d.ts → TxEnvelopeEip4844.d.ts} +54 -54
  108. package/_types/core/TxEnvelopeEip4844.d.ts.map +1 -0
  109. package/_types/core/{TransactionEnvelopeEip7702.d.ts → TxEnvelopeEip7702.d.ts} +49 -49
  110. package/_types/core/TxEnvelopeEip7702.d.ts.map +1 -0
  111. package/_types/core/{TransactionEnvelopeLegacy.d.ts → TxEnvelopeLegacy.d.ts} +54 -54
  112. package/_types/core/TxEnvelopeLegacy.d.ts.map +1 -0
  113. package/_types/core/WebAuthnP256.d.ts +1 -1
  114. package/_types/core/WebAuthnP256.d.ts.map +1 -1
  115. package/_types/erc8021/Attribution.d.ts +20 -6
  116. package/_types/erc8021/Attribution.d.ts.map +1 -1
  117. package/_types/index.d.ts +192 -192
  118. package/_types/index.d.ts.map +1 -1
  119. package/_types/index.docs.d.ts +1 -0
  120. package/_types/index.docs.d.ts.map +1 -1
  121. package/_types/tempo/AuthorizationTempo.d.ts +688 -0
  122. package/_types/tempo/AuthorizationTempo.d.ts.map +1 -0
  123. package/_types/tempo/KeyAuthorization.d.ts +437 -0
  124. package/_types/tempo/KeyAuthorization.d.ts.map +1 -0
  125. package/_types/tempo/PoolId.d.ts +33 -0
  126. package/_types/tempo/PoolId.d.ts.map +1 -0
  127. package/_types/tempo/SignatureEnvelope.d.ts +438 -0
  128. package/_types/tempo/SignatureEnvelope.d.ts.map +1 -0
  129. package/_types/tempo/Tick.d.ts +120 -0
  130. package/_types/tempo/Tick.d.ts.map +1 -0
  131. package/_types/tempo/TokenId.d.ts +55 -0
  132. package/_types/tempo/TokenId.d.ts.map +1 -0
  133. package/_types/tempo/TokenRole.d.ts +29 -0
  134. package/_types/tempo/TokenRole.d.ts.map +1 -0
  135. package/_types/tempo/Transaction.d.ts +208 -0
  136. package/_types/tempo/Transaction.d.ts.map +1 -0
  137. package/_types/tempo/TransactionReceipt.d.ts +165 -0
  138. package/_types/tempo/TransactionReceipt.d.ts.map +1 -0
  139. package/_types/tempo/TransactionRequest.d.ts +89 -0
  140. package/_types/tempo/TransactionRequest.d.ts.map +1 -0
  141. package/_types/tempo/TxEnvelopeTempo.d.ts +551 -0
  142. package/_types/tempo/TxEnvelopeTempo.d.ts.map +1 -0
  143. package/_types/tempo/index.d.ts +300 -0
  144. package/_types/tempo/index.d.ts.map +1 -0
  145. package/_types/version.d.ts +1 -1
  146. package/core/Blobs.ts +8 -8
  147. package/core/{TransactionEnvelope.ts → TxEnvelope.ts} +10 -10
  148. package/core/{TransactionEnvelopeEip1559.ts → TxEnvelopeEip1559.ts} +60 -69
  149. package/core/{TransactionEnvelopeEip2930.ts → TxEnvelopeEip2930.ts} +61 -72
  150. package/core/{TransactionEnvelopeEip4844.ts → TxEnvelopeEip4844.ts} +62 -71
  151. package/core/{TransactionEnvelopeEip7702.ts → TxEnvelopeEip7702.ts} +58 -67
  152. package/core/{TransactionEnvelopeLegacy.ts → TxEnvelopeLegacy.ts} +59 -68
  153. package/core/WebAuthnP256.ts +3 -1
  154. package/erc8021/Attribution.ts +77 -15
  155. package/index.docs.ts +1 -0
  156. package/index.ts +192 -195
  157. package/package.json +91 -31
  158. package/tempo/AuthorizationTempo/package.json +6 -0
  159. package/tempo/AuthorizationTempo.test.ts +1293 -0
  160. package/tempo/AuthorizationTempo.ts +884 -0
  161. package/tempo/KeyAuthorization/package.json +6 -0
  162. package/tempo/KeyAuthorization.test.ts +1373 -0
  163. package/tempo/KeyAuthorization.ts +622 -0
  164. package/tempo/PoolId/package.json +6 -0
  165. package/tempo/PoolId.test.ts +33 -0
  166. package/tempo/PoolId.ts +42 -0
  167. package/tempo/SignatureEnvelope/package.json +6 -0
  168. package/tempo/SignatureEnvelope.test.ts +1877 -0
  169. package/tempo/SignatureEnvelope.ts +973 -0
  170. package/tempo/Tick/package.json +6 -0
  171. package/tempo/Tick.test.ts +281 -0
  172. package/tempo/Tick.ts +186 -0
  173. package/tempo/TokenId/package.json +6 -0
  174. package/tempo/TokenId.test.ts +40 -0
  175. package/tempo/TokenId.ts +80 -0
  176. package/tempo/TokenRole/package.json +6 -0
  177. package/tempo/TokenRole.test.ts +16 -0
  178. package/tempo/TokenRole.ts +45 -0
  179. package/tempo/Transaction/package.json +6 -0
  180. package/tempo/Transaction.test.ts +523 -0
  181. package/tempo/Transaction.ts +339 -0
  182. package/tempo/TransactionReceipt/package.json +6 -0
  183. package/tempo/TransactionReceipt.ts +200 -0
  184. package/tempo/TransactionRequest/package.json +6 -0
  185. package/tempo/TransactionRequest.ts +160 -0
  186. package/tempo/TxEnvelopeTempo/package.json +6 -0
  187. package/tempo/TxEnvelopeTempo.test.ts +1371 -0
  188. package/tempo/TxEnvelopeTempo.ts +972 -0
  189. package/tempo/e2e.test.ts +1387 -0
  190. package/tempo/index.ts +308 -0
  191. package/tempo/package.json +6 -0
  192. package/version.ts +1 -1
  193. package/TransactionEnvelope/package.json +0 -6
  194. package/TransactionEnvelopeEip1559/package.json +0 -6
  195. package/TransactionEnvelopeEip2930/package.json +0 -6
  196. package/TransactionEnvelopeEip4844/package.json +0 -6
  197. package/TransactionEnvelopeEip7702/package.json +0 -6
  198. package/TransactionEnvelopeLegacy/package.json +0 -6
  199. package/_cjs/core/TransactionEnvelope.js.map +0 -1
  200. package/_cjs/core/TransactionEnvelopeEip1559.js.map +0 -1
  201. package/_cjs/core/TransactionEnvelopeEip2930.js.map +0 -1
  202. package/_cjs/core/TransactionEnvelopeEip4844.js.map +0 -1
  203. package/_cjs/core/TransactionEnvelopeEip7702.js.map +0 -1
  204. package/_cjs/core/TransactionEnvelopeLegacy.js.map +0 -1
  205. package/_esm/core/TransactionEnvelope.js.map +0 -1
  206. package/_esm/core/TransactionEnvelopeEip1559.js.map +0 -1
  207. package/_esm/core/TransactionEnvelopeEip2930.js.map +0 -1
  208. package/_esm/core/TransactionEnvelopeEip4844.js.map +0 -1
  209. package/_esm/core/TransactionEnvelopeEip7702.js.map +0 -1
  210. package/_esm/core/TransactionEnvelopeLegacy.js.map +0 -1
  211. package/_types/core/TransactionEnvelope.d.ts.map +0 -1
  212. package/_types/core/TransactionEnvelopeEip1559.d.ts.map +0 -1
  213. package/_types/core/TransactionEnvelopeEip2930.d.ts.map +0 -1
  214. package/_types/core/TransactionEnvelopeEip4844.d.ts.map +0 -1
  215. package/_types/core/TransactionEnvelopeEip7702.d.ts.map +0 -1
  216. package/_types/core/TransactionEnvelopeLegacy.d.ts.map +0 -1
@@ -0,0 +1,523 @@
1
+ import { Transaction } from 'ox/tempo'
2
+ import { describe, expect, test } from 'vitest'
3
+
4
+ describe('fromRpc', () => {
5
+ test('default', () => {
6
+ const transaction = Transaction.fromRpc({
7
+ accessList: [],
8
+ calls: [
9
+ {
10
+ input: '0xdeadbeef',
11
+ to: '0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad',
12
+ value: '0x9b6e64a8ec60000',
13
+ },
14
+ ],
15
+ maxFeePerGas: '0x2',
16
+ maxPriorityFeePerGas: '0x1',
17
+ hash: '0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0',
18
+ nonce: '0x357',
19
+ blockHash:
20
+ '0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b',
21
+ blockNumber: '0x12f296f',
22
+ transactionIndex: '0x2',
23
+ feeToken: '0x20c0000000000000000000000000000000000000',
24
+ from: '0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6',
25
+ gas: '0x43f5d',
26
+ gasPrice: '0x2ca6ae494',
27
+ signature: {
28
+ r: '0x635dc2033e60185bb36709c29c75d64ea51dfbd91c32ef4be198e4ceb169fb4d',
29
+ s: '0x50c2667ac4c771072746acfdcf1f1483336dcca8bd2df47cd83175dbe60f0540',
30
+ v: '0x0',
31
+ type: 'secp256k1',
32
+ yParity: '0x0',
33
+ },
34
+ chainId: '0x1',
35
+ type: '0x76',
36
+ })
37
+ expect(transaction).toMatchInlineSnapshot(`
38
+ {
39
+ "accessList": [],
40
+ "blockHash": "0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b",
41
+ "blockNumber": 19868015n,
42
+ "calls": [
43
+ {
44
+ "data": "0xdeadbeef",
45
+ "to": "0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad",
46
+ "value": 700000000000000000n,
47
+ },
48
+ ],
49
+ "chainId": 1,
50
+ "data": undefined,
51
+ "feeToken": "0x20c0000000000000000000000000000000000000",
52
+ "from": "0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6",
53
+ "gas": 278365n,
54
+ "gasPrice": 11985937556n,
55
+ "hash": "0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0",
56
+ "maxFeePerGas": 2n,
57
+ "maxPriorityFeePerGas": 1n,
58
+ "nonce": 855n,
59
+ "signature": {
60
+ "signature": {
61
+ "r": 44944627813007772897391531230081695102703289123332187696115181104739239197517n,
62
+ "s": 36528503505192438307355164441104001310566505351980369085208178712678799181120n,
63
+ "yParity": 0,
64
+ },
65
+ "type": "secp256k1",
66
+ },
67
+ "transactionIndex": 2,
68
+ "type": "tempo",
69
+ "value": 0n,
70
+ }
71
+ `)
72
+ })
73
+
74
+ test('with feePayerSignature', () => {
75
+ const transaction = Transaction.fromRpc({
76
+ accessList: [],
77
+ calls: [
78
+ {
79
+ input: '0xdeadbeef',
80
+ to: '0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad',
81
+ value: '0x9b6e64a8ec60000',
82
+ },
83
+ ],
84
+ feePayerSignature: {
85
+ r: '0x12f4d9e9924f62b19de816252efc125006298f43e62d394151e62600e2c2f91e',
86
+ s: '0x31daa78bb3e95dd22f6370e59617c60d109bf28e55c92b25994ddbed420e2a80',
87
+ v: '0x0',
88
+ yParity: '0x0',
89
+ },
90
+ maxFeePerGas: '0x2',
91
+ maxPriorityFeePerGas: '0x1',
92
+ hash: '0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0',
93
+ nonce: '0x357',
94
+ blockHash:
95
+ '0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b',
96
+ blockNumber: '0x12f296f',
97
+ transactionIndex: '0x2',
98
+ feeToken: '0x20c0000000000000000000000000000000000000',
99
+ from: '0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6',
100
+ gas: '0x43f5d',
101
+ gasPrice: '0x2ca6ae494',
102
+ signature: {
103
+ r: '0x635dc2033e60185bb36709c29c75d64ea51dfbd91c32ef4be198e4ceb169fb4d',
104
+ s: '0x50c2667ac4c771072746acfdcf1f1483336dcca8bd2df47cd83175dbe60f0540',
105
+ v: '0x0',
106
+ type: 'secp256k1',
107
+ yParity: '0x0',
108
+ },
109
+ chainId: '0x1',
110
+ type: '0x76',
111
+ })
112
+
113
+ expect(transaction).toMatchInlineSnapshot(`
114
+ {
115
+ "accessList": [],
116
+ "blockHash": "0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b",
117
+ "blockNumber": 19868015n,
118
+ "calls": [
119
+ {
120
+ "data": "0xdeadbeef",
121
+ "to": "0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad",
122
+ "value": 700000000000000000n,
123
+ },
124
+ ],
125
+ "chainId": 1,
126
+ "data": undefined,
127
+ "feePayerSignature": {
128
+ "r": 8574245934337799659042750864278046211314109527666697413298781631396794530078n,
129
+ "s": 22549658598721143185960614158212618570884225122794367192341714237232002247296n,
130
+ "v": 27,
131
+ "yParity": 0,
132
+ },
133
+ "feeToken": "0x20c0000000000000000000000000000000000000",
134
+ "from": "0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6",
135
+ "gas": 278365n,
136
+ "gasPrice": 11985937556n,
137
+ "hash": "0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0",
138
+ "maxFeePerGas": 2n,
139
+ "maxPriorityFeePerGas": 1n,
140
+ "nonce": 855n,
141
+ "signature": {
142
+ "signature": {
143
+ "r": 44944627813007772897391531230081695102703289123332187696115181104739239197517n,
144
+ "s": 36528503505192438307355164441104001310566505351980369085208178712678799181120n,
145
+ "yParity": 0,
146
+ },
147
+ "type": "secp256k1",
148
+ },
149
+ "transactionIndex": 2,
150
+ "type": "tempo",
151
+ "value": 0n,
152
+ }
153
+ `)
154
+ })
155
+
156
+ test('with keyAuthorization', () => {
157
+ const transaction = Transaction.fromRpc({
158
+ accessList: [],
159
+ calls: [
160
+ {
161
+ input: '0xdeadbeef',
162
+ to: '0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad',
163
+ value: '0x9b6e64a8ec60000',
164
+ },
165
+ ],
166
+ keyAuthorization: {
167
+ expiry: '0xffffffffffff',
168
+ keyId: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
169
+ keyType: 'secp256k1',
170
+ limits: [
171
+ {
172
+ token: '0x20c0000000000000000000000000000000000001',
173
+ limit: '0x8ac7230489e80000',
174
+ },
175
+ ],
176
+ signature: {
177
+ r: '0x635dc2033e60185bb36709c29c75d64ea51dfbd91c32ef4be198e4ceb169fb4d',
178
+ s: '0x50c2667ac4c771072746acfdcf1f1483336dcca8bd2df47cd83175dbe60f0540',
179
+ type: 'secp256k1',
180
+ yParity: '0x0',
181
+ },
182
+ },
183
+ maxFeePerGas: '0x2',
184
+ maxPriorityFeePerGas: '0x1',
185
+ hash: '0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0',
186
+ nonce: '0x357',
187
+ blockHash:
188
+ '0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b',
189
+ blockNumber: '0x12f296f',
190
+ transactionIndex: '0x2',
191
+ feeToken: '0x20c0000000000000000000000000000000000000',
192
+ from: '0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6',
193
+ gas: '0x43f5d',
194
+ gasPrice: '0x2ca6ae494',
195
+ signature: {
196
+ r: '0x635dc2033e60185bb36709c29c75d64ea51dfbd91c32ef4be198e4ceb169fb4d',
197
+ s: '0x50c2667ac4c771072746acfdcf1f1483336dcca8bd2df47cd83175dbe60f0540',
198
+ v: '0x0',
199
+ type: 'secp256k1',
200
+ yParity: '0x0',
201
+ },
202
+ chainId: '0x1',
203
+ type: '0x76',
204
+ })
205
+
206
+ expect(transaction).toMatchInlineSnapshot(`
207
+ {
208
+ "accessList": [],
209
+ "blockHash": "0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b",
210
+ "blockNumber": 19868015n,
211
+ "calls": [
212
+ {
213
+ "data": "0xdeadbeef",
214
+ "to": "0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad",
215
+ "value": 700000000000000000n,
216
+ },
217
+ ],
218
+ "chainId": 1,
219
+ "data": undefined,
220
+ "feeToken": "0x20c0000000000000000000000000000000000000",
221
+ "from": "0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6",
222
+ "gas": 278365n,
223
+ "gasPrice": 11985937556n,
224
+ "hash": "0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0",
225
+ "keyAuthorization": {
226
+ "address": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
227
+ "chainId": 0n,
228
+ "expiry": 281474976710655,
229
+ "limits": [
230
+ {
231
+ "limit": 10000000000000000000n,
232
+ "token": "0x20c0000000000000000000000000000000000001",
233
+ },
234
+ ],
235
+ "signature": {
236
+ "signature": {
237
+ "r": 44944627813007772897391531230081695102703289123332187696115181104739239197517n,
238
+ "s": 36528503505192438307355164441104001310566505351980369085208178712678799181120n,
239
+ "yParity": 0,
240
+ },
241
+ "type": "secp256k1",
242
+ },
243
+ "type": "secp256k1",
244
+ },
245
+ "maxFeePerGas": 2n,
246
+ "maxPriorityFeePerGas": 1n,
247
+ "nonce": 855n,
248
+ "signature": {
249
+ "signature": {
250
+ "r": 44944627813007772897391531230081695102703289123332187696115181104739239197517n,
251
+ "s": 36528503505192438307355164441104001310566505351980369085208178712678799181120n,
252
+ "yParity": 0,
253
+ },
254
+ "type": "secp256k1",
255
+ },
256
+ "transactionIndex": 2,
257
+ "type": "tempo",
258
+ "value": 0n,
259
+ }
260
+ `)
261
+ })
262
+ })
263
+
264
+ describe('toRpc', () => {
265
+ test('default', () => {
266
+ const transaction = Transaction.toRpc({
267
+ accessList: [],
268
+ blockHash:
269
+ '0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b',
270
+ blockNumber: 19868015n,
271
+ calls: [
272
+ {
273
+ data: '0xdeadbeef',
274
+ to: '0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad',
275
+ value: 700000000000000000n,
276
+ },
277
+ ],
278
+ chainId: 1,
279
+ data: undefined,
280
+ feeToken: '0x20c0000000000000000000000000000000000000',
281
+ from: '0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6',
282
+ gas: 278365n,
283
+ gasPrice: 11985937556n,
284
+ hash: '0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0',
285
+ maxFeePerGas: 2n,
286
+ maxPriorityFeePerGas: 1n,
287
+ nonce: 855n,
288
+ signature: {
289
+ signature: {
290
+ r: 44944627813007772897391531230081695102703289123332187696115181104739239197517n,
291
+ s: 36528503505192438307355164441104001310566505351980369085208178712678799181120n,
292
+ yParity: 0,
293
+ },
294
+ type: 'secp256k1',
295
+ },
296
+ transactionIndex: 2,
297
+ type: 'tempo',
298
+ })
299
+ expect(transaction).toMatchInlineSnapshot(`
300
+ {
301
+ "accessList": [],
302
+ "blockHash": "0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b",
303
+ "blockNumber": "0x12f296f",
304
+ "calls": [
305
+ {
306
+ "data": "0xdeadbeef",
307
+ "to": "0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad",
308
+ "value": "0x9b6e64a8ec60000",
309
+ },
310
+ ],
311
+ "chainId": "0x1",
312
+ "feeToken": "0x20c0000000000000000000000000000000000000",
313
+ "from": "0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6",
314
+ "gas": "0x43f5d",
315
+ "gasPrice": "0x2ca6ae494",
316
+ "hash": "0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0",
317
+ "input": undefined,
318
+ "maxFeePerGas": "0x2",
319
+ "maxPriorityFeePerGas": "0x1",
320
+ "nonce": "0x357",
321
+ "signature": {
322
+ "r": "0x635dc2033e60185bb36709c29c75d64ea51dfbd91c32ef4be198e4ceb169fb4d",
323
+ "s": "0x50c2667ac4c771072746acfdcf1f1483336dcca8bd2df47cd83175dbe60f0540",
324
+ "type": "secp256k1",
325
+ "yParity": "0x0",
326
+ },
327
+ "to": undefined,
328
+ "transactionIndex": "0x2",
329
+ "type": "0x76",
330
+ "value": "0x0",
331
+ }
332
+ `)
333
+ })
334
+
335
+ test('default', () => {
336
+ const transaction = Transaction.toRpc({
337
+ accessList: [],
338
+ blockHash:
339
+ '0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b',
340
+ blockNumber: 19868015n,
341
+ calls: [
342
+ {
343
+ data: '0xdeadbeef',
344
+ to: '0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad',
345
+ value: 700000000000000000n,
346
+ },
347
+ ],
348
+ chainId: 1,
349
+ data: undefined,
350
+ feePayerSignature: {
351
+ r: 8574245934337799659042750864278046211314109527666697413298781631396794530078n,
352
+ s: 22549658598721143185960614158212618570884225122794367192341714237232002247296n,
353
+ v: 27,
354
+ yParity: 0,
355
+ },
356
+ feeToken: '0x20c0000000000000000000000000000000000000',
357
+ from: '0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6',
358
+ gas: 278365n,
359
+ gasPrice: 11985937556n,
360
+ hash: '0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0',
361
+ maxFeePerGas: 2n,
362
+ maxPriorityFeePerGas: 1n,
363
+ nonce: 855n,
364
+ signature: {
365
+ signature: {
366
+ r: 44944627813007772897391531230081695102703289123332187696115181104739239197517n,
367
+ s: 36528503505192438307355164441104001310566505351980369085208178712678799181120n,
368
+ yParity: 0,
369
+ },
370
+ type: 'secp256k1',
371
+ },
372
+ transactionIndex: 2,
373
+ type: 'tempo',
374
+ })
375
+ expect(transaction).toMatchInlineSnapshot(`
376
+ {
377
+ "accessList": [],
378
+ "blockHash": "0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b",
379
+ "blockNumber": "0x12f296f",
380
+ "calls": [
381
+ {
382
+ "data": "0xdeadbeef",
383
+ "to": "0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad",
384
+ "value": "0x9b6e64a8ec60000",
385
+ },
386
+ ],
387
+ "chainId": "0x1",
388
+ "feePayerSignature": {
389
+ "r": "0x12f4d9e9924f62b19de816252efc125006298f43e62d394151e62600e2c2f91e",
390
+ "s": "0x31daa78bb3e95dd22f6370e59617c60d109bf28e55c92b25994ddbed420e2a80",
391
+ "v": "0x1b",
392
+ "yParity": "0x0",
393
+ },
394
+ "feeToken": "0x20c0000000000000000000000000000000000000",
395
+ "from": "0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6",
396
+ "gas": "0x43f5d",
397
+ "gasPrice": "0x2ca6ae494",
398
+ "hash": "0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0",
399
+ "input": undefined,
400
+ "maxFeePerGas": "0x2",
401
+ "maxPriorityFeePerGas": "0x1",
402
+ "nonce": "0x357",
403
+ "signature": {
404
+ "r": "0x635dc2033e60185bb36709c29c75d64ea51dfbd91c32ef4be198e4ceb169fb4d",
405
+ "s": "0x50c2667ac4c771072746acfdcf1f1483336dcca8bd2df47cd83175dbe60f0540",
406
+ "type": "secp256k1",
407
+ "yParity": "0x0",
408
+ },
409
+ "to": undefined,
410
+ "transactionIndex": "0x2",
411
+ "type": "0x76",
412
+ "value": "0x0",
413
+ }
414
+ `)
415
+ })
416
+
417
+ test('with keyAuthorization', () => {
418
+ const transaction = Transaction.toRpc({
419
+ accessList: [],
420
+ blockHash:
421
+ '0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b',
422
+ blockNumber: 19868015n,
423
+ calls: [
424
+ {
425
+ data: '0xdeadbeef',
426
+ to: '0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad',
427
+ value: 700000000000000000n,
428
+ },
429
+ ],
430
+ chainId: 1,
431
+ data: undefined,
432
+ keyAuthorization: {
433
+ address: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
434
+ expiry: 281474976710655,
435
+ type: 'secp256k1',
436
+ limits: [
437
+ {
438
+ limit: 10000000000000000000n,
439
+ token: '0x20c0000000000000000000000000000000000001',
440
+ },
441
+ ],
442
+ signature: {
443
+ signature: {
444
+ r: 44944627813007772897391531230081695102703289123332187696115181104739239197517n,
445
+ s: 36528503505192438307355164441104001310566505351980369085208178712678799181120n,
446
+ yParity: 0,
447
+ },
448
+ type: 'secp256k1',
449
+ },
450
+ },
451
+ feeToken: '0x20c0000000000000000000000000000000000000',
452
+ from: '0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6',
453
+ gas: 278365n,
454
+ gasPrice: 11985937556n,
455
+ hash: '0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0',
456
+ maxFeePerGas: 2n,
457
+ maxPriorityFeePerGas: 1n,
458
+ nonce: 855n,
459
+ signature: {
460
+ signature: {
461
+ r: 44944627813007772897391531230081695102703289123332187696115181104739239197517n,
462
+ s: 36528503505192438307355164441104001310566505351980369085208178712678799181120n,
463
+ yParity: 0,
464
+ },
465
+ type: 'secp256k1',
466
+ },
467
+ transactionIndex: 2,
468
+ type: 'tempo',
469
+ })
470
+ expect(transaction).toMatchInlineSnapshot(`
471
+ {
472
+ "accessList": [],
473
+ "blockHash": "0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b",
474
+ "blockNumber": "0x12f296f",
475
+ "calls": [
476
+ {
477
+ "data": "0xdeadbeef",
478
+ "to": "0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad",
479
+ "value": "0x9b6e64a8ec60000",
480
+ },
481
+ ],
482
+ "chainId": "0x1",
483
+ "feeToken": "0x20c0000000000000000000000000000000000000",
484
+ "from": "0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6",
485
+ "gas": "0x43f5d",
486
+ "gasPrice": "0x2ca6ae494",
487
+ "hash": "0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0",
488
+ "input": undefined,
489
+ "keyAuthorization": {
490
+ "chainId": "0x",
491
+ "expiry": "0xffffffffffff",
492
+ "keyId": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
493
+ "keyType": "secp256k1",
494
+ "limits": [
495
+ {
496
+ "limit": "0x8ac7230489e80000",
497
+ "token": "0x20c0000000000000000000000000000000000001",
498
+ },
499
+ ],
500
+ "signature": {
501
+ "r": "0x635dc2033e60185bb36709c29c75d64ea51dfbd91c32ef4be198e4ceb169fb4d",
502
+ "s": "0x50c2667ac4c771072746acfdcf1f1483336dcca8bd2df47cd83175dbe60f0540",
503
+ "type": "secp256k1",
504
+ "yParity": "0x0",
505
+ },
506
+ },
507
+ "maxFeePerGas": "0x2",
508
+ "maxPriorityFeePerGas": "0x1",
509
+ "nonce": "0x357",
510
+ "signature": {
511
+ "r": "0x635dc2033e60185bb36709c29c75d64ea51dfbd91c32ef4be198e4ceb169fb4d",
512
+ "s": "0x50c2667ac4c771072746acfdcf1f1483336dcca8bd2df47cd83175dbe60f0540",
513
+ "type": "secp256k1",
514
+ "yParity": "0x0",
515
+ },
516
+ "to": undefined,
517
+ "transactionIndex": "0x2",
518
+ "type": "0x76",
519
+ "value": "0x0",
520
+ }
521
+ `)
522
+ })
523
+ })