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 TxEnvelopeEip2930<
|
|
17
17
|
signed extends boolean = boolean,
|
|
18
18
|
bigintType = bigint,
|
|
19
19
|
numberType = number,
|
|
@@ -27,7 +27,7 @@ export type TransactionEnvelopeEip2930<
|
|
|
27
27
|
}
|
|
28
28
|
>
|
|
29
29
|
|
|
30
|
-
export type Rpc<signed extends boolean = boolean> =
|
|
30
|
+
export type Rpc<signed extends boolean = boolean> = TxEnvelopeEip2930<
|
|
31
31
|
signed,
|
|
32
32
|
Hex.Hex,
|
|
33
33
|
Hex.Hex,
|
|
@@ -39,19 +39,19 @@ export type Serialized = `${SerializedType}${string}`
|
|
|
39
39
|
export const serializedType = '0x01' as const
|
|
40
40
|
export type SerializedType = typeof serializedType
|
|
41
41
|
|
|
42
|
-
export type Signed =
|
|
42
|
+
export type Signed = TxEnvelopeEip2930<true>
|
|
43
43
|
|
|
44
44
|
export const type = 'eip2930' as const
|
|
45
45
|
export type Type = typeof type
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
|
-
* Asserts a {@link ox#
|
|
48
|
+
* Asserts a {@link ox#TxEnvelopeEip2930.TxEnvelopeEip2930} is valid.
|
|
49
49
|
*
|
|
50
50
|
* @example
|
|
51
51
|
* ```ts twoslash
|
|
52
|
-
* import {
|
|
52
|
+
* import { TxEnvelopeEip2930, Value } from 'ox'
|
|
53
53
|
*
|
|
54
|
-
*
|
|
54
|
+
* TxEnvelopeEip2930.assert({
|
|
55
55
|
* gasPrice: 2n ** 256n - 1n + 1n,
|
|
56
56
|
* chainId: 1,
|
|
57
57
|
* to: '0x0000000000000000000000000000000000000000',
|
|
@@ -64,9 +64,7 @@ export type Type = typeof type
|
|
|
64
64
|
*
|
|
65
65
|
* @param envelope - The transaction envelope to assert.
|
|
66
66
|
*/
|
|
67
|
-
export function assert(
|
|
68
|
-
envelope: PartialBy<TransactionEnvelopeEip2930, 'type'>,
|
|
69
|
-
) {
|
|
67
|
+
export function assert(envelope: PartialBy<TxEnvelopeEip2930, 'type'>) {
|
|
70
68
|
const { chainId, gasPrice, to } = envelope
|
|
71
69
|
if (chainId <= 0)
|
|
72
70
|
throw new TransactionEnvelope.InvalidChainIdError({ chainId })
|
|
@@ -84,13 +82,13 @@ export declare namespace assert {
|
|
|
84
82
|
}
|
|
85
83
|
|
|
86
84
|
/**
|
|
87
|
-
* Deserializes a {@link ox#
|
|
85
|
+
* Deserializes a {@link ox#TxEnvelopeEip2930.TxEnvelopeEip2930} from its serialized form.
|
|
88
86
|
*
|
|
89
87
|
* @example
|
|
90
88
|
* ```ts twoslash
|
|
91
|
-
* import {
|
|
89
|
+
* import { TxEnvelopeEip2930 } from 'ox'
|
|
92
90
|
*
|
|
93
|
-
* const envelope =
|
|
91
|
+
* const envelope = TxEnvelopeEip2930.deserialize('0x01ef0182031184773594008477359400809470997970c51812dc3a010c7d01b50e0d17dc79c8880de0b6b3a764000080c0')
|
|
94
92
|
* // @log: {
|
|
95
93
|
* // @log: type: 'eip2930',
|
|
96
94
|
* // @log: nonce: 785n,
|
|
@@ -104,9 +102,7 @@ export declare namespace assert {
|
|
|
104
102
|
* @param serialized - The serialized transaction.
|
|
105
103
|
* @returns Deserialized Transaction Envelope.
|
|
106
104
|
*/
|
|
107
|
-
export function deserialize(
|
|
108
|
-
serialized: Serialized,
|
|
109
|
-
): TransactionEnvelopeEip2930 {
|
|
105
|
+
export function deserialize(serialized: Serialized): TxEnvelopeEip2930 {
|
|
110
106
|
const transactionArray = Rlp.toHex(Hex.slice(serialized, 1))
|
|
111
107
|
|
|
112
108
|
const [
|
|
@@ -149,7 +145,7 @@ export function deserialize(
|
|
|
149
145
|
let transaction = {
|
|
150
146
|
chainId: Number(chainId as Hex.Hex),
|
|
151
147
|
type,
|
|
152
|
-
} as
|
|
148
|
+
} as TxEnvelopeEip2930
|
|
153
149
|
if (Hex.validate(to) && to !== '0x') transaction.to = to
|
|
154
150
|
if (Hex.validate(gas) && gas !== '0x') transaction.gas = BigInt(gas)
|
|
155
151
|
if (Hex.validate(data) && data !== '0x') transaction.data = data
|
|
@@ -167,7 +163,7 @@ export function deserialize(
|
|
|
167
163
|
transaction = {
|
|
168
164
|
...transaction,
|
|
169
165
|
...signature,
|
|
170
|
-
} as
|
|
166
|
+
} as TxEnvelopeEip2930
|
|
171
167
|
|
|
172
168
|
assert(transaction)
|
|
173
169
|
|
|
@@ -184,9 +180,9 @@ export declare namespace deserialize {
|
|
|
184
180
|
* @example
|
|
185
181
|
* ```ts twoslash
|
|
186
182
|
* // @noErrors
|
|
187
|
-
* import {
|
|
183
|
+
* import { TxEnvelopeEip2930, Value } from 'ox'
|
|
188
184
|
*
|
|
189
|
-
* const envelope =
|
|
185
|
+
* const envelope = TxEnvelopeEip2930.from({
|
|
190
186
|
* chainId: 1,
|
|
191
187
|
* accessList: [...],
|
|
192
188
|
* gasPrice: Value.fromGwei('10'),
|
|
@@ -201,9 +197,9 @@ export declare namespace deserialize {
|
|
|
201
197
|
* It is possible to attach a `signature` to the transaction envelope.
|
|
202
198
|
*
|
|
203
199
|
* ```ts twoslash
|
|
204
|
-
* import { Secp256k1,
|
|
200
|
+
* import { Secp256k1, TxEnvelopeEip2930, Value } from 'ox'
|
|
205
201
|
*
|
|
206
|
-
* const envelope =
|
|
202
|
+
* const envelope = TxEnvelopeEip2930.from({
|
|
207
203
|
* chainId: 1,
|
|
208
204
|
* gasPrice: Value.fromGwei('10'),
|
|
209
205
|
* to: '0x0000000000000000000000000000000000000000',
|
|
@@ -211,11 +207,11 @@ export declare namespace deserialize {
|
|
|
211
207
|
* })
|
|
212
208
|
*
|
|
213
209
|
* const signature = Secp256k1.sign({
|
|
214
|
-
* payload:
|
|
210
|
+
* payload: TxEnvelopeEip2930.getSignPayload(envelope),
|
|
215
211
|
* privateKey: '0x...',
|
|
216
212
|
* })
|
|
217
213
|
*
|
|
218
|
-
* const envelope_signed =
|
|
214
|
+
* const envelope_signed = TxEnvelopeEip2930.from(envelope, { // [!code focus]
|
|
219
215
|
* signature, // [!code focus]
|
|
220
216
|
* }) // [!code focus]
|
|
221
217
|
* // @log: {
|
|
@@ -233,12 +229,12 @@ export declare namespace deserialize {
|
|
|
233
229
|
* @example
|
|
234
230
|
* ### From Serialized
|
|
235
231
|
*
|
|
236
|
-
* It is possible to instantiate an EIP-2930 Transaction Envelope from a {@link ox#
|
|
232
|
+
* It is possible to instantiate an EIP-2930 Transaction Envelope from a {@link ox#TxEnvelopeEip2930.Serialized} value.
|
|
237
233
|
*
|
|
238
234
|
* ```ts twoslash
|
|
239
|
-
* import {
|
|
235
|
+
* import { TxEnvelopeEip2930 } from 'ox'
|
|
240
236
|
*
|
|
241
|
-
* const envelope =
|
|
237
|
+
* const envelope = TxEnvelopeEip2930.from('0x01f858018203118502540be4008504a817c800809470997970c51812dc3a010c7d01b50e0d17dc79c8880de0b6b3a764000080c08477359400e1a001627c687261b0e7f8638af1112efa8a77e23656f6e7945275b19e9deed80261')
|
|
242
238
|
* // @log: {
|
|
243
239
|
* // @log: chainId: 1,
|
|
244
240
|
* // @log: gasPrice: 10000000000n,
|
|
@@ -250,25 +246,20 @@ export declare namespace deserialize {
|
|
|
250
246
|
*
|
|
251
247
|
* @param envelope - The transaction object to convert.
|
|
252
248
|
* @param options - Options.
|
|
253
|
-
* @returns A {@link ox#
|
|
249
|
+
* @returns A {@link ox#TxEnvelopeEip2930.TxEnvelopeEip2930}
|
|
254
250
|
*/
|
|
255
251
|
export function from<
|
|
256
|
-
const envelope extends
|
|
257
|
-
| UnionPartialBy<TransactionEnvelopeEip2930, 'type'>
|
|
258
|
-
| Serialized,
|
|
252
|
+
const envelope extends UnionPartialBy<TxEnvelopeEip2930, 'type'> | Serialized,
|
|
259
253
|
const signature extends Signature.Signature | undefined = undefined,
|
|
260
254
|
>(
|
|
261
|
-
envelope:
|
|
262
|
-
| envelope
|
|
263
|
-
| UnionPartialBy<TransactionEnvelopeEip2930, 'type'>
|
|
264
|
-
| Serialized,
|
|
255
|
+
envelope: envelope | UnionPartialBy<TxEnvelopeEip2930, 'type'> | Serialized,
|
|
265
256
|
options: from.Options<signature> = {},
|
|
266
257
|
): from.ReturnType<envelope, signature> {
|
|
267
258
|
const { signature } = options
|
|
268
259
|
|
|
269
260
|
const envelope_ = (
|
|
270
261
|
typeof envelope === 'string' ? deserialize(envelope) : envelope
|
|
271
|
-
) as
|
|
262
|
+
) as TxEnvelopeEip2930
|
|
272
263
|
|
|
273
264
|
assert(envelope_)
|
|
274
265
|
|
|
@@ -286,13 +277,13 @@ export declare namespace from {
|
|
|
286
277
|
}
|
|
287
278
|
|
|
288
279
|
type ReturnType<
|
|
289
|
-
envelope extends
|
|
290
|
-
|
|
|
291
|
-
| Hex.Hex
|
|
280
|
+
envelope extends UnionPartialBy<TxEnvelopeEip2930, 'type'> | Hex.Hex =
|
|
281
|
+
| TxEnvelopeEip2930
|
|
282
|
+
| Hex.Hex,
|
|
292
283
|
signature extends Signature.Signature | undefined = undefined,
|
|
293
284
|
> = Compute<
|
|
294
285
|
envelope extends Hex.Hex
|
|
295
|
-
?
|
|
286
|
+
? TxEnvelopeEip2930
|
|
296
287
|
: Assign<
|
|
297
288
|
envelope,
|
|
298
289
|
(signature extends Signature.Signature ? Readonly<signature> : {}) & {
|
|
@@ -308,16 +299,16 @@ export declare namespace from {
|
|
|
308
299
|
}
|
|
309
300
|
|
|
310
301
|
/**
|
|
311
|
-
* Returns the payload to sign for a {@link ox#
|
|
302
|
+
* Returns the payload to sign for a {@link ox#TxEnvelopeEip2930.TxEnvelopeEip2930}.
|
|
312
303
|
*
|
|
313
304
|
* @example
|
|
314
305
|
* The example below demonstrates how to compute the sign payload which can be used
|
|
315
306
|
* with ECDSA signing utilities like {@link ox#Secp256k1.(sign:function)}.
|
|
316
307
|
*
|
|
317
308
|
* ```ts twoslash
|
|
318
|
-
* import { Secp256k1,
|
|
309
|
+
* import { Secp256k1, TxEnvelopeEip2930 } from 'ox'
|
|
319
310
|
*
|
|
320
|
-
* const envelope =
|
|
311
|
+
* const envelope = TxEnvelopeEip2930.from({
|
|
321
312
|
* chainId: 1,
|
|
322
313
|
* nonce: 0n,
|
|
323
314
|
* gasPrice: 1000000000n,
|
|
@@ -326,7 +317,7 @@ export declare namespace from {
|
|
|
326
317
|
* value: 1000000000000000000n,
|
|
327
318
|
* })
|
|
328
319
|
*
|
|
329
|
-
* const payload =
|
|
320
|
+
* const payload = TxEnvelopeEip2930.getSignPayload(envelope) // [!code focus]
|
|
330
321
|
* // @log: '0x...'
|
|
331
322
|
*
|
|
332
323
|
* const signature = Secp256k1.sign({ payload, privateKey: '0x...' })
|
|
@@ -336,7 +327,7 @@ export declare namespace from {
|
|
|
336
327
|
* @returns The sign payload.
|
|
337
328
|
*/
|
|
338
329
|
export function getSignPayload(
|
|
339
|
-
envelope:
|
|
330
|
+
envelope: TxEnvelopeEip2930,
|
|
340
331
|
): getSignPayload.ReturnType {
|
|
341
332
|
return hash(envelope, { presign: true })
|
|
342
333
|
}
|
|
@@ -348,13 +339,13 @@ export declare namespace getSignPayload {
|
|
|
348
339
|
}
|
|
349
340
|
|
|
350
341
|
/**
|
|
351
|
-
* Hashes a {@link ox#
|
|
342
|
+
* Hashes a {@link ox#TxEnvelopeEip2930.TxEnvelopeEip2930}. This is the "transaction hash".
|
|
352
343
|
*
|
|
353
344
|
* @example
|
|
354
345
|
* ```ts twoslash
|
|
355
|
-
* import { Secp256k1,
|
|
346
|
+
* import { Secp256k1, TxEnvelopeEip2930 } from 'ox'
|
|
356
347
|
*
|
|
357
|
-
* const envelope =
|
|
348
|
+
* const envelope = TxEnvelopeEip2930.from({
|
|
358
349
|
* chainId: 1,
|
|
359
350
|
* nonce: 0n,
|
|
360
351
|
* gasPrice: 1000000000n,
|
|
@@ -364,15 +355,15 @@ export declare namespace getSignPayload {
|
|
|
364
355
|
* })
|
|
365
356
|
*
|
|
366
357
|
* const signature = Secp256k1.sign({
|
|
367
|
-
* payload:
|
|
358
|
+
* payload: TxEnvelopeEip2930.getSignPayload(envelope),
|
|
368
359
|
* privateKey: '0x...',
|
|
369
360
|
* })
|
|
370
361
|
*
|
|
371
|
-
* const envelope_signed =
|
|
362
|
+
* const envelope_signed = TxEnvelopeEip2930.from(envelope, {
|
|
372
363
|
* signature,
|
|
373
364
|
* })
|
|
374
365
|
*
|
|
375
|
-
* const hash =
|
|
366
|
+
* const hash = TxEnvelopeEip2930.hash(envelope_signed) // [!code focus]
|
|
376
367
|
* ```
|
|
377
368
|
*
|
|
378
369
|
* @param envelope - The EIP-2930 Transaction Envelope to hash.
|
|
@@ -380,7 +371,7 @@ export declare namespace getSignPayload {
|
|
|
380
371
|
* @returns The hash of the transaction envelope.
|
|
381
372
|
*/
|
|
382
373
|
export function hash<presign extends boolean = false>(
|
|
383
|
-
envelope:
|
|
374
|
+
envelope: TxEnvelopeEip2930<presign extends true ? false : true>,
|
|
384
375
|
options: hash.Options<presign> = {},
|
|
385
376
|
): hash.ReturnType {
|
|
386
377
|
const { presign } = options
|
|
@@ -414,20 +405,20 @@ export declare namespace hash {
|
|
|
414
405
|
}
|
|
415
406
|
|
|
416
407
|
/**
|
|
417
|
-
* Serializes a {@link ox#
|
|
408
|
+
* Serializes a {@link ox#TxEnvelopeEip2930.TxEnvelopeEip2930}.
|
|
418
409
|
*
|
|
419
410
|
* @example
|
|
420
411
|
* ```ts twoslash
|
|
421
|
-
* import {
|
|
412
|
+
* import { TxEnvelopeEip2930, Value } from 'ox'
|
|
422
413
|
*
|
|
423
|
-
* const envelope =
|
|
414
|
+
* const envelope = TxEnvelopeEip2930.from({
|
|
424
415
|
* chainId: 1,
|
|
425
416
|
* gasPrice: Value.fromGwei('10'),
|
|
426
417
|
* to: '0x0000000000000000000000000000000000000000',
|
|
427
418
|
* value: Value.fromEther('1'),
|
|
428
419
|
* })
|
|
429
420
|
*
|
|
430
|
-
* const serialized =
|
|
421
|
+
* const serialized = TxEnvelopeEip2930.serialize(envelope) // [!code focus]
|
|
431
422
|
* ```
|
|
432
423
|
*
|
|
433
424
|
* @example
|
|
@@ -436,9 +427,9 @@ export declare namespace hash {
|
|
|
436
427
|
* It is possible to attach a `signature` to the serialized Transaction Envelope.
|
|
437
428
|
*
|
|
438
429
|
* ```ts twoslash
|
|
439
|
-
* import { Secp256k1,
|
|
430
|
+
* import { Secp256k1, TxEnvelopeEip2930, Value } from 'ox'
|
|
440
431
|
*
|
|
441
|
-
* const envelope =
|
|
432
|
+
* const envelope = TxEnvelopeEip2930.from({
|
|
442
433
|
* chainId: 1,
|
|
443
434
|
* gasPrice: Value.fromGwei('10'),
|
|
444
435
|
* to: '0x0000000000000000000000000000000000000000',
|
|
@@ -446,11 +437,11 @@ export declare namespace hash {
|
|
|
446
437
|
* })
|
|
447
438
|
*
|
|
448
439
|
* const signature = Secp256k1.sign({
|
|
449
|
-
* payload:
|
|
440
|
+
* payload: TxEnvelopeEip2930.getSignPayload(envelope),
|
|
450
441
|
* privateKey: '0x...',
|
|
451
442
|
* })
|
|
452
443
|
*
|
|
453
|
-
* const serialized =
|
|
444
|
+
* const serialized = TxEnvelopeEip2930.serialize(envelope, { // [!code focus]
|
|
454
445
|
* signature, // [!code focus]
|
|
455
446
|
* }) // [!code focus]
|
|
456
447
|
*
|
|
@@ -462,7 +453,7 @@ export declare namespace hash {
|
|
|
462
453
|
* @returns The serialized Transaction Envelope.
|
|
463
454
|
*/
|
|
464
455
|
export function serialize(
|
|
465
|
-
envelope: PartialBy<
|
|
456
|
+
envelope: PartialBy<TxEnvelopeEip2930, 'type'>,
|
|
466
457
|
options: serialize.Options = {},
|
|
467
458
|
): Serialized {
|
|
468
459
|
const { chainId, gas, data, input, nonce, to, value, accessList, gasPrice } =
|
|
@@ -505,13 +496,13 @@ export declare namespace serialize {
|
|
|
505
496
|
}
|
|
506
497
|
|
|
507
498
|
/**
|
|
508
|
-
* Converts an {@link ox#
|
|
499
|
+
* Converts an {@link ox#TxEnvelopeEip2930.TxEnvelopeEip2930} to an {@link ox#TxEnvelopeEip2930.Rpc}.
|
|
509
500
|
*
|
|
510
501
|
* @example
|
|
511
502
|
* ```ts twoslash
|
|
512
|
-
* import { RpcRequest,
|
|
503
|
+
* import { RpcRequest, TxEnvelopeEip2930, Value } from 'ox'
|
|
513
504
|
*
|
|
514
|
-
* const envelope =
|
|
505
|
+
* const envelope = TxEnvelopeEip2930.from({
|
|
515
506
|
* chainId: 1,
|
|
516
507
|
* nonce: 0n,
|
|
517
508
|
* gas: 21000n,
|
|
@@ -520,7 +511,7 @@ export declare namespace serialize {
|
|
|
520
511
|
* value: Value.fromEther('1'),
|
|
521
512
|
* })
|
|
522
513
|
*
|
|
523
|
-
* const envelope_rpc =
|
|
514
|
+
* const envelope_rpc = TxEnvelopeEip2930.toRpc(envelope) // [!code focus]
|
|
524
515
|
*
|
|
525
516
|
* const request = RpcRequest.from({
|
|
526
517
|
* id: 0,
|
|
@@ -532,7 +523,7 @@ export declare namespace serialize {
|
|
|
532
523
|
* @param envelope - The EIP-2930 transaction envelope to convert.
|
|
533
524
|
* @returns An RPC-formatted EIP-2930 transaction envelope.
|
|
534
525
|
*/
|
|
535
|
-
export function toRpc(envelope: Omit<
|
|
526
|
+
export function toRpc(envelope: Omit<TxEnvelopeEip2930, 'type'>): Rpc {
|
|
536
527
|
const signature = Signature.extract(envelope)!
|
|
537
528
|
|
|
538
529
|
return {
|
|
@@ -561,13 +552,13 @@ export declare namespace toRpc {
|
|
|
561
552
|
}
|
|
562
553
|
|
|
563
554
|
/**
|
|
564
|
-
* Validates a {@link ox#
|
|
555
|
+
* Validates a {@link ox#TxEnvelopeEip2930.TxEnvelopeEip2930}. Returns `true` if the envelope is valid, `false` otherwise.
|
|
565
556
|
*
|
|
566
557
|
* @example
|
|
567
558
|
* ```ts twoslash
|
|
568
|
-
* import {
|
|
559
|
+
* import { TxEnvelopeEip2930, Value } from 'ox'
|
|
569
560
|
*
|
|
570
|
-
* const valid =
|
|
561
|
+
* const valid = TxEnvelopeEip2930.assert({
|
|
571
562
|
* gasPrice: 2n ** 256n - 1n + 1n,
|
|
572
563
|
* chainId: 1,
|
|
573
564
|
* to: '0x0000000000000000000000000000000000000000',
|
|
@@ -578,9 +569,7 @@ export declare namespace toRpc {
|
|
|
578
569
|
*
|
|
579
570
|
* @param envelope - The transaction envelope to validate.
|
|
580
571
|
*/
|
|
581
|
-
export function validate(
|
|
582
|
-
envelope: PartialBy<TransactionEnvelopeEip2930, 'type'>,
|
|
583
|
-
) {
|
|
572
|
+
export function validate(envelope: PartialBy<TxEnvelopeEip2930, 'type'>) {
|
|
584
573
|
try {
|
|
585
574
|
assert(envelope)
|
|
586
575
|
return true
|