tempo.ts 0.10.5 → 0.11.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 (224) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +0 -41
  3. package/dist/viem/Account.d.ts +8 -3
  4. package/dist/viem/Account.d.ts.map +1 -1
  5. package/dist/viem/Account.js +9 -2
  6. package/dist/viem/Account.js.map +1 -1
  7. package/dist/viem/Actions/amm.d.ts +1 -1
  8. package/dist/viem/Actions/amm.d.ts.map +1 -1
  9. package/dist/viem/Actions/amm.js +1 -2
  10. package/dist/viem/Actions/amm.js.map +1 -1
  11. package/dist/viem/Actions/dex.d.ts +0 -35
  12. package/dist/viem/Actions/dex.d.ts.map +1 -1
  13. package/dist/viem/Actions/dex.js +0 -43
  14. package/dist/viem/Actions/dex.js.map +1 -1
  15. package/dist/viem/Actions/fee.d.ts +1 -1
  16. package/dist/viem/Actions/fee.d.ts.map +1 -1
  17. package/dist/viem/Actions/fee.js +1 -1
  18. package/dist/viem/Actions/fee.js.map +1 -1
  19. package/dist/viem/Actions/nonce.d.ts.map +1 -1
  20. package/dist/viem/Actions/nonce.js +6 -4
  21. package/dist/viem/Actions/nonce.js.map +1 -1
  22. package/dist/viem/Actions/token.d.ts +1 -2
  23. package/dist/viem/Actions/token.d.ts.map +1 -1
  24. package/dist/viem/Actions/token.js +1 -2
  25. package/dist/viem/Actions/token.js.map +1 -1
  26. package/dist/viem/Chain.d.ts +34 -34
  27. package/dist/viem/Chain.d.ts.map +1 -1
  28. package/dist/viem/Chain.js +2 -0
  29. package/dist/viem/Chain.js.map +1 -1
  30. package/dist/viem/Formatters.d.ts.map +1 -1
  31. package/dist/viem/Formatters.js +5 -3
  32. package/dist/viem/Formatters.js.map +1 -1
  33. package/dist/viem/Transaction.d.ts +8 -5
  34. package/dist/viem/Transaction.d.ts.map +1 -1
  35. package/dist/viem/Transaction.js +13 -3
  36. package/dist/viem/Transaction.js.map +1 -1
  37. package/dist/viem/internal/types.d.ts +1 -1
  38. package/dist/viem/internal/types.d.ts.map +1 -1
  39. package/dist/wagmi/Actions/dex.d.ts +1 -45
  40. package/dist/wagmi/Actions/dex.d.ts.map +1 -1
  41. package/dist/wagmi/Actions/dex.js +0 -55
  42. package/dist/wagmi/Actions/dex.js.map +1 -1
  43. package/dist/wagmi/Connector.d.ts +1 -1
  44. package/dist/wagmi/Connector.d.ts.map +1 -1
  45. package/dist/wagmi/Connector.js +1 -2
  46. package/dist/wagmi/Connector.js.map +1 -1
  47. package/dist/wagmi/Hooks/dex.d.ts +3 -46
  48. package/dist/wagmi/Hooks/dex.d.ts.map +1 -1
  49. package/dist/wagmi/Hooks/dex.js +2 -54
  50. package/dist/wagmi/Hooks/dex.js.map +1 -1
  51. package/dist/wagmi/index.d.ts +1 -1
  52. package/dist/wagmi/index.d.ts.map +1 -1
  53. package/dist/wagmi/index.js +1 -1
  54. package/dist/wagmi/index.js.map +1 -1
  55. package/package.json +5 -23
  56. package/src/viem/Account.test.ts +1 -1
  57. package/src/viem/Account.ts +11 -2
  58. package/src/viem/Actions/account.ts +1 -1
  59. package/src/viem/Actions/amm.ts +1 -2
  60. package/src/viem/Actions/dex.test.ts +1 -195
  61. package/src/viem/Actions/dex.ts +0 -53
  62. package/src/viem/Actions/fee.test.ts +2 -2
  63. package/src/viem/Actions/fee.ts +1 -1
  64. package/src/viem/Actions/nonce.test.ts +27 -14
  65. package/src/viem/Actions/nonce.ts +6 -4
  66. package/src/viem/Actions/token.test.ts +18 -52
  67. package/src/viem/Actions/token.ts +1 -2
  68. package/src/viem/Chain.ts +3 -1
  69. package/src/viem/Decorator.ts +0 -30
  70. package/src/viem/Formatters.ts +9 -3
  71. package/src/viem/Transaction.ts +23 -7
  72. package/src/viem/e2e.test.ts +19 -0
  73. package/src/viem/index.ts +12 -1
  74. package/src/viem/internal/types.ts +1 -1
  75. package/src/wagmi/Actions/dex.test.ts +0 -26
  76. package/src/wagmi/Actions/dex.ts +1 -111
  77. package/src/wagmi/Actions/nonce.test.ts +8 -4
  78. package/src/wagmi/Actions/token.test.ts +2 -2
  79. package/src/wagmi/Connector.ts +1 -2
  80. package/src/wagmi/Hooks/dex.test.ts +0 -26
  81. package/src/wagmi/Hooks/dex.ts +1 -88
  82. package/src/wagmi/Hooks/nonce.test.ts +3 -3
  83. package/src/wagmi/index.ts +4 -1
  84. package/dist/chains.d.ts +0 -73
  85. package/dist/chains.d.ts.map +0 -1
  86. package/dist/chains.js +0 -51
  87. package/dist/chains.js.map +0 -1
  88. package/dist/ox/AuthorizationTempo.d.ts +0 -450
  89. package/dist/ox/AuthorizationTempo.d.ts.map +0 -1
  90. package/dist/ox/AuthorizationTempo.js +0 -433
  91. package/dist/ox/AuthorizationTempo.js.map +0 -1
  92. package/dist/ox/KeyAuthorization.d.ts +0 -356
  93. package/dist/ox/KeyAuthorization.d.ts.map +0 -1
  94. package/dist/ox/KeyAuthorization.js +0 -359
  95. package/dist/ox/KeyAuthorization.js.map +0 -1
  96. package/dist/ox/Order.d.ts +0 -92
  97. package/dist/ox/Order.d.ts.map +0 -1
  98. package/dist/ox/Order.js +0 -88
  99. package/dist/ox/Order.js.map +0 -1
  100. package/dist/ox/OrdersFilters.d.ts +0 -72
  101. package/dist/ox/OrdersFilters.d.ts.map +0 -1
  102. package/dist/ox/OrdersFilters.js +0 -100
  103. package/dist/ox/OrdersFilters.js.map +0 -1
  104. package/dist/ox/Pagination.d.ts +0 -128
  105. package/dist/ox/Pagination.d.ts.map +0 -1
  106. package/dist/ox/Pagination.js +0 -78
  107. package/dist/ox/Pagination.js.map +0 -1
  108. package/dist/ox/PoolId.d.ts +0 -18
  109. package/dist/ox/PoolId.d.ts.map +0 -1
  110. package/dist/ox/PoolId.js +0 -13
  111. package/dist/ox/PoolId.js.map +0 -1
  112. package/dist/ox/RpcSchema.d.ts +0 -32
  113. package/dist/ox/RpcSchema.d.ts.map +0 -1
  114. package/dist/ox/RpcSchema.js +0 -2
  115. package/dist/ox/RpcSchema.js.map +0 -1
  116. package/dist/ox/SignatureEnvelope.d.ts +0 -260
  117. package/dist/ox/SignatureEnvelope.d.ts.map +0 -1
  118. package/dist/ox/SignatureEnvelope.js +0 -477
  119. package/dist/ox/SignatureEnvelope.js.map +0 -1
  120. package/dist/ox/Tick.d.ts +0 -115
  121. package/dist/ox/Tick.d.ts.map +0 -1
  122. package/dist/ox/Tick.js +0 -127
  123. package/dist/ox/Tick.js.map +0 -1
  124. package/dist/ox/TokenId.d.ts +0 -25
  125. package/dist/ox/TokenId.d.ts.map +0 -1
  126. package/dist/ox/TokenId.js +0 -41
  127. package/dist/ox/TokenId.js.map +0 -1
  128. package/dist/ox/TokenRole.d.ts +0 -11
  129. package/dist/ox/TokenRole.d.ts.map +0 -1
  130. package/dist/ox/TokenRole.js +0 -22
  131. package/dist/ox/TokenRole.js.map +0 -1
  132. package/dist/ox/Transaction.d.ts +0 -201
  133. package/dist/ox/Transaction.d.ts.map +0 -1
  134. package/dist/ox/Transaction.js +0 -167
  135. package/dist/ox/Transaction.js.map +0 -1
  136. package/dist/ox/TransactionEnvelopeTempo.d.ts +0 -470
  137. package/dist/ox/TransactionEnvelopeTempo.d.ts.map +0 -1
  138. package/dist/ox/TransactionEnvelopeTempo.js +0 -547
  139. package/dist/ox/TransactionEnvelopeTempo.js.map +0 -1
  140. package/dist/ox/TransactionReceipt.d.ts +0 -155
  141. package/dist/ox/TransactionReceipt.d.ts.map +0 -1
  142. package/dist/ox/TransactionReceipt.js +0 -136
  143. package/dist/ox/TransactionReceipt.js.map +0 -1
  144. package/dist/ox/TransactionRequest.d.ts +0 -76
  145. package/dist/ox/TransactionRequest.d.ts.map +0 -1
  146. package/dist/ox/TransactionRequest.js +0 -93
  147. package/dist/ox/TransactionRequest.js.map +0 -1
  148. package/dist/ox/index.d.ts +0 -14
  149. package/dist/ox/index.d.ts.map +0 -1
  150. package/dist/ox/index.js +0 -14
  151. package/dist/ox/index.js.map +0 -1
  152. package/dist/prool/Instance.d.ts +0 -101
  153. package/dist/prool/Instance.d.ts.map +0 -1
  154. package/dist/prool/Instance.js +0 -136
  155. package/dist/prool/Instance.js.map +0 -1
  156. package/dist/prool/chain.json +0 -238
  157. package/dist/prool/index.d.ts +0 -2
  158. package/dist/prool/index.d.ts.map +0 -1
  159. package/dist/prool/index.js +0 -2
  160. package/dist/prool/index.js.map +0 -1
  161. package/dist/viem/Actions/account.d.ts +0 -40
  162. package/dist/viem/Actions/account.d.ts.map +0 -1
  163. package/dist/viem/Actions/account.js +0 -86
  164. package/dist/viem/Actions/account.js.map +0 -1
  165. package/dist/viem/Actions/index.d.ts +0 -10
  166. package/dist/viem/Actions/index.d.ts.map +0 -1
  167. package/dist/viem/Actions/index.js +0 -10
  168. package/dist/viem/Actions/index.js.map +0 -1
  169. package/dist/viem/Decorator.d.ts +0 -2810
  170. package/dist/viem/Decorator.d.ts.map +0 -1
  171. package/dist/viem/Decorator.js +0 -138
  172. package/dist/viem/Decorator.js.map +0 -1
  173. package/dist/viem/P256.d.ts +0 -2
  174. package/dist/viem/P256.d.ts.map +0 -1
  175. package/dist/viem/P256.js +0 -2
  176. package/dist/viem/P256.js.map +0 -1
  177. package/dist/viem/Secp256k1.d.ts +0 -2
  178. package/dist/viem/Secp256k1.d.ts.map +0 -1
  179. package/dist/viem/Secp256k1.js +0 -2
  180. package/dist/viem/Secp256k1.js.map +0 -1
  181. package/dist/viem/TokenIds.d.ts +0 -2
  182. package/dist/viem/TokenIds.d.ts.map +0 -1
  183. package/dist/viem/TokenIds.js +0 -2
  184. package/dist/viem/TokenIds.js.map +0 -1
  185. package/dist/viem/index.d.ts +0 -17
  186. package/dist/viem/index.d.ts.map +0 -1
  187. package/dist/viem/index.js +0 -17
  188. package/dist/viem/index.js.map +0 -1
  189. package/src/ox/AuthorizationTempo.test.ts +0 -1256
  190. package/src/ox/AuthorizationTempo.ts +0 -648
  191. package/src/ox/KeyAuthorization.test.ts +0 -1332
  192. package/src/ox/KeyAuthorization.ts +0 -540
  193. package/src/ox/Order.test.ts +0 -78
  194. package/src/ox/Order.ts +0 -125
  195. package/src/ox/OrdersFilters.test.ts +0 -182
  196. package/src/ox/OrdersFilters.ts +0 -125
  197. package/src/ox/Pagination.test.ts +0 -162
  198. package/src/ox/Pagination.ts +0 -164
  199. package/src/ox/PoolId.test.ts +0 -33
  200. package/src/ox/PoolId.ts +0 -27
  201. package/src/ox/RpcSchema.ts +0 -35
  202. package/src/ox/SignatureEnvelope.test.ts +0 -1876
  203. package/src/ox/SignatureEnvelope.ts +0 -791
  204. package/src/ox/Tick.test.ts +0 -281
  205. package/src/ox/Tick.ts +0 -181
  206. package/src/ox/TokenId.test.ts +0 -40
  207. package/src/ox/TokenId.ts +0 -50
  208. package/src/ox/TokenRole.test.ts +0 -16
  209. package/src/ox/TokenRole.ts +0 -27
  210. package/src/ox/Transaction.test.ts +0 -523
  211. package/src/ox/Transaction.ts +0 -332
  212. package/src/ox/TransactionEnvelopeTempo.test.ts +0 -1352
  213. package/src/ox/TransactionEnvelopeTempo.ts +0 -905
  214. package/src/ox/TransactionReceipt.ts +0 -190
  215. package/src/ox/TransactionRequest.ts +0 -147
  216. package/src/ox/e2e.test.ts +0 -1393
  217. package/src/ox/index.ts +0 -13
  218. package/src/prool/Instance.test.ts +0 -43
  219. package/src/prool/Instance.ts +0 -247
  220. package/src/prool/chain.json +0 -238
  221. package/src/prool/index.ts +0 -1
  222. package/src/viem/Actions/__snapshots__/dex.test.ts.snap +0 -850
  223. package/src/wagmi/Actions/__snapshots__/dex.test.ts.snap +0 -310
  224. package/src/wagmi/Hooks/__snapshots__/dex.test.ts.snap +0 -457
@@ -1,433 +0,0 @@
1
- import * as Hash from 'ox/Hash';
2
- import * as Hex from 'ox/Hex';
3
- import * as Rlp from 'ox/Rlp';
4
- import * as SignatureEnvelope from './SignatureEnvelope.js';
5
- /**
6
- * Converts an [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) AA Authorization object into a typed {@link ox#AuthorizationTempo.AuthorizationTempo}.
7
- *
8
- * @example
9
- * An AA Authorization can be instantiated from an [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) AA Authorization tuple in object format.
10
- *
11
- * ```ts twoslash
12
- * import { AuthorizationTempo } from 'ox'
13
- *
14
- * const authorization = AuthorizationTempo.from({
15
- * address: '0x1234567890abcdef1234567890abcdef12345678',
16
- * chainId: 1,
17
- * nonce: 69n,
18
- * })
19
- * ```
20
- *
21
- * @example
22
- * ### Attaching Signatures
23
- *
24
- * A {@link ox#SignatureEnvelope.SignatureEnvelope} can be attached with the `signature` option. The example below demonstrates signing
25
- * an AA Authorization with {@link ox#Secp256k1.(sign:function)}.
26
- *
27
- * ```ts twoslash
28
- * import { AuthorizationTempo, Secp256k1 } from 'ox'
29
- *
30
- * const authorization = AuthorizationTempo.from({
31
- * address: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
32
- * chainId: 1,
33
- * nonce: 40n,
34
- * })
35
- *
36
- * const signature = Secp256k1.sign({
37
- * payload: AuthorizationTempo.getSignPayload(authorization),
38
- * privateKey: '0x...',
39
- * })
40
- *
41
- * const authorization_signed = AuthorizationTempo.from(authorization, { signature }) // [!code focus]
42
- * ```
43
- *
44
- * @param authorization - An [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) AA Authorization tuple in object format.
45
- * @param options - AA Authorization options.
46
- * @returns The {@link ox#AuthorizationTempo.AuthorizationTempo}.
47
- */
48
- export function from(authorization, options = {}) {
49
- if (typeof authorization.chainId === 'string')
50
- return fromRpc(authorization);
51
- if (options.signature) {
52
- return { ...authorization, signature: options.signature };
53
- }
54
- return authorization;
55
- }
56
- /**
57
- * Converts an {@link ox#AuthorizationTempo.Rpc} to an {@link ox#AuthorizationTempo.AuthorizationTempo}.
58
- *
59
- * @example
60
- * ```ts twoslash
61
- * import { AuthorizationTempo } from 'ox'
62
- *
63
- * const authorization = AuthorizationTempo.fromRpc({
64
- * address: '0x0000000000000000000000000000000000000000',
65
- * chainId: '0x1',
66
- * nonce: '0x1',
67
- * signature: {
68
- * r: '0x635dc2033e60185bb36709c29c75d64ea51dfbd91c32ef4be198e4ceb169fb4d',
69
- * s: '0x50c2667ac4c771072746acfdcf1f1483336dcca8bd2df47cd83175dbe60f0540',
70
- * yParity: '0x0',
71
- * },
72
- * })
73
- * ```
74
- *
75
- * @param authorization - The RPC-formatted AA Authorization.
76
- * @returns A signed {@link ox#AuthorizationTempo.AuthorizationTempo}.
77
- */
78
- export function fromRpc(authorization) {
79
- const { address, chainId, nonce } = authorization;
80
- const signature = SignatureEnvelope.fromRpc(authorization.signature);
81
- return {
82
- address,
83
- chainId: Number(chainId),
84
- nonce: BigInt(nonce),
85
- signature,
86
- };
87
- }
88
- /**
89
- * Converts an {@link ox#AuthorizationTempo.ListRpc} to an {@link ox#AuthorizationTempo.List}.
90
- *
91
- * @example
92
- * ```ts twoslash
93
- * import { AuthorizationTempo } from 'ox'
94
- *
95
- * const authorizationList = AuthorizationTempo.fromRpcList([{
96
- * address: '0x0000000000000000000000000000000000000000',
97
- * chainId: '0x1',
98
- * nonce: '0x1',
99
- * signature: {
100
- * r: '0x635dc2033e60185bb36709c29c75d64ea51dfbd91c32ef4be198e4ceb169fb4d',
101
- * s: '0x50c2667ac4c771072746acfdcf1f1483336dcca8bd2df47cd83175dbe60f0540',
102
- * yParity: '0x0',
103
- * },
104
- * }])
105
- * ```
106
- *
107
- * @param authorizationList - The RPC-formatted AA Authorization list.
108
- * @returns A signed {@link ox#AuthorizationTempo.List}.
109
- */
110
- export function fromRpcList(authorizationList) {
111
- return authorizationList.map((x) => fromRpc(x));
112
- }
113
- /**
114
- * Converts an {@link ox#AuthorizationTempo.Tuple} to an {@link ox#AuthorizationTempo.AuthorizationTempo}.
115
- *
116
- * @example
117
- * ```ts twoslash
118
- * import { AuthorizationTempo } from 'ox'
119
- *
120
- * const authorization = AuthorizationTempo.fromTuple([
121
- * '0x1',
122
- * '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
123
- * '0x3'
124
- * ])
125
- * // @log: {
126
- * // @log: address: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
127
- * // @log: chainId: 1,
128
- * // @log: nonce: 3n
129
- * // @log: }
130
- * ```
131
- *
132
- * @example
133
- * It is also possible to append a serialized SignatureEnvelope to the end of an AA Authorization tuple.
134
- *
135
- * ```ts twoslash
136
- * import { AuthorizationTempo } from 'ox'
137
- *
138
- * const authorization = AuthorizationTempo.fromTuple([
139
- * '0x1',
140
- * '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
141
- * '0x3',
142
- * '0x01a068a020a209d3d56c46f38cc50a33f704f4a9a10a59377f8dd762ac66910e9b907e865ad05c4035ab5792787d4a0297a43617ae897930a6fe4d822b8faea52064',
143
- * ])
144
- * // @log: {
145
- * // @log: address: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
146
- * // @log: chainId: 1,
147
- * // @log: nonce: 3n
148
- * // @log: signature: {
149
- * // @log: r: BigInt('0x68a020a209d3d56c46f38cc50a33f704f4a9a10a59377f8dd762ac66910e9b90'),
150
- * // @log: s: BigInt('0x7e865ad05c4035ab5792787d4a0297a43617ae897930a6fe4d822b8faea52064'),
151
- * // @log: yParity: 0,
152
- * // @log: },
153
- * // @log: }
154
- * ```
155
- *
156
- * @param tuple - The [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) AA Authorization tuple.
157
- * @returns The {@link ox#AuthorizationTempo.AuthorizationTempo}.
158
- */
159
- export function fromTuple(tuple) {
160
- const [chainId, address, nonce, signatureSerialized] = tuple;
161
- const args = {
162
- address,
163
- chainId: chainId === '0x' ? 0 : Number(chainId),
164
- nonce: nonce === '0x' ? 0n : BigInt(nonce),
165
- };
166
- if (signatureSerialized)
167
- args.signature = SignatureEnvelope.deserialize(signatureSerialized);
168
- return from(args);
169
- }
170
- /**
171
- * Converts an {@link ox#AuthorizationTempo.TupleList} to an {@link ox#AuthorizationTempo.List}.
172
- *
173
- * @example
174
- * ```ts twoslash
175
- * import { AuthorizationTempo } from 'ox'
176
- *
177
- * const authorizationList = AuthorizationTempo.fromTupleList([
178
- * ['0x1', '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c', '0x3'],
179
- * ['0x3', '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c', '0x14'],
180
- * ])
181
- * // @log: [
182
- * // @log: {
183
- * // @log: address: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
184
- * // @log: chainId: 1,
185
- * // @log: nonce: 3n,
186
- * // @log: },
187
- * // @log: {
188
- * // @log: address: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
189
- * // @log: chainId: 3,
190
- * // @log: nonce: 20n,
191
- * // @log: },
192
- * // @log: ]
193
- * ```
194
- *
195
- * @example
196
- * It is also possible to append a serialized SignatureEnvelope to the end of an AA Authorization tuple.
197
- *
198
- * ```ts twoslash
199
- * import { AuthorizationTempo } from 'ox'
200
- *
201
- * const authorizationList = AuthorizationTempo.fromTupleList([
202
- * ['0x1', '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c', '0x3', '0x01a068a020a209d3d56c46f38cc50a33f704f4a9a10a59377f8dd762ac66910e9b907e865ad05c4035ab5792787d4a0297a43617ae897930a6fe4d822b8faea52064'],
203
- * ['0x3', '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c', '0x14', '0x01a068a020a209d3d56c46f38cc50a33f704f4a9a10a59377f8dd762ac66910e9b907e865ad05c4035ab5792787d4a0297a43617ae897930a6fe4d822b8faea52064'],
204
- * ])
205
- * // @log: [
206
- * // @log: {
207
- * // @log: address: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
208
- * // @log: chainId: 1,
209
- * // @log: nonce: 3n,
210
- * // @log: signature: {
211
- * // @log: r: BigInt('0x68a020a209d3d56c46f38cc50a33f704f4a9a10a59377f8dd762ac66910e9b90'),
212
- * // @log: s: BigInt('0x7e865ad05c4035ab5792787d4a0297a43617ae897930a6fe4d822b8faea52064'),
213
- * // @log: yParity: 0,
214
- * // @log: },
215
- * // @log: },
216
- * // @log: {
217
- * // @log: address: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
218
- * // @log: chainId: 3,
219
- * // @log: nonce: 20n,
220
- * // @log: signature: {
221
- * // @log: r: BigInt('0x68a020a209d3d56c46f38cc50a33f704f4a9a10a59377f8dd762ac66910e9b90'),
222
- * // @log: s: BigInt('0x7e865ad05c4035ab5792787d4a0297a43617ae897930a6fe4d822b8faea52064'),
223
- * // @log: yParity: 0,
224
- * // @log: },
225
- * // @log: },
226
- * // @log: ]
227
- * ```
228
- *
229
- * @param tupleList - The [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) AA Authorization tuple list.
230
- * @returns An {@link ox#AuthorizationTempo.List}.
231
- */
232
- export function fromTupleList(tupleList) {
233
- const list = [];
234
- for (const tuple of tupleList)
235
- list.push(fromTuple(tuple));
236
- return list;
237
- }
238
- /**
239
- * Computes the sign payload for an {@link ox#AuthorizationTempo.AuthorizationTempo} in [EIP-7702 format](https://eips.ethereum.org/EIPS/eip-7702): `keccak256('0x05' || rlp([chain_id, address, nonce]))`.
240
- *
241
- * @example
242
- * The example below demonstrates computing the sign payload for an {@link ox#AuthorizationTempo.AuthorizationTempo}. This payload
243
- * can then be passed to signing functions like {@link ox#Secp256k1.(sign:function)}.
244
- *
245
- * ```ts twoslash
246
- * import { AuthorizationTempo, Secp256k1 } from 'ox'
247
- *
248
- * const authorization = AuthorizationTempo.from({
249
- * address: '0x1234567890abcdef1234567890abcdef12345678',
250
- * chainId: 1,
251
- * nonce: 69n,
252
- * })
253
- *
254
- * const payload = AuthorizationTempo.getSignPayload(authorization) // [!code focus]
255
- *
256
- * const signature = Secp256k1.sign({
257
- * payload,
258
- * privateKey: '0x...',
259
- * })
260
- * ```
261
- *
262
- * @param authorization - The {@link ox#AuthorizationTempo.AuthorizationTempo}.
263
- * @returns The sign payload.
264
- */
265
- export function getSignPayload(authorization) {
266
- return hash(authorization, { presign: true });
267
- }
268
- /**
269
- * Computes the hash for an {@link ox#AuthorizationTempo.AuthorizationTempo} in [EIP-7702 format](https://eips.ethereum.org/EIPS/eip-7702): `keccak256('0x05' || rlp([chain_id, address, nonce]))`.
270
- *
271
- * @example
272
- * ```ts twoslash
273
- * import { AuthorizationTempo } from 'ox'
274
- *
275
- * const authorization = AuthorizationTempo.from({
276
- * address: '0x1234567890abcdef1234567890abcdef12345678',
277
- * chainId: 1,
278
- * nonce: 69n,
279
- * })
280
- *
281
- * const hash = AuthorizationTempo.hash(authorization) // [!code focus]
282
- * ```
283
- *
284
- * @param authorization - The {@link ox#AuthorizationTempo.AuthorizationTempo}.
285
- * @returns The hash.
286
- */
287
- export function hash(authorization, options = {}) {
288
- const { presign } = options;
289
- return Hash.keccak256(Hex.concat('0x05', Rlp.fromHex(toTuple(presign
290
- ? {
291
- address: authorization.address,
292
- chainId: authorization.chainId,
293
- nonce: authorization.nonce,
294
- }
295
- : authorization))));
296
- }
297
- /**
298
- * Converts an {@link ox#AuthorizationTempo.AuthorizationTempo} to an {@link ox#AuthorizationTempo.Rpc}.
299
- *
300
- * @example
301
- * ```ts twoslash
302
- * import { AuthorizationTempo } from 'ox'
303
- *
304
- * const authorization = AuthorizationTempo.toRpc({
305
- * address: '0x0000000000000000000000000000000000000000',
306
- * chainId: 1,
307
- * nonce: 1n,
308
- * signature: {
309
- * r: 44944627813007772897391531230081695102703289123332187696115181104739239197517n,
310
- * s: 36528503505192438307355164441104001310566505351980369085208178712678799181120n,
311
- * yParity: 0,
312
- * },
313
- * })
314
- * ```
315
- *
316
- * @param authorization - An AA Authorization.
317
- * @returns An RPC-formatted AA Authorization.
318
- */
319
- export function toRpc(authorization) {
320
- const { address, chainId, nonce, signature } = authorization;
321
- return {
322
- address,
323
- chainId: Hex.fromNumber(chainId),
324
- nonce: Hex.fromNumber(nonce),
325
- signature: SignatureEnvelope.toRpc(signature),
326
- };
327
- }
328
- /**
329
- * Converts an {@link ox#AuthorizationTempo.List} to an {@link ox#AuthorizationTempo.ListRpc}.
330
- *
331
- * @example
332
- * ```ts twoslash
333
- * import { AuthorizationTempo } from 'ox'
334
- *
335
- * const authorization = AuthorizationTempo.toRpcList([{
336
- * address: '0x0000000000000000000000000000000000000000',
337
- * chainId: 1,
338
- * nonce: 1n,
339
- * signature: {
340
- * r: 44944627813007772897391531230081695102703289123332187696115181104739239197517n,
341
- * s: 36528503505192438307355164441104001310566505351980369085208178712678799181120n,
342
- * yParity: 0,
343
- * },
344
- * }])
345
- * ```
346
- *
347
- * @param authorizationList - An AA Authorization List.
348
- * @returns An RPC-formatted AA Authorization List.
349
- */
350
- export function toRpcList(authorizationList) {
351
- return authorizationList.map((x) => toRpc(x));
352
- }
353
- /**
354
- * Converts an {@link ox#AuthorizationTempo.AuthorizationTempo} to an {@link ox#AuthorizationTempo.Tuple}.
355
- *
356
- * @example
357
- * ```ts twoslash
358
- * import { AuthorizationTempo } from 'ox'
359
- *
360
- * const authorization = AuthorizationTempo.from({
361
- * address: '0x1234567890abcdef1234567890abcdef12345678',
362
- * chainId: 1,
363
- * nonce: 69n,
364
- * })
365
- *
366
- * const tuple = AuthorizationTempo.toTuple(authorization) // [!code focus]
367
- * // @log: [
368
- * // @log: address: '0x1234567890abcdef1234567890abcdef12345678',
369
- * // @log: chainId: 1,
370
- * // @log: nonce: 69n,
371
- * // @log: ]
372
- * ```
373
- *
374
- * @param authorization - The {@link ox#AuthorizationTempo.AuthorizationTempo}.
375
- * @returns An [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) AA Authorization tuple.
376
- */
377
- export function toTuple(authorization) {
378
- const { address, chainId, nonce } = authorization;
379
- const signature = authorization.signature
380
- ? SignatureEnvelope.serialize(authorization.signature)
381
- : undefined;
382
- return [
383
- chainId ? Hex.fromNumber(chainId) : '0x',
384
- address,
385
- nonce ? Hex.fromNumber(nonce) : '0x',
386
- ...(signature ? [signature] : []),
387
- ];
388
- }
389
- /**
390
- * Converts an {@link ox#AuthorizationTempo.List} to an {@link ox#AuthorizationTempo.TupleList}.
391
- *
392
- * @example
393
- * ```ts twoslash
394
- * import { AuthorizationTempo } from 'ox'
395
- *
396
- * const authorization_1 = AuthorizationTempo.from({
397
- * address: '0x1234567890abcdef1234567890abcdef12345678',
398
- * chainId: 1,
399
- * nonce: 69n,
400
- * })
401
- * const authorization_2 = AuthorizationTempo.from({
402
- * address: '0x1234567890abcdef1234567890abcdef12345678',
403
- * chainId: 3,
404
- * nonce: 20n,
405
- * })
406
- *
407
- * const tuple = AuthorizationTempo.toTupleList([authorization_1, authorization_2]) // [!code focus]
408
- * // @log: [
409
- * // @log: [
410
- * // @log: address: '0x1234567890abcdef1234567890abcdef12345678',
411
- * // @log: chainId: 1,
412
- * // @log: nonce: 69n,
413
- * // @log: ],
414
- * // @log: [
415
- * // @log: address: '0x1234567890abcdef1234567890abcdef12345678',
416
- * // @log: chainId: 3,
417
- * // @log: nonce: 20n,
418
- * // @log: ],
419
- * // @log: ]
420
- * ```
421
- *
422
- * @param list - An {@link ox#AuthorizationTempo.List}.
423
- * @returns An [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) AA Authorization tuple list.
424
- */
425
- export function toTupleList(list) {
426
- if (!list || list.length === 0)
427
- return [];
428
- const tupleList = [];
429
- for (const authorization of list)
430
- tupleList.push(toTuple(authorization));
431
- return tupleList;
432
- }
433
- //# sourceMappingURL=AuthorizationTempo.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AuthorizationTempo.js","sourceRoot":"","sources":["../../src/ox/AuthorizationTempo.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,IAAI,MAAM,SAAS,CAAA;AAC/B,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAA;AAC7B,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAA;AAE7B,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAA;AA2E3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,MAAM,UAA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