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
|
@@ -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 './
|
|
14
|
+
import * as TransactionEnvelope from './TxEnvelope.js'
|
|
15
15
|
|
|
16
|
-
export type
|
|
16
|
+
export type TxEnvelopeEip1559<
|
|
17
17
|
signed extends boolean = boolean,
|
|
18
18
|
bigintType = bigint,
|
|
19
19
|
numberType = number,
|
|
@@ -29,7 +29,7 @@ export type TransactionEnvelopeEip1559<
|
|
|
29
29
|
}
|
|
30
30
|
>
|
|
31
31
|
|
|
32
|
-
export type Rpc<signed extends boolean = boolean> =
|
|
32
|
+
export type Rpc<signed extends boolean = boolean> = TxEnvelopeEip1559<
|
|
33
33
|
signed,
|
|
34
34
|
Hex.Hex,
|
|
35
35
|
Hex.Hex,
|
|
@@ -41,19 +41,19 @@ export type Serialized = `${SerializedType}${string}`
|
|
|
41
41
|
export const serializedType = '0x02' as const
|
|
42
42
|
export type SerializedType = typeof serializedType
|
|
43
43
|
|
|
44
|
-
export type Signed =
|
|
44
|
+
export type Signed = TxEnvelopeEip1559<true>
|
|
45
45
|
|
|
46
46
|
export const type = 'eip1559' as const
|
|
47
47
|
export type Type = typeof type
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
|
-
* Asserts a {@link ox#
|
|
50
|
+
* Asserts a {@link ox#TxEnvelopeEip1559.TxEnvelopeEip1559} is valid.
|
|
51
51
|
*
|
|
52
52
|
* @example
|
|
53
53
|
* ```ts twoslash
|
|
54
|
-
* import {
|
|
54
|
+
* import { TxEnvelopeEip1559, Value } from 'ox'
|
|
55
55
|
*
|
|
56
|
-
*
|
|
56
|
+
* TxEnvelopeEip1559.assert({
|
|
57
57
|
* maxFeePerGas: 2n ** 256n - 1n + 1n,
|
|
58
58
|
* chainId: 1,
|
|
59
59
|
* to: '0x0000000000000000000000000000000000000000',
|
|
@@ -66,9 +66,7 @@ export type Type = typeof type
|
|
|
66
66
|
*
|
|
67
67
|
* @param envelope - The transaction envelope to assert.
|
|
68
68
|
*/
|
|
69
|
-
export function assert(
|
|
70
|
-
envelope: PartialBy<TransactionEnvelopeEip1559, 'type'>,
|
|
71
|
-
) {
|
|
69
|
+
export function assert(envelope: PartialBy<TxEnvelopeEip1559, 'type'>) {
|
|
72
70
|
const { chainId, maxPriorityFeePerGas, maxFeePerGas, to } = envelope
|
|
73
71
|
if (chainId <= 0)
|
|
74
72
|
throw new TransactionEnvelope.InvalidChainIdError({ chainId })
|
|
@@ -96,13 +94,13 @@ export declare namespace assert {
|
|
|
96
94
|
}
|
|
97
95
|
|
|
98
96
|
/**
|
|
99
|
-
* Deserializes a {@link ox#
|
|
97
|
+
* Deserializes a {@link ox#TxEnvelopeEip1559.TxEnvelopeEip1559} from its serialized form.
|
|
100
98
|
*
|
|
101
99
|
* @example
|
|
102
100
|
* ```ts twoslash
|
|
103
|
-
* import {
|
|
101
|
+
* import { TxEnvelopeEip1559 } from 'ox'
|
|
104
102
|
*
|
|
105
|
-
* const envelope =
|
|
103
|
+
* const envelope = TxEnvelopeEip1559.deserialize('0x02ef0182031184773594008477359400809470997970c51812dc3a010c7d01b50e0d17dc79c8880de0b6b3a764000080c0')
|
|
106
104
|
* // @log: {
|
|
107
105
|
* // @log: type: 'eip1559',
|
|
108
106
|
* // @log: nonce: 785n,
|
|
@@ -118,7 +116,7 @@ export declare namespace assert {
|
|
|
118
116
|
*/
|
|
119
117
|
export function deserialize(
|
|
120
118
|
serialized: Serialized,
|
|
121
|
-
): Compute<
|
|
119
|
+
): Compute<TxEnvelopeEip1559> {
|
|
122
120
|
const transactionArray = Rlp.toHex(Hex.slice(serialized, 1))
|
|
123
121
|
|
|
124
122
|
const [
|
|
@@ -163,7 +161,7 @@ export function deserialize(
|
|
|
163
161
|
let transaction = {
|
|
164
162
|
chainId: Number(chainId),
|
|
165
163
|
type,
|
|
166
|
-
} as
|
|
164
|
+
} as TxEnvelopeEip1559
|
|
167
165
|
if (Hex.validate(to) && to !== '0x') transaction.to = to
|
|
168
166
|
if (Hex.validate(gas) && gas !== '0x') transaction.gas = BigInt(gas)
|
|
169
167
|
if (Hex.validate(data) && data !== '0x') transaction.data = data
|
|
@@ -183,7 +181,7 @@ export function deserialize(
|
|
|
183
181
|
transaction = {
|
|
184
182
|
...transaction,
|
|
185
183
|
...signature,
|
|
186
|
-
} as
|
|
184
|
+
} as TxEnvelopeEip1559
|
|
187
185
|
|
|
188
186
|
assert(transaction)
|
|
189
187
|
|
|
@@ -199,9 +197,9 @@ export declare namespace deserialize {
|
|
|
199
197
|
*
|
|
200
198
|
* @example
|
|
201
199
|
* ```ts twoslash
|
|
202
|
-
* import {
|
|
200
|
+
* import { TxEnvelopeEip1559, Value } from 'ox'
|
|
203
201
|
*
|
|
204
|
-
* const envelope =
|
|
202
|
+
* const envelope = TxEnvelopeEip1559.from({
|
|
205
203
|
* chainId: 1,
|
|
206
204
|
* maxFeePerGas: Value.fromGwei('10'),
|
|
207
205
|
* maxPriorityFeePerGas: Value.fromGwei('1'),
|
|
@@ -216,9 +214,9 @@ export declare namespace deserialize {
|
|
|
216
214
|
* It is possible to attach a `signature` to the transaction envelope.
|
|
217
215
|
*
|
|
218
216
|
* ```ts twoslash
|
|
219
|
-
* import { Secp256k1,
|
|
217
|
+
* import { Secp256k1, TxEnvelopeEip1559, Value } from 'ox'
|
|
220
218
|
*
|
|
221
|
-
* const envelope =
|
|
219
|
+
* const envelope = TxEnvelopeEip1559.from({
|
|
222
220
|
* chainId: 1,
|
|
223
221
|
* maxFeePerGas: Value.fromGwei('10'),
|
|
224
222
|
* maxPriorityFeePerGas: Value.fromGwei('1'),
|
|
@@ -227,11 +225,11 @@ export declare namespace deserialize {
|
|
|
227
225
|
* })
|
|
228
226
|
*
|
|
229
227
|
* const signature = Secp256k1.sign({
|
|
230
|
-
* payload:
|
|
228
|
+
* payload: TxEnvelopeEip1559.getSignPayload(envelope),
|
|
231
229
|
* privateKey: '0x...',
|
|
232
230
|
* })
|
|
233
231
|
*
|
|
234
|
-
* const envelope_signed =
|
|
232
|
+
* const envelope_signed = TxEnvelopeEip1559.from(envelope, { // [!code focus]
|
|
235
233
|
* signature, // [!code focus]
|
|
236
234
|
* }) // [!code focus]
|
|
237
235
|
* // @log: {
|
|
@@ -250,12 +248,12 @@ export declare namespace deserialize {
|
|
|
250
248
|
* @example
|
|
251
249
|
* ### From Serialized
|
|
252
250
|
*
|
|
253
|
-
* It is possible to instantiate an EIP-1559 Transaction Envelope from a {@link ox#
|
|
251
|
+
* It is possible to instantiate an EIP-1559 Transaction Envelope from a {@link ox#TxEnvelopeEip1559.Serialized} value.
|
|
254
252
|
*
|
|
255
253
|
* ```ts twoslash
|
|
256
|
-
* import {
|
|
254
|
+
* import { TxEnvelopeEip1559 } from 'ox'
|
|
257
255
|
*
|
|
258
|
-
* const envelope =
|
|
256
|
+
* const envelope = TxEnvelopeEip1559.from('0x02f858018203118502540be4008504a817c800809470997970c51812dc3a010c7d01b50e0d17dc79c8880de0b6b3a764000080c08477359400e1a001627c687261b0e7f8638af1112efa8a77e23656f6e7945275b19e9deed80261')
|
|
259
257
|
* // @log: {
|
|
260
258
|
* // @log: chainId: 1,
|
|
261
259
|
* // @log: maxFeePerGas: 10000000000n,
|
|
@@ -271,22 +269,17 @@ export declare namespace deserialize {
|
|
|
271
269
|
* @returns An EIP-1559 Transaction Envelope.
|
|
272
270
|
*/
|
|
273
271
|
export function from<
|
|
274
|
-
const envelope extends
|
|
275
|
-
| UnionPartialBy<TransactionEnvelopeEip1559, 'type'>
|
|
276
|
-
| Serialized,
|
|
272
|
+
const envelope extends UnionPartialBy<TxEnvelopeEip1559, 'type'> | Serialized,
|
|
277
273
|
const signature extends Signature.Signature | undefined = undefined,
|
|
278
274
|
>(
|
|
279
|
-
envelope:
|
|
280
|
-
| envelope
|
|
281
|
-
| UnionPartialBy<TransactionEnvelopeEip1559, 'type'>
|
|
282
|
-
| Serialized,
|
|
275
|
+
envelope: envelope | UnionPartialBy<TxEnvelopeEip1559, 'type'> | Serialized,
|
|
283
276
|
options: from.Options<signature> = {},
|
|
284
277
|
): from.ReturnType<envelope, signature> {
|
|
285
278
|
const { signature } = options
|
|
286
279
|
|
|
287
280
|
const envelope_ = (
|
|
288
281
|
typeof envelope === 'string' ? deserialize(envelope) : envelope
|
|
289
|
-
) as
|
|
282
|
+
) as TxEnvelopeEip1559
|
|
290
283
|
|
|
291
284
|
assert(envelope_)
|
|
292
285
|
|
|
@@ -304,13 +297,13 @@ export declare namespace from {
|
|
|
304
297
|
}
|
|
305
298
|
|
|
306
299
|
type ReturnType<
|
|
307
|
-
envelope extends
|
|
308
|
-
|
|
|
309
|
-
| Hex.Hex
|
|
300
|
+
envelope extends UnionPartialBy<TxEnvelopeEip1559, 'type'> | Hex.Hex =
|
|
301
|
+
| TxEnvelopeEip1559
|
|
302
|
+
| Hex.Hex,
|
|
310
303
|
signature extends Signature.Signature | undefined = undefined,
|
|
311
304
|
> = Compute<
|
|
312
305
|
envelope extends Hex.Hex
|
|
313
|
-
?
|
|
306
|
+
? TxEnvelopeEip1559
|
|
314
307
|
: Assign<
|
|
315
308
|
envelope,
|
|
316
309
|
(signature extends Signature.Signature ? Readonly<signature> : {}) & {
|
|
@@ -326,16 +319,16 @@ export declare namespace from {
|
|
|
326
319
|
}
|
|
327
320
|
|
|
328
321
|
/**
|
|
329
|
-
* Returns the payload to sign for a {@link ox#
|
|
322
|
+
* Returns the payload to sign for a {@link ox#TxEnvelopeEip1559.TxEnvelopeEip1559}.
|
|
330
323
|
*
|
|
331
324
|
* @example
|
|
332
325
|
* The example below demonstrates how to compute the sign payload which can be used
|
|
333
326
|
* with ECDSA signing utilities like {@link ox#Secp256k1.(sign:function)}.
|
|
334
327
|
*
|
|
335
328
|
* ```ts twoslash
|
|
336
|
-
* import { Secp256k1,
|
|
329
|
+
* import { Secp256k1, TxEnvelopeEip1559 } from 'ox'
|
|
337
330
|
*
|
|
338
|
-
* const envelope =
|
|
331
|
+
* const envelope = TxEnvelopeEip1559.from({
|
|
339
332
|
* chainId: 1,
|
|
340
333
|
* nonce: 0n,
|
|
341
334
|
* maxFeePerGas: 1000000000n,
|
|
@@ -344,7 +337,7 @@ export declare namespace from {
|
|
|
344
337
|
* value: 1000000000000000000n,
|
|
345
338
|
* })
|
|
346
339
|
*
|
|
347
|
-
* const payload =
|
|
340
|
+
* const payload = TxEnvelopeEip1559.getSignPayload(envelope) // [!code focus]
|
|
348
341
|
* // @log: '0x...'
|
|
349
342
|
*
|
|
350
343
|
* const signature = Secp256k1.sign({ payload, privateKey: '0x...' })
|
|
@@ -354,7 +347,7 @@ export declare namespace from {
|
|
|
354
347
|
* @returns The sign payload.
|
|
355
348
|
*/
|
|
356
349
|
export function getSignPayload(
|
|
357
|
-
envelope:
|
|
350
|
+
envelope: TxEnvelopeEip1559,
|
|
358
351
|
): getSignPayload.ReturnType {
|
|
359
352
|
return hash(envelope, { presign: true })
|
|
360
353
|
}
|
|
@@ -366,13 +359,13 @@ export declare namespace getSignPayload {
|
|
|
366
359
|
}
|
|
367
360
|
|
|
368
361
|
/**
|
|
369
|
-
* Hashes a {@link ox#
|
|
362
|
+
* Hashes a {@link ox#TxEnvelopeEip1559.TxEnvelopeEip1559}. This is the "transaction hash".
|
|
370
363
|
*
|
|
371
364
|
* @example
|
|
372
365
|
* ```ts twoslash
|
|
373
|
-
* import { Secp256k1,
|
|
366
|
+
* import { Secp256k1, TxEnvelopeEip1559 } from 'ox'
|
|
374
367
|
*
|
|
375
|
-
* const envelope =
|
|
368
|
+
* const envelope = TxEnvelopeEip1559.from({
|
|
376
369
|
* chainId: 1,
|
|
377
370
|
* nonce: 0n,
|
|
378
371
|
* maxFeePerGas: 1000000000n,
|
|
@@ -382,13 +375,13 @@ export declare namespace getSignPayload {
|
|
|
382
375
|
* })
|
|
383
376
|
*
|
|
384
377
|
* const signature = Secp256k1.sign({
|
|
385
|
-
* payload:
|
|
378
|
+
* payload: TxEnvelopeEip1559.getSignPayload(envelope),
|
|
386
379
|
* privateKey: '0x...'
|
|
387
380
|
* })
|
|
388
381
|
*
|
|
389
|
-
* const envelope_signed =
|
|
382
|
+
* const envelope_signed = TxEnvelopeEip1559.from(envelope, { signature })
|
|
390
383
|
*
|
|
391
|
-
* const hash =
|
|
384
|
+
* const hash = TxEnvelopeEip1559.hash(envelope_signed) // [!code focus]
|
|
392
385
|
* ```
|
|
393
386
|
*
|
|
394
387
|
* @param envelope - The EIP-1559 Transaction Envelope to hash.
|
|
@@ -396,7 +389,7 @@ export declare namespace getSignPayload {
|
|
|
396
389
|
* @returns The hash of the transaction envelope.
|
|
397
390
|
*/
|
|
398
391
|
export function hash<presign extends boolean = false>(
|
|
399
|
-
envelope:
|
|
392
|
+
envelope: TxEnvelopeEip1559<presign extends true ? false : true>,
|
|
400
393
|
options: hash.Options<presign> = {},
|
|
401
394
|
): hash.ReturnType {
|
|
402
395
|
const { presign } = options
|
|
@@ -430,13 +423,13 @@ export declare namespace hash {
|
|
|
430
423
|
}
|
|
431
424
|
|
|
432
425
|
/**
|
|
433
|
-
* Serializes a {@link ox#
|
|
426
|
+
* Serializes a {@link ox#TxEnvelopeEip1559.TxEnvelopeEip1559}.
|
|
434
427
|
*
|
|
435
428
|
* @example
|
|
436
429
|
* ```ts twoslash
|
|
437
|
-
* import {
|
|
430
|
+
* import { TxEnvelopeEip1559, Value } from 'ox'
|
|
438
431
|
*
|
|
439
|
-
* const envelope =
|
|
432
|
+
* const envelope = TxEnvelopeEip1559.from({
|
|
440
433
|
* chainId: 1,
|
|
441
434
|
* maxFeePerGas: Value.fromGwei('10'),
|
|
442
435
|
* maxPriorityFeePerGas: Value.fromGwei('1'),
|
|
@@ -444,7 +437,7 @@ export declare namespace hash {
|
|
|
444
437
|
* value: Value.fromEther('1'),
|
|
445
438
|
* })
|
|
446
439
|
*
|
|
447
|
-
* const serialized =
|
|
440
|
+
* const serialized = TxEnvelopeEip1559.serialize(envelope) // [!code focus]
|
|
448
441
|
* ```
|
|
449
442
|
*
|
|
450
443
|
* @example
|
|
@@ -453,9 +446,9 @@ export declare namespace hash {
|
|
|
453
446
|
* It is possible to attach a `signature` to the serialized Transaction Envelope.
|
|
454
447
|
*
|
|
455
448
|
* ```ts twoslash
|
|
456
|
-
* import { Secp256k1,
|
|
449
|
+
* import { Secp256k1, TxEnvelopeEip1559, Value } from 'ox'
|
|
457
450
|
*
|
|
458
|
-
* const envelope =
|
|
451
|
+
* const envelope = TxEnvelopeEip1559.from({
|
|
459
452
|
* chainId: 1,
|
|
460
453
|
* maxFeePerGas: Value.fromGwei('10'),
|
|
461
454
|
* maxPriorityFeePerGas: Value.fromGwei('1'),
|
|
@@ -464,11 +457,11 @@ export declare namespace hash {
|
|
|
464
457
|
* })
|
|
465
458
|
*
|
|
466
459
|
* const signature = Secp256k1.sign({
|
|
467
|
-
* payload:
|
|
460
|
+
* payload: TxEnvelopeEip1559.getSignPayload(envelope),
|
|
468
461
|
* privateKey: '0x...',
|
|
469
462
|
* })
|
|
470
463
|
*
|
|
471
|
-
* const serialized =
|
|
464
|
+
* const serialized = TxEnvelopeEip1559.serialize(envelope, { // [!code focus]
|
|
472
465
|
* signature, // [!code focus]
|
|
473
466
|
* }) // [!code focus]
|
|
474
467
|
*
|
|
@@ -480,7 +473,7 @@ export declare namespace hash {
|
|
|
480
473
|
* @returns The serialized Transaction Envelope.
|
|
481
474
|
*/
|
|
482
475
|
export function serialize(
|
|
483
|
-
envelope: PartialBy<
|
|
476
|
+
envelope: PartialBy<TxEnvelopeEip1559, 'type'>,
|
|
484
477
|
options: serialize.Options = {},
|
|
485
478
|
): Serialized {
|
|
486
479
|
const {
|
|
@@ -534,13 +527,13 @@ export declare namespace serialize {
|
|
|
534
527
|
}
|
|
535
528
|
|
|
536
529
|
/**
|
|
537
|
-
* Converts an {@link ox#
|
|
530
|
+
* Converts an {@link ox#TxEnvelopeEip1559.TxEnvelopeEip1559} to an {@link ox#TxEnvelopeEip1559.Rpc}.
|
|
538
531
|
*
|
|
539
532
|
* @example
|
|
540
533
|
* ```ts twoslash
|
|
541
|
-
* import { RpcRequest,
|
|
534
|
+
* import { RpcRequest, TxEnvelopeEip1559, Value } from 'ox'
|
|
542
535
|
*
|
|
543
|
-
* const envelope =
|
|
536
|
+
* const envelope = TxEnvelopeEip1559.from({
|
|
544
537
|
* chainId: 1,
|
|
545
538
|
* nonce: 0n,
|
|
546
539
|
* gas: 21000n,
|
|
@@ -548,7 +541,7 @@ export declare namespace serialize {
|
|
|
548
541
|
* value: Value.fromEther('1'),
|
|
549
542
|
* })
|
|
550
543
|
*
|
|
551
|
-
* const envelope_rpc =
|
|
544
|
+
* const envelope_rpc = TxEnvelopeEip1559.toRpc(envelope) // [!code focus]
|
|
552
545
|
*
|
|
553
546
|
* const request = RpcRequest.from({
|
|
554
547
|
* id: 0,
|
|
@@ -560,7 +553,7 @@ export declare namespace serialize {
|
|
|
560
553
|
* @param envelope - The EIP-1559 transaction envelope to convert.
|
|
561
554
|
* @returns An RPC-formatted EIP-1559 transaction envelope.
|
|
562
555
|
*/
|
|
563
|
-
export function toRpc(envelope: Omit<
|
|
556
|
+
export function toRpc(envelope: Omit<TxEnvelopeEip1559, 'type'>): Rpc {
|
|
564
557
|
const signature = Signature.extract(envelope)
|
|
565
558
|
|
|
566
559
|
return {
|
|
@@ -594,13 +587,13 @@ export declare namespace toRpc {
|
|
|
594
587
|
}
|
|
595
588
|
|
|
596
589
|
/**
|
|
597
|
-
* Validates a {@link ox#
|
|
590
|
+
* Validates a {@link ox#TxEnvelopeEip1559.TxEnvelopeEip1559}. Returns `true` if the envelope is valid, `false` otherwise.
|
|
598
591
|
*
|
|
599
592
|
* @example
|
|
600
593
|
* ```ts twoslash
|
|
601
|
-
* import {
|
|
594
|
+
* import { TxEnvelopeEip1559, Value } from 'ox'
|
|
602
595
|
*
|
|
603
|
-
* const valid =
|
|
596
|
+
* const valid = TxEnvelopeEip1559.assert({
|
|
604
597
|
* maxFeePerGas: 2n ** 256n - 1n + 1n,
|
|
605
598
|
* chainId: 1,
|
|
606
599
|
* to: '0x0000000000000000000000000000000000000000',
|
|
@@ -611,9 +604,7 @@ export declare namespace toRpc {
|
|
|
611
604
|
*
|
|
612
605
|
* @param envelope - The transaction envelope to validate.
|
|
613
606
|
*/
|
|
614
|
-
export function validate(
|
|
615
|
-
envelope: PartialBy<TransactionEnvelopeEip1559, 'type'>,
|
|
616
|
-
) {
|
|
607
|
+
export function validate(envelope: PartialBy<TxEnvelopeEip1559, 'type'>) {
|
|
617
608
|
try {
|
|
618
609
|
assert(envelope)
|
|
619
610
|
return true
|