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
|
@@ -6,28 +6,28 @@ import * as Hex from './Hex.js';
|
|
|
6
6
|
import type { Assign, Compute, PartialBy, UnionPartialBy } from './internal/types.js';
|
|
7
7
|
import * as Rlp from './Rlp.js';
|
|
8
8
|
import * as Signature from './Signature.js';
|
|
9
|
-
import * as TransactionEnvelope from './
|
|
10
|
-
export type
|
|
9
|
+
import * as TransactionEnvelope from './TxEnvelope.js';
|
|
10
|
+
export type TxEnvelopeEip2930<signed extends boolean = boolean, bigintType = bigint, numberType = number, type extends string = Type> = Compute<TransactionEnvelope.Base<type, signed, bigintType, numberType> & {
|
|
11
11
|
/** EIP-2930 Access List. */
|
|
12
12
|
accessList?: AccessList.AccessList | undefined;
|
|
13
13
|
/** Base fee per gas. */
|
|
14
14
|
gasPrice?: bigintType | undefined;
|
|
15
15
|
}>;
|
|
16
|
-
export type Rpc<signed extends boolean = boolean> =
|
|
16
|
+
export type Rpc<signed extends boolean = boolean> = TxEnvelopeEip2930<signed, Hex.Hex, Hex.Hex, '0x1'>;
|
|
17
17
|
export type Serialized = `${SerializedType}${string}`;
|
|
18
18
|
export declare const serializedType: "0x01";
|
|
19
19
|
export type SerializedType = typeof serializedType;
|
|
20
|
-
export type Signed =
|
|
20
|
+
export type Signed = TxEnvelopeEip2930<true>;
|
|
21
21
|
export declare const type: "eip2930";
|
|
22
22
|
export type Type = typeof type;
|
|
23
23
|
/**
|
|
24
|
-
* Asserts a {@link ox#
|
|
24
|
+
* Asserts a {@link ox#TxEnvelopeEip2930.TxEnvelopeEip2930} is valid.
|
|
25
25
|
*
|
|
26
26
|
* @example
|
|
27
27
|
* ```ts twoslash
|
|
28
|
-
* import {
|
|
28
|
+
* import { TxEnvelopeEip2930, Value } from 'ox'
|
|
29
29
|
*
|
|
30
|
-
*
|
|
30
|
+
* TxEnvelopeEip2930.assert({
|
|
31
31
|
* gasPrice: 2n ** 256n - 1n + 1n,
|
|
32
32
|
* chainId: 1,
|
|
33
33
|
* to: '0x0000000000000000000000000000000000000000',
|
|
@@ -40,18 +40,18 @@ export type Type = typeof type;
|
|
|
40
40
|
*
|
|
41
41
|
* @param envelope - The transaction envelope to assert.
|
|
42
42
|
*/
|
|
43
|
-
export declare function assert(envelope: PartialBy<
|
|
43
|
+
export declare function assert(envelope: PartialBy<TxEnvelopeEip2930, 'type'>): void;
|
|
44
44
|
export declare namespace assert {
|
|
45
45
|
type ErrorType = Address.assert.ErrorType | TransactionEnvelope.InvalidChainIdError | TransactionEnvelope.GasPriceTooHighError | Errors.GlobalErrorType;
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
|
-
* Deserializes a {@link ox#
|
|
48
|
+
* Deserializes a {@link ox#TxEnvelopeEip2930.TxEnvelopeEip2930} from its serialized form.
|
|
49
49
|
*
|
|
50
50
|
* @example
|
|
51
51
|
* ```ts twoslash
|
|
52
|
-
* import {
|
|
52
|
+
* import { TxEnvelopeEip2930 } from 'ox'
|
|
53
53
|
*
|
|
54
|
-
* const envelope =
|
|
54
|
+
* const envelope = TxEnvelopeEip2930.deserialize('0x01ef0182031184773594008477359400809470997970c51812dc3a010c7d01b50e0d17dc79c8880de0b6b3a764000080c0')
|
|
55
55
|
* // @log: {
|
|
56
56
|
* // @log: type: 'eip2930',
|
|
57
57
|
* // @log: nonce: 785n,
|
|
@@ -65,7 +65,7 @@ export declare namespace assert {
|
|
|
65
65
|
* @param serialized - The serialized transaction.
|
|
66
66
|
* @returns Deserialized Transaction Envelope.
|
|
67
67
|
*/
|
|
68
|
-
export declare function deserialize(serialized: Serialized):
|
|
68
|
+
export declare function deserialize(serialized: Serialized): TxEnvelopeEip2930;
|
|
69
69
|
export declare namespace deserialize {
|
|
70
70
|
type ErrorType = Errors.GlobalErrorType;
|
|
71
71
|
}
|
|
@@ -75,9 +75,9 @@ export declare namespace deserialize {
|
|
|
75
75
|
* @example
|
|
76
76
|
* ```ts twoslash
|
|
77
77
|
* // @noErrors
|
|
78
|
-
* import {
|
|
78
|
+
* import { TxEnvelopeEip2930, Value } from 'ox'
|
|
79
79
|
*
|
|
80
|
-
* const envelope =
|
|
80
|
+
* const envelope = TxEnvelopeEip2930.from({
|
|
81
81
|
* chainId: 1,
|
|
82
82
|
* accessList: [...],
|
|
83
83
|
* gasPrice: Value.fromGwei('10'),
|
|
@@ -92,9 +92,9 @@ export declare namespace deserialize {
|
|
|
92
92
|
* It is possible to attach a `signature` to the transaction envelope.
|
|
93
93
|
*
|
|
94
94
|
* ```ts twoslash
|
|
95
|
-
* import { Secp256k1,
|
|
95
|
+
* import { Secp256k1, TxEnvelopeEip2930, Value } from 'ox'
|
|
96
96
|
*
|
|
97
|
-
* const envelope =
|
|
97
|
+
* const envelope = TxEnvelopeEip2930.from({
|
|
98
98
|
* chainId: 1,
|
|
99
99
|
* gasPrice: Value.fromGwei('10'),
|
|
100
100
|
* to: '0x0000000000000000000000000000000000000000',
|
|
@@ -102,11 +102,11 @@ export declare namespace deserialize {
|
|
|
102
102
|
* })
|
|
103
103
|
*
|
|
104
104
|
* const signature = Secp256k1.sign({
|
|
105
|
-
* payload:
|
|
105
|
+
* payload: TxEnvelopeEip2930.getSignPayload(envelope),
|
|
106
106
|
* privateKey: '0x...',
|
|
107
107
|
* })
|
|
108
108
|
*
|
|
109
|
-
* const envelope_signed =
|
|
109
|
+
* const envelope_signed = TxEnvelopeEip2930.from(envelope, { // [!code focus]
|
|
110
110
|
* signature, // [!code focus]
|
|
111
111
|
* }) // [!code focus]
|
|
112
112
|
* // @log: {
|
|
@@ -124,12 +124,12 @@ export declare namespace deserialize {
|
|
|
124
124
|
* @example
|
|
125
125
|
* ### From Serialized
|
|
126
126
|
*
|
|
127
|
-
* It is possible to instantiate an EIP-2930 Transaction Envelope from a {@link ox#
|
|
127
|
+
* It is possible to instantiate an EIP-2930 Transaction Envelope from a {@link ox#TxEnvelopeEip2930.Serialized} value.
|
|
128
128
|
*
|
|
129
129
|
* ```ts twoslash
|
|
130
|
-
* import {
|
|
130
|
+
* import { TxEnvelopeEip2930 } from 'ox'
|
|
131
131
|
*
|
|
132
|
-
* const envelope =
|
|
132
|
+
* const envelope = TxEnvelopeEip2930.from('0x01f858018203118502540be4008504a817c800809470997970c51812dc3a010c7d01b50e0d17dc79c8880de0b6b3a764000080c08477359400e1a001627c687261b0e7f8638af1112efa8a77e23656f6e7945275b19e9deed80261')
|
|
133
133
|
* // @log: {
|
|
134
134
|
* // @log: chainId: 1,
|
|
135
135
|
* // @log: gasPrice: 10000000000n,
|
|
@@ -141,29 +141,29 @@ export declare namespace deserialize {
|
|
|
141
141
|
*
|
|
142
142
|
* @param envelope - The transaction object to convert.
|
|
143
143
|
* @param options - Options.
|
|
144
|
-
* @returns A {@link ox#
|
|
144
|
+
* @returns A {@link ox#TxEnvelopeEip2930.TxEnvelopeEip2930}
|
|
145
145
|
*/
|
|
146
|
-
export declare function from<const envelope extends UnionPartialBy<
|
|
146
|
+
export declare function from<const envelope extends UnionPartialBy<TxEnvelopeEip2930, 'type'> | Serialized, const signature extends Signature.Signature | undefined = undefined>(envelope: envelope | UnionPartialBy<TxEnvelopeEip2930, 'type'> | Serialized, options?: from.Options<signature>): from.ReturnType<envelope, signature>;
|
|
147
147
|
export declare namespace from {
|
|
148
148
|
type Options<signature extends Signature.Signature | undefined = undefined> = {
|
|
149
149
|
signature?: signature | Signature.Signature | undefined;
|
|
150
150
|
};
|
|
151
|
-
type ReturnType<envelope extends UnionPartialBy<
|
|
151
|
+
type ReturnType<envelope extends UnionPartialBy<TxEnvelopeEip2930, 'type'> | Hex.Hex = TxEnvelopeEip2930 | Hex.Hex, signature extends Signature.Signature | undefined = undefined> = Compute<envelope extends Hex.Hex ? TxEnvelopeEip2930 : Assign<envelope, (signature extends Signature.Signature ? Readonly<signature> : {}) & {
|
|
152
152
|
readonly type: 'eip2930';
|
|
153
153
|
}>>;
|
|
154
154
|
type ErrorType = deserialize.ErrorType | assert.ErrorType | Errors.GlobalErrorType;
|
|
155
155
|
}
|
|
156
156
|
/**
|
|
157
|
-
* Returns the payload to sign for a {@link ox#
|
|
157
|
+
* Returns the payload to sign for a {@link ox#TxEnvelopeEip2930.TxEnvelopeEip2930}.
|
|
158
158
|
*
|
|
159
159
|
* @example
|
|
160
160
|
* The example below demonstrates how to compute the sign payload which can be used
|
|
161
161
|
* with ECDSA signing utilities like {@link ox#Secp256k1.(sign:function)}.
|
|
162
162
|
*
|
|
163
163
|
* ```ts twoslash
|
|
164
|
-
* import { Secp256k1,
|
|
164
|
+
* import { Secp256k1, TxEnvelopeEip2930 } from 'ox'
|
|
165
165
|
*
|
|
166
|
-
* const envelope =
|
|
166
|
+
* const envelope = TxEnvelopeEip2930.from({
|
|
167
167
|
* chainId: 1,
|
|
168
168
|
* nonce: 0n,
|
|
169
169
|
* gasPrice: 1000000000n,
|
|
@@ -172,7 +172,7 @@ export declare namespace from {
|
|
|
172
172
|
* value: 1000000000000000000n,
|
|
173
173
|
* })
|
|
174
174
|
*
|
|
175
|
-
* const payload =
|
|
175
|
+
* const payload = TxEnvelopeEip2930.getSignPayload(envelope) // [!code focus]
|
|
176
176
|
* // @log: '0x...'
|
|
177
177
|
*
|
|
178
178
|
* const signature = Secp256k1.sign({ payload, privateKey: '0x...' })
|
|
@@ -181,19 +181,19 @@ export declare namespace from {
|
|
|
181
181
|
* @param envelope - The transaction envelope to get the sign payload for.
|
|
182
182
|
* @returns The sign payload.
|
|
183
183
|
*/
|
|
184
|
-
export declare function getSignPayload(envelope:
|
|
184
|
+
export declare function getSignPayload(envelope: TxEnvelopeEip2930): getSignPayload.ReturnType;
|
|
185
185
|
export declare namespace getSignPayload {
|
|
186
186
|
type ReturnType = Hex.Hex;
|
|
187
187
|
type ErrorType = hash.ErrorType | Errors.GlobalErrorType;
|
|
188
188
|
}
|
|
189
189
|
/**
|
|
190
|
-
* Hashes a {@link ox#
|
|
190
|
+
* Hashes a {@link ox#TxEnvelopeEip2930.TxEnvelopeEip2930}. This is the "transaction hash".
|
|
191
191
|
*
|
|
192
192
|
* @example
|
|
193
193
|
* ```ts twoslash
|
|
194
|
-
* import { Secp256k1,
|
|
194
|
+
* import { Secp256k1, TxEnvelopeEip2930 } from 'ox'
|
|
195
195
|
*
|
|
196
|
-
* const envelope =
|
|
196
|
+
* const envelope = TxEnvelopeEip2930.from({
|
|
197
197
|
* chainId: 1,
|
|
198
198
|
* nonce: 0n,
|
|
199
199
|
* gasPrice: 1000000000n,
|
|
@@ -203,22 +203,22 @@ export declare namespace getSignPayload {
|
|
|
203
203
|
* })
|
|
204
204
|
*
|
|
205
205
|
* const signature = Secp256k1.sign({
|
|
206
|
-
* payload:
|
|
206
|
+
* payload: TxEnvelopeEip2930.getSignPayload(envelope),
|
|
207
207
|
* privateKey: '0x...',
|
|
208
208
|
* })
|
|
209
209
|
*
|
|
210
|
-
* const envelope_signed =
|
|
210
|
+
* const envelope_signed = TxEnvelopeEip2930.from(envelope, {
|
|
211
211
|
* signature,
|
|
212
212
|
* })
|
|
213
213
|
*
|
|
214
|
-
* const hash =
|
|
214
|
+
* const hash = TxEnvelopeEip2930.hash(envelope_signed) // [!code focus]
|
|
215
215
|
* ```
|
|
216
216
|
*
|
|
217
217
|
* @param envelope - The EIP-2930 Transaction Envelope to hash.
|
|
218
218
|
* @param options - Options.
|
|
219
219
|
* @returns The hash of the transaction envelope.
|
|
220
220
|
*/
|
|
221
|
-
export declare function hash<presign extends boolean = false>(envelope:
|
|
221
|
+
export declare function hash<presign extends boolean = false>(envelope: TxEnvelopeEip2930<presign extends true ? false : true>, options?: hash.Options<presign>): hash.ReturnType;
|
|
222
222
|
export declare namespace hash {
|
|
223
223
|
type Options<presign extends boolean = false> = {
|
|
224
224
|
/** Whether to hash this transaction for signing. @default false */
|
|
@@ -228,20 +228,20 @@ export declare namespace hash {
|
|
|
228
228
|
type ErrorType = Hash.keccak256.ErrorType | serialize.ErrorType | Errors.GlobalErrorType;
|
|
229
229
|
}
|
|
230
230
|
/**
|
|
231
|
-
* Serializes a {@link ox#
|
|
231
|
+
* Serializes a {@link ox#TxEnvelopeEip2930.TxEnvelopeEip2930}.
|
|
232
232
|
*
|
|
233
233
|
* @example
|
|
234
234
|
* ```ts twoslash
|
|
235
|
-
* import {
|
|
235
|
+
* import { TxEnvelopeEip2930, Value } from 'ox'
|
|
236
236
|
*
|
|
237
|
-
* const envelope =
|
|
237
|
+
* const envelope = TxEnvelopeEip2930.from({
|
|
238
238
|
* chainId: 1,
|
|
239
239
|
* gasPrice: Value.fromGwei('10'),
|
|
240
240
|
* to: '0x0000000000000000000000000000000000000000',
|
|
241
241
|
* value: Value.fromEther('1'),
|
|
242
242
|
* })
|
|
243
243
|
*
|
|
244
|
-
* const serialized =
|
|
244
|
+
* const serialized = TxEnvelopeEip2930.serialize(envelope) // [!code focus]
|
|
245
245
|
* ```
|
|
246
246
|
*
|
|
247
247
|
* @example
|
|
@@ -250,9 +250,9 @@ export declare namespace hash {
|
|
|
250
250
|
* It is possible to attach a `signature` to the serialized Transaction Envelope.
|
|
251
251
|
*
|
|
252
252
|
* ```ts twoslash
|
|
253
|
-
* import { Secp256k1,
|
|
253
|
+
* import { Secp256k1, TxEnvelopeEip2930, Value } from 'ox'
|
|
254
254
|
*
|
|
255
|
-
* const envelope =
|
|
255
|
+
* const envelope = TxEnvelopeEip2930.from({
|
|
256
256
|
* chainId: 1,
|
|
257
257
|
* gasPrice: Value.fromGwei('10'),
|
|
258
258
|
* to: '0x0000000000000000000000000000000000000000',
|
|
@@ -260,11 +260,11 @@ export declare namespace hash {
|
|
|
260
260
|
* })
|
|
261
261
|
*
|
|
262
262
|
* const signature = Secp256k1.sign({
|
|
263
|
-
* payload:
|
|
263
|
+
* payload: TxEnvelopeEip2930.getSignPayload(envelope),
|
|
264
264
|
* privateKey: '0x...',
|
|
265
265
|
* })
|
|
266
266
|
*
|
|
267
|
-
* const serialized =
|
|
267
|
+
* const serialized = TxEnvelopeEip2930.serialize(envelope, { // [!code focus]
|
|
268
268
|
* signature, // [!code focus]
|
|
269
269
|
* }) // [!code focus]
|
|
270
270
|
*
|
|
@@ -275,7 +275,7 @@ export declare namespace hash {
|
|
|
275
275
|
* @param options - Options.
|
|
276
276
|
* @returns The serialized Transaction Envelope.
|
|
277
277
|
*/
|
|
278
|
-
export declare function serialize(envelope: PartialBy<
|
|
278
|
+
export declare function serialize(envelope: PartialBy<TxEnvelopeEip2930, 'type'>, options?: serialize.Options): Serialized;
|
|
279
279
|
export declare namespace serialize {
|
|
280
280
|
type Options = {
|
|
281
281
|
/** Signature to append to the serialized Transaction Envelope. */
|
|
@@ -284,13 +284,13 @@ export declare namespace serialize {
|
|
|
284
284
|
type ErrorType = assert.ErrorType | Hex.fromNumber.ErrorType | Signature.toTuple.ErrorType | Hex.concat.ErrorType | Rlp.fromHex.ErrorType | Errors.GlobalErrorType;
|
|
285
285
|
}
|
|
286
286
|
/**
|
|
287
|
-
* Converts an {@link ox#
|
|
287
|
+
* Converts an {@link ox#TxEnvelopeEip2930.TxEnvelopeEip2930} to an {@link ox#TxEnvelopeEip2930.Rpc}.
|
|
288
288
|
*
|
|
289
289
|
* @example
|
|
290
290
|
* ```ts twoslash
|
|
291
|
-
* import { RpcRequest,
|
|
291
|
+
* import { RpcRequest, TxEnvelopeEip2930, Value } from 'ox'
|
|
292
292
|
*
|
|
293
|
-
* const envelope =
|
|
293
|
+
* const envelope = TxEnvelopeEip2930.from({
|
|
294
294
|
* chainId: 1,
|
|
295
295
|
* nonce: 0n,
|
|
296
296
|
* gas: 21000n,
|
|
@@ -299,7 +299,7 @@ export declare namespace serialize {
|
|
|
299
299
|
* value: Value.fromEther('1'),
|
|
300
300
|
* })
|
|
301
301
|
*
|
|
302
|
-
* const envelope_rpc =
|
|
302
|
+
* const envelope_rpc = TxEnvelopeEip2930.toRpc(envelope) // [!code focus]
|
|
303
303
|
*
|
|
304
304
|
* const request = RpcRequest.from({
|
|
305
305
|
* id: 0,
|
|
@@ -311,18 +311,18 @@ export declare namespace serialize {
|
|
|
311
311
|
* @param envelope - The EIP-2930 transaction envelope to convert.
|
|
312
312
|
* @returns An RPC-formatted EIP-2930 transaction envelope.
|
|
313
313
|
*/
|
|
314
|
-
export declare function toRpc(envelope: Omit<
|
|
314
|
+
export declare function toRpc(envelope: Omit<TxEnvelopeEip2930, 'type'>): Rpc;
|
|
315
315
|
export declare namespace toRpc {
|
|
316
316
|
type ErrorType = Signature.extract.ErrorType | Errors.GlobalErrorType;
|
|
317
317
|
}
|
|
318
318
|
/**
|
|
319
|
-
* Validates a {@link ox#
|
|
319
|
+
* Validates a {@link ox#TxEnvelopeEip2930.TxEnvelopeEip2930}. Returns `true` if the envelope is valid, `false` otherwise.
|
|
320
320
|
*
|
|
321
321
|
* @example
|
|
322
322
|
* ```ts twoslash
|
|
323
|
-
* import {
|
|
323
|
+
* import { TxEnvelopeEip2930, Value } from 'ox'
|
|
324
324
|
*
|
|
325
|
-
* const valid =
|
|
325
|
+
* const valid = TxEnvelopeEip2930.assert({
|
|
326
326
|
* gasPrice: 2n ** 256n - 1n + 1n,
|
|
327
327
|
* chainId: 1,
|
|
328
328
|
* to: '0x0000000000000000000000000000000000000000',
|
|
@@ -333,8 +333,8 @@ export declare namespace toRpc {
|
|
|
333
333
|
*
|
|
334
334
|
* @param envelope - The transaction envelope to validate.
|
|
335
335
|
*/
|
|
336
|
-
export declare function validate(envelope: PartialBy<
|
|
336
|
+
export declare function validate(envelope: PartialBy<TxEnvelopeEip2930, 'type'>): boolean;
|
|
337
337
|
export declare namespace validate {
|
|
338
338
|
type ErrorType = Errors.GlobalErrorType;
|
|
339
339
|
}
|
|
340
|
-
//# sourceMappingURL=
|
|
340
|
+
//# sourceMappingURL=TxEnvelopeEip2930.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TxEnvelopeEip2930.d.ts","sourceRoot":"","sources":["../../core/TxEnvelopeEip2930.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;A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