ox 1.7.5 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/core/Frame.d.ts +290 -0
- package/dist/core/Frame.d.ts.map +1 -0
- package/dist/core/Frame.js +306 -0
- package/dist/core/Frame.js.map +1 -0
- package/dist/core/FrameReceipt.d.ts +92 -0
- package/dist/core/FrameReceipt.d.ts.map +1 -0
- package/dist/core/FrameReceipt.js +72 -0
- package/dist/core/FrameReceipt.js.map +1 -0
- package/dist/core/FrameSignature.d.ts +357 -0
- package/dist/core/FrameSignature.d.ts.map +1 -0
- package/dist/core/FrameSignature.js +411 -0
- package/dist/core/FrameSignature.js.map +1 -0
- package/dist/core/Transaction.d.ts +29 -4
- package/dist/core/Transaction.d.ts.map +1 -1
- package/dist/core/Transaction.js +25 -4
- package/dist/core/Transaction.js.map +1 -1
- package/dist/core/TransactionReceipt.d.ts +13 -4
- package/dist/core/TransactionReceipt.d.ts.map +1 -1
- package/dist/core/TransactionReceipt.js +14 -0
- package/dist/core/TransactionReceipt.js.map +1 -1
- package/dist/core/TransactionRequest.d.ts +15 -7
- package/dist/core/TransactionRequest.d.ts.map +1 -1
- package/dist/core/TransactionRequest.js +47 -1
- package/dist/core/TransactionRequest.js.map +1 -1
- package/dist/core/TxEnvelope.d.ts +35 -21
- package/dist/core/TxEnvelope.d.ts.map +1 -1
- package/dist/core/TxEnvelope.js +46 -6
- package/dist/core/TxEnvelope.js.map +1 -1
- package/dist/core/TxEnvelopeEip8141.d.ts +341 -0
- package/dist/core/TxEnvelopeEip8141.d.ts.map +1 -0
- package/dist/core/TxEnvelopeEip8141.js +484 -0
- package/dist/core/TxEnvelopeEip8141.js.map +1 -0
- package/dist/core/internal/curves.d.ts +2 -0
- package/dist/core/internal/curves.d.ts.map +1 -1
- package/dist/core/internal/curves.js +2 -0
- package/dist/core/internal/curves.js.map +1 -1
- package/dist/index.d.ts +73 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +73 -0
- package/dist/index.js.map +1 -1
- package/dist/tempo/Transaction.d.ts +2 -0
- package/dist/tempo/Transaction.d.ts.map +1 -1
- package/dist/tempo/TransactionReceipt.d.ts +2 -0
- package/dist/tempo/TransactionReceipt.d.ts.map +1 -1
- package/dist/zod/Block.d.ts +123 -0
- package/dist/zod/Block.d.ts.map +1 -1
- package/dist/zod/Frame.d.ts +73 -0
- package/dist/zod/Frame.d.ts.map +1 -0
- package/dist/zod/Frame.js +74 -0
- package/dist/zod/Frame.js.map +1 -0
- package/dist/zod/FrameReceipt.d.ts +50 -0
- package/dist/zod/FrameReceipt.d.ts.map +1 -0
- package/dist/zod/FrameReceipt.js +37 -0
- package/dist/zod/FrameReceipt.js.map +1 -0
- package/dist/zod/FrameSignature.d.ts +63 -0
- package/dist/zod/FrameSignature.d.ts.map +1 -0
- package/dist/zod/FrameSignature.js +66 -0
- package/dist/zod/FrameSignature.js.map +1 -0
- package/dist/zod/RpcSchema.d.ts +806 -11
- package/dist/zod/RpcSchema.d.ts.map +1 -1
- package/dist/zod/Transaction.d.ts +252 -0
- package/dist/zod/Transaction.d.ts.map +1 -1
- package/dist/zod/Transaction.js +54 -0
- package/dist/zod/Transaction.js.map +1 -1
- package/dist/zod/TransactionEnvelope.d.ts +233 -4
- package/dist/zod/TransactionEnvelope.d.ts.map +1 -1
- package/dist/zod/TransactionEnvelope.js +9 -0
- package/dist/zod/TransactionEnvelope.js.map +1 -1
- package/dist/zod/TransactionReceipt.d.ts +48 -0
- package/dist/zod/TransactionReceipt.d.ts.map +1 -1
- package/dist/zod/TransactionReceipt.js +8 -3
- package/dist/zod/TransactionReceipt.js.map +1 -1
- package/dist/zod/TransactionRequest.d.ts +50 -2
- package/dist/zod/TransactionRequest.d.ts.map +1 -1
- package/dist/zod/TransactionRequest.js +10 -4
- package/dist/zod/TransactionRequest.js.map +1 -1
- package/dist/zod/TxEnvelopeEip8141.d.ts +166 -0
- package/dist/zod/TxEnvelopeEip8141.d.ts.map +1 -0
- package/dist/zod/TxEnvelopeEip8141.js +76 -0
- package/dist/zod/TxEnvelopeEip8141.js.map +1 -0
- package/dist/zod/internal/Frame.d.ts +4 -0
- package/dist/zod/internal/Frame.d.ts.map +1 -0
- package/dist/zod/internal/Frame.js +17 -0
- package/dist/zod/internal/Frame.js.map +1 -0
- package/dist/zod/internal/rpcSchemas/Eth.d.ts +842 -11
- package/dist/zod/internal/rpcSchemas/Eth.d.ts.map +1 -1
- package/dist/zod/internal/rpcSchemas/Wallet.d.ts +56 -2
- package/dist/zod/internal/rpcSchemas/Wallet.d.ts.map +1 -1
- package/dist/zod/tempo/RpcSchemaTempo.d.ts +140 -0
- package/dist/zod/tempo/RpcSchemaTempo.d.ts.map +1 -1
- package/dist/zod/tempo/Transaction.d.ts +123 -0
- package/dist/zod/tempo/Transaction.d.ts.map +1 -1
- package/dist/zod/z.d.ts +4 -0
- package/dist/zod/z.d.ts.map +1 -1
- package/dist/zod/z.js +4 -0
- package/dist/zod/z.js.map +1 -1
- package/package.json +41 -1
- package/src/core/Frame.ts +442 -0
- package/src/core/FrameReceipt.ts +117 -0
- package/src/core/FrameSignature.ts +593 -0
- package/src/core/Transaction.ts +82 -5
- package/src/core/TransactionReceipt.ts +41 -3
- package/src/core/TransactionRequest.ts +71 -4
- package/src/core/TxEnvelope.ts +159 -90
- package/src/core/TxEnvelopeEip8141.ts +714 -0
- package/src/core/_test/Frame.test-d.ts +108 -0
- package/src/core/_test/Frame.test.ts +280 -0
- package/src/core/_test/FrameReceipt.test.ts +86 -0
- package/src/core/_test/FrameSignature.test-d.ts +93 -0
- package/src/core/_test/FrameSignature.test.ts +554 -0
- package/src/core/_test/Transaction.test.ts +33 -0
- package/src/core/_test/TransactionEnvelope.test-d.ts +74 -0
- package/src/core/_test/TransactionEnvelope.test.ts +107 -0
- package/src/core/_test/TransactionReceipt.test.ts +59 -0
- package/src/core/_test/TransactionRequest.test-d.ts +50 -0
- package/src/core/_test/TransactionRequest.test.ts +88 -1
- package/src/core/_test/TxEnvelopeEip8141.test-d.ts +44 -0
- package/src/core/_test/TxEnvelopeEip8141.test.ts +1775 -0
- package/src/core/_test/curves.test.ts +6 -1
- package/src/core/_test/index.test.ts +4 -0
- package/src/core/internal/curves.ts +4 -0
- package/src/index.ts +77 -0
- package/src/version.ts +1 -1
- package/src/zod/Frame.ts +82 -0
- package/src/zod/FrameReceipt.ts +48 -0
- package/src/zod/FrameSignature.ts +78 -0
- package/src/zod/Transaction.ts +63 -0
- package/src/zod/TransactionEnvelope.ts +33 -0
- package/src/zod/TransactionReceipt.ts +14 -3
- package/src/zod/TransactionRequest.ts +18 -3
- package/src/zod/TxEnvelopeEip8141.ts +102 -0
- package/src/zod/_test/Frame.test-d.ts +41 -0
- package/src/zod/_test/Frame.test.ts +57 -0
- package/src/zod/_test/FrameReceipt.test.ts +75 -0
- package/src/zod/_test/FrameSignature.test.ts +94 -0
- package/src/zod/_test/TxEnvelopeEip8141.test.ts +116 -0
- package/src/zod/internal/Frame.ts +26 -0
- package/src/zod/z.ts +4 -0
package/src/core/TxEnvelope.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type * as Address from './Address.js'
|
|
|
2
2
|
import * as Errors from './Errors.js'
|
|
3
3
|
import type * as Hash from './Hash.js'
|
|
4
4
|
import * as Hex from './Hex.js'
|
|
5
|
-
import type { Compute, UnionPartialBy } from './internal/types.js'
|
|
5
|
+
import type { Compute, PartialBy, UnionPartialBy } from './internal/types.js'
|
|
6
6
|
import type * as Signature from './Signature.js'
|
|
7
7
|
import * as Transaction from './Transaction.js'
|
|
8
8
|
import type * as TransactionRequest from './TransactionRequest.js'
|
|
@@ -10,6 +10,7 @@ import * as TxEnvelopeEip1559 from './TxEnvelopeEip1559.js'
|
|
|
10
10
|
import * as TxEnvelopeEip2930 from './TxEnvelopeEip2930.js'
|
|
11
11
|
import * as TxEnvelopeEip4844 from './TxEnvelopeEip4844.js'
|
|
12
12
|
import * as TxEnvelopeEip7702 from './TxEnvelopeEip7702.js'
|
|
13
|
+
import * as TxEnvelopeEip8141 from './TxEnvelopeEip8141.js'
|
|
13
14
|
import * as TxEnvelopeLegacy from './TxEnvelopeLegacy.js'
|
|
14
15
|
import * as Value from './Value.js'
|
|
15
16
|
|
|
@@ -74,7 +75,8 @@ export type TxEnvelope<
|
|
|
74
75
|
| TxEnvelopeEip2930.TxEnvelopeEip2930<signed, bigintType, numberType>
|
|
75
76
|
| TxEnvelopeEip1559.TxEnvelopeEip1559<signed, bigintType, numberType>
|
|
76
77
|
| TxEnvelopeEip4844.TxEnvelopeEip4844<signed, bigintType, numberType>
|
|
77
|
-
| TxEnvelopeEip7702.TxEnvelopeEip7702<signed, bigintType, numberType
|
|
78
|
+
| TxEnvelopeEip7702.TxEnvelopeEip7702<signed, bigintType, numberType>
|
|
79
|
+
| TxEnvelopeEip8141.TxEnvelopeEip8141,
|
|
78
80
|
'type'
|
|
79
81
|
>
|
|
80
82
|
|
|
@@ -85,6 +87,7 @@ export type Rpc<signed extends boolean = false> =
|
|
|
85
87
|
| TxEnvelopeEip1559.Rpc<signed>
|
|
86
88
|
| TxEnvelopeEip4844.Rpc<signed>
|
|
87
89
|
| TxEnvelopeEip7702.Rpc<signed>
|
|
90
|
+
| TxEnvelopeEip8141.Rpc
|
|
88
91
|
|
|
89
92
|
/** Serialized Transaction Envelope. */
|
|
90
93
|
export type Serialized =
|
|
@@ -93,6 +96,7 @@ export type Serialized =
|
|
|
93
96
|
| TxEnvelopeEip1559.Serialized
|
|
94
97
|
| TxEnvelopeEip4844.Serialized
|
|
95
98
|
| TxEnvelopeEip7702.Serialized
|
|
99
|
+
| TxEnvelopeEip8141.Serialized
|
|
96
100
|
|
|
97
101
|
/** Transaction Envelope type. */
|
|
98
102
|
export type Type =
|
|
@@ -101,6 +105,7 @@ export type Type =
|
|
|
101
105
|
| TxEnvelopeEip1559.Type
|
|
102
106
|
| TxEnvelopeEip4844.Type
|
|
103
107
|
| TxEnvelopeEip7702.Type
|
|
108
|
+
| TxEnvelopeEip8141.Type
|
|
104
109
|
|
|
105
110
|
type Typeable =
|
|
106
111
|
| TxEnvelope
|
|
@@ -135,6 +140,7 @@ type HasDefined<envelope, key extends string> = envelope extends {
|
|
|
135
140
|
*/
|
|
136
141
|
export function assert(envelope: TxEnvelope) {
|
|
137
142
|
const type = getType(envelope) as Type | string
|
|
143
|
+
if (type === 'eip8141') return TxEnvelopeEip8141.assert(envelope as never)
|
|
138
144
|
if (type === 'legacy') return TxEnvelopeLegacy.assert(envelope as never)
|
|
139
145
|
if (type === 'eip2930') return TxEnvelopeEip2930.assert(envelope as never)
|
|
140
146
|
if (type === 'eip1559') return TxEnvelopeEip1559.assert(envelope as never)
|
|
@@ -150,6 +156,7 @@ export declare namespace assert {
|
|
|
150
156
|
| TxEnvelopeEip1559.assert.ErrorType
|
|
151
157
|
| TxEnvelopeEip4844.assert.ErrorType
|
|
152
158
|
| TxEnvelopeEip7702.assert.ErrorType
|
|
159
|
+
| TxEnvelopeEip8141.assert.ErrorType
|
|
153
160
|
| InvalidTypeError
|
|
154
161
|
| Errors.GlobalErrorType
|
|
155
162
|
}
|
|
@@ -173,6 +180,8 @@ export function deserialize<const serialized extends Serialized | Hex.Hex>(
|
|
|
173
180
|
serialized: serialized | Serialized | Hex.Hex,
|
|
174
181
|
): deserialize.ReturnType<serialized> {
|
|
175
182
|
const type = getSerializedType(serialized)
|
|
183
|
+
if (type === 'eip8141')
|
|
184
|
+
return TxEnvelopeEip8141.deserialize(serialized as never) as never
|
|
176
185
|
if (type === 'legacy')
|
|
177
186
|
return TxEnvelopeLegacy.deserialize(serialized) as never
|
|
178
187
|
if (type === 'eip2930')
|
|
@@ -186,17 +195,19 @@ export function deserialize<const serialized extends Serialized | Hex.Hex>(
|
|
|
186
195
|
|
|
187
196
|
export declare namespace deserialize {
|
|
188
197
|
type ReturnType<serialized extends Serialized | Hex.Hex = Serialized> =
|
|
189
|
-
serialized extends
|
|
190
|
-
?
|
|
191
|
-
: serialized extends
|
|
192
|
-
?
|
|
193
|
-
: serialized extends
|
|
194
|
-
?
|
|
195
|
-
: serialized extends
|
|
196
|
-
?
|
|
197
|
-
: serialized extends
|
|
198
|
-
?
|
|
199
|
-
:
|
|
198
|
+
serialized extends TxEnvelopeEip8141.Serialized
|
|
199
|
+
? TxEnvelopeEip8141.TxEnvelopeEip8141
|
|
200
|
+
: serialized extends TxEnvelopeLegacy.Serialized
|
|
201
|
+
? TxEnvelopeLegacy.TxEnvelopeLegacy
|
|
202
|
+
: serialized extends TxEnvelopeEip2930.Serialized
|
|
203
|
+
? TxEnvelopeEip2930.TxEnvelopeEip2930
|
|
204
|
+
: serialized extends TxEnvelopeEip1559.Serialized
|
|
205
|
+
? TxEnvelopeEip1559.TxEnvelopeEip1559
|
|
206
|
+
: serialized extends TxEnvelopeEip4844.Serialized
|
|
207
|
+
? TxEnvelopeEip4844.TxEnvelopeEip4844
|
|
208
|
+
: serialized extends TxEnvelopeEip7702.Serialized
|
|
209
|
+
? TxEnvelopeEip7702.TxEnvelopeEip7702
|
|
210
|
+
: TxEnvelope
|
|
200
211
|
|
|
201
212
|
type ErrorType =
|
|
202
213
|
| getSerializedType.ErrorType
|
|
@@ -205,6 +216,7 @@ export declare namespace deserialize {
|
|
|
205
216
|
| TxEnvelopeEip1559.deserialize.ErrorType
|
|
206
217
|
| TxEnvelopeEip4844.deserialize.ErrorType
|
|
207
218
|
| TxEnvelopeEip7702.deserialize.ErrorType
|
|
219
|
+
| TxEnvelopeEip8141.deserialize.ErrorType
|
|
208
220
|
| Errors.GlobalErrorType
|
|
209
221
|
}
|
|
210
222
|
|
|
@@ -222,6 +234,19 @@ export declare namespace deserialize {
|
|
|
222
234
|
* })
|
|
223
235
|
* ```
|
|
224
236
|
*
|
|
237
|
+
* @example
|
|
238
|
+
* ### Frame Transaction
|
|
239
|
+
*
|
|
240
|
+
* ```ts twoslash
|
|
241
|
+
* import { Frame, TransactionEnvelope } from 'ox'
|
|
242
|
+
*
|
|
243
|
+
* const envelope = TransactionEnvelope.from({
|
|
244
|
+
* chainId: 1,
|
|
245
|
+
* frames: [Frame.from({ gas: 50_000n, mode: 'sender' })],
|
|
246
|
+
* sender: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8'
|
|
247
|
+
* })
|
|
248
|
+
* ```
|
|
249
|
+
*
|
|
225
250
|
* @param envelope - The transaction envelope.
|
|
226
251
|
* @param options - Options.
|
|
227
252
|
* @returns Transaction Envelope.
|
|
@@ -236,6 +261,8 @@ export function from<
|
|
|
236
261
|
if (typeof envelope === 'string') return deserialize(envelope) as never
|
|
237
262
|
|
|
238
263
|
const type = getType(envelope) as Type | string
|
|
264
|
+
if (type === 'eip8141')
|
|
265
|
+
return TxEnvelopeEip8141.from(envelope as never) as never
|
|
239
266
|
if (type === 'legacy')
|
|
240
267
|
return TxEnvelopeLegacy.from(envelope as never, options) as never
|
|
241
268
|
if (type === 'eip2930')
|
|
@@ -252,7 +279,7 @@ export function from<
|
|
|
252
279
|
export declare namespace from {
|
|
253
280
|
type Options<signature extends Signature.Signature | undefined = undefined> =
|
|
254
281
|
{
|
|
255
|
-
/**
|
|
282
|
+
/** Outer signature to append. EIP-8141 uses the envelope’s `signatures` list. */
|
|
256
283
|
signature?: signature | Signature.Signature | undefined
|
|
257
284
|
}
|
|
258
285
|
|
|
@@ -267,30 +294,34 @@ export declare namespace from {
|
|
|
267
294
|
envelope extends Typeable,
|
|
268
295
|
signature extends Signature.Signature | undefined = undefined,
|
|
269
296
|
> =
|
|
270
|
-
getType.ReturnType<envelope> extends '
|
|
271
|
-
?
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
envelope & TxEnvelopeEip2930.TxEnvelopeEip2930,
|
|
297
|
+
getType.ReturnType<envelope> extends 'eip8141'
|
|
298
|
+
? envelope extends PartialBy<TxEnvelopeEip8141.TxEnvelopeEip8141, 'type'>
|
|
299
|
+
? TxEnvelopeEip8141.from.ReturnType<envelope>
|
|
300
|
+
: never
|
|
301
|
+
: getType.ReturnType<envelope> extends 'legacy'
|
|
302
|
+
? TxEnvelopeLegacy.from.ReturnType<
|
|
303
|
+
envelope & TxEnvelopeLegacy.TxEnvelopeLegacy,
|
|
278
304
|
signature
|
|
279
305
|
>
|
|
280
|
-
: getType.ReturnType<envelope> extends '
|
|
281
|
-
?
|
|
282
|
-
envelope &
|
|
306
|
+
: getType.ReturnType<envelope> extends 'eip2930'
|
|
307
|
+
? TxEnvelopeEip2930.from.ReturnType<
|
|
308
|
+
envelope & TxEnvelopeEip2930.TxEnvelopeEip2930,
|
|
283
309
|
signature
|
|
284
310
|
>
|
|
285
|
-
: getType.ReturnType<envelope> extends '
|
|
286
|
-
?
|
|
287
|
-
envelope &
|
|
288
|
-
signature
|
|
289
|
-
>
|
|
290
|
-
: TxEnvelopeEip1559.from.ReturnType<
|
|
291
|
-
Omit<envelope, 'type'> & TxEnvelopeEip1559.TxEnvelopeEip1559,
|
|
311
|
+
: getType.ReturnType<envelope> extends 'eip4844'
|
|
312
|
+
? TxEnvelopeEip4844.from.ReturnType<
|
|
313
|
+
envelope & TxEnvelopeEip4844.TxEnvelopeEip4844,
|
|
292
314
|
signature
|
|
293
315
|
>
|
|
316
|
+
: getType.ReturnType<envelope> extends 'eip7702'
|
|
317
|
+
? TxEnvelopeEip7702.from.ReturnType<
|
|
318
|
+
envelope & TxEnvelopeEip7702.TxEnvelopeEip7702,
|
|
319
|
+
signature
|
|
320
|
+
>
|
|
321
|
+
: TxEnvelopeEip1559.from.ReturnType<
|
|
322
|
+
Omit<envelope, 'type'> & TxEnvelopeEip1559.TxEnvelopeEip1559,
|
|
323
|
+
signature
|
|
324
|
+
>
|
|
294
325
|
|
|
295
326
|
type ErrorType =
|
|
296
327
|
| deserialize.ErrorType
|
|
@@ -299,6 +330,7 @@ export declare namespace from {
|
|
|
299
330
|
| TxEnvelopeEip1559.from.ErrorType
|
|
300
331
|
| TxEnvelopeEip4844.from.ErrorType
|
|
301
332
|
| TxEnvelopeEip7702.from.ErrorType
|
|
333
|
+
| TxEnvelopeEip8141.from.ErrorType
|
|
302
334
|
| InvalidTypeError
|
|
303
335
|
| Errors.GlobalErrorType
|
|
304
336
|
}
|
|
@@ -322,6 +354,8 @@ export declare namespace from {
|
|
|
322
354
|
*/
|
|
323
355
|
export function getSignPayload(envelope: TxEnvelope<false>): Hex.Hex {
|
|
324
356
|
const type = getType(envelope) as Type | string
|
|
357
|
+
if (type === 'eip8141')
|
|
358
|
+
return TxEnvelopeEip8141.getSignPayload(envelope as never)
|
|
325
359
|
if (type === 'legacy')
|
|
326
360
|
return TxEnvelopeLegacy.getSignPayload(envelope as never)
|
|
327
361
|
if (type === 'eip2930')
|
|
@@ -344,6 +378,7 @@ export declare namespace getSignPayload {
|
|
|
344
378
|
| TxEnvelopeEip1559.getSignPayload.ErrorType
|
|
345
379
|
| TxEnvelopeEip4844.getSignPayload.ErrorType
|
|
346
380
|
| TxEnvelopeEip7702.getSignPayload.ErrorType
|
|
381
|
+
| TxEnvelopeEip8141.getSignPayload.ErrorType
|
|
347
382
|
| InvalidTypeError
|
|
348
383
|
| Errors.GlobalErrorType
|
|
349
384
|
}
|
|
@@ -369,17 +404,14 @@ export function getType<const envelope extends Typeable>(
|
|
|
369
404
|
): getType.ReturnType<envelope> {
|
|
370
405
|
const type = envelope.type
|
|
371
406
|
if (type) {
|
|
372
|
-
//
|
|
373
|
-
// canonical envelope type ('0x0'…'0x4'). Canonical envelopes use
|
|
374
|
-
// 'legacy' | 'eip2930' | 'eip1559' | 'eip4844' | 'eip7702'. RPC payloads
|
|
375
|
-
// should be normalized through `TransactionRequest.fromRpc` (which
|
|
376
|
-
// translates via `Transaction.fromRpcType`) before reaching the envelope
|
|
377
|
-
// layer. Other custom `0x*` types (e.g. OP-Stack `0x7e`) pass through.
|
|
407
|
+
// Reject known RPC type strings at the envelope boundary. Custom transaction types still pass through.
|
|
378
408
|
if (typeof type === 'string' && type in Transaction.fromRpcType)
|
|
379
409
|
throw new InvalidTypeError({ type })
|
|
380
410
|
return type as never
|
|
381
411
|
}
|
|
382
412
|
|
|
413
|
+
if ('frames' in envelope && envelope.frames !== undefined)
|
|
414
|
+
return 'eip8141' as never
|
|
383
415
|
if (
|
|
384
416
|
'authorizationList' in envelope &&
|
|
385
417
|
envelope.authorizationList !== undefined
|
|
@@ -412,25 +444,27 @@ export declare namespace getType {
|
|
|
412
444
|
type: infer type extends string
|
|
413
445
|
}
|
|
414
446
|
? type
|
|
415
|
-
: HasDefined<envelope, '
|
|
416
|
-
?
|
|
417
|
-
: HasDefined<envelope, '
|
|
418
|
-
?
|
|
419
|
-
: HasDefined<envelope, '
|
|
447
|
+
: HasDefined<envelope, 'frames'> extends true
|
|
448
|
+
? TxEnvelopeEip8141.Type
|
|
449
|
+
: HasDefined<envelope, 'authorizationList'> extends true
|
|
450
|
+
? TxEnvelopeEip7702.Type
|
|
451
|
+
: HasDefined<envelope, 'blobs'> extends true
|
|
420
452
|
? TxEnvelopeEip4844.Type
|
|
421
|
-
: HasDefined<envelope, '
|
|
453
|
+
: HasDefined<envelope, 'blobVersionedHashes'> extends true
|
|
422
454
|
? TxEnvelopeEip4844.Type
|
|
423
|
-
: HasDefined<envelope, '
|
|
455
|
+
: HasDefined<envelope, 'sidecars'> extends true
|
|
424
456
|
? TxEnvelopeEip4844.Type
|
|
425
|
-
: HasDefined<envelope, '
|
|
426
|
-
?
|
|
427
|
-
: HasDefined<envelope, '
|
|
457
|
+
: HasDefined<envelope, 'maxFeePerBlobGas'> extends true
|
|
458
|
+
? TxEnvelopeEip4844.Type
|
|
459
|
+
: HasDefined<envelope, 'maxFeePerGas'> extends true
|
|
428
460
|
? TxEnvelopeEip1559.Type
|
|
429
|
-
: HasDefined<envelope, '
|
|
430
|
-
?
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
461
|
+
: HasDefined<envelope, 'maxPriorityFeePerGas'> extends true
|
|
462
|
+
? TxEnvelopeEip1559.Type
|
|
463
|
+
: HasDefined<envelope, 'gasPrice'> extends true
|
|
464
|
+
? HasDefined<envelope, 'accessList'> extends true
|
|
465
|
+
? TxEnvelopeEip2930.Type
|
|
466
|
+
: TxEnvelopeLegacy.Type
|
|
467
|
+
: TxEnvelopeEip1559.Type
|
|
434
468
|
|
|
435
469
|
type ErrorType = InvalidTypeError | Errors.GlobalErrorType
|
|
436
470
|
}
|
|
@@ -460,6 +494,8 @@ export function getSerializedType<
|
|
|
460
494
|
throw new InvalidSerializedTypeError({ serialized })
|
|
461
495
|
|
|
462
496
|
const serializedType = Hex.slice(serialized, 0, 1)
|
|
497
|
+
if (serializedType === TxEnvelopeEip8141.serializedType)
|
|
498
|
+
return 'eip8141' as never
|
|
463
499
|
if (serializedType === TxEnvelopeEip2930.serializedType)
|
|
464
500
|
return 'eip2930' as never
|
|
465
501
|
if (serializedType === TxEnvelopeEip1559.serializedType)
|
|
@@ -474,17 +510,19 @@ export function getSerializedType<
|
|
|
474
510
|
|
|
475
511
|
export declare namespace getSerializedType {
|
|
476
512
|
type ReturnType<serialized extends Serialized | Hex.Hex = Serialized> =
|
|
477
|
-
serialized extends
|
|
478
|
-
?
|
|
479
|
-
: serialized extends
|
|
480
|
-
?
|
|
481
|
-
: serialized extends
|
|
482
|
-
?
|
|
483
|
-
: serialized extends
|
|
484
|
-
?
|
|
485
|
-
: serialized extends
|
|
486
|
-
?
|
|
487
|
-
:
|
|
513
|
+
serialized extends TxEnvelopeEip8141.Serialized
|
|
514
|
+
? TxEnvelopeEip8141.Type
|
|
515
|
+
: serialized extends TxEnvelopeEip2930.Serialized
|
|
516
|
+
? TxEnvelopeEip2930.Type
|
|
517
|
+
: serialized extends TxEnvelopeEip1559.Serialized
|
|
518
|
+
? TxEnvelopeEip1559.Type
|
|
519
|
+
: serialized extends TxEnvelopeEip4844.Serialized
|
|
520
|
+
? TxEnvelopeEip4844.Type
|
|
521
|
+
: serialized extends TxEnvelopeEip7702.Serialized
|
|
522
|
+
? TxEnvelopeEip7702.Type
|
|
523
|
+
: serialized extends TxEnvelopeLegacy.Serialized
|
|
524
|
+
? TxEnvelopeLegacy.Type
|
|
525
|
+
: Type
|
|
488
526
|
|
|
489
527
|
type ErrorType =
|
|
490
528
|
| Hex.size.ErrorType
|
|
@@ -520,6 +558,8 @@ export function hash<presign extends boolean = false>(
|
|
|
520
558
|
options: hash.Options<presign> = {},
|
|
521
559
|
): hash.ReturnType {
|
|
522
560
|
const type = getType(envelope) as Type | string
|
|
561
|
+
if (type === 'eip8141')
|
|
562
|
+
return TxEnvelopeEip8141.hash(envelope as never, options)
|
|
523
563
|
if (type === 'legacy')
|
|
524
564
|
return TxEnvelopeLegacy.hash(envelope as never, options)
|
|
525
565
|
if (type === 'eip2930')
|
|
@@ -571,6 +611,11 @@ export function serialize<const envelope extends Typeable>(
|
|
|
571
611
|
options: serialize.Options = {},
|
|
572
612
|
): serialize.ReturnType<envelope> {
|
|
573
613
|
const type = getType(envelope) as Type | string
|
|
614
|
+
if (type === 'eip8141')
|
|
615
|
+
return TxEnvelopeEip8141.serialize({
|
|
616
|
+
...envelope,
|
|
617
|
+
...(options.sidecars ? { sidecars: options.sidecars } : {}),
|
|
618
|
+
} as never) as never
|
|
574
619
|
if (type === 'legacy')
|
|
575
620
|
return TxEnvelopeLegacy.serialize(envelope as never, options) as never
|
|
576
621
|
if (type === 'eip2930')
|
|
@@ -586,22 +631,24 @@ export function serialize<const envelope extends Typeable>(
|
|
|
586
631
|
|
|
587
632
|
export declare namespace serialize {
|
|
588
633
|
type Options = {
|
|
589
|
-
/**
|
|
634
|
+
/** Outer signature to append. EIP-8141 uses the envelope’s `signatures` list. */
|
|
590
635
|
signature?: Signature.Signature | undefined
|
|
591
636
|
/** PeerDAS sidecars to append, producing the 5-element network wrapper. */
|
|
592
637
|
sidecars?: TxEnvelopeEip4844.Sidecars<Hex.Hex> | undefined
|
|
593
638
|
}
|
|
594
639
|
|
|
595
640
|
type ReturnType<envelope extends Typeable = TxEnvelope> =
|
|
596
|
-
getType.ReturnType<envelope> extends '
|
|
597
|
-
?
|
|
598
|
-
: getType.ReturnType<envelope> extends '
|
|
599
|
-
?
|
|
600
|
-
: getType.ReturnType<envelope> extends '
|
|
601
|
-
?
|
|
602
|
-
: getType.ReturnType<envelope> extends '
|
|
603
|
-
?
|
|
604
|
-
:
|
|
641
|
+
getType.ReturnType<envelope> extends 'eip8141'
|
|
642
|
+
? TxEnvelopeEip8141.Serialized
|
|
643
|
+
: getType.ReturnType<envelope> extends 'legacy'
|
|
644
|
+
? TxEnvelopeLegacy.Serialized
|
|
645
|
+
: getType.ReturnType<envelope> extends 'eip2930'
|
|
646
|
+
? TxEnvelopeEip2930.Serialized
|
|
647
|
+
: getType.ReturnType<envelope> extends 'eip4844'
|
|
648
|
+
? TxEnvelopeEip4844.Serialized
|
|
649
|
+
: getType.ReturnType<envelope> extends 'eip7702'
|
|
650
|
+
? TxEnvelopeEip7702.Serialized
|
|
651
|
+
: TxEnvelopeEip1559.Serialized
|
|
605
652
|
|
|
606
653
|
type ErrorType =
|
|
607
654
|
| TxEnvelopeLegacy.serialize.ErrorType
|
|
@@ -609,6 +656,7 @@ export declare namespace serialize {
|
|
|
609
656
|
| TxEnvelopeEip1559.serialize.ErrorType
|
|
610
657
|
| TxEnvelopeEip4844.serialize.ErrorType
|
|
611
658
|
| TxEnvelopeEip7702.serialize.ErrorType
|
|
659
|
+
| TxEnvelopeEip8141.serialize.ErrorType
|
|
612
660
|
| InvalidTypeError
|
|
613
661
|
| Errors.GlobalErrorType
|
|
614
662
|
}
|
|
@@ -634,6 +682,8 @@ export function toRpc<const envelope extends toRpc.Input>(
|
|
|
634
682
|
envelope: envelope | toRpc.Input,
|
|
635
683
|
): toRpc.ReturnType<envelope> {
|
|
636
684
|
const type = getType(envelope) as Type | string
|
|
685
|
+
if (type === 'eip8141')
|
|
686
|
+
return TxEnvelopeEip8141.toRpc(envelope as never) as never
|
|
637
687
|
if (type === 'legacy')
|
|
638
688
|
return TxEnvelopeLegacy.toRpc(envelope as never) as never
|
|
639
689
|
if (type === 'eip2930')
|
|
@@ -649,22 +699,22 @@ export function toRpc<const envelope extends toRpc.Input>(
|
|
|
649
699
|
|
|
650
700
|
export declare namespace toRpc {
|
|
651
701
|
/** Numberish input accepted by {@link ox#(TransactionEnvelope:namespace).(toRpc:function)}. */
|
|
652
|
-
export type Input =
|
|
653
|
-
boolean,
|
|
654
|
-
|
|
655
|
-
Hex.Hex | number
|
|
656
|
-
>
|
|
702
|
+
export type Input =
|
|
703
|
+
| TxEnvelope<boolean, Hex.Hex | bigint | number, Hex.Hex | number>
|
|
704
|
+
| TxEnvelopeEip8141.toRpc.Input
|
|
657
705
|
|
|
658
706
|
export type ReturnType<envelope extends Typeable = TxEnvelope> =
|
|
659
|
-
getType.ReturnType<envelope> extends '
|
|
660
|
-
?
|
|
661
|
-
: getType.ReturnType<envelope> extends '
|
|
662
|
-
?
|
|
663
|
-
: getType.ReturnType<envelope> extends '
|
|
664
|
-
?
|
|
665
|
-
: getType.ReturnType<envelope> extends '
|
|
666
|
-
?
|
|
667
|
-
:
|
|
707
|
+
getType.ReturnType<envelope> extends 'eip8141'
|
|
708
|
+
? TxEnvelopeEip8141.Rpc
|
|
709
|
+
: getType.ReturnType<envelope> extends 'legacy'
|
|
710
|
+
? TxEnvelopeLegacy.Rpc
|
|
711
|
+
: getType.ReturnType<envelope> extends 'eip2930'
|
|
712
|
+
? TxEnvelopeEip2930.Rpc
|
|
713
|
+
: getType.ReturnType<envelope> extends 'eip4844'
|
|
714
|
+
? TxEnvelopeEip4844.Rpc
|
|
715
|
+
: getType.ReturnType<envelope> extends 'eip7702'
|
|
716
|
+
? TxEnvelopeEip7702.Rpc
|
|
717
|
+
: TxEnvelopeEip1559.Rpc
|
|
668
718
|
|
|
669
719
|
export type ErrorType =
|
|
670
720
|
| TxEnvelopeLegacy.toRpc.ErrorType
|
|
@@ -672,6 +722,7 @@ export declare namespace toRpc {
|
|
|
672
722
|
| TxEnvelopeEip1559.toRpc.ErrorType
|
|
673
723
|
| TxEnvelopeEip4844.toRpc.ErrorType
|
|
674
724
|
| TxEnvelopeEip7702.toRpc.ErrorType
|
|
725
|
+
| TxEnvelopeEip8141.toRpc.ErrorType
|
|
675
726
|
| InvalidTypeError
|
|
676
727
|
| Errors.GlobalErrorType
|
|
677
728
|
}
|
|
@@ -720,12 +771,26 @@ export declare namespace toRpc {
|
|
|
720
771
|
export function toTransactionRequest(
|
|
721
772
|
envelope: TxEnvelope,
|
|
722
773
|
): TransactionRequest.TransactionRequest {
|
|
774
|
+
const type = getType(envelope) as Type | string
|
|
775
|
+
if (type === 'eip8141') {
|
|
776
|
+
const { sender, sidecars, ...rest } =
|
|
777
|
+
envelope as TxEnvelopeEip8141.TxEnvelopeEip8141
|
|
778
|
+
return {
|
|
779
|
+
...rest,
|
|
780
|
+
...(sidecars ? { blobs: sidecars.blobs } : {}),
|
|
781
|
+
chainId: Hex.toNumber(Hex.fromNumber(rest.chainId)),
|
|
782
|
+
from: sender,
|
|
783
|
+
}
|
|
784
|
+
}
|
|
723
785
|
const {
|
|
724
786
|
// Flatten sidecars; surface their `blobs` payload instead.
|
|
725
787
|
sidecars,
|
|
726
788
|
blobs,
|
|
727
789
|
...rest
|
|
728
|
-
} = envelope as
|
|
790
|
+
} = envelope as Exclude<
|
|
791
|
+
TxEnvelope,
|
|
792
|
+
{ type?: TxEnvelopeEip8141.Type | undefined }
|
|
793
|
+
> & {
|
|
729
794
|
sidecars?: TxEnvelopeEip4844.Sidecars<Hex.Hex> | undefined
|
|
730
795
|
blobs?: readonly Hex.Hex[] | undefined
|
|
731
796
|
}
|
|
@@ -739,7 +804,11 @@ export function toTransactionRequest(
|
|
|
739
804
|
}
|
|
740
805
|
|
|
741
806
|
export declare namespace toTransactionRequest {
|
|
742
|
-
type ErrorType =
|
|
807
|
+
type ErrorType =
|
|
808
|
+
| getType.ErrorType
|
|
809
|
+
| Hex.fromNumber.ErrorType
|
|
810
|
+
| Hex.toNumber.ErrorType
|
|
811
|
+
| Errors.GlobalErrorType
|
|
743
812
|
}
|
|
744
813
|
|
|
745
814
|
/**
|