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
|
} from './internal/types.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 TxEnvelopeEip7702<
|
|
19
19
|
signed extends boolean = boolean,
|
|
20
20
|
bigintType = bigint,
|
|
21
21
|
numberType = number,
|
|
@@ -33,7 +33,7 @@ export type TransactionEnvelopeEip7702<
|
|
|
33
33
|
}
|
|
34
34
|
>
|
|
35
35
|
|
|
36
|
-
export type Rpc<signed extends boolean = boolean> =
|
|
36
|
+
export type Rpc<signed extends boolean = boolean> = TxEnvelopeEip7702<
|
|
37
37
|
signed,
|
|
38
38
|
Hex.Hex,
|
|
39
39
|
Hex.Hex,
|
|
@@ -42,7 +42,7 @@ export type Rpc<signed extends boolean = boolean> = TransactionEnvelopeEip7702<
|
|
|
42
42
|
|
|
43
43
|
export type Serialized = `${SerializedType}${string}`
|
|
44
44
|
|
|
45
|
-
export type Signed =
|
|
45
|
+
export type Signed = TxEnvelopeEip7702<true>
|
|
46
46
|
|
|
47
47
|
export const serializedType = '0x04' as const
|
|
48
48
|
export type SerializedType = typeof serializedType
|
|
@@ -51,13 +51,13 @@ export const type = 'eip7702' as const
|
|
|
51
51
|
export type Type = typeof type
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
|
-
* Asserts a {@link ox#
|
|
54
|
+
* Asserts a {@link ox#TxEnvelopeEip7702.TxEnvelopeEip7702} is valid.
|
|
55
55
|
*
|
|
56
56
|
* @example
|
|
57
57
|
* ```ts twoslash
|
|
58
|
-
* import {
|
|
58
|
+
* import { TxEnvelopeEip7702, Value } from 'ox'
|
|
59
59
|
*
|
|
60
|
-
*
|
|
60
|
+
* TxEnvelopeEip7702.assert({
|
|
61
61
|
* authorizationList: [],
|
|
62
62
|
* maxFeePerGas: 2n ** 256n - 1n + 1n,
|
|
63
63
|
* chainId: 1,
|
|
@@ -71,9 +71,7 @@ export type Type = typeof type
|
|
|
71
71
|
*
|
|
72
72
|
* @param envelope - The transaction envelope to assert.
|
|
73
73
|
*/
|
|
74
|
-
export function assert(
|
|
75
|
-
envelope: PartialBy<TransactionEnvelopeEip7702, 'type'>,
|
|
76
|
-
) {
|
|
74
|
+
export function assert(envelope: PartialBy<TxEnvelopeEip7702, 'type'>) {
|
|
77
75
|
const { authorizationList } = envelope
|
|
78
76
|
if (authorizationList) {
|
|
79
77
|
for (const authorization of authorizationList) {
|
|
@@ -83,8 +81,8 @@ export function assert(
|
|
|
83
81
|
throw new TransactionEnvelope.InvalidChainIdError({ chainId })
|
|
84
82
|
}
|
|
85
83
|
}
|
|
86
|
-
|
|
87
|
-
envelope as {} as
|
|
84
|
+
TxEnvelopeEip1559.assert(
|
|
85
|
+
envelope as {} as TxEnvelopeEip1559.TxEnvelopeEip1559,
|
|
88
86
|
)
|
|
89
87
|
}
|
|
90
88
|
|
|
@@ -96,13 +94,13 @@ export declare namespace assert {
|
|
|
96
94
|
}
|
|
97
95
|
|
|
98
96
|
/**
|
|
99
|
-
* Deserializes a {@link ox#
|
|
97
|
+
* Deserializes a {@link ox#TxEnvelopeEip7702.TxEnvelopeEip7702} from its serialized form.
|
|
100
98
|
*
|
|
101
99
|
* @example
|
|
102
100
|
* ```ts twoslash
|
|
103
|
-
* import {
|
|
101
|
+
* import { TxEnvelopeEip7702 } from 'ox'
|
|
104
102
|
*
|
|
105
|
-
* const envelope =
|
|
103
|
+
* const envelope = TxEnvelopeEip7702.deserialize('0x04ef0182031184773594008477359400809470997970c51812dc3a010c7d01b50e0d17dc79c8880de0b6b3a764000080c0')
|
|
106
104
|
* // @log: {
|
|
107
105
|
* // @log: authorizationList: [...],
|
|
108
106
|
* // @log: type: 'eip7702',
|
|
@@ -119,7 +117,7 @@ export declare namespace assert {
|
|
|
119
117
|
*/
|
|
120
118
|
export function deserialize(
|
|
121
119
|
serialized: Serialized,
|
|
122
|
-
): Compute<
|
|
120
|
+
): Compute<TxEnvelopeEip7702> {
|
|
123
121
|
const transactionArray = Rlp.toHex(Hex.slice(serialized, 1))
|
|
124
122
|
|
|
125
123
|
const [
|
|
@@ -166,7 +164,7 @@ export function deserialize(
|
|
|
166
164
|
let transaction = {
|
|
167
165
|
chainId: Number(chainId),
|
|
168
166
|
type,
|
|
169
|
-
} as
|
|
167
|
+
} as TxEnvelopeEip7702
|
|
170
168
|
if (Hex.validate(to) && to !== '0x') transaction.to = to
|
|
171
169
|
if (Hex.validate(gas) && gas !== '0x') transaction.gas = BigInt(gas)
|
|
172
170
|
if (Hex.validate(data) && data !== '0x') transaction.data = data
|
|
@@ -190,7 +188,7 @@ export function deserialize(
|
|
|
190
188
|
transaction = {
|
|
191
189
|
...transaction,
|
|
192
190
|
...signature,
|
|
193
|
-
} as
|
|
191
|
+
} as TxEnvelopeEip7702
|
|
194
192
|
|
|
195
193
|
assert(transaction)
|
|
196
194
|
|
|
@@ -206,7 +204,7 @@ export declare namespace deserialize {
|
|
|
206
204
|
*
|
|
207
205
|
* @example
|
|
208
206
|
* ```ts twoslash
|
|
209
|
-
* import { Authorization, Secp256k1,
|
|
207
|
+
* import { Authorization, Secp256k1, TxEnvelopeEip7702, Value } from 'ox'
|
|
210
208
|
*
|
|
211
209
|
* const authorization = Authorization.from({
|
|
212
210
|
* address: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
@@ -221,7 +219,7 @@ export declare namespace deserialize {
|
|
|
221
219
|
*
|
|
222
220
|
* const authorizationList = [Authorization.from(authorization, { signature })]
|
|
223
221
|
*
|
|
224
|
-
* const envelope =
|
|
222
|
+
* const envelope = TxEnvelopeEip7702.from({ // [!code focus]
|
|
225
223
|
* authorizationList, // [!code focus]
|
|
226
224
|
* chainId: 1, // [!code focus]
|
|
227
225
|
* maxFeePerGas: Value.fromGwei('10'), // [!code focus]
|
|
@@ -238,9 +236,9 @@ export declare namespace deserialize {
|
|
|
238
236
|
*
|
|
239
237
|
* ```ts twoslash
|
|
240
238
|
* // @noErrors
|
|
241
|
-
* import { Secp256k1,
|
|
239
|
+
* import { Secp256k1, TxEnvelopeEip7702, Value } from 'ox'
|
|
242
240
|
*
|
|
243
|
-
* const envelope =
|
|
241
|
+
* const envelope = TxEnvelopeEip7702.from({
|
|
244
242
|
* authorizationList: [...],
|
|
245
243
|
* chainId: 1,
|
|
246
244
|
* maxFeePerGas: Value.fromGwei('10'),
|
|
@@ -250,11 +248,11 @@ export declare namespace deserialize {
|
|
|
250
248
|
* })
|
|
251
249
|
*
|
|
252
250
|
* const signature = Secp256k1.sign({
|
|
253
|
-
* payload:
|
|
251
|
+
* payload: TxEnvelopeEip7702.getSignPayload(envelope),
|
|
254
252
|
* privateKey: '0x...',
|
|
255
253
|
* })
|
|
256
254
|
*
|
|
257
|
-
* const envelope_signed =
|
|
255
|
+
* const envelope_signed = TxEnvelopeEip7702.from(envelope, { // [!code focus]
|
|
258
256
|
* signature, // [!code focus]
|
|
259
257
|
* }) // [!code focus]
|
|
260
258
|
* // @log: {
|
|
@@ -274,12 +272,12 @@ export declare namespace deserialize {
|
|
|
274
272
|
* @example
|
|
275
273
|
* ### From Serialized
|
|
276
274
|
*
|
|
277
|
-
* It is possible to instantiate an EIP-7702 Transaction Envelope from a {@link ox#
|
|
275
|
+
* It is possible to instantiate an EIP-7702 Transaction Envelope from a {@link ox#TxEnvelopeEip7702.Serialized} value.
|
|
278
276
|
*
|
|
279
277
|
* ```ts twoslash
|
|
280
|
-
* import {
|
|
278
|
+
* import { TxEnvelopeEip7702 } from 'ox'
|
|
281
279
|
*
|
|
282
|
-
* const envelope =
|
|
280
|
+
* const envelope = TxEnvelopeEip7702.from('0x04f858018203118502540be4008504a817c800809470997970c51812dc3a010c7d01b50e0d17dc79c8880de0b6b3a764000080c08477359400e1a001627c687261b0e7f8638af1112efa8a77e23656f6e7945275b19e9deed80261')
|
|
283
281
|
* // @log: {
|
|
284
282
|
* // @log: authorizationList: [...],
|
|
285
283
|
* // @log: chainId: 1,
|
|
@@ -295,22 +293,17 @@ export declare namespace deserialize {
|
|
|
295
293
|
* @returns An EIP-7702 Transaction Envelope.
|
|
296
294
|
*/
|
|
297
295
|
export function from<
|
|
298
|
-
const envelope extends
|
|
299
|
-
| UnionPartialBy<TransactionEnvelopeEip7702, 'type'>
|
|
300
|
-
| Serialized,
|
|
296
|
+
const envelope extends UnionPartialBy<TxEnvelopeEip7702, 'type'> | Serialized,
|
|
301
297
|
const signature extends Signature.Signature | undefined = undefined,
|
|
302
298
|
>(
|
|
303
|
-
envelope:
|
|
304
|
-
| envelope
|
|
305
|
-
| UnionPartialBy<TransactionEnvelopeEip7702, 'type'>
|
|
306
|
-
| Serialized,
|
|
299
|
+
envelope: envelope | UnionPartialBy<TxEnvelopeEip7702, 'type'> | Serialized,
|
|
307
300
|
options: from.Options<signature> = {},
|
|
308
301
|
): from.ReturnType<envelope, signature> {
|
|
309
302
|
const { signature } = options
|
|
310
303
|
|
|
311
304
|
const envelope_ = (
|
|
312
305
|
typeof envelope === 'string' ? deserialize(envelope) : envelope
|
|
313
|
-
) as
|
|
306
|
+
) as TxEnvelopeEip7702
|
|
314
307
|
|
|
315
308
|
assert(envelope_)
|
|
316
309
|
|
|
@@ -328,13 +321,13 @@ export declare namespace from {
|
|
|
328
321
|
}
|
|
329
322
|
|
|
330
323
|
type ReturnType<
|
|
331
|
-
envelope extends
|
|
332
|
-
|
|
|
333
|
-
| Hex.Hex
|
|
324
|
+
envelope extends UnionPartialBy<TxEnvelopeEip7702, 'type'> | Hex.Hex =
|
|
325
|
+
| TxEnvelopeEip7702
|
|
326
|
+
| Hex.Hex,
|
|
334
327
|
signature extends Signature.Signature | undefined = undefined,
|
|
335
328
|
> = Compute<
|
|
336
329
|
envelope extends Hex.Hex
|
|
337
|
-
?
|
|
330
|
+
? TxEnvelopeEip7702
|
|
338
331
|
: Assign<
|
|
339
332
|
envelope,
|
|
340
333
|
(signature extends Signature.Signature ? Readonly<signature> : {}) & {
|
|
@@ -350,7 +343,7 @@ export declare namespace from {
|
|
|
350
343
|
}
|
|
351
344
|
|
|
352
345
|
/**
|
|
353
|
-
* Returns the payload to sign for a {@link ox#
|
|
346
|
+
* Returns the payload to sign for a {@link ox#TxEnvelopeEip7702.TxEnvelopeEip7702}.
|
|
354
347
|
*
|
|
355
348
|
* @example
|
|
356
349
|
* The example below demonstrates how to compute the sign payload which can be used
|
|
@@ -358,9 +351,9 @@ export declare namespace from {
|
|
|
358
351
|
*
|
|
359
352
|
* ```ts twoslash
|
|
360
353
|
* // @noErrors
|
|
361
|
-
* import { Secp256k1,
|
|
354
|
+
* import { Secp256k1, TxEnvelopeEip7702 } from 'ox'
|
|
362
355
|
*
|
|
363
|
-
* const envelope =
|
|
356
|
+
* const envelope = TxEnvelopeEip7702.from({
|
|
364
357
|
* authorizationList: [...],
|
|
365
358
|
* chainId: 1,
|
|
366
359
|
* nonce: 0n,
|
|
@@ -370,7 +363,7 @@ export declare namespace from {
|
|
|
370
363
|
* value: 1000000000000000000n,
|
|
371
364
|
* })
|
|
372
365
|
*
|
|
373
|
-
* const payload =
|
|
366
|
+
* const payload = TxEnvelopeEip7702.getSignPayload(envelope) // [!code focus]
|
|
374
367
|
* // @log: '0x...'
|
|
375
368
|
*
|
|
376
369
|
* const signature = Secp256k1.sign({ payload, privateKey: '0x...' })
|
|
@@ -380,7 +373,7 @@ export declare namespace from {
|
|
|
380
373
|
* @returns The sign payload.
|
|
381
374
|
*/
|
|
382
375
|
export function getSignPayload(
|
|
383
|
-
envelope:
|
|
376
|
+
envelope: TxEnvelopeEip7702,
|
|
384
377
|
): getSignPayload.ReturnType {
|
|
385
378
|
return hash(envelope, { presign: true })
|
|
386
379
|
}
|
|
@@ -392,14 +385,14 @@ export declare namespace getSignPayload {
|
|
|
392
385
|
}
|
|
393
386
|
|
|
394
387
|
/**
|
|
395
|
-
* Hashes a {@link ox#
|
|
388
|
+
* Hashes a {@link ox#TxEnvelopeEip7702.TxEnvelopeEip7702}. This is the "transaction hash".
|
|
396
389
|
*
|
|
397
390
|
* @example
|
|
398
391
|
* ```ts twoslash
|
|
399
392
|
* // @noErrors
|
|
400
|
-
* import { Secp256k1,
|
|
393
|
+
* import { Secp256k1, TxEnvelopeEip7702 } from 'ox'
|
|
401
394
|
*
|
|
402
|
-
* const envelope =
|
|
395
|
+
* const envelope = TxEnvelopeEip7702.from({
|
|
403
396
|
* authorizationList: [...],
|
|
404
397
|
* chainId: 1,
|
|
405
398
|
* nonce: 0n,
|
|
@@ -410,13 +403,13 @@ export declare namespace getSignPayload {
|
|
|
410
403
|
* })
|
|
411
404
|
*
|
|
412
405
|
* const signature = Secp256k1.sign({
|
|
413
|
-
* payload:
|
|
406
|
+
* payload: TxEnvelopeEip7702.getSignPayload(envelope),
|
|
414
407
|
* privateKey: '0x...'
|
|
415
408
|
* })
|
|
416
409
|
*
|
|
417
|
-
* const envelope_signed =
|
|
410
|
+
* const envelope_signed = TxEnvelopeEip7702.from(envelope, { signature })
|
|
418
411
|
*
|
|
419
|
-
* const hash =
|
|
412
|
+
* const hash = TxEnvelopeEip7702.hash(envelope_signed) // [!code focus]
|
|
420
413
|
* ```
|
|
421
414
|
*
|
|
422
415
|
* @param envelope - The EIP-7702 Transaction Envelope to hash.
|
|
@@ -424,7 +417,7 @@ export declare namespace getSignPayload {
|
|
|
424
417
|
* @returns The hash of the transaction envelope.
|
|
425
418
|
*/
|
|
426
419
|
export function hash<presign extends boolean = false>(
|
|
427
|
-
envelope:
|
|
420
|
+
envelope: TxEnvelopeEip7702<presign extends true ? false : true>,
|
|
428
421
|
options: hash.Options<presign> = {},
|
|
429
422
|
): hash.ReturnType {
|
|
430
423
|
const { presign } = options
|
|
@@ -457,12 +450,12 @@ export declare namespace hash {
|
|
|
457
450
|
}
|
|
458
451
|
|
|
459
452
|
/**
|
|
460
|
-
* Serializes a {@link ox#
|
|
453
|
+
* Serializes a {@link ox#TxEnvelopeEip7702.TxEnvelopeEip7702}.
|
|
461
454
|
*
|
|
462
455
|
* @example
|
|
463
456
|
* ```ts twoslash
|
|
464
457
|
* // @noErrors
|
|
465
|
-
* import { Authorization, Secp256k1,
|
|
458
|
+
* import { Authorization, Secp256k1, TxEnvelopeEip7702, Value } from 'ox'
|
|
466
459
|
*
|
|
467
460
|
* const authorization = Authorization.from({
|
|
468
461
|
* address: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
@@ -477,7 +470,7 @@ export declare namespace hash {
|
|
|
477
470
|
*
|
|
478
471
|
* const authorizationList = [Authorization.from(authorization, { signature })]
|
|
479
472
|
*
|
|
480
|
-
* const envelope =
|
|
473
|
+
* const envelope = TxEnvelopeEip7702.from({
|
|
481
474
|
* authorizationList,
|
|
482
475
|
* chainId: 1,
|
|
483
476
|
* maxFeePerGas: Value.fromGwei('10'),
|
|
@@ -485,7 +478,7 @@ export declare namespace hash {
|
|
|
485
478
|
* value: Value.fromEther('1'),
|
|
486
479
|
* })
|
|
487
480
|
*
|
|
488
|
-
* const serialized =
|
|
481
|
+
* const serialized = TxEnvelopeEip7702.serialize(envelope) // [!code focus]
|
|
489
482
|
* ```
|
|
490
483
|
*
|
|
491
484
|
* @example
|
|
@@ -495,9 +488,9 @@ export declare namespace hash {
|
|
|
495
488
|
*
|
|
496
489
|
* ```ts twoslash
|
|
497
490
|
* // @noErrors
|
|
498
|
-
* import { Secp256k1,
|
|
491
|
+
* import { Secp256k1, TxEnvelopeEip7702, Value } from 'ox'
|
|
499
492
|
*
|
|
500
|
-
* const envelope =
|
|
493
|
+
* const envelope = TxEnvelopeEip7702.from({
|
|
501
494
|
* authorizationList: [...],
|
|
502
495
|
* chainId: 1,
|
|
503
496
|
* maxFeePerGas: Value.fromGwei('10'),
|
|
@@ -506,11 +499,11 @@ export declare namespace hash {
|
|
|
506
499
|
* })
|
|
507
500
|
*
|
|
508
501
|
* const signature = Secp256k1.sign({
|
|
509
|
-
* payload:
|
|
502
|
+
* payload: TxEnvelopeEip7702.getSignPayload(envelope),
|
|
510
503
|
* privateKey: '0x...',
|
|
511
504
|
* })
|
|
512
505
|
*
|
|
513
|
-
* const serialized =
|
|
506
|
+
* const serialized = TxEnvelopeEip7702.serialize(envelope, { // [!code focus]
|
|
514
507
|
* signature, // [!code focus]
|
|
515
508
|
* }) // [!code focus]
|
|
516
509
|
*
|
|
@@ -522,7 +515,7 @@ export declare namespace hash {
|
|
|
522
515
|
* @returns The serialized Transaction Envelope.
|
|
523
516
|
*/
|
|
524
517
|
export function serialize(
|
|
525
|
-
envelope: PartialBy<
|
|
518
|
+
envelope: PartialBy<TxEnvelopeEip7702, 'type'>,
|
|
526
519
|
options: serialize.Options = {},
|
|
527
520
|
): Serialized {
|
|
528
521
|
const {
|
|
@@ -579,13 +572,13 @@ export declare namespace serialize {
|
|
|
579
572
|
}
|
|
580
573
|
|
|
581
574
|
/**
|
|
582
|
-
* Validates a {@link ox#
|
|
575
|
+
* Validates a {@link ox#TxEnvelopeEip7702.TxEnvelopeEip7702}. Returns `true` if the envelope is valid, `false` otherwise.
|
|
583
576
|
*
|
|
584
577
|
* @example
|
|
585
578
|
* ```ts twoslash
|
|
586
|
-
* import {
|
|
579
|
+
* import { TxEnvelopeEip7702, Value } from 'ox'
|
|
587
580
|
*
|
|
588
|
-
* const valid =
|
|
581
|
+
* const valid = TxEnvelopeEip7702.validate({
|
|
589
582
|
* authorizationList: [],
|
|
590
583
|
* maxFeePerGas: 2n ** 256n - 1n + 1n,
|
|
591
584
|
* chainId: 1,
|
|
@@ -597,9 +590,7 @@ export declare namespace serialize {
|
|
|
597
590
|
*
|
|
598
591
|
* @param envelope - The transaction envelope to validate.
|
|
599
592
|
*/
|
|
600
|
-
export function validate(
|
|
601
|
-
envelope: PartialBy<TransactionEnvelopeEip7702, 'type'>,
|
|
602
|
-
) {
|
|
593
|
+
export function validate(envelope: PartialBy<TxEnvelopeEip7702, 'type'>) {
|
|
603
594
|
try {
|
|
604
595
|
assert(envelope)
|
|
605
596
|
return true
|