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,339 @@
1
+ import type * as AccessList from '../core/AccessList.js'
2
+ import type * as Address from '../core/Address.js'
3
+ import type * as Errors from '../core/Errors.js'
4
+ import * as Hex from '../core/Hex.js'
5
+ import type { Compute, OneOf, UnionCompute } from '../core/internal/types.js'
6
+ import * as Signature from '../core/Signature.js'
7
+ import * as ox_Transaction from '../core/Transaction.js'
8
+ import * as AuthorizationTempo from './AuthorizationTempo.js'
9
+ import * as KeyAuthorization from './KeyAuthorization.js'
10
+ import * as SignatureEnvelope from './SignatureEnvelope.js'
11
+ import type { Call } from './TxEnvelopeTempo.js'
12
+
13
+ /**
14
+ * A Transaction as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/transaction.yaml).
15
+ *
16
+ * @see {@link https://docs.tempo.xyz/protocol/transactions Tempo Transactions}
17
+ */
18
+ export type Transaction<
19
+ pending extends boolean = false,
20
+ bigintType = bigint,
21
+ numberType = number,
22
+ > = UnionCompute<
23
+ OneOf<
24
+ | Tempo<pending, bigintType, numberType>
25
+ | ox_Transaction.Transaction<pending, bigintType, numberType>
26
+ >
27
+ >
28
+
29
+ /**
30
+ * An RPC Transaction as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/transaction.yaml).
31
+ */
32
+ export type Rpc<pending extends boolean = false> = UnionCompute<
33
+ OneOf<TempoRpc<pending> | ox_Transaction.Rpc<pending>>
34
+ >
35
+
36
+ /**
37
+ * Native account abstraction transaction (type `0x76`).
38
+ *
39
+ * Features configurable fee tokens, call batching, fee sponsorship, access keys,
40
+ * parallelizable nonces, and scheduled execution via `validAfter`/`validBefore`.
41
+ *
42
+ * @see {@link https://docs.tempo.xyz/protocol/transactions/spec-tempo-transaction Tempo Transaction Specification}
43
+ */
44
+ export type Tempo<
45
+ pending extends boolean = false,
46
+ bigintType = bigint,
47
+ numberType = number,
48
+ type extends string = 'tempo',
49
+ > = Compute<
50
+ Omit<
51
+ ox_Transaction.Base<type, pending, bigintType, numberType>,
52
+ // Tempo transactions don't have these properties.
53
+ 'input' | 'to' | 'value' | 'v' | 'r' | 's' | 'yParity'
54
+ > & {
55
+ /** EIP-2930 Access List. */
56
+ accessList: AccessList.AccessList
57
+ /** EIP-7702 Authorization list for the transaction. */
58
+ authorizationList?:
59
+ | AuthorizationTempo.ListSigned<bigintType, numberType>
60
+ | undefined
61
+ /** Array of calls to execute. */
62
+ calls: readonly Call<bigintType>[]
63
+ /** Fee payer signature. */
64
+ feePayerSignature?:
65
+ | {
66
+ /** ECDSA signature r. */
67
+ r: bigintType
68
+ /** ECDSA signature s. */
69
+ s: bigintType
70
+ /** ECDSA signature yParity. */
71
+ yParity: numberType
72
+ /** @deprecated ECDSA signature v (for backwards compatibility). */
73
+ v?: numberType | undefined
74
+ }
75
+ | undefined
76
+ /** Fee token preference. */
77
+ feeToken: Address.Address
78
+ /** Effective gas price paid by the sender in wei. */
79
+ gasPrice?: bigintType | undefined
80
+ /** Key authorization for provisioning a new access key. */
81
+ keyAuthorization?:
82
+ | KeyAuthorization.KeyAuthorization<true, bigintType, numberType>
83
+ | undefined
84
+ /** Total fee per gas in wei (gasPrice/baseFeePerGas + maxPriorityFeePerGas). */
85
+ maxFeePerGas: bigintType
86
+ /** Max priority fee per gas (in wei). */
87
+ maxPriorityFeePerGas: bigintType
88
+ /** Nonce key for 2D nonce system (192 bits). */
89
+ nonceKey?: bigintType | undefined
90
+ /** Sender signature. */
91
+ signature: SignatureEnvelope.SignatureEnvelope<bigintType, numberType>
92
+ /** Transaction can only be included in a block before this timestamp. */
93
+ validBefore?: numberType | undefined
94
+ /** Transaction can only be included in a block after this timestamp. */
95
+ validAfter?: numberType | undefined
96
+ }
97
+ >
98
+
99
+ /**
100
+ * Native account abstraction transaction in RPC format.
101
+ */
102
+ export type TempoRpc<pending extends boolean = false> = Compute<
103
+ Omit<
104
+ Tempo<pending, Hex.Hex, Hex.Hex, ToRpcType['tempo']>,
105
+ 'authorizationList' | 'calls' | 'keyAuthorization' | 'signature'
106
+ > & {
107
+ aaAuthorizationList?: AuthorizationTempo.ListRpc | undefined
108
+ calls:
109
+ | readonly {
110
+ input?: Hex.Hex | undefined
111
+ to?: Hex.Hex | undefined
112
+ value?: Hex.Hex | undefined
113
+ }[]
114
+ | undefined
115
+ keyAuthorization?: KeyAuthorization.Rpc | undefined
116
+ signature: SignatureEnvelope.SignatureEnvelopeRpc
117
+ }
118
+ >
119
+
120
+ /** Type to RPC Type mapping. */
121
+ export const toRpcType = {
122
+ ...ox_Transaction.toRpcType,
123
+ tempo: '0x76',
124
+ } as const
125
+
126
+ /** Type to RPC Type mapping. */
127
+ export type ToRpcType = typeof toRpcType & {
128
+ [type: string]: `0x${string}`
129
+ }
130
+
131
+ /** RPC Type to Type mapping. */
132
+ export const fromRpcType = {
133
+ ...ox_Transaction.fromRpcType,
134
+ '0x76': 'tempo',
135
+ } as const
136
+
137
+ /** RPC Type to Type mapping. */
138
+
139
+ export type FromRpcType = typeof fromRpcType & {
140
+ [type: `0x${string}`]: string
141
+ }
142
+
143
+ /**
144
+ * Converts an {@link ox#Transaction.Rpc} to an {@link ox#Transaction.Transaction}.
145
+ *
146
+ * @example
147
+ * ```ts twoslash
148
+ * import { Transaction } from 'ox/tempo'
149
+ *
150
+ * const transaction = Transaction.fromRpc({
151
+ * hash: '0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0',
152
+ * nonce: '0x357',
153
+ * blockHash:
154
+ * '0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b',
155
+ * blockNumber: '0x12f296f',
156
+ * calls: [
157
+ * {
158
+ * input: '0xdeadbeef',
159
+ * to: '0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad',
160
+ * value: '0x9b6e64a8ec60000',
161
+ * },
162
+ * ],
163
+ * feeToken: '0x20c0000000000000000000000000000000000000',
164
+ * transactionIndex: '0x2',
165
+ * from: '0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6',
166
+ * value: '0x9b6e64a8ec60000',
167
+ * gas: '0x43f5d',
168
+ * maxFeePerGas: '0x2ca6ae494',
169
+ * maxPriorityFeePerGas: '0x41cc3c0',
170
+ * input:
171
+ * '0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000006643504700000000000000000000000000000000000000000000000000000000000000040b080604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec600000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec60000000000000000000000000000000000000000000000000000019124bb5ae978c000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b80000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b8000000000000000000000000000000fee13a103a10d593b9ae06b3e05f2e7e1c00000000000000000000000000000000000000000000000000000000000000190000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b800000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000190240001b9872b',
172
+ * signature: {
173
+ * r: '0x635dc2033e60185bb36709c29c75d64ea51dfbd91c32ef4be198e4ceb169fb4d',
174
+ * s: '0x50c2667ac4c771072746acfdcf1f1483336dcca8bd2df47cd83175dbe60f0540',
175
+ * type: 'secp256k1',
176
+ * yParity: '0x0',
177
+ * },
178
+ * chainId: '0x1',
179
+ * accessList: [],
180
+ * type: '0x76',
181
+ * })
182
+ * ```
183
+ *
184
+ * @param transaction - The RPC transaction to convert.
185
+ * @returns An instantiated {@link ox#Transaction.Transaction}.
186
+ */
187
+ export function fromRpc<
188
+ const transaction extends Rpc | null,
189
+ pending extends boolean = false,
190
+ >(
191
+ transaction: transaction | Rpc<pending> | null,
192
+ _options: fromRpc.Options<pending> = {},
193
+ ): transaction extends Rpc<pending> ? Transaction<pending> : null {
194
+ if (!transaction) return null as never
195
+
196
+ const transaction_ = ox_Transaction.fromRpc(
197
+ transaction as ox_Transaction.Rpc<pending>,
198
+ ) as Transaction<pending>
199
+
200
+ transaction_.type = fromRpcType[transaction.type as keyof typeof fromRpcType]
201
+
202
+ if (transaction.aaAuthorizationList) {
203
+ transaction_.authorizationList = AuthorizationTempo.fromRpcList(
204
+ transaction.aaAuthorizationList,
205
+ )
206
+ delete (transaction_ as any).aaAuthorizationList
207
+ }
208
+ if (transaction.calls)
209
+ transaction_.calls = transaction.calls.map((call) => ({
210
+ to: call.to,
211
+ value: call.value && call.value !== '0x' ? BigInt(call.value) : undefined,
212
+ // @ts-expect-error
213
+ data: call.input || call.data || '0x',
214
+ }))
215
+ if (transaction.feeToken) transaction_.feeToken = transaction.feeToken
216
+ if (transaction.nonceKey) transaction_.nonceKey = BigInt(transaction.nonceKey)
217
+ if (transaction.signature)
218
+ transaction_.signature = SignatureEnvelope.fromRpc(transaction.signature)
219
+ if (transaction.validAfter)
220
+ transaction_.validAfter = Number(transaction.validAfter)
221
+ if (transaction.validBefore)
222
+ transaction_.validBefore = Number(transaction.validBefore)
223
+ if (transaction.keyAuthorization)
224
+ transaction_.keyAuthorization = KeyAuthorization.fromRpc(
225
+ transaction.keyAuthorization,
226
+ )
227
+ if (transaction.feePayerSignature) {
228
+ transaction_.feePayerSignature = Signature.fromRpc(
229
+ transaction.feePayerSignature,
230
+ )
231
+ ;(transaction_.feePayerSignature as any).v = Signature.yParityToV(
232
+ transaction_.feePayerSignature.yParity,
233
+ )
234
+ }
235
+
236
+ return transaction_ as never
237
+ }
238
+
239
+ export declare namespace fromRpc {
240
+ type Options<pending extends boolean = false> = {
241
+ pending?: pending | boolean | undefined
242
+ }
243
+
244
+ type ErrorType = ox_Transaction.fromRpc.ErrorType | Errors.GlobalErrorType
245
+ }
246
+
247
+ /**
248
+ * Converts an {@link ox#Transaction.Transaction} to an {@link ox#Transaction.Rpc}.
249
+ *
250
+ * @example
251
+ * ```ts twoslash
252
+ * import { Transaction } from 'ox/tempo'
253
+ *
254
+ * const transaction = Transaction.toRpc({
255
+ * accessList: [],
256
+ * blockHash:
257
+ * '0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b',
258
+ * blockNumber: 19868015n,
259
+ * calls: [
260
+ * {
261
+ * data: '0xdeadbeef',
262
+ * to: '0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad',
263
+ * value: 700000000000000000n,
264
+ * },
265
+ * ],
266
+ * chainId: 1,
267
+ * feeToken: '0x20c0000000000000000000000000000000000000',
268
+ * from: '0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6',
269
+ * gas: 278365n,
270
+ * hash: '0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0',
271
+ * input:
272
+ * '0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000006643504700000000000000000000000000000000000000000000000000000000000000040b080604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec600000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec60000000000000000000000000000000000000000000000000000019124bb5ae978c000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b80000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b8000000000000000000000000000000fee13a103a10d593b9ae06b3e05f2e7e1c00000000000000000000000000000000000000000000000000000000000000190000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b800000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000190240001b9872b',
273
+ * maxFeePerGas: 11985937556n,
274
+ * maxPriorityFeePerGas: 68993984n,
275
+ * nonce: 855n,
276
+ * signature: {
277
+ * signature: {
278
+ * r: 44944627813007772897391531230081695102703289123332187696115181104739239197517n,
279
+ * s: 36528503505192438307355164441104001310566505351980369085208178712678799181120n,
280
+ * yParity: 0,
281
+ * },
282
+ * type: 'secp256k1',
283
+ * },
284
+ * transactionIndex: 2,
285
+ * type: 'tempo',
286
+ * })
287
+ * ```
288
+ *
289
+ * @param transaction - The transaction to convert.
290
+ * @returns An RPC-formatted transaction.
291
+ */
292
+ export function toRpc<pending extends boolean = false>(
293
+ transaction: Transaction<pending>,
294
+ _options?: toRpc.Options<pending>,
295
+ ): Rpc<pending> {
296
+ const rpc = ox_Transaction.toRpc(
297
+ transaction as ox_Transaction.Transaction<pending>,
298
+ ) as Rpc<pending>
299
+
300
+ rpc.type = toRpcType[transaction.type as keyof typeof toRpcType]
301
+
302
+ if (transaction.authorizationList)
303
+ rpc.aaAuthorizationList = AuthorizationTempo.toRpcList(
304
+ transaction.authorizationList as AuthorizationTempo.ListSigned,
305
+ )
306
+ if (transaction.calls)
307
+ rpc.calls = transaction.calls.map((call) => ({
308
+ to: call.to,
309
+ value: call.value ? Hex.fromNumber(call.value) : undefined,
310
+ data: call.data,
311
+ }))
312
+ if (transaction.feeToken) rpc.feeToken = transaction.feeToken
313
+ if (transaction.keyAuthorization)
314
+ rpc.keyAuthorization = KeyAuthorization.toRpc(transaction.keyAuthorization)
315
+ if (transaction.feePayerSignature) {
316
+ rpc.feePayerSignature = Signature.toRpc(
317
+ transaction.feePayerSignature,
318
+ ) as any
319
+ ;(rpc.feePayerSignature as any).v = Hex.fromNumber(
320
+ Signature.yParityToV(transaction.feePayerSignature?.yParity),
321
+ )
322
+ }
323
+ if (transaction.signature)
324
+ rpc.signature = SignatureEnvelope.toRpc(transaction.signature)
325
+ if (typeof transaction.validAfter === 'number')
326
+ rpc.validAfter = Hex.fromNumber(transaction.validAfter)
327
+ if (typeof transaction.validBefore === 'number')
328
+ rpc.validBefore = Hex.fromNumber(transaction.validBefore)
329
+
330
+ return rpc as Rpc<pending>
331
+ }
332
+
333
+ export declare namespace toRpc {
334
+ type Options<pending extends boolean = false> = {
335
+ pending?: pending | boolean | undefined
336
+ }
337
+
338
+ type ErrorType = ox_Transaction.toRpc.ErrorType | Errors.GlobalErrorType
339
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "type": "module",
3
+ "types": "../../_types/tempo/TransactionReceipt.d.ts",
4
+ "main": "../../_cjs/tempo/TransactionReceipt.js",
5
+ "module": "../../_esm/tempo/TransactionReceipt.js"
6
+ }
@@ -0,0 +1,200 @@
1
+ import type * as Address from '../core/Address.js'
2
+ import type * as Hex from '../core/Hex.js'
3
+ import type { Compute } from '../core/internal/types.js'
4
+ import * as ox_TransactionReceipt from '../core/TransactionReceipt.js'
5
+
6
+ /**
7
+ * Tempo transaction receipt.
8
+ *
9
+ * Extends standard receipts with `feePayer` (the address that paid fees) and
10
+ * `feeToken` (the TIP-20 token used for fee payment).
11
+ *
12
+ * @see {@link https://docs.tempo.xyz/protocol/transactions Tempo Transactions}
13
+ */
14
+ export type TransactionReceipt<
15
+ status = ox_TransactionReceipt.Status,
16
+ type = ox_TransactionReceipt.Type,
17
+ bigintType = bigint,
18
+ numberType = number,
19
+ > = Compute<
20
+ ox_TransactionReceipt.TransactionReceipt<
21
+ status,
22
+ type,
23
+ bigintType,
24
+ numberType
25
+ > & {
26
+ /** Address of the fee payer. */
27
+ feePayer?: Address.Address | undefined
28
+ /** Address of the fee token. */
29
+ feeToken?: Address.Address | undefined
30
+ }
31
+ >
32
+
33
+ export type Rpc = TransactionReceipt<
34
+ ox_TransactionReceipt.RpcStatus,
35
+ ox_TransactionReceipt.RpcType,
36
+ Hex.Hex,
37
+ Hex.Hex
38
+ >
39
+
40
+ export type Type = 'tempo' | ox_TransactionReceipt.Type
41
+
42
+ export type RpcType = '0x76' | ox_TransactionReceipt.RpcType
43
+
44
+ export type Status = ox_TransactionReceipt.Status
45
+
46
+ export type RpcStatus = ox_TransactionReceipt.RpcStatus
47
+
48
+ /** RPC type to type mapping. */
49
+ export const fromRpcType = {
50
+ ...ox_TransactionReceipt.fromRpcType,
51
+ '0x76': 'tempo',
52
+ } as const
53
+
54
+ /** Type to RPC type mapping. */
55
+ export const toRpcType = {
56
+ ...ox_TransactionReceipt.toRpcType,
57
+ tempo: '0x76',
58
+ } as const
59
+
60
+ /**
61
+ * Converts an RPC receipt to a TransactionReceipt.
62
+ *
63
+ * @see {@link https://docs.tempo.xyz/protocol/transactions Tempo Transactions}
64
+ *
65
+ * @example
66
+ * ```ts twoslash
67
+ * import { TransactionReceipt } from 'ox/tempo'
68
+ *
69
+ * const receipt = TransactionReceipt.fromRpc({
70
+ * blobGasPrice: '0x42069',
71
+ * blobGasUsed: '0x1337',
72
+ * blockHash:
73
+ * '0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b',
74
+ * blockNumber: '0x12f296f',
75
+ * contractAddress: null,
76
+ * cumulativeGasUsed: '0x82515',
77
+ * effectiveGasPrice: '0x21c2f6c09',
78
+ * feePayer: '0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6',
79
+ * feeToken: '0x20c0000000000000000000000000000000000001',
80
+ * from: '0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6',
81
+ * gasUsed: '0x2abba',
82
+ * logs: [],
83
+ * logsBloom:
84
+ * '0x00200000000000000000008080000000000000000040000000000000000000000000000000000000000000000000000022000000080000000000000000000000000000080000000000000008000000200000000000000000000200008020400000000000000000280000000000100000000000000000000000000010000000000000000000020000000000000020000000000001000000080000004000000000000000000000000000000000000000000000400000000000001000000000000000000002000000000000000020000000000000000000001000000000000000000000200000000000000000000000000000001000000000c00000000000000000',
85
+ * status: '0x1',
86
+ * to: '0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad',
87
+ * transactionHash:
88
+ * '0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0',
89
+ * transactionIndex: '0x2',
90
+ * type: '0x2',
91
+ * })
92
+ * // @log: {
93
+ * // @log: blobGasPrice: 270441n,
94
+ * // @log: blobGasUsed: 4919n,
95
+ * // @log: blockHash: "0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b",
96
+ * // @log: blockNumber: 19868015n,
97
+ * // @log: contractAddress: null,
98
+ * // @log: cumulativeGasUsed: 533781n,
99
+ * // @log: effectiveGasPrice: 9062804489n,
100
+ * // @log: feePayer: "0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6",
101
+ * // @log: feeToken: "0x20c0000000000000000000000000000000000001",
102
+ * // @log: from: "0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6",
103
+ * // @log: gasUsed: 175034n,
104
+ * // @log: logs: [],
105
+ * // @log: logsBloom: "0x00200000000000000000008080000000000000000040000000000000000000000000000000000000000000000000000022000000080000000000000000000000000000080000000000000008000000200000000000000000000200008020400000000000000000280000000000100000000000000000000000000010000000000000000000020000000000000020000000000001000000080000004000000000000000000000000000000000000000000000400000000000001000000000000000000002000000000000000020000000000000000000001000000000000000000000200000000000000000000000000000001000000000c00000000000000000",
106
+ * // @log: root: undefined,
107
+ * // @log: status: "success",
108
+ * // @log: to: "0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad",
109
+ * // @log: transactionHash: "0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0",
110
+ * // @log: transactionIndex: 2,
111
+ * // @log: type: "eip1559",
112
+ * // @log: }
113
+ * ```
114
+ *
115
+ * @param receipt - The RPC receipt to convert.
116
+ * @returns A TransactionReceipt.
117
+ */
118
+ export function fromRpc<const receipt extends Rpc | null>(
119
+ receipt: receipt | Rpc | null,
120
+ ): receipt extends Rpc ? TransactionReceipt : null {
121
+ return ox_TransactionReceipt.fromRpc(
122
+ receipt as ox_TransactionReceipt.Rpc,
123
+ ) as never
124
+ }
125
+
126
+ export declare namespace fromRpc {
127
+ export type ErrorType = ox_TransactionReceipt.fromRpc.ErrorType
128
+ }
129
+
130
+ /**
131
+ * Converts a TransactionReceipt to an RPC receipt.
132
+ *
133
+ * @example
134
+ * ```ts twoslash
135
+ * import { TransactionReceipt } from 'ox/tempo'
136
+ *
137
+ * const receipt = TransactionReceipt.toRpc({
138
+ * blobGasPrice: 270441n,
139
+ * blobGasUsed: 4919n,
140
+ * blockHash:
141
+ * '0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b',
142
+ * blockNumber: 19868015n,
143
+ * contractAddress: null,
144
+ * cumulativeGasUsed: 533781n,
145
+ * effectiveGasPrice: 9062804489n,
146
+ * feePayer: '0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6',
147
+ * feeToken: '0x20c0000000000000000000000000000000000001',
148
+ * from: '0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6',
149
+ * gasUsed: 175034n,
150
+ * logs: [],
151
+ * logsBloom:
152
+ * '0x00200000000000000000008080000000000000000040000000000000000000000000000000000000000000000000000022000000080000000000000000000000000000080000000000000008000000200000000000000000000200008020400000000000000000280000000000100000000000000000000000000010000000000000000000020000000000000020000000000001000000080000004000000000000000000000000000000000000000000000400000000000001000000000000000000002000000000000000020000000000000000000001000000000000000000000200000000000000000000000000000001000000000c00000000000000000',
153
+ * root: undefined,
154
+ * status: 'success',
155
+ * to: '0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad',
156
+ * transactionHash:
157
+ * '0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0',
158
+ * transactionIndex: 2,
159
+ * type: 'eip1559',
160
+ * })
161
+ * // @log: {
162
+ * // @log: blobGasPrice: "0x042069",
163
+ * // @log: blobGasUsed: "0x1337",
164
+ * // @log: blockHash: "0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b",
165
+ * // @log: blockNumber: "0x012f296f",
166
+ * // @log: contractAddress: null,
167
+ * // @log: cumulativeGasUsed: "0x082515",
168
+ * // @log: effectiveGasPrice: "0x021c2f6c09",
169
+ * // @log: feePayer: "0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6",
170
+ * // @log: feeToken: "0x20c0000000000000000000000000000000000001",
171
+ * // @log: from: "0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6",
172
+ * // @log: gasUsed: "0x02abba",
173
+ * // @log: logs: [],
174
+ * // @log: logsBloom: "0x00200000000000000000008080000000000000000040000000000000000000000000000000000000000000000000000022000000080000000000000000000000000000080000000000000008000000200000000000000000000200008020400000000000000000280000000000100000000000000000000000000010000000000000000000020000000000000020000000000001000000080000004000000000000000000000000000000000000000000000400000000000001000000000000000000002000000000000000020000000000000000000001000000000000000000000200000000000000000000000000000001000000000c00000000000000000",
175
+ * // @log: root: undefined,
176
+ * // @log: status: "0x1",
177
+ * // @log: to: "0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad",
178
+ * // @log: transactionHash: "0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0",
179
+ * // @log: transactionIndex: "0x02",
180
+ * // @log: type: "eip1559",
181
+ * // @log: }
182
+ * ```
183
+ *
184
+ * @param receipt - The receipt to convert.
185
+ * @returns An RPC receipt.
186
+ */
187
+ export function toRpc(receipt: TransactionReceipt): Rpc {
188
+ const rpc = ox_TransactionReceipt.toRpc(
189
+ receipt as ox_TransactionReceipt.TransactionReceipt,
190
+ ) as Rpc
191
+ return {
192
+ ...rpc,
193
+ feePayer: receipt.feePayer,
194
+ feeToken: receipt.feeToken,
195
+ }
196
+ }
197
+
198
+ export declare namespace toRpc {
199
+ export type ErrorType = ox_TransactionReceipt.toRpc.ErrorType
200
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "type": "module",
3
+ "types": "../../_types/tempo/TransactionRequest.d.ts",
4
+ "main": "../../_cjs/tempo/TransactionRequest.js",
5
+ "module": "../../_esm/tempo/TransactionRequest.js"
6
+ }