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
@@ -11,9 +11,9 @@ import type {
11
11
  } from './internal/types.js'
12
12
  import * as Rlp from './Rlp.js'
13
13
  import * as Signature from './Signature.js'
14
- import * as TransactionEnvelope from './TransactionEnvelope.js'
14
+ import * as TransactionEnvelope from './TxEnvelope.js'
15
15
 
16
- export type TransactionEnvelopeLegacy<
16
+ export type TxEnvelopeLegacy<
17
17
  signed extends boolean = boolean,
18
18
  bigintType = bigint,
19
19
  numberType = number,
@@ -28,7 +28,7 @@ export type TransactionEnvelopeLegacy<
28
28
  }
29
29
  >
30
30
 
31
- export type Rpc<signed extends boolean = boolean> = TransactionEnvelopeLegacy<
31
+ export type Rpc<signed extends boolean = boolean> = TxEnvelopeLegacy<
32
32
  signed,
33
33
  Hex.Hex,
34
34
  Hex.Hex,
@@ -37,19 +37,19 @@ export type Rpc<signed extends boolean = boolean> = TransactionEnvelopeLegacy<
37
37
 
38
38
  export type Serialized = Branded<`0x${string}`, 'legacy'>
39
39
 
40
- export type Signed = TransactionEnvelopeLegacy<true>
40
+ export type Signed = TxEnvelopeLegacy<true>
41
41
 
42
42
  export const type = 'legacy'
43
43
  export type Type = typeof type
44
44
 
45
45
  /**
46
- * Asserts a {@link ox#TransactionEnvelopeLegacy.TransactionEnvelopeLegacy} is valid.
46
+ * Asserts a {@link ox#TxEnvelopeLegacy.TxEnvelopeLegacy} is valid.
47
47
  *
48
48
  * @example
49
49
  * ```ts twoslash
50
- * import { TransactionEnvelopeLegacy, Value } from 'ox'
50
+ * import { TxEnvelopeLegacy, Value } from 'ox'
51
51
  *
52
- * TransactionEnvelopeLegacy.assert({
52
+ * TxEnvelopeLegacy.assert({
53
53
  * gasPrice: 2n ** 256n - 1n + 1n,
54
54
  * chainId: 1,
55
55
  * to: '0x0000000000000000000000000000000000000000',
@@ -62,7 +62,7 @@ export type Type = typeof type
62
62
  *
63
63
  * @param envelope - The transaction envelope to assert.
64
64
  */
65
- export function assert(envelope: PartialBy<TransactionEnvelopeLegacy, 'type'>) {
65
+ export function assert(envelope: PartialBy<TxEnvelopeLegacy, 'type'>) {
66
66
  const { chainId, gasPrice, to } = envelope
67
67
  if (to) Address.assert(to, { strict: false })
68
68
  if (typeof chainId !== 'undefined' && chainId <= 0)
@@ -80,13 +80,13 @@ export declare namespace assert {
80
80
  }
81
81
 
82
82
  /**
83
- * Deserializes a {@link ox#TransactionEnvelopeLegacy.TransactionEnvelopeLegacy} from its serialized form.
83
+ * Deserializes a {@link ox#TxEnvelopeLegacy.TxEnvelopeLegacy} from its serialized form.
84
84
  *
85
85
  * @example
86
86
  * ```ts twoslash
87
- * import { TransactionEnvelopeLegacy } from 'ox'
87
+ * import { TxEnvelopeLegacy } from 'ox'
88
88
  *
89
- * const envelope = TransactionEnvelopeLegacy.deserialize('0x01ef0182031184773594008477359400809470997970c51812dc3a010c7d01b50e0d17dc79c8880de0b6b3a764000080c0')
89
+ * const envelope = TxEnvelopeLegacy.deserialize('0x01ef0182031184773594008477359400809470997970c51812dc3a010c7d01b50e0d17dc79c8880de0b6b3a764000080c0')
90
90
  * // @log: {
91
91
  * // @log: type: 'legacy',
92
92
  * // @log: nonce: 785n,
@@ -100,9 +100,7 @@ export declare namespace assert {
100
100
  * @param serialized - The serialized transaction.
101
101
  * @returns Deserialized Transaction Envelope.
102
102
  */
103
- export function deserialize(
104
- serialized: Hex.Hex,
105
- ): Compute<TransactionEnvelopeLegacy> {
103
+ export function deserialize(serialized: Hex.Hex): Compute<TxEnvelopeLegacy> {
106
104
  const tuple = Rlp.toHex(serialized)
107
105
 
108
106
  const [nonce, gasPrice, gas, to, value, data, chainIdOrV_, r, s] =
@@ -131,7 +129,7 @@ export function deserialize(
131
129
 
132
130
  const transaction = {
133
131
  type,
134
- } as TransactionEnvelopeLegacy
132
+ } as TxEnvelopeLegacy
135
133
  if (Hex.validate(to) && to !== '0x') transaction.to = to
136
134
  if (Hex.validate(gas) && gas !== '0x') transaction.gas = BigInt(gas)
137
135
  if (Hex.validate(data) && data !== '0x') transaction.data = data
@@ -177,9 +175,9 @@ export declare namespace deserialize {
177
175
  *
178
176
  * @example
179
177
  * ```ts twoslash
180
- * import { TransactionEnvelopeLegacy, Value } from 'ox'
178
+ * import { TxEnvelopeLegacy, Value } from 'ox'
181
179
  *
182
- * const envelope = TransactionEnvelopeLegacy.from({
180
+ * const envelope = TxEnvelopeLegacy.from({
183
181
  * gasPrice: Value.fromGwei('10'),
184
182
  * to: '0x0000000000000000000000000000000000000000',
185
183
  * value: Value.fromEther('1'),
@@ -192,9 +190,9 @@ export declare namespace deserialize {
192
190
  * It is possible to attach a `signature` to the transaction envelope.
193
191
  *
194
192
  * ```ts twoslash
195
- * import { Secp256k1, TransactionEnvelopeLegacy, Value } from 'ox'
193
+ * import { Secp256k1, TxEnvelopeLegacy, Value } from 'ox'
196
194
  *
197
- * const envelope = TransactionEnvelopeLegacy.from({
195
+ * const envelope = TxEnvelopeLegacy.from({
198
196
  * chainId: 1,
199
197
  * gasPrice: Value.fromGwei('10'),
200
198
  * to: '0x0000000000000000000000000000000000000000',
@@ -202,11 +200,11 @@ export declare namespace deserialize {
202
200
  * })
203
201
  *
204
202
  * const signature = Secp256k1.sign({
205
- * payload: TransactionEnvelopeLegacy.getSignPayload(envelope),
203
+ * payload: TxEnvelopeLegacy.getSignPayload(envelope),
206
204
  * privateKey: '0x...',
207
205
  * })
208
206
  *
209
- * const envelope_signed = TransactionEnvelopeLegacy.from(envelope, { // [!code focus]
207
+ * const envelope_signed = TxEnvelopeLegacy.from(envelope, { // [!code focus]
210
208
  * signature, // [!code focus]
211
209
  * }) // [!code focus]
212
210
  * // @log: {
@@ -225,12 +223,12 @@ export declare namespace deserialize {
225
223
  * @example
226
224
  * ### From Serialized
227
225
  *
228
- * It is possible to instantiate an legacy Transaction Envelope from a {@link ox#TransactionEnvelopeLegacy.Serialized} value.
226
+ * It is possible to instantiate an legacy Transaction Envelope from a {@link ox#TxEnvelopeLegacy.Serialized} value.
229
227
  *
230
228
  * ```ts twoslash
231
- * import { TransactionEnvelopeLegacy } from 'ox'
229
+ * import { TxEnvelopeLegacy } from 'ox'
232
230
  *
233
- * const envelope = TransactionEnvelopeLegacy.from('0xf858018203118502540be4008504a817c800809470997970c51812dc3a010c7d01b50e0d17dc79c8880de0b6b3a764000080c08477359400e1a001627c687261b0e7f8638af1112efa8a77e23656f6e7945275b19e9deed80261')
231
+ * const envelope = TxEnvelopeLegacy.from('0xf858018203118502540be4008504a817c800809470997970c51812dc3a010c7d01b50e0d17dc79c8880de0b6b3a764000080c08477359400e1a001627c687261b0e7f8638af1112efa8a77e23656f6e7945275b19e9deed80261')
234
232
  * // @log: {
235
233
  * // @log: chainId: 1,
236
234
  * // @log: gasPrice: 10000000000n,
@@ -245,22 +243,17 @@ export declare namespace deserialize {
245
243
  * @returns A legacy Transaction Envelope.
246
244
  */
247
245
  export function from<
248
- const envelope extends
249
- | UnionPartialBy<TransactionEnvelopeLegacy, 'type'>
250
- | Hex.Hex,
246
+ const envelope extends UnionPartialBy<TxEnvelopeLegacy, 'type'> | Hex.Hex,
251
247
  const signature extends Signature.Signature | undefined = undefined,
252
248
  >(
253
- envelope:
254
- | envelope
255
- | UnionPartialBy<TransactionEnvelopeLegacy, 'type'>
256
- | Hex.Hex,
249
+ envelope: envelope | UnionPartialBy<TxEnvelopeLegacy, 'type'> | Hex.Hex,
257
250
  options: from.Options<signature> = {},
258
251
  ): from.ReturnType<envelope, signature> {
259
252
  const { signature } = options
260
253
 
261
254
  const envelope_ = (
262
255
  typeof envelope === 'string' ? deserialize(envelope) : envelope
263
- ) as TransactionEnvelopeLegacy
256
+ ) as TxEnvelopeLegacy
264
257
 
265
258
  assert(envelope_)
266
259
 
@@ -285,13 +278,13 @@ export declare namespace from {
285
278
  }
286
279
 
287
280
  type ReturnType<
288
- envelope extends
289
- | UnionPartialBy<TransactionEnvelopeLegacy, 'type'>
290
- | Hex.Hex = TransactionEnvelopeLegacy | Hex.Hex,
281
+ envelope extends UnionPartialBy<TxEnvelopeLegacy, 'type'> | Hex.Hex =
282
+ | TxEnvelopeLegacy
283
+ | Hex.Hex,
291
284
  signature extends Signature.Signature | undefined = undefined,
292
285
  > = Compute<
293
286
  envelope extends Hex.Hex
294
- ? TransactionEnvelopeLegacy
287
+ ? TxEnvelopeLegacy
295
288
  : Assign<
296
289
  envelope,
297
290
  (signature extends Signature.Signature
@@ -313,7 +306,7 @@ export declare namespace from {
313
306
  }
314
307
 
315
308
  /**
316
- * Returns the payload to sign for a {@link ox#TransactionEnvelopeLegacy.TransactionEnvelopeLegacy}.
309
+ * Returns the payload to sign for a {@link ox#TxEnvelopeLegacy.TxEnvelopeLegacy}.
317
310
  *
318
311
  * @example
319
312
  * The example below demonstrates how to compute the sign payload which can be used
@@ -321,9 +314,9 @@ export declare namespace from {
321
314
  *
322
315
  * ```ts twoslash
323
316
  * // @noErrors
324
- * import { Secp256k1, TransactionEnvelopeLegacy } from 'ox'
317
+ * import { Secp256k1, TxEnvelopeLegacy } from 'ox'
325
318
  *
326
- * const envelope = TransactionEnvelopeLegacy.from({
319
+ * const envelope = TxEnvelopeLegacy.from({
327
320
  * nonce: 0n,
328
321
  * gasPrice: 1000000000n,
329
322
  * gas: 21000n,
@@ -331,7 +324,7 @@ export declare namespace from {
331
324
  * value: 1000000000000000000n,
332
325
  * })
333
326
  *
334
- * const payload = TransactionEnvelopeLegacy.getSignPayload(envelope) // [!code focus]
327
+ * const payload = TxEnvelopeLegacy.getSignPayload(envelope) // [!code focus]
335
328
  * // @log: '0x...'
336
329
  *
337
330
  * const signature = Secp256k1.sign({ payload, privateKey: '0x...' })
@@ -341,7 +334,7 @@ export declare namespace from {
341
334
  * @returns The sign payload.
342
335
  */
343
336
  export function getSignPayload(
344
- envelope: TransactionEnvelopeLegacy<false>,
337
+ envelope: TxEnvelopeLegacy<false>,
345
338
  ): getSignPayload.ReturnType {
346
339
  return hash(envelope, { presign: true })
347
340
  }
@@ -353,13 +346,13 @@ export declare namespace getSignPayload {
353
346
  }
354
347
 
355
348
  /**
356
- * Hashes a {@link ox#TransactionEnvelopeLegacy.TransactionEnvelopeLegacy}. This is the "transaction hash".
349
+ * Hashes a {@link ox#TxEnvelopeLegacy.TxEnvelopeLegacy}. This is the "transaction hash".
357
350
  *
358
351
  * @example
359
352
  * ```ts twoslash
360
- * import { Secp256k1, TransactionEnvelopeLegacy } from 'ox'
353
+ * import { Secp256k1, TxEnvelopeLegacy } from 'ox'
361
354
  *
362
- * const envelope = TransactionEnvelopeLegacy.from({
355
+ * const envelope = TxEnvelopeLegacy.from({
363
356
  * chainId: 1,
364
357
  * nonce: 0n,
365
358
  * gasPrice: 1000000000n,
@@ -369,13 +362,13 @@ export declare namespace getSignPayload {
369
362
  * })
370
363
  *
371
364
  * const signature = Secp256k1.sign({
372
- * payload: TransactionEnvelopeLegacy.getSignPayload(envelope),
365
+ * payload: TxEnvelopeLegacy.getSignPayload(envelope),
373
366
  * privateKey: '0x...'
374
367
  * })
375
368
  *
376
- * const envelope_signed = TransactionEnvelopeLegacy.from(envelope, { signature })
369
+ * const envelope_signed = TxEnvelopeLegacy.from(envelope, { signature })
377
370
  *
378
- * const hash = TransactionEnvelopeLegacy.hash(envelope_signed) // [!code focus]
371
+ * const hash = TxEnvelopeLegacy.hash(envelope_signed) // [!code focus]
379
372
  * ```
380
373
  *
381
374
  * @param envelope - The Legacy Transaction Envelope to hash.
@@ -383,7 +376,7 @@ export declare namespace getSignPayload {
383
376
  * @returns The hash of the transaction envelope.
384
377
  */
385
378
  export function hash<presign extends boolean = false>(
386
- envelope: TransactionEnvelopeLegacy<presign extends true ? false : true>,
379
+ envelope: TxEnvelopeLegacy<presign extends true ? false : true>,
387
380
  options: hash.Options<presign> = {},
388
381
  ): hash.ReturnType {
389
382
  const { presign } = options
@@ -417,21 +410,21 @@ export declare namespace hash {
417
410
  }
418
411
 
419
412
  /**
420
- * Serializes a {@link ox#TransactionEnvelopeLegacy.TransactionEnvelopeLegacy}.
413
+ * Serializes a {@link ox#TxEnvelopeLegacy.TxEnvelopeLegacy}.
421
414
  *
422
415
  * @example
423
416
  * ```ts twoslash
424
417
  * // @noErrors
425
- * import { TransactionEnvelopeLegacy } from 'ox'
418
+ * import { TxEnvelopeLegacy } from 'ox'
426
419
  *
427
- * const envelope = TransactionEnvelopeLegacy.from({
420
+ * const envelope = TxEnvelopeLegacy.from({
428
421
  * chainId: 1,
429
422
  * gasPrice: Value.fromGwei('10'),
430
423
  * to: '0x0000000000000000000000000000000000000000',
431
424
  * value: Value.fromEther('1'),
432
425
  * })
433
426
  *
434
- * const serialized = TransactionEnvelopeLegacy.serialize(envelope) // [!code focus]
427
+ * const serialized = TxEnvelopeLegacy.serialize(envelope) // [!code focus]
435
428
  * ```
436
429
  *
437
430
  * @example
@@ -441,9 +434,9 @@ export declare namespace hash {
441
434
  *
442
435
  * ```ts twoslash
443
436
  * // @noErrors
444
- * import { Secp256k1, TransactionEnvelopeLegacy, Value } from 'ox'
437
+ * import { Secp256k1, TxEnvelopeLegacy, Value } from 'ox'
445
438
  *
446
- * const envelope = TransactionEnvelopeLegacy.from({
439
+ * const envelope = TxEnvelopeLegacy.from({
447
440
  * chainId: 1,
448
441
  * gasPrice: Value.fromGwei('10'),
449
442
  * to: '0x0000000000000000000000000000000000000000',
@@ -451,11 +444,11 @@ export declare namespace hash {
451
444
  * })
452
445
  *
453
446
  * const signature = Secp256k1.sign({
454
- * payload: TransactionEnvelopeLegacy.getSignPayload(envelope),
447
+ * payload: TxEnvelopeLegacy.getSignPayload(envelope),
455
448
  * privateKey: '0x...',
456
449
  * })
457
450
  *
458
- * const serialized = TransactionEnvelopeLegacy.serialize(envelope, { // [!code focus]
451
+ * const serialized = TxEnvelopeLegacy.serialize(envelope, { // [!code focus]
459
452
  * signature, // [!code focus]
460
453
  * }) // [!code focus]
461
454
  *
@@ -467,7 +460,7 @@ export declare namespace hash {
467
460
  * @returns The serialized Transaction Envelope.
468
461
  */
469
462
  export function serialize(
470
- envelope: PartialBy<TransactionEnvelopeLegacy, 'type'>,
463
+ envelope: PartialBy<TxEnvelopeLegacy, 'type'>,
471
464
  options: serialize.Options = {},
472
465
  ): Serialized {
473
466
  const { chainId = 0, gas, data, input, nonce, to, value, gasPrice } = envelope
@@ -547,13 +540,13 @@ export declare namespace serialize {
547
540
  }
548
541
 
549
542
  /**
550
- * Converts an {@link ox#TransactionEnvelopeLegacy.TransactionEnvelopeLegacy} to an {@link ox#TransactionEnvelopeLegacy.Rpc}.
543
+ * Converts an {@link ox#TxEnvelopeLegacy.TxEnvelopeLegacy} to an {@link ox#TxEnvelopeLegacy.Rpc}.
551
544
  *
552
545
  * @example
553
546
  * ```ts twoslash
554
- * import { RpcRequest, TransactionEnvelopeLegacy, Value } from 'ox'
547
+ * import { RpcRequest, TxEnvelopeLegacy, Value } from 'ox'
555
548
  *
556
- * const envelope = TransactionEnvelopeLegacy.from({
549
+ * const envelope = TxEnvelopeLegacy.from({
557
550
  * chainId: 1,
558
551
  * nonce: 0n,
559
552
  * gas: 21000n,
@@ -561,7 +554,7 @@ export declare namespace serialize {
561
554
  * value: Value.fromEther('1'),
562
555
  * })
563
556
  *
564
- * const envelope_rpc = TransactionEnvelopeLegacy.toRpc(envelope) // [!code focus]
557
+ * const envelope_rpc = TxEnvelopeLegacy.toRpc(envelope) // [!code focus]
565
558
  *
566
559
  * const request = RpcRequest.from({
567
560
  * id: 0,
@@ -573,7 +566,7 @@ export declare namespace serialize {
573
566
  * @param envelope - The legacy transaction envelope to convert.
574
567
  * @returns An RPC-formatted legacy transaction envelope.
575
568
  */
576
- export function toRpc(envelope: Omit<TransactionEnvelopeLegacy, 'type'>): Rpc {
569
+ export function toRpc(envelope: Omit<TxEnvelopeLegacy, 'type'>): Rpc {
577
570
  const signature = Signature.extract(envelope)!
578
571
 
579
572
  return {
@@ -610,13 +603,13 @@ export declare namespace toRpc {
610
603
  }
611
604
 
612
605
  /**
613
- * Validates a {@link ox#TransactionEnvelopeLegacy.TransactionEnvelopeLegacy}. Returns `true` if the envelope is valid, `false` otherwise.
606
+ * Validates a {@link ox#TxEnvelopeLegacy.TxEnvelopeLegacy}. Returns `true` if the envelope is valid, `false` otherwise.
614
607
  *
615
608
  * @example
616
609
  * ```ts twoslash
617
- * import { TransactionEnvelopeLegacy, Value } from 'ox'
610
+ * import { TxEnvelopeLegacy, Value } from 'ox'
618
611
  *
619
- * const valid = TransactionEnvelopeLegacy.assert({
612
+ * const valid = TxEnvelopeLegacy.assert({
620
613
  * gasPrice: 2n ** 256n - 1n + 1n,
621
614
  * chainId: 1,
622
615
  * to: '0x0000000000000000000000000000000000000000',
@@ -627,9 +620,7 @@ export declare namespace toRpc {
627
620
  *
628
621
  * @param envelope - The transaction envelope to validate.
629
622
  */
630
- export function validate(
631
- envelope: PartialBy<TransactionEnvelopeLegacy, 'type'>,
632
- ) {
623
+ export function validate(envelope: PartialBy<TxEnvelopeLegacy, 'type'>) {
633
624
  try {
634
625
  assert(envelope)
635
626
  return true
@@ -254,7 +254,8 @@ export function getCredentialCreationOptions(
254
254
  publicKey: {
255
255
  attestation,
256
256
  authenticatorSelection,
257
- challenge,
257
+ challenge:
258
+ typeof challenge === 'string' ? Bytes.fromHex(challenge) : challenge,
258
259
  ...(excludeCredentialIds
259
260
  ? {
260
261
  excludeCredentials: excludeCredentialIds?.map((id) => ({
@@ -301,6 +302,7 @@ export declare namespace getCredentialCreationOptions {
301
302
  * An `ArrayBuffer`, `TypedArray`, or `DataView` used as a cryptographic challenge.
302
303
  */
303
304
  challenge?:
305
+ | Hex.Hex
304
306
  | internal.PublicKeyCredentialCreationOptions['challenge']
305
307
  | undefined
306
308
  /**
@@ -31,12 +31,19 @@ export type AttributionSchemaId0 = {
31
31
  export type AttributionSchemaId1 = {
32
32
  /** Attribution codes identifying entities involved in the transaction. */
33
33
  codes: readonly string[]
34
- /** Address of the custom code registry contract. */
35
- codeRegistryAddress: Address.Address
34
+ /* The custom code registry contract. */
35
+ codeRegistry: AttributionSchemaId1Registry
36
36
  /** Schema identifier (1 for custom registry). */
37
37
  id?: 1 | undefined
38
38
  }
39
39
 
40
+ export type AttributionSchemaId1Registry = {
41
+ /** Address of the custom code registry contract. */
42
+ address: Address.Address
43
+ /** Chain Id of the chain the custom code registry contract is deployed on. */
44
+ chainId: number
45
+ }
46
+
40
47
  /**
41
48
  * Attribution schema identifier.
42
49
  *
@@ -71,7 +78,10 @@ export const ercSuffixSize = /*#__PURE__*/ Hex.size(ercSuffix)
71
78
  *
72
79
  * const schemaId2 = Attribution.getSchemaId({
73
80
  * codes: ['baseapp'],
74
- * codeRegistryAddress: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'
81
+ * codeRegistry: {
82
+ * address: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
83
+ * chainId: 8453,
84
+ * }
75
85
  * })
76
86
  * // @log: 1
77
87
  * ```
@@ -80,7 +90,7 @@ export const ercSuffixSize = /*#__PURE__*/ Hex.size(ercSuffix)
80
90
  * @returns The schema ID (0 for canonical registry, 1 for custom registry).
81
91
  */
82
92
  export function getSchemaId(attribution: Attribution): SchemaId {
83
- if ('codeRegistryAddress' in attribution) return 1
93
+ if ('codeRegistry' in attribution) return 1
84
94
  return 0
85
95
  }
86
96
 
@@ -111,7 +121,10 @@ export declare namespace getSchemaId {
111
121
  *
112
122
  * const suffix = Attribution.toDataSuffix({
113
123
  * codes: ['baseapp'],
114
- * codeRegistryAddress: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'
124
+ * codeRegistry: {
125
+ * address: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
126
+ * chainId: 8453,
127
+ * }
115
128
  * })
116
129
  * ```
117
130
  *
@@ -133,15 +146,17 @@ export function toDataSuffix(attribution: Attribution): Hex.Hex {
133
146
  const schemaIdHex = Hex.fromNumber(schemaId, { size: 1 })
134
147
 
135
148
  // Build the suffix based on schema
136
- if (schemaId === 1)
137
- // Schema 1: codeRegistryAddress codes ∥ codesLength ∥ schemaId ∥ ercSuffix
149
+ if (schemaId === 1) {
150
+ const schema1 = attribution as AttributionSchemaId1
151
+ // Schema 1: codeRegistryAddress (20 bytes) ∥ chainId ∥ chainIdLength (1 byte) ∥ codes ∥ codesLength (1 byte) ∥ schemaId (1 byte) ∥ ercSuffix
138
152
  return Hex.concat(
139
- attribution.codeRegistryAddress!.toLowerCase() as Address.Address,
153
+ registryToData(schema1.codeRegistry),
140
154
  codesHex,
141
155
  codesLengthHex,
142
156
  schemaIdHex,
143
157
  ercSuffix,
144
158
  )
159
+ }
145
160
 
146
161
  // Schema 0: codes ∥ codesLength ∥ schemaId ∥ ercSuffix
147
162
  return Hex.concat(codesHex, codesLengthHex, schemaIdHex, ercSuffix)
@@ -179,11 +194,14 @@ export declare namespace toDataSuffix {
179
194
  * import { Attribution } from 'ox/erc8021'
180
195
  *
181
196
  * const attribution = Attribution.fromData(
182
- * '0xddddddddcccccccccccccccccccccccccccccccccccccccc626173656170702c6d6f7270686f0e0180218021802180218021802180218021'
197
+ * '0xddddddddcccccccccccccccccccccccccccccccccccccccc210502626173656170702C6D6F7270686F0E0180218021802180218021802180218021'
183
198
  * )
184
199
  * // @log: {
185
200
  * // @log: codes: ['baseapp', 'morpho'],
186
- * // @log: codeRegistryAddress: '0xcccccccccccccccccccccccccccccccccccccccc',
201
+ * // @log: registry: {
202
+ * // @log: address: '0xcccccccccccccccccccccccccccccccccccccccc`
203
+ * // @log: chainId: 8453,
204
+ * // @log: }
187
205
  * // @log: id: 1
188
206
  * // @log: }
189
207
  * ```
@@ -225,7 +243,7 @@ export function fromData(data: Hex.Hex): Attribution | undefined {
225
243
  }
226
244
 
227
245
  // Schema 1: Custom registry
228
- // Format: codeRegistryAddress (20 bytes) ∥ codes ∥ codesLength (1 byte) ∥ schemaId (1 byte) ∥ ercSuffix
246
+ // Format: codeRegistryAddress (20 bytes) ∥ chainId ∥ chainIdLength (1 byte) ∥ codes ∥ codesLength (1 byte) ∥ schemaId (1 byte) ∥ ercSuffix
229
247
  if (schemaId === 1) {
230
248
  // Extract codes length (1 byte before schema ID)
231
249
  const codesLengthHex = Hex.slice(
@@ -242,13 +260,13 @@ export function fromData(data: Hex.Hex): Attribution | undefined {
242
260
  const codesString = Hex.toString(codesHex)
243
261
  const codes = codesString.length > 0 ? codesString.split(',') : []
244
262
 
245
- // Extract registry address (20 bytes before codes)
246
- const registryStart = codesStart - 20
247
- const codeRegistryAddress = Hex.slice(data, registryStart, codesStart)
263
+ // Extract registry by reading backwards from just before codes
264
+ const codeRegistry = registryFromData(Hex.slice(data, 0, codesStart))
265
+ if (codeRegistry === undefined) return undefined
248
266
 
249
267
  return {
250
268
  codes,
251
- codeRegistryAddress,
269
+ codeRegistry,
252
270
  id: 1,
253
271
  }
254
272
  }
@@ -257,6 +275,50 @@ export function fromData(data: Hex.Hex): Attribution | undefined {
257
275
  return undefined
258
276
  }
259
277
 
278
+ function registryFromData(
279
+ data: Hex.Hex,
280
+ ): AttributionSchemaId1Registry | undefined {
281
+ // Expect at least: address (20 bytes) + chainIdLen (1 byte)
282
+ const minRegistrySize = 20 + 1
283
+ if (Hex.size(data) < minRegistrySize) return undefined
284
+
285
+ // Read chainId length from the last byte of the registry segment
286
+ const chainIdLenHex = Hex.slice(data, -1)
287
+ const chainIdLen = Hex.toNumber(chainIdLenHex)
288
+
289
+ if (chainIdLen === 0) return undefined
290
+
291
+ // Validate we have enough bytes to cover address + chainId + chainIdLen
292
+ const totalRegistrySize = 20 + chainIdLen + 1
293
+ if (Hex.size(data) < totalRegistrySize) return undefined
294
+
295
+ // Address is located immediately before chainId and chainIdLen (read from back)
296
+ const addressStart = -(chainIdLen + 1 + 20)
297
+ const addressEnd = -(chainIdLen + 1)
298
+ const addressHex = Hex.slice(data, addressStart, addressEnd)
299
+ // Chain ID occupies the bytes preceding the final length byte (read from back)
300
+ const chainIdHex = Hex.slice(data, -(chainIdLen + 1), -1)
301
+
302
+ const codeRegistry: AttributionSchemaId1Registry = {
303
+ address: addressHex as Address.Address,
304
+ chainId: Hex.toNumber(chainIdHex),
305
+ }
306
+
307
+ return codeRegistry
308
+ }
309
+
310
+ function registryToData(registry: AttributionSchemaId1Registry): Hex.Hex {
311
+ const chainIdAsHex = Hex.fromNumber(registry.chainId)
312
+ const chainIdLen = Hex.size(chainIdAsHex)
313
+ // Need to padleft because the output of size may not be a full byte (1 -> 0x1 vs 0x01)
314
+ const paddedChainId = Hex.padLeft(chainIdAsHex, chainIdLen)
315
+ return Hex.concat(
316
+ registry.address as Hex.Hex,
317
+ paddedChainId,
318
+ Hex.fromNumber(chainIdLen, { size: 1 }),
319
+ )
320
+ }
321
+
260
322
  export declare namespace fromData {
261
323
  type ErrorType =
262
324
  | Hex.slice.ErrorType
package/index.docs.ts CHANGED
@@ -7,3 +7,4 @@ export * from './erc6492/index.js'
7
7
  export * from './erc7821/index.js'
8
8
  export * from './erc8010/index.js'
9
9
  export * from './erc8021/index.js'
10
+ export * from './tempo/index.js'