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.
- package/CHANGELOG.md +27 -0
- package/README.md +4 -4
- package/TxEnvelope/package.json +6 -0
- package/TxEnvelopeEip1559/package.json +6 -0
- package/TxEnvelopeEip2930/package.json +6 -0
- package/TxEnvelopeEip4844/package.json +6 -0
- package/TxEnvelopeEip7702/package.json +6 -0
- package/TxEnvelopeLegacy/package.json +6 -0
- package/_cjs/core/{TransactionEnvelope.js → TxEnvelope.js} +1 -1
- package/_cjs/core/TxEnvelope.js.map +1 -0
- package/_cjs/core/{TransactionEnvelopeEip1559.js → TxEnvelopeEip1559.js} +2 -2
- package/_cjs/core/TxEnvelopeEip1559.js.map +1 -0
- package/_cjs/core/{TransactionEnvelopeEip2930.js → TxEnvelopeEip2930.js} +2 -2
- package/_cjs/core/TxEnvelopeEip2930.js.map +1 -0
- package/_cjs/core/{TransactionEnvelopeEip4844.js → TxEnvelopeEip4844.js} +4 -4
- package/_cjs/core/TxEnvelopeEip4844.js.map +1 -0
- package/_cjs/core/{TransactionEnvelopeEip7702.js → TxEnvelopeEip7702.js} +4 -4
- package/_cjs/core/TxEnvelopeEip7702.js.map +1 -0
- package/_cjs/core/{TransactionEnvelopeLegacy.js → TxEnvelopeLegacy.js} +2 -2
- package/_cjs/core/TxEnvelopeLegacy.js.map +1 -0
- package/_cjs/core/WebAuthnP256.js +1 -1
- package/_cjs/core/WebAuthnP256.js.map +1 -1
- package/_cjs/erc8021/Attribution.js +36 -6
- package/_cjs/erc8021/Attribution.js.map +1 -1
- package/_cjs/index.docs.js +1 -0
- package/_cjs/index.docs.js.map +1 -1
- package/_cjs/index.js +7 -7
- package/_cjs/index.js.map +1 -1
- package/_cjs/tempo/AuthorizationTempo.js +101 -0
- package/_cjs/tempo/AuthorizationTempo.js.map +1 -0
- package/_cjs/tempo/KeyAuthorization.js +123 -0
- package/_cjs/tempo/KeyAuthorization.js.map +1 -0
- package/_cjs/tempo/PoolId.js +10 -0
- package/_cjs/tempo/PoolId.js.map +1 -0
- package/_cjs/tempo/SignatureEnvelope.js +394 -0
- package/_cjs/tempo/SignatureEnvelope.js.map +1 -0
- package/_cjs/tempo/Tick.js +77 -0
- package/_cjs/tempo/Tick.js.map +1 -0
- package/_cjs/tempo/TokenId.js +28 -0
- package/_cjs/tempo/TokenId.js.map +1 -0
- package/_cjs/tempo/TokenRole.js +26 -0
- package/_cjs/tempo/TokenRole.js.map +1 -0
- package/_cjs/tempo/Transaction.js +80 -0
- package/_cjs/tempo/Transaction.js.map +1 -0
- package/_cjs/tempo/TransactionReceipt.js +26 -0
- package/_cjs/tempo/TransactionReceipt.js.map +1 -0
- package/_cjs/tempo/TransactionRequest.js +53 -0
- package/_cjs/tempo/TransactionRequest.js.map +1 -0
- package/_cjs/tempo/TxEnvelopeTempo.js +267 -0
- package/_cjs/tempo/TxEnvelopeTempo.js.map +1 -0
- package/_cjs/tempo/index.js +15 -0
- package/_cjs/tempo/index.js.map +1 -0
- package/_cjs/version.js +1 -1
- package/_esm/core/Blobs.js +8 -8
- package/_esm/core/{TransactionEnvelope.js → TxEnvelope.js} +11 -11
- package/_esm/core/TxEnvelope.js.map +1 -0
- package/_esm/core/{TransactionEnvelopeEip1559.js → TxEnvelopeEip1559.js} +42 -42
- package/_esm/core/TxEnvelopeEip1559.js.map +1 -0
- package/_esm/core/{TransactionEnvelopeEip2930.js → TxEnvelopeEip2930.js} +43 -43
- package/_esm/core/TxEnvelopeEip2930.js.map +1 -0
- package/_esm/core/{TransactionEnvelopeEip4844.js → TxEnvelopeEip4844.js} +42 -42
- package/_esm/core/TxEnvelopeEip4844.js.map +1 -0
- package/_esm/core/{TransactionEnvelopeEip7702.js → TxEnvelopeEip7702.js} +40 -40
- package/_esm/core/TxEnvelopeEip7702.js.map +1 -0
- package/_esm/core/{TransactionEnvelopeLegacy.js → TxEnvelopeLegacy.js} +42 -42
- package/_esm/core/TxEnvelopeLegacy.js.map +1 -0
- package/_esm/core/WebAuthnP256.js +1 -1
- package/_esm/core/WebAuthnP256.js.map +1 -1
- package/_esm/erc8021/Attribution.js +58 -13
- package/_esm/erc8021/Attribution.js.map +1 -1
- package/_esm/index.docs.js +1 -0
- package/_esm/index.docs.js.map +1 -1
- package/_esm/index.js +192 -192
- package/_esm/index.js.map +1 -1
- package/_esm/tempo/AuthorizationTempo.js +664 -0
- package/_esm/tempo/AuthorizationTempo.js.map +1 -0
- package/_esm/tempo/KeyAuthorization.js +426 -0
- package/_esm/tempo/KeyAuthorization.js.map +1 -0
- package/_esm/tempo/PoolId.js +28 -0
- package/_esm/tempo/PoolId.js.map +1 -0
- package/_esm/tempo/SignatureEnvelope.js +660 -0
- package/_esm/tempo/SignatureEnvelope.js.map +1 -0
- package/_esm/tempo/Tick.js +147 -0
- package/_esm/tempo/Tick.js.map +1 -0
- package/_esm/tempo/TokenId.js +71 -0
- package/_esm/tempo/TokenId.js.map +1 -0
- package/_esm/tempo/TokenRole.js +40 -0
- package/_esm/tempo/TokenRole.js.map +1 -0
- package/_esm/tempo/Transaction.js +167 -0
- package/_esm/tempo/Transaction.js.map +1 -0
- package/_esm/tempo/TransactionReceipt.js +138 -0
- package/_esm/tempo/TransactionReceipt.js.map +1 -0
- package/_esm/tempo/TransactionRequest.js +99 -0
- package/_esm/tempo/TransactionRequest.js.map +1 -0
- package/_esm/tempo/TxEnvelopeTempo.js +607 -0
- package/_esm/tempo/TxEnvelopeTempo.js.map +1 -0
- package/_esm/tempo/index.js +298 -0
- package/_esm/tempo/index.js.map +1 -0
- package/_esm/version.js +1 -1
- package/_types/core/Blobs.d.ts +8 -8
- package/_types/core/{TransactionEnvelope.d.ts → TxEnvelope.d.ts} +11 -11
- package/_types/core/TxEnvelope.d.ts.map +1 -0
- package/_types/core/{TransactionEnvelopeEip1559.d.ts → TxEnvelopeEip1559.d.ts} +54 -54
- package/_types/core/TxEnvelopeEip1559.d.ts.map +1 -0
- package/_types/core/{TransactionEnvelopeEip2930.d.ts → TxEnvelopeEip2930.d.ts} +55 -55
- package/_types/core/TxEnvelopeEip2930.d.ts.map +1 -0
- package/_types/core/{TransactionEnvelopeEip4844.d.ts → TxEnvelopeEip4844.d.ts} +54 -54
- package/_types/core/TxEnvelopeEip4844.d.ts.map +1 -0
- package/_types/core/{TransactionEnvelopeEip7702.d.ts → TxEnvelopeEip7702.d.ts} +49 -49
- package/_types/core/TxEnvelopeEip7702.d.ts.map +1 -0
- package/_types/core/{TransactionEnvelopeLegacy.d.ts → TxEnvelopeLegacy.d.ts} +54 -54
- package/_types/core/TxEnvelopeLegacy.d.ts.map +1 -0
- package/_types/core/WebAuthnP256.d.ts +1 -1
- package/_types/core/WebAuthnP256.d.ts.map +1 -1
- package/_types/erc8021/Attribution.d.ts +20 -6
- package/_types/erc8021/Attribution.d.ts.map +1 -1
- package/_types/index.d.ts +192 -192
- package/_types/index.d.ts.map +1 -1
- package/_types/index.docs.d.ts +1 -0
- package/_types/index.docs.d.ts.map +1 -1
- package/_types/tempo/AuthorizationTempo.d.ts +688 -0
- package/_types/tempo/AuthorizationTempo.d.ts.map +1 -0
- package/_types/tempo/KeyAuthorization.d.ts +437 -0
- package/_types/tempo/KeyAuthorization.d.ts.map +1 -0
- package/_types/tempo/PoolId.d.ts +33 -0
- package/_types/tempo/PoolId.d.ts.map +1 -0
- package/_types/tempo/SignatureEnvelope.d.ts +438 -0
- package/_types/tempo/SignatureEnvelope.d.ts.map +1 -0
- package/_types/tempo/Tick.d.ts +120 -0
- package/_types/tempo/Tick.d.ts.map +1 -0
- package/_types/tempo/TokenId.d.ts +55 -0
- package/_types/tempo/TokenId.d.ts.map +1 -0
- package/_types/tempo/TokenRole.d.ts +29 -0
- package/_types/tempo/TokenRole.d.ts.map +1 -0
- package/_types/tempo/Transaction.d.ts +208 -0
- package/_types/tempo/Transaction.d.ts.map +1 -0
- package/_types/tempo/TransactionReceipt.d.ts +165 -0
- package/_types/tempo/TransactionReceipt.d.ts.map +1 -0
- package/_types/tempo/TransactionRequest.d.ts +89 -0
- package/_types/tempo/TransactionRequest.d.ts.map +1 -0
- package/_types/tempo/TxEnvelopeTempo.d.ts +551 -0
- package/_types/tempo/TxEnvelopeTempo.d.ts.map +1 -0
- package/_types/tempo/index.d.ts +300 -0
- package/_types/tempo/index.d.ts.map +1 -0
- package/_types/version.d.ts +1 -1
- package/core/Blobs.ts +8 -8
- package/core/{TransactionEnvelope.ts → TxEnvelope.ts} +10 -10
- package/core/{TransactionEnvelopeEip1559.ts → TxEnvelopeEip1559.ts} +60 -69
- package/core/{TransactionEnvelopeEip2930.ts → TxEnvelopeEip2930.ts} +61 -72
- package/core/{TransactionEnvelopeEip4844.ts → TxEnvelopeEip4844.ts} +62 -71
- package/core/{TransactionEnvelopeEip7702.ts → TxEnvelopeEip7702.ts} +58 -67
- package/core/{TransactionEnvelopeLegacy.ts → TxEnvelopeLegacy.ts} +59 -68
- package/core/WebAuthnP256.ts +3 -1
- package/erc8021/Attribution.ts +77 -15
- package/index.docs.ts +1 -0
- package/index.ts +192 -195
- package/package.json +91 -31
- package/tempo/AuthorizationTempo/package.json +6 -0
- package/tempo/AuthorizationTempo.test.ts +1293 -0
- package/tempo/AuthorizationTempo.ts +884 -0
- package/tempo/KeyAuthorization/package.json +6 -0
- package/tempo/KeyAuthorization.test.ts +1373 -0
- package/tempo/KeyAuthorization.ts +622 -0
- package/tempo/PoolId/package.json +6 -0
- package/tempo/PoolId.test.ts +33 -0
- package/tempo/PoolId.ts +42 -0
- package/tempo/SignatureEnvelope/package.json +6 -0
- package/tempo/SignatureEnvelope.test.ts +1877 -0
- package/tempo/SignatureEnvelope.ts +973 -0
- package/tempo/Tick/package.json +6 -0
- package/tempo/Tick.test.ts +281 -0
- package/tempo/Tick.ts +186 -0
- package/tempo/TokenId/package.json +6 -0
- package/tempo/TokenId.test.ts +40 -0
- package/tempo/TokenId.ts +80 -0
- package/tempo/TokenRole/package.json +6 -0
- package/tempo/TokenRole.test.ts +16 -0
- package/tempo/TokenRole.ts +45 -0
- package/tempo/Transaction/package.json +6 -0
- package/tempo/Transaction.test.ts +523 -0
- package/tempo/Transaction.ts +339 -0
- package/tempo/TransactionReceipt/package.json +6 -0
- package/tempo/TransactionReceipt.ts +200 -0
- package/tempo/TransactionRequest/package.json +6 -0
- package/tempo/TransactionRequest.ts +160 -0
- package/tempo/TxEnvelopeTempo/package.json +6 -0
- package/tempo/TxEnvelopeTempo.test.ts +1371 -0
- package/tempo/TxEnvelopeTempo.ts +972 -0
- package/tempo/e2e.test.ts +1387 -0
- package/tempo/index.ts +308 -0
- package/tempo/package.json +6 -0
- package/version.ts +1 -1
- package/TransactionEnvelope/package.json +0 -6
- package/TransactionEnvelopeEip1559/package.json +0 -6
- package/TransactionEnvelopeEip2930/package.json +0 -6
- package/TransactionEnvelopeEip4844/package.json +0 -6
- package/TransactionEnvelopeEip7702/package.json +0 -6
- package/TransactionEnvelopeLegacy/package.json +0 -6
- package/_cjs/core/TransactionEnvelope.js.map +0 -1
- package/_cjs/core/TransactionEnvelopeEip1559.js.map +0 -1
- package/_cjs/core/TransactionEnvelopeEip2930.js.map +0 -1
- package/_cjs/core/TransactionEnvelopeEip4844.js.map +0 -1
- package/_cjs/core/TransactionEnvelopeEip7702.js.map +0 -1
- package/_cjs/core/TransactionEnvelopeLegacy.js.map +0 -1
- package/_esm/core/TransactionEnvelope.js.map +0 -1
- package/_esm/core/TransactionEnvelopeEip1559.js.map +0 -1
- package/_esm/core/TransactionEnvelopeEip2930.js.map +0 -1
- package/_esm/core/TransactionEnvelopeEip4844.js.map +0 -1
- package/_esm/core/TransactionEnvelopeEip7702.js.map +0 -1
- package/_esm/core/TransactionEnvelopeLegacy.js.map +0 -1
- package/_types/core/TransactionEnvelope.d.ts.map +0 -1
- package/_types/core/TransactionEnvelopeEip1559.d.ts.map +0 -1
- package/_types/core/TransactionEnvelopeEip2930.d.ts.map +0 -1
- package/_types/core/TransactionEnvelopeEip4844.d.ts.map +0 -1
- package/_types/core/TransactionEnvelopeEip7702.d.ts.map +0 -1
- package/_types/core/TransactionEnvelopeLegacy.d.ts.map +0 -1
|
@@ -12,10 +12,10 @@ import type {
|
|
|
12
12
|
import * as Kzg from './Kzg.js'
|
|
13
13
|
import * as Rlp from './Rlp.js'
|
|
14
14
|
import * as Signature from './Signature.js'
|
|
15
|
-
import * as TransactionEnvelope from './
|
|
16
|
-
import * as
|
|
15
|
+
import * as TransactionEnvelope from './TxEnvelope.js'
|
|
16
|
+
import * as TxEnvelopeEip1559 from './TxEnvelopeEip1559.js'
|
|
17
17
|
|
|
18
|
-
export type
|
|
18
|
+
export type TxEnvelopeEip4844<
|
|
19
19
|
signed extends boolean = boolean,
|
|
20
20
|
bigintType = bigint,
|
|
21
21
|
numberType = number,
|
|
@@ -37,7 +37,7 @@ export type TransactionEnvelopeEip4844<
|
|
|
37
37
|
}
|
|
38
38
|
>
|
|
39
39
|
|
|
40
|
-
export type Rpc<signed extends boolean = boolean> =
|
|
40
|
+
export type Rpc<signed extends boolean = boolean> = TxEnvelopeEip4844<
|
|
41
41
|
signed,
|
|
42
42
|
Hex.Hex,
|
|
43
43
|
Hex.Hex,
|
|
@@ -49,19 +49,19 @@ export type Serialized = `${SerializedType}${string}`
|
|
|
49
49
|
export const serializedType = '0x03' as const
|
|
50
50
|
export type SerializedType = typeof serializedType
|
|
51
51
|
|
|
52
|
-
export type Signed =
|
|
52
|
+
export type Signed = TxEnvelopeEip4844<true>
|
|
53
53
|
|
|
54
54
|
export const type = 'eip4844' as const
|
|
55
55
|
export type Type = 'eip4844'
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
|
-
* Asserts a {@link ox#
|
|
58
|
+
* Asserts a {@link ox#TxEnvelopeEip4844.TxEnvelopeEip4844} is valid.
|
|
59
59
|
*
|
|
60
60
|
* @example
|
|
61
61
|
* ```ts twoslash
|
|
62
|
-
* import {
|
|
62
|
+
* import { TxEnvelopeEip4844, Value } from 'ox'
|
|
63
63
|
*
|
|
64
|
-
*
|
|
64
|
+
* TxEnvelopeEip4844.assert({
|
|
65
65
|
* blobVersionedHashes: [],
|
|
66
66
|
* chainId: 1,
|
|
67
67
|
* to: '0x0000000000000000000000000000000000000000',
|
|
@@ -72,9 +72,7 @@ export type Type = 'eip4844'
|
|
|
72
72
|
*
|
|
73
73
|
* @param envelope - The transaction envelope to assert.
|
|
74
74
|
*/
|
|
75
|
-
export function assert(
|
|
76
|
-
envelope: PartialBy<TransactionEnvelopeEip4844, 'type'>,
|
|
77
|
-
) {
|
|
75
|
+
export function assert(envelope: PartialBy<TxEnvelopeEip4844, 'type'>) {
|
|
78
76
|
const { blobVersionedHashes } = envelope
|
|
79
77
|
if (blobVersionedHashes) {
|
|
80
78
|
if (blobVersionedHashes.length === 0)
|
|
@@ -91,14 +89,14 @@ export function assert(
|
|
|
91
89
|
})
|
|
92
90
|
}
|
|
93
91
|
}
|
|
94
|
-
|
|
95
|
-
envelope as {} as
|
|
92
|
+
TxEnvelopeEip1559.assert(
|
|
93
|
+
envelope as {} as TxEnvelopeEip1559.TxEnvelopeEip1559,
|
|
96
94
|
)
|
|
97
95
|
}
|
|
98
96
|
|
|
99
97
|
export declare namespace assert {
|
|
100
98
|
type ErrorType =
|
|
101
|
-
|
|
|
99
|
+
| TxEnvelopeEip1559.assert.ErrorType
|
|
102
100
|
| Hex.size.ErrorType
|
|
103
101
|
| Hex.toNumber.ErrorType
|
|
104
102
|
| Hex.slice.ErrorType
|
|
@@ -109,13 +107,13 @@ export declare namespace assert {
|
|
|
109
107
|
}
|
|
110
108
|
|
|
111
109
|
/**
|
|
112
|
-
* Deserializes a {@link ox#
|
|
110
|
+
* Deserializes a {@link ox#TxEnvelopeEip4844.TxEnvelopeEip4844} from its serialized form.
|
|
113
111
|
*
|
|
114
112
|
* @example
|
|
115
113
|
* ```ts twoslash
|
|
116
|
-
* import {
|
|
114
|
+
* import { TxEnvelopeEip4844 } from 'ox'
|
|
117
115
|
*
|
|
118
|
-
* const envelope =
|
|
116
|
+
* const envelope = TxEnvelopeEip4844.deserialize('0x03ef0182031184773594008477359400809470997970c51812dc3a010c7d01b50e0d17dc79c8880de0b6b3a764000080c0')
|
|
119
117
|
* // @log: {
|
|
120
118
|
* // @log: blobVersionedHashes: [...],
|
|
121
119
|
* // @log: type: 'eip4844',
|
|
@@ -132,7 +130,7 @@ export declare namespace assert {
|
|
|
132
130
|
*/
|
|
133
131
|
export function deserialize(
|
|
134
132
|
serialized: Serialized,
|
|
135
|
-
): Compute<
|
|
133
|
+
): Compute<TxEnvelopeEip4844> {
|
|
136
134
|
const transactionOrWrapperArray = Rlp.toHex(Hex.slice(serialized, 1))
|
|
137
135
|
|
|
138
136
|
const hasNetworkWrapper = transactionOrWrapperArray.length === 4
|
|
@@ -190,7 +188,7 @@ export function deserialize(
|
|
|
190
188
|
blobVersionedHashes: blobVersionedHashes as Hex.Hex[],
|
|
191
189
|
chainId: Number(chainId),
|
|
192
190
|
type,
|
|
193
|
-
} as
|
|
191
|
+
} as TxEnvelopeEip4844
|
|
194
192
|
if (Hex.validate(to) && to !== '0x') transaction.to = to
|
|
195
193
|
if (Hex.validate(gas) && gas !== '0x') transaction.gas = BigInt(gas)
|
|
196
194
|
if (Hex.validate(data) && data !== '0x') transaction.data = data
|
|
@@ -219,7 +217,7 @@ export function deserialize(
|
|
|
219
217
|
transaction = {
|
|
220
218
|
...transaction,
|
|
221
219
|
...signature,
|
|
222
|
-
} as
|
|
220
|
+
} as TxEnvelopeEip4844
|
|
223
221
|
|
|
224
222
|
assert(transaction)
|
|
225
223
|
|
|
@@ -236,13 +234,13 @@ export declare namespace deserialize {
|
|
|
236
234
|
* @example
|
|
237
235
|
* ```ts twoslash
|
|
238
236
|
* // @noErrors
|
|
239
|
-
* import { Blobs,
|
|
237
|
+
* import { Blobs, TxEnvelopeEip4844, Value } from 'ox'
|
|
240
238
|
* import { kzg } from './kzg'
|
|
241
239
|
*
|
|
242
240
|
* const blobs = Blobs.from('0xdeadbeef')
|
|
243
241
|
* const blobVersionedHashes = Blobs.toVersionedHashes(blobs, { kzg })
|
|
244
242
|
*
|
|
245
|
-
* const envelope =
|
|
243
|
+
* const envelope = TxEnvelopeEip4844.from({
|
|
246
244
|
* chainId: 1,
|
|
247
245
|
* blobVersionedHashes,
|
|
248
246
|
* maxFeePerBlobGas: Value.fromGwei('3'),
|
|
@@ -260,14 +258,14 @@ export declare namespace deserialize {
|
|
|
260
258
|
*
|
|
261
259
|
* ```ts twoslash
|
|
262
260
|
* // @noErrors
|
|
263
|
-
* import { Blobs, Secp256k1,
|
|
261
|
+
* import { Blobs, Secp256k1, TxEnvelopeEip4844, Value } from 'ox'
|
|
264
262
|
* import { kzg } from './kzg'
|
|
265
263
|
*
|
|
266
264
|
* const blobs = Blobs.from('0xdeadbeef')
|
|
267
265
|
* const sidecars = Blobs.toSidecars(blobs, { kzg })
|
|
268
266
|
* const blobVersionedHashes = Blobs.sidecarsToVersionedHashes(sidecars)
|
|
269
267
|
*
|
|
270
|
-
* const envelope =
|
|
268
|
+
* const envelope = TxEnvelopeEip4844.from({
|
|
271
269
|
* blobVersionedHashes,
|
|
272
270
|
* chainId: 1,
|
|
273
271
|
* maxFeePerBlobGas: Value.fromGwei('3'),
|
|
@@ -278,11 +276,11 @@ export declare namespace deserialize {
|
|
|
278
276
|
* })
|
|
279
277
|
*
|
|
280
278
|
* const signature = Secp256k1.sign({
|
|
281
|
-
* payload:
|
|
279
|
+
* payload: TxEnvelopeEip4844.getSignPayload(envelope),
|
|
282
280
|
* privateKey: '0x...',
|
|
283
281
|
* })
|
|
284
282
|
*
|
|
285
|
-
* const envelope_signed =
|
|
283
|
+
* const envelope_signed = TxEnvelopeEip4844.from(envelope, { // [!code focus]
|
|
286
284
|
* sidecars, // [!code focus]
|
|
287
285
|
* signature, // [!code focus]
|
|
288
286
|
* }) // [!code focus]
|
|
@@ -304,12 +302,12 @@ export declare namespace deserialize {
|
|
|
304
302
|
* @example
|
|
305
303
|
* ### From Serialized
|
|
306
304
|
*
|
|
307
|
-
* It is possible to instantiate an EIP-4844 Transaction Envelope from a {@link ox#
|
|
305
|
+
* It is possible to instantiate an EIP-4844 Transaction Envelope from a {@link ox#TxEnvelopeEip4844.Serialized} value.
|
|
308
306
|
*
|
|
309
307
|
* ```ts twoslash
|
|
310
|
-
* import {
|
|
308
|
+
* import { TxEnvelopeEip4844 } from 'ox'
|
|
311
309
|
*
|
|
312
|
-
* const envelope =
|
|
310
|
+
* const envelope = TxEnvelopeEip4844.from('0x03f858018203118502540be4008504a817c800809470997970c51812dc3a010c7d01b50e0d17dc79c8880de0b6b3a764000080c08477359400e1a001627c687261b0e7f8638af1112efa8a77e23656f6e7945275b19e9deed80261')
|
|
313
311
|
* // @log: {
|
|
314
312
|
* // @log: blobVersionedHashes: [...],
|
|
315
313
|
* // @log: chainId: 1,
|
|
@@ -325,22 +323,17 @@ export declare namespace deserialize {
|
|
|
325
323
|
* @returns An EIP-4844 Transaction Envelope.
|
|
326
324
|
*/
|
|
327
325
|
export function from<
|
|
328
|
-
const envelope extends
|
|
329
|
-
| UnionPartialBy<TransactionEnvelopeEip4844, 'type'>
|
|
330
|
-
| Serialized,
|
|
326
|
+
const envelope extends UnionPartialBy<TxEnvelopeEip4844, 'type'> | Serialized,
|
|
331
327
|
const signature extends Signature.Signature | undefined = undefined,
|
|
332
328
|
>(
|
|
333
|
-
envelope:
|
|
334
|
-
| envelope
|
|
335
|
-
| UnionPartialBy<TransactionEnvelopeEip4844, 'type'>
|
|
336
|
-
| Serialized,
|
|
329
|
+
envelope: envelope | UnionPartialBy<TxEnvelopeEip4844, 'type'> | Serialized,
|
|
337
330
|
options: from.Options<signature> = {},
|
|
338
331
|
): from.ReturnType<envelope, signature> {
|
|
339
332
|
const { signature } = options
|
|
340
333
|
|
|
341
334
|
const envelope_ = (
|
|
342
335
|
typeof envelope === 'string' ? deserialize(envelope) : envelope
|
|
343
|
-
) as
|
|
336
|
+
) as TxEnvelopeEip4844
|
|
344
337
|
|
|
345
338
|
assert(envelope_)
|
|
346
339
|
|
|
@@ -358,13 +351,13 @@ export declare namespace from {
|
|
|
358
351
|
}
|
|
359
352
|
|
|
360
353
|
type ReturnType<
|
|
361
|
-
envelope extends
|
|
362
|
-
|
|
|
363
|
-
| Hex.Hex
|
|
354
|
+
envelope extends UnionPartialBy<TxEnvelopeEip4844, 'type'> | Hex.Hex =
|
|
355
|
+
| TxEnvelopeEip4844
|
|
356
|
+
| Hex.Hex,
|
|
364
357
|
signature extends Signature.Signature | undefined = undefined,
|
|
365
358
|
> = Compute<
|
|
366
359
|
envelope extends Hex.Hex
|
|
367
|
-
?
|
|
360
|
+
? TxEnvelopeEip4844
|
|
368
361
|
: Assign<
|
|
369
362
|
envelope,
|
|
370
363
|
(signature extends Signature.Signature ? Readonly<signature> : {}) & {
|
|
@@ -380,7 +373,7 @@ export declare namespace from {
|
|
|
380
373
|
}
|
|
381
374
|
|
|
382
375
|
/**
|
|
383
|
-
* Returns the payload to sign for a {@link ox#
|
|
376
|
+
* Returns the payload to sign for a {@link ox#TxEnvelopeEip4844.TxEnvelopeEip4844}.
|
|
384
377
|
*
|
|
385
378
|
* @example
|
|
386
379
|
* The example below demonstrates how to compute the sign payload which can be used
|
|
@@ -388,13 +381,13 @@ export declare namespace from {
|
|
|
388
381
|
*
|
|
389
382
|
* ```ts twoslash
|
|
390
383
|
* // @noErrors
|
|
391
|
-
* import { Blobs, Secp256k1,
|
|
384
|
+
* import { Blobs, Secp256k1, TxEnvelopeEip4844 } from 'ox'
|
|
392
385
|
* import { kzg } from './kzg'
|
|
393
386
|
*
|
|
394
387
|
* const blobs = Blobs.from('0xdeadbeef')
|
|
395
388
|
* const blobVersionedHashes = Blobs.toVersionedHashes(blobs, { kzg })
|
|
396
389
|
*
|
|
397
|
-
* const envelope =
|
|
390
|
+
* const envelope = TxEnvelopeEip4844.from({
|
|
398
391
|
* blobVersionedHashes,
|
|
399
392
|
* chainId: 1,
|
|
400
393
|
* nonce: 0n,
|
|
@@ -404,7 +397,7 @@ export declare namespace from {
|
|
|
404
397
|
* value: 1000000000000000000n,
|
|
405
398
|
* })
|
|
406
399
|
*
|
|
407
|
-
* const payload =
|
|
400
|
+
* const payload = TxEnvelopeEip4844.getSignPayload(envelope) // [!code focus]
|
|
408
401
|
* // @log: '0x...'
|
|
409
402
|
*
|
|
410
403
|
* const signature = Secp256k1.sign({ payload, privateKey: '0x...' })
|
|
@@ -414,7 +407,7 @@ export declare namespace from {
|
|
|
414
407
|
* @returns The sign payload.
|
|
415
408
|
*/
|
|
416
409
|
export function getSignPayload(
|
|
417
|
-
envelope:
|
|
410
|
+
envelope: TxEnvelopeEip4844,
|
|
418
411
|
): getSignPayload.ReturnType {
|
|
419
412
|
return hash(envelope, { presign: true })
|
|
420
413
|
}
|
|
@@ -426,18 +419,18 @@ export declare namespace getSignPayload {
|
|
|
426
419
|
}
|
|
427
420
|
|
|
428
421
|
/**
|
|
429
|
-
* Hashes a {@link ox#
|
|
422
|
+
* Hashes a {@link ox#TxEnvelopeEip4844.TxEnvelopeEip4844}. This is the "transaction hash".
|
|
430
423
|
*
|
|
431
424
|
* @example
|
|
432
425
|
* ```ts twoslash
|
|
433
426
|
* // @noErrors
|
|
434
|
-
* import { Blobs,
|
|
427
|
+
* import { Blobs, TxEnvelopeEip4844 } from 'ox'
|
|
435
428
|
* import { kzg } from './kzg'
|
|
436
429
|
*
|
|
437
430
|
* const blobs = Blobs.from('0xdeadbeef')
|
|
438
431
|
* const blobVersionedHashes = Blobs.toVersionedHashes(blobs, { kzg })
|
|
439
432
|
*
|
|
440
|
-
* const envelope =
|
|
433
|
+
* const envelope = TxEnvelopeEip4844.from({
|
|
441
434
|
* blobVersionedHashes,
|
|
442
435
|
* chainId: 1,
|
|
443
436
|
* nonce: 0n,
|
|
@@ -447,7 +440,7 @@ export declare namespace getSignPayload {
|
|
|
447
440
|
* value: 1000000000000000000n,
|
|
448
441
|
* })
|
|
449
442
|
*
|
|
450
|
-
* const hash =
|
|
443
|
+
* const hash = TxEnvelopeEip4844.hash(envelope) // [!code focus]
|
|
451
444
|
* ```
|
|
452
445
|
*
|
|
453
446
|
* @param envelope - The EIP-4844 Transaction Envelope to hash.
|
|
@@ -455,7 +448,7 @@ export declare namespace getSignPayload {
|
|
|
455
448
|
* @returns The hash of the transaction envelope.
|
|
456
449
|
*/
|
|
457
450
|
export function hash<presign extends boolean = false>(
|
|
458
|
-
envelope:
|
|
451
|
+
envelope: TxEnvelopeEip4844<presign extends true ? false : true>,
|
|
459
452
|
options: hash.Options<presign> = {},
|
|
460
453
|
): hash.ReturnType {
|
|
461
454
|
const { presign } = options
|
|
@@ -490,18 +483,18 @@ export declare namespace hash {
|
|
|
490
483
|
}
|
|
491
484
|
|
|
492
485
|
/**
|
|
493
|
-
* Serializes a {@link ox#
|
|
486
|
+
* Serializes a {@link ox#TxEnvelopeEip4844.TxEnvelopeEip4844}.
|
|
494
487
|
*
|
|
495
488
|
* @example
|
|
496
489
|
* ```ts twoslash
|
|
497
490
|
* // @noErrors
|
|
498
|
-
* import { Blobs,
|
|
491
|
+
* import { Blobs, TxEnvelopeEip4844 } from 'ox'
|
|
499
492
|
* import { kzg } from './kzg'
|
|
500
493
|
*
|
|
501
494
|
* const blobs = Blobs.from('0xdeadbeef')
|
|
502
495
|
* const blobVersionedHashes = Blobs.toVersionedHashes(blobs, { kzg })
|
|
503
496
|
*
|
|
504
|
-
* const envelope =
|
|
497
|
+
* const envelope = TxEnvelopeEip4844.from({
|
|
505
498
|
* blobVersionedHashes,
|
|
506
499
|
* chainId: 1,
|
|
507
500
|
* maxFeePerGas: Value.fromGwei('10'),
|
|
@@ -509,7 +502,7 @@ export declare namespace hash {
|
|
|
509
502
|
* value: Value.fromEther('1'),
|
|
510
503
|
* })
|
|
511
504
|
*
|
|
512
|
-
* const serialized =
|
|
505
|
+
* const serialized = TxEnvelopeEip4844.serialize(envelope) // [!code focus]
|
|
513
506
|
* ```
|
|
514
507
|
*
|
|
515
508
|
* @example
|
|
@@ -519,14 +512,14 @@ export declare namespace hash {
|
|
|
519
512
|
*
|
|
520
513
|
* ```ts twoslash
|
|
521
514
|
* // @noErrors
|
|
522
|
-
* import { Blobs, Secp256k1,
|
|
515
|
+
* import { Blobs, Secp256k1, TxEnvelopeEip4844, Value } from 'ox'
|
|
523
516
|
* import { kzg } from './kzg'
|
|
524
517
|
*
|
|
525
518
|
* const blobs = Blobs.from('0xdeadbeef')
|
|
526
519
|
* const sidecars = Blobs.toSidecars(blobs, { kzg })
|
|
527
520
|
* const blobVersionedHashes = Blobs.sidecarsToVersionedHashes(blobs)
|
|
528
521
|
*
|
|
529
|
-
* const envelope =
|
|
522
|
+
* const envelope = TxEnvelopeEip4844.from({
|
|
530
523
|
* blobVersionedHashes,
|
|
531
524
|
* chainId: 1,
|
|
532
525
|
* maxFeePerBlobGas: Value.fromGwei('3'),
|
|
@@ -537,11 +530,11 @@ export declare namespace hash {
|
|
|
537
530
|
* })
|
|
538
531
|
*
|
|
539
532
|
* const signature = Secp256k1.sign({
|
|
540
|
-
* payload:
|
|
533
|
+
* payload: TxEnvelopeEip4844.getSignPayload(envelope),
|
|
541
534
|
* privateKey: '0x...',
|
|
542
535
|
* })
|
|
543
536
|
*
|
|
544
|
-
* const serialized =
|
|
537
|
+
* const serialized = TxEnvelopeEip4844.serialize(envelope, { // [!code focus]
|
|
545
538
|
* sidecars, // [!code focus]
|
|
546
539
|
* signature, // [!code focus]
|
|
547
540
|
* }) // [!code focus]
|
|
@@ -554,7 +547,7 @@ export declare namespace hash {
|
|
|
554
547
|
* @returns The serialized Transaction Envelope.
|
|
555
548
|
*/
|
|
556
549
|
export function serialize(
|
|
557
|
-
envelope: PartialBy<
|
|
550
|
+
envelope: PartialBy<TxEnvelopeEip4844, 'type'>,
|
|
558
551
|
options: serialize.Options = {},
|
|
559
552
|
): Serialized {
|
|
560
553
|
const {
|
|
@@ -632,18 +625,18 @@ export declare namespace serialize {
|
|
|
632
625
|
}
|
|
633
626
|
|
|
634
627
|
/**
|
|
635
|
-
* Converts an {@link ox#
|
|
628
|
+
* Converts an {@link ox#TxEnvelopeEip4844.TxEnvelopeEip4844} to an {@link ox#TxEnvelopeEip4844.Rpc}.
|
|
636
629
|
*
|
|
637
630
|
* @example
|
|
638
631
|
* ```ts twoslash
|
|
639
632
|
* // @noErrors
|
|
640
|
-
* import { Blobs, RpcRequest,
|
|
633
|
+
* import { Blobs, RpcRequest, TxEnvelopeEip4844, Value } from 'ox'
|
|
641
634
|
* import { kzg } from './kzg'
|
|
642
635
|
*
|
|
643
636
|
* const blobs = Blobs.from('0xdeadbeef')
|
|
644
637
|
* const blobVersionedHashes = Blobs.toVersionedHashes(blobs, { kzg })
|
|
645
638
|
*
|
|
646
|
-
* const envelope =
|
|
639
|
+
* const envelope = TxEnvelopeEip4844.from({
|
|
647
640
|
* blobVersionedHashes,
|
|
648
641
|
* chainId: 1,
|
|
649
642
|
* nonce: 0n,
|
|
@@ -653,7 +646,7 @@ export declare namespace serialize {
|
|
|
653
646
|
* value: Value.fromEther('1'),
|
|
654
647
|
* })
|
|
655
648
|
*
|
|
656
|
-
* const envelope_rpc =
|
|
649
|
+
* const envelope_rpc = TxEnvelopeEip4844.toRpc(envelope) // [!code focus]
|
|
657
650
|
*
|
|
658
651
|
* const request = RpcRequest.from({
|
|
659
652
|
* id: 0,
|
|
@@ -665,7 +658,7 @@ export declare namespace serialize {
|
|
|
665
658
|
* @param envelope - The EIP-4844 transaction envelope to convert.
|
|
666
659
|
* @returns An RPC-formatted EIP-4844 transaction envelope.
|
|
667
660
|
*/
|
|
668
|
-
export function toRpc(envelope: Omit<
|
|
661
|
+
export function toRpc(envelope: Omit<TxEnvelopeEip4844, 'type'>): Rpc {
|
|
669
662
|
const signature = Signature.extract(envelope)
|
|
670
663
|
|
|
671
664
|
return {
|
|
@@ -700,13 +693,13 @@ export declare namespace toRpc {
|
|
|
700
693
|
}
|
|
701
694
|
|
|
702
695
|
/**
|
|
703
|
-
* Validates a {@link ox#
|
|
696
|
+
* Validates a {@link ox#TxEnvelopeEip4844.TxEnvelopeEip4844}. Returns `true` if the envelope is valid, `false` otherwise.
|
|
704
697
|
*
|
|
705
698
|
* @example
|
|
706
699
|
* ```ts twoslash
|
|
707
|
-
* import {
|
|
700
|
+
* import { TxEnvelopeEip4844, Value } from 'ox'
|
|
708
701
|
*
|
|
709
|
-
* const valid =
|
|
702
|
+
* const valid = TxEnvelopeEip4844.assert({
|
|
710
703
|
* blobVersionedHashes: [],
|
|
711
704
|
* chainId: 1,
|
|
712
705
|
* to: '0x0000000000000000000000000000000000000000',
|
|
@@ -717,9 +710,7 @@ export declare namespace toRpc {
|
|
|
717
710
|
*
|
|
718
711
|
* @param envelope - The transaction envelope to validate.
|
|
719
712
|
*/
|
|
720
|
-
export function validate(
|
|
721
|
-
envelope: PartialBy<TransactionEnvelopeEip4844, 'type'>,
|
|
722
|
-
) {
|
|
713
|
+
export function validate(envelope: PartialBy<TxEnvelopeEip4844, 'type'>) {
|
|
723
714
|
try {
|
|
724
715
|
assert(envelope)
|
|
725
716
|
return true
|