ox 0.14.45 → 0.14.46
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 +6 -0
- package/Frame/package.json +6 -0
- package/FrameReceipt/package.json +6 -0
- package/FrameSignature/package.json +6 -0
- package/TxEnvelopeEip8141/package.json +6 -0
- package/_cjs/core/Frame.js +147 -0
- package/_cjs/core/Frame.js.map +1 -0
- package/_cjs/core/FrameReceipt.js +34 -0
- package/_cjs/core/FrameReceipt.js.map +1 -0
- package/_cjs/core/FrameSignature.js +203 -0
- package/_cjs/core/FrameSignature.js.map +1 -0
- package/_cjs/core/Transaction.js +18 -2
- package/_cjs/core/Transaction.js.map +1 -1
- package/_cjs/core/TransactionReceipt.js +10 -0
- package/_cjs/core/TransactionReceipt.js.map +1 -1
- package/_cjs/core/TransactionRequest.js +11 -1
- package/_cjs/core/TransactionRequest.js.map +1 -1
- package/_cjs/core/TxEnvelopeEip8141.js +283 -0
- package/_cjs/core/TxEnvelopeEip8141.js.map +1 -0
- package/_cjs/core/internal/curves.js +6 -0
- package/_cjs/core/internal/curves.js.map +1 -0
- package/_cjs/core/internal/quantity.js +10 -0
- package/_cjs/core/internal/quantity.js.map +1 -0
- package/_cjs/erc4337/UserOperationReceipt.js.map +1 -1
- package/_cjs/index.js +6 -2
- package/_cjs/index.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/core/Frame.js +311 -0
- package/_esm/core/Frame.js.map +1 -0
- package/_esm/core/FrameReceipt.js +72 -0
- package/_esm/core/FrameReceipt.js.map +1 -0
- package/_esm/core/FrameSignature.js +422 -0
- package/_esm/core/FrameSignature.js.map +1 -0
- package/_esm/core/Transaction.js +18 -2
- package/_esm/core/Transaction.js.map +1 -1
- package/_esm/core/TransactionReceipt.js +10 -0
- package/_esm/core/TransactionReceipt.js.map +1 -1
- package/_esm/core/TransactionRequest.js +11 -1
- package/_esm/core/TransactionRequest.js.map +1 -1
- package/_esm/core/TxEnvelopeEip8141.js +490 -0
- package/_esm/core/TxEnvelopeEip8141.js.map +1 -0
- package/_esm/core/internal/curves.js +19 -0
- package/_esm/core/internal/curves.js.map +1 -0
- package/_esm/core/internal/quantity.js +14 -0
- package/_esm/core/internal/quantity.js.map +1 -0
- package/_esm/erc4337/UserOperationReceipt.js.map +1 -1
- package/_esm/index.js +73 -0
- package/_esm/index.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/core/Frame.d.ts +290 -0
- package/_types/core/Frame.d.ts.map +1 -0
- package/_types/core/FrameReceipt.d.ts +92 -0
- package/_types/core/FrameReceipt.d.ts.map +1 -0
- package/_types/core/FrameSignature.d.ts +357 -0
- package/_types/core/FrameSignature.d.ts.map +1 -0
- package/_types/core/Transaction.d.ts +29 -4
- package/_types/core/Transaction.d.ts.map +1 -1
- package/_types/core/TransactionReceipt.d.ts +15 -6
- package/_types/core/TransactionReceipt.d.ts.map +1 -1
- package/_types/core/TransactionRequest.d.ts +10 -4
- package/_types/core/TransactionRequest.d.ts.map +1 -1
- package/_types/core/TxEnvelopeEip8141.d.ts +343 -0
- package/_types/core/TxEnvelopeEip8141.d.ts.map +1 -0
- package/_types/core/internal/curves.d.ts +19 -0
- package/_types/core/internal/curves.d.ts.map +1 -0
- package/_types/core/internal/quantity.d.ts +10 -0
- package/_types/core/internal/quantity.d.ts.map +1 -0
- package/_types/erc4337/UserOperationReceipt.d.ts +1 -1
- package/_types/erc4337/UserOperationReceipt.d.ts.map +1 -1
- package/_types/index.d.ts +73 -0
- package/_types/index.d.ts.map +1 -1
- package/_types/tempo/Transaction.d.ts +2 -0
- package/_types/tempo/Transaction.d.ts.map +1 -1
- package/_types/tempo/TransactionReceipt.d.ts +2 -0
- package/_types/tempo/TransactionReceipt.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/core/Frame.ts +443 -0
- package/core/FrameReceipt.ts +117 -0
- package/core/FrameSignature.ts +606 -0
- package/core/Transaction.ts +73 -4
- package/core/TransactionReceipt.ts +41 -4
- package/core/TransactionRequest.ts +26 -2
- package/core/TxEnvelopeEip8141.ts +717 -0
- package/core/internal/curves.ts +22 -0
- package/core/internal/quantity.ts +16 -0
- package/erc4337/UserOperationReceipt.ts +1 -6
- package/index.ts +73 -0
- package/package.json +21 -1
- package/version.ts +1 -1
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
import * as Address from './Address.js';
|
|
2
|
+
import * as Errors from './Errors.js';
|
|
3
|
+
import * as Hex from './Hex.js';
|
|
4
|
+
import { p256N, secp256k1N } from './internal/curves.js';
|
|
5
|
+
import * as PublicKey from './PublicKey.js';
|
|
6
|
+
import * as Signature from './Signature.js';
|
|
7
|
+
/** Signature schemes supported by EIP-8141. */
|
|
8
|
+
export const schemes = { arbitrary: 0, p256: 2, secp256k1: 1 };
|
|
9
|
+
/**
|
|
10
|
+
* Asserts that a {@link ox#FrameSignature.FrameSignature} is structurally valid.
|
|
11
|
+
*
|
|
12
|
+
* Checks metadata, signature scalars, and public key shape without verifying
|
|
13
|
+
* authorization.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ### Basic Usage
|
|
17
|
+
*
|
|
18
|
+
* Unsigned protocol entries are accepted by default.
|
|
19
|
+
*
|
|
20
|
+
* ```ts twoslash
|
|
21
|
+
* import { FrameSignature } from 'ox'
|
|
22
|
+
*
|
|
23
|
+
* FrameSignature.assert({
|
|
24
|
+
* payload: '0x',
|
|
25
|
+
* scheme: 'secp256k1'
|
|
26
|
+
* })
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ### Requiring a Signature
|
|
31
|
+
*
|
|
32
|
+
* Set `signed` to require a protocol signature.
|
|
33
|
+
*
|
|
34
|
+
* ```ts twoslash
|
|
35
|
+
* import { FrameSignature, Hash, Secp256k1 } from 'ox'
|
|
36
|
+
*
|
|
37
|
+
* const payload = Hash.keccak256('0xdeadbeef')
|
|
38
|
+
* const privateKey = Secp256k1.randomPrivateKey()
|
|
39
|
+
* const signature = Secp256k1.sign({ payload, privateKey })
|
|
40
|
+
*
|
|
41
|
+
* const entry = FrameSignature.from({
|
|
42
|
+
* payload,
|
|
43
|
+
* scheme: 'secp256k1',
|
|
44
|
+
* signature
|
|
45
|
+
* })
|
|
46
|
+
*
|
|
47
|
+
* FrameSignature.assert(entry, { signed: true })
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @param entry - The signature entry to assert.
|
|
51
|
+
* @param options - Validation options.
|
|
52
|
+
*/
|
|
53
|
+
export function assert(entry, options = {}) {
|
|
54
|
+
const scheme = typeof entry.scheme === 'string' ? schemes[entry.scheme] : entry.scheme;
|
|
55
|
+
if (!Number.isInteger(scheme) || scheme < 0 || scheme > 2)
|
|
56
|
+
throw new InvalidError('Unsupported signature scheme.');
|
|
57
|
+
if (scheme === 0 && entry.signer !== undefined)
|
|
58
|
+
throw new InvalidError('Arbitrary signatures cannot specify a signer.');
|
|
59
|
+
if (entry.signer !== undefined)
|
|
60
|
+
Address.assert(entry.signer, { strict: false });
|
|
61
|
+
const payload = entry.payload ?? '0x';
|
|
62
|
+
Hex.assert(payload, { strict: true });
|
|
63
|
+
if (payload !== '0x' &&
|
|
64
|
+
(payload.length !== 66 || Hex.toBigInt(payload) === 0n))
|
|
65
|
+
throw new InvalidError('payload must be empty or a nonzero 32-byte digest.');
|
|
66
|
+
switch (entry.scheme) {
|
|
67
|
+
case 0:
|
|
68
|
+
case 'arbitrary':
|
|
69
|
+
Hex.assert(entry.signature, { strict: true });
|
|
70
|
+
if (entry.signature.length % 2 !== 0)
|
|
71
|
+
throw new InvalidError('signature must contain whole bytes.');
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (entry.scheme === 2 || entry.scheme === 'p256') {
|
|
75
|
+
if (entry.publicKey !== undefined) {
|
|
76
|
+
PublicKey.assert(entry.publicKey, { compressed: false });
|
|
77
|
+
for (const coordinate of [entry.publicKey.x, entry.publicKey.y]) {
|
|
78
|
+
if (typeof coordinate !== 'bigint' ||
|
|
79
|
+
coordinate < 0n ||
|
|
80
|
+
coordinate >= 2n ** 256n)
|
|
81
|
+
throw new InvalidError('Public key coordinates must fit in 32 bytes.');
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (entry.signature !== undefined && entry.publicKey === undefined)
|
|
85
|
+
throw new InvalidError('P-256 signatures require a public key.');
|
|
86
|
+
}
|
|
87
|
+
if (entry.signature === undefined) {
|
|
88
|
+
if (options.signed)
|
|
89
|
+
throw new InvalidError('Signature is required.');
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (typeof entry.signature.r !== 'bigint' ||
|
|
93
|
+
typeof entry.signature.s !== 'bigint')
|
|
94
|
+
throw new InvalidError('Signature scalars must be bigint.');
|
|
95
|
+
if ((scheme === 1 || entry.signature.yParity !== undefined) &&
|
|
96
|
+
entry.signature.yParity !== 0 &&
|
|
97
|
+
entry.signature.yParity !== 1)
|
|
98
|
+
throw new InvalidError('Signature parity must be 0 or 1.');
|
|
99
|
+
Signature.assert(entry.signature, { recovered: scheme === 1 });
|
|
100
|
+
const r = entry.signature.r;
|
|
101
|
+
const s = entry.signature.s;
|
|
102
|
+
const order = scheme === 1 ? secp256k1N : p256N;
|
|
103
|
+
if (r === 0n ||
|
|
104
|
+
r >= order ||
|
|
105
|
+
s === 0n ||
|
|
106
|
+
s >= order ||
|
|
107
|
+
(scheme === 1 && s > order / 2n))
|
|
108
|
+
throw new InvalidError('Signature scalars must be in range; secp256k1 requires low-s.');
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Coerces a value into a {@link ox#FrameSignature.FrameSignature}.
|
|
112
|
+
*
|
|
113
|
+
* Accepts arbitrary signature bytes or a structured signature entry. Omitted
|
|
114
|
+
* `scheme` and `payload` default to `'arbitrary'` and `'0x'`, respectively.
|
|
115
|
+
* An empty payload selects the canonical transaction signing hash; an explicit
|
|
116
|
+
* payload must be a nonzero 32-byte digest.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ### From Hex
|
|
120
|
+
*
|
|
121
|
+
* Wrap arbitrary witness bytes for contract-defined verification.
|
|
122
|
+
*
|
|
123
|
+
* ```ts twoslash
|
|
124
|
+
* import { FrameSignature } from 'ox'
|
|
125
|
+
*
|
|
126
|
+
* const entry = FrameSignature.from('0xaabb')
|
|
127
|
+
* // @log: { payload: '0x', scheme: 'arbitrary', signature: '0xaabb' }
|
|
128
|
+
* ```
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ### Secp256k1
|
|
132
|
+
*
|
|
133
|
+
* Wrap a signature over an explicit digest, retaining the same payload in the entry.
|
|
134
|
+
*
|
|
135
|
+
* ```ts twoslash
|
|
136
|
+
* import { FrameSignature, Hash, Secp256k1 } from 'ox'
|
|
137
|
+
*
|
|
138
|
+
* const payload = Hash.keccak256('0xdeadbeef')
|
|
139
|
+
* const privateKey = Secp256k1.randomPrivateKey()
|
|
140
|
+
* const signature = Secp256k1.sign({ payload, privateKey })
|
|
141
|
+
*
|
|
142
|
+
* const entry = FrameSignature.from({
|
|
143
|
+
* payload,
|
|
144
|
+
* scheme: 'secp256k1',
|
|
145
|
+
* signature
|
|
146
|
+
* })
|
|
147
|
+
* ```
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ### P256
|
|
151
|
+
*
|
|
152
|
+
* Include the public key with a P-256 signature over an explicit digest.
|
|
153
|
+
*
|
|
154
|
+
* ```ts twoslash
|
|
155
|
+
* import { FrameSignature, Hash, P256 } from 'ox'
|
|
156
|
+
*
|
|
157
|
+
* const { privateKey, publicKey } = P256.createKeyPair()
|
|
158
|
+
* const payload = Hash.keccak256('0xdeadbeef')
|
|
159
|
+
* const signature = P256.sign({ payload, privateKey })
|
|
160
|
+
*
|
|
161
|
+
* const entry = FrameSignature.from({
|
|
162
|
+
* payload,
|
|
163
|
+
* publicKey,
|
|
164
|
+
* scheme: 'p256',
|
|
165
|
+
* signature
|
|
166
|
+
* })
|
|
167
|
+
* ```
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ### Unsigned Entries
|
|
171
|
+
*
|
|
172
|
+
* Omit the signature to prepare a protocol entry before signing the transaction.
|
|
173
|
+
*
|
|
174
|
+
* ```ts twoslash
|
|
175
|
+
* import { FrameSignature } from 'ox'
|
|
176
|
+
*
|
|
177
|
+
* const entry = FrameSignature.from({ scheme: 'secp256k1' })
|
|
178
|
+
* // @log: { payload: '0x', scheme: 'secp256k1' }
|
|
179
|
+
* ```
|
|
180
|
+
*
|
|
181
|
+
* @param entry - Arbitrary signature bytes or a structured signature entry.
|
|
182
|
+
* @returns The validated entry, preserving supplied signature and scheme types.
|
|
183
|
+
*/
|
|
184
|
+
export function from(entry) {
|
|
185
|
+
const result = (typeof entry === 'string'
|
|
186
|
+
? { payload: '0x', scheme: 'arbitrary', signature: entry }
|
|
187
|
+
: {
|
|
188
|
+
...entry,
|
|
189
|
+
payload: entry.payload ?? '0x',
|
|
190
|
+
scheme: entry.scheme ?? 'arbitrary',
|
|
191
|
+
});
|
|
192
|
+
assert(result);
|
|
193
|
+
return result;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Converts an RPC signature entry to a structured frame signature.
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ### Basic Usage
|
|
200
|
+
*
|
|
201
|
+
* ```ts twoslash
|
|
202
|
+
* import { FrameSignature } from 'ox'
|
|
203
|
+
*
|
|
204
|
+
* const entry = FrameSignature.fromRpc({
|
|
205
|
+
* msg: '0x',
|
|
206
|
+
* scheme: 0,
|
|
207
|
+
* signature: '0xdeadbeef'
|
|
208
|
+
* })
|
|
209
|
+
* ```
|
|
210
|
+
*
|
|
211
|
+
* @param entry - The value to convert.
|
|
212
|
+
* @returns The converted value.
|
|
213
|
+
*/
|
|
214
|
+
export function fromRpc(entry) {
|
|
215
|
+
return fromTuple([
|
|
216
|
+
entry.scheme === 0 ? '0x' : Hex.fromNumber(entry.scheme, { size: 1 }),
|
|
217
|
+
entry.signer ?? '0x',
|
|
218
|
+
entry.msg,
|
|
219
|
+
entry.signature,
|
|
220
|
+
]);
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Converts a structured frame signature to its RPC representation.
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* ### Basic Usage
|
|
227
|
+
*
|
|
228
|
+
* ```ts twoslash
|
|
229
|
+
* import { FrameSignature } from 'ox'
|
|
230
|
+
*
|
|
231
|
+
* const entry = FrameSignature.from('0xdeadbeef')
|
|
232
|
+
* const rpc = FrameSignature.toRpc(entry)
|
|
233
|
+
* ```
|
|
234
|
+
*
|
|
235
|
+
* @param entry - The value to convert.
|
|
236
|
+
* @returns The converted value.
|
|
237
|
+
*/
|
|
238
|
+
export function toRpc(entry) {
|
|
239
|
+
const [scheme, signer, msg, signature] = toTuple(entry);
|
|
240
|
+
return {
|
|
241
|
+
msg,
|
|
242
|
+
scheme: (scheme === '0x' ? 0 : Hex.toNumber(scheme)),
|
|
243
|
+
signature,
|
|
244
|
+
...(signer === '0x' ? {} : { signer }),
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Converts a {@link ox#FrameSignature.Tuple} to a structured
|
|
249
|
+
* {@link ox#FrameSignature.FrameSignature}.
|
|
250
|
+
*
|
|
251
|
+
* Returns a named scheme and unpacks protocol signatures. Empty protocol signatures
|
|
252
|
+
* become unsigned entries. Rejects noncanonical encodings.
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* ### Basic Usage
|
|
256
|
+
*
|
|
257
|
+
* Decode an arbitrary signature tuple.
|
|
258
|
+
*
|
|
259
|
+
* ```ts twoslash
|
|
260
|
+
* import { FrameSignature } from 'ox'
|
|
261
|
+
*
|
|
262
|
+
* const entry = FrameSignature.fromTuple([
|
|
263
|
+
* '0x',
|
|
264
|
+
* '0x',
|
|
265
|
+
* '0x',
|
|
266
|
+
* '0xaabb'
|
|
267
|
+
* ])
|
|
268
|
+
* // @log: { payload: '0x', scheme: 'arbitrary', signature: '0xaabb' }
|
|
269
|
+
* ```
|
|
270
|
+
*
|
|
271
|
+
* @param tuple - The signature tuple to convert.
|
|
272
|
+
* @returns The decoded signature entry.
|
|
273
|
+
*/
|
|
274
|
+
export function fromTuple(tuple) {
|
|
275
|
+
if (!Array.isArray(tuple) || tuple.length !== 4)
|
|
276
|
+
throw new InvalidError('Expected [scheme, signer, payload, signature].');
|
|
277
|
+
const [scheme, signer, payload, signature] = tuple;
|
|
278
|
+
Hex.assert(signer, { strict: true });
|
|
279
|
+
Hex.assert(signature, { strict: true });
|
|
280
|
+
if (signature.length % 2 !== 0)
|
|
281
|
+
throw new InvalidError('signature must contain whole bytes.');
|
|
282
|
+
if (scheme !== '0x' && scheme !== '0x01' && scheme !== '0x02')
|
|
283
|
+
throw new InvalidError('Expected a canonical scheme encoding: empty bytes, 0x01, or 0x02.');
|
|
284
|
+
const metadata = { ...(signer === '0x' ? {} : { signer }), payload };
|
|
285
|
+
if (scheme === '0x') {
|
|
286
|
+
if (signer !== '0x')
|
|
287
|
+
throw new InvalidError('Arbitrary signatures cannot specify a signer.');
|
|
288
|
+
return from({ payload, scheme: 'arbitrary', signature });
|
|
289
|
+
}
|
|
290
|
+
if (signature === '0x')
|
|
291
|
+
return scheme === '0x01'
|
|
292
|
+
? from({ ...metadata, scheme: 'secp256k1' })
|
|
293
|
+
: from({ ...metadata, scheme: 'p256' });
|
|
294
|
+
if (Hex.size(signature) !== (scheme === '0x01' ? 65 : 128))
|
|
295
|
+
throw new InvalidError('Invalid protocol signature length.');
|
|
296
|
+
if (scheme === '0x01') {
|
|
297
|
+
if (Hex.toNumber(Hex.slice(signature, 0, 1)) > 1)
|
|
298
|
+
throw new InvalidError('Recovery parity must be 0 or 1.');
|
|
299
|
+
return from({
|
|
300
|
+
...metadata,
|
|
301
|
+
scheme: 'secp256k1',
|
|
302
|
+
signature: {
|
|
303
|
+
r: Hex.toBigInt(Hex.slice(signature, 1, 33)),
|
|
304
|
+
s: Hex.toBigInt(Hex.slice(signature, 33, 65)),
|
|
305
|
+
yParity: Hex.toNumber(Hex.slice(signature, 0, 1)),
|
|
306
|
+
},
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
const s = Hex.toBigInt(Hex.slice(signature, 32, 64));
|
|
310
|
+
if (s > p256N / 2n)
|
|
311
|
+
throw new InvalidError('P-256 wire signatures require low-s.');
|
|
312
|
+
return from({
|
|
313
|
+
...metadata,
|
|
314
|
+
publicKey: {
|
|
315
|
+
prefix: 4,
|
|
316
|
+
x: Hex.toBigInt(Hex.slice(signature, 64, 96)),
|
|
317
|
+
y: Hex.toBigInt(Hex.slice(signature, 96, 128)),
|
|
318
|
+
},
|
|
319
|
+
scheme: 'p256',
|
|
320
|
+
signature: { r: Hex.toBigInt(Hex.slice(signature, 0, 32)), s },
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Converts a {@link ox#FrameSignature.FrameSignature} to its RLP-ready
|
|
325
|
+
* {@link ox#FrameSignature.Tuple}.
|
|
326
|
+
*
|
|
327
|
+
* Encodes numeric scheme identifiers and packs protocol signatures without mutating
|
|
328
|
+
* the entry. Omitted protocol signatures become empty bytes.
|
|
329
|
+
*
|
|
330
|
+
* @example
|
|
331
|
+
* ### Basic Usage
|
|
332
|
+
*
|
|
333
|
+
* Encode arbitrary witness bytes with the default scheme and payload.
|
|
334
|
+
*
|
|
335
|
+
* ```ts twoslash
|
|
336
|
+
* import { FrameSignature } from 'ox'
|
|
337
|
+
*
|
|
338
|
+
* const entry = FrameSignature.from('0xaabb')
|
|
339
|
+
* const tuple = FrameSignature.toTuple(entry)
|
|
340
|
+
* // @log: ['0x', '0x', '0x', '0xaabb']
|
|
341
|
+
* ```
|
|
342
|
+
*
|
|
343
|
+
* @param entry - The signature entry to convert.
|
|
344
|
+
* @returns The encoded signature tuple.
|
|
345
|
+
*/
|
|
346
|
+
export function toTuple(entry) {
|
|
347
|
+
assert(entry);
|
|
348
|
+
const scheme = typeof entry.scheme === 'string' ? schemes[entry.scheme] : entry.scheme;
|
|
349
|
+
const signature = (() => {
|
|
350
|
+
switch (entry.scheme) {
|
|
351
|
+
case 0:
|
|
352
|
+
case 'arbitrary':
|
|
353
|
+
return entry.signature;
|
|
354
|
+
case 1:
|
|
355
|
+
case 'secp256k1':
|
|
356
|
+
return entry.signature === undefined
|
|
357
|
+
? '0x'
|
|
358
|
+
: Hex.concat(Hex.fromNumber(entry.signature.yParity, { size: 1 }), Hex.fromNumber(entry.signature.r, { size: 32 }), Hex.fromNumber(entry.signature.s, { size: 32 }));
|
|
359
|
+
case 2:
|
|
360
|
+
case 'p256': {
|
|
361
|
+
if (entry.signature === undefined)
|
|
362
|
+
return '0x';
|
|
363
|
+
const { publicKey, signature } = entry;
|
|
364
|
+
const s = signature.s;
|
|
365
|
+
return Hex.concat(Hex.fromNumber(signature.r, { size: 32 }), Hex.fromNumber(s > p256N / 2n ? p256N - s : s, { size: 32 }), Hex.fromNumber(publicKey.x, { size: 32 }), Hex.fromNumber(publicKey.y, { size: 32 }));
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
})();
|
|
369
|
+
return [
|
|
370
|
+
scheme ? Hex.fromNumber(scheme, { size: 1 }) : '0x',
|
|
371
|
+
entry.signer ?? '0x',
|
|
372
|
+
entry.payload ?? '0x',
|
|
373
|
+
signature,
|
|
374
|
+
];
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Returns whether a {@link ox#FrameSignature.FrameSignature} is structurally valid.
|
|
378
|
+
*
|
|
379
|
+
* Performs the same checks as {@link ox#FrameSignature.(assert:function)}, returning
|
|
380
|
+
* `false` instead of throwing. Does not verify that the signature authorizes a payload.
|
|
381
|
+
*
|
|
382
|
+
* @example
|
|
383
|
+
* ### Basic Usage
|
|
384
|
+
*
|
|
385
|
+
* Require a signature when checking a protocol entry.
|
|
386
|
+
*
|
|
387
|
+
* ```ts twoslash
|
|
388
|
+
* import { FrameSignature } from 'ox'
|
|
389
|
+
*
|
|
390
|
+
* const entry = FrameSignature.from({ scheme: 'secp256k1' })
|
|
391
|
+
* const valid = FrameSignature.validate(entry, {
|
|
392
|
+
* signed: true
|
|
393
|
+
* })
|
|
394
|
+
* // @log: false
|
|
395
|
+
* ```
|
|
396
|
+
*
|
|
397
|
+
* @param entry - The signature entry to validate.
|
|
398
|
+
* @param options - Validation options.
|
|
399
|
+
* @returns Whether the entry is structurally valid.
|
|
400
|
+
*/
|
|
401
|
+
export function validate(entry, options = {}) {
|
|
402
|
+
try {
|
|
403
|
+
assert(entry, options);
|
|
404
|
+
return true;
|
|
405
|
+
}
|
|
406
|
+
catch {
|
|
407
|
+
return false;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
/** Thrown when frame signature metadata or encoding is invalid. */
|
|
411
|
+
export class InvalidError extends Errors.BaseError {
|
|
412
|
+
constructor(details) {
|
|
413
|
+
super('Invalid frame signature.', { details });
|
|
414
|
+
Object.defineProperty(this, "name", {
|
|
415
|
+
enumerable: true,
|
|
416
|
+
configurable: true,
|
|
417
|
+
writable: true,
|
|
418
|
+
value: 'FrameSignature.InvalidError'
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
//# sourceMappingURL=FrameSignature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FrameSignature.js","sourceRoot":"","sources":["../../core/FrameSignature.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAExD,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAE3C,+CAA+C;AAC/C,MAAM,C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ED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import * as Authorization from './Authorization.js';
|
|
2
|
+
import * as Frame from './Frame.js';
|
|
3
|
+
import * as FrameSignature from './FrameSignature.js';
|
|
2
4
|
import * as Hex from './Hex.js';
|
|
3
5
|
import * as Signature from './Signature.js';
|
|
4
6
|
/** Type to RPC Type mapping. */
|
|
@@ -8,6 +10,7 @@ export const toRpcType = {
|
|
|
8
10
|
eip1559: '0x2',
|
|
9
11
|
eip4844: '0x3',
|
|
10
12
|
eip7702: '0x4',
|
|
13
|
+
eip8141: '0x6',
|
|
11
14
|
};
|
|
12
15
|
/** RPC Type to Type mapping. */
|
|
13
16
|
export const fromRpcType = {
|
|
@@ -16,6 +19,7 @@ export const fromRpcType = {
|
|
|
16
19
|
'0x2': 'eip1559',
|
|
17
20
|
'0x3': 'eip4844',
|
|
18
21
|
'0x4': 'eip7702',
|
|
22
|
+
'0x6': 'eip8141',
|
|
19
23
|
};
|
|
20
24
|
/**
|
|
21
25
|
* Converts an {@link ox#Transaction.Rpc} to an {@link ox#Transaction.Transaction}.
|
|
@@ -54,7 +58,7 @@ export const fromRpcType = {
|
|
|
54
58
|
export function fromRpc(transaction, _options = {}) {
|
|
55
59
|
if (!transaction)
|
|
56
60
|
return null;
|
|
57
|
-
const signature = Signature.extract(transaction);
|
|
61
|
+
const signature = transaction.type === '0x6' ? undefined : Signature.extract(transaction);
|
|
58
62
|
const transaction_ = {
|
|
59
63
|
...transaction,
|
|
60
64
|
...signature,
|
|
@@ -75,10 +79,18 @@ export function fromRpc(transaction, _options = {}) {
|
|
|
75
79
|
? Number(transaction.transactionIndex)
|
|
76
80
|
: null;
|
|
77
81
|
transaction_.value = BigInt(transaction.value ?? 0n);
|
|
82
|
+
if (transaction.frames)
|
|
83
|
+
transaction_.frames = transaction.frames.map(Frame.fromRpc);
|
|
84
|
+
if (transaction.signatures)
|
|
85
|
+
transaction_.signatures = transaction.signatures.map(FrameSignature.fromRpc);
|
|
78
86
|
if (transaction.authorizationList)
|
|
79
87
|
transaction_.authorizationList = Authorization.fromRpcList(transaction.authorizationList);
|
|
80
88
|
if (transaction.chainId)
|
|
81
|
-
transaction_.chainId =
|
|
89
|
+
transaction_.chainId =
|
|
90
|
+
transaction.type === '0x6' &&
|
|
91
|
+
BigInt(transaction.chainId) > BigInt(Number.MAX_SAFE_INTEGER)
|
|
92
|
+
? BigInt(transaction.chainId)
|
|
93
|
+
: Number(transaction.chainId);
|
|
82
94
|
if (transaction.gasPrice)
|
|
83
95
|
transaction_.gasPrice = BigInt(transaction.gasPrice);
|
|
84
96
|
if (transaction.maxFeePerBlobGas)
|
|
@@ -151,6 +163,10 @@ export function toRpc(transaction, _options) {
|
|
|
151
163
|
: null;
|
|
152
164
|
rpc.type = toRpcType[transaction.type] ?? transaction.type;
|
|
153
165
|
rpc.value = Hex.fromNumber(transaction.value ?? 0n);
|
|
166
|
+
if (transaction.frames)
|
|
167
|
+
rpc.frames = transaction.frames.map(Frame.toRpc);
|
|
168
|
+
if (transaction.signatures)
|
|
169
|
+
rpc.signatures = transaction.signatures.map(FrameSignature.toRpc);
|
|
154
170
|
if (transaction.accessList)
|
|
155
171
|
rpc.accessList = transaction.accessList;
|
|
156
172
|
if (transaction.authorizationList)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transaction.js","sourceRoot":"","sources":["../../core/Transaction.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AAEnD,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAE/B,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"Transaction.js","sourceRoot":"","sources":["../../core/Transaction.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AAEnD,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AACrD,OAAO,KAAK,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AQ;QACzC,GAAG,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAA;IAEzD,OAAO,GAAmB,CAAA;AAC5B,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as FrameReceipt from './FrameReceipt.js';
|
|
1
2
|
import * as Hex from './Hex.js';
|
|
2
3
|
import * as Log from './Log.js';
|
|
3
4
|
/** RPC status to status mapping. */
|
|
@@ -17,6 +18,7 @@ export const fromRpcType = {
|
|
|
17
18
|
'0x2': 'eip1559',
|
|
18
19
|
'0x3': 'eip4844',
|
|
19
20
|
'0x4': 'eip7702',
|
|
21
|
+
'0x6': 'eip8141',
|
|
20
22
|
};
|
|
21
23
|
/** Type to RPC type mapping. */
|
|
22
24
|
export const toRpcType = {
|
|
@@ -25,6 +27,7 @@ export const toRpcType = {
|
|
|
25
27
|
eip1559: '0x2',
|
|
26
28
|
eip4844: '0x3',
|
|
27
29
|
eip7702: '0x4',
|
|
30
|
+
eip8141: '0x6',
|
|
28
31
|
};
|
|
29
32
|
/**
|
|
30
33
|
* Converts a {@link ox#TransactionReceipt.Rpc} to an {@link ox#TransactionReceipt.TransactionReceipt}.
|
|
@@ -128,6 +131,9 @@ export function fromRpc(receipt) {
|
|
|
128
131
|
return null;
|
|
129
132
|
return {
|
|
130
133
|
...receipt,
|
|
134
|
+
...(receipt.frameReceipts
|
|
135
|
+
? { frameReceipts: receipt.frameReceipts.map(FrameReceipt.fromRpc) }
|
|
136
|
+
: {}),
|
|
131
137
|
blobGasPrice: receipt.blobGasPrice
|
|
132
138
|
? BigInt(receipt.blobGasPrice)
|
|
133
139
|
: undefined,
|
|
@@ -197,6 +203,10 @@ export function fromRpc(receipt) {
|
|
|
197
203
|
*/
|
|
198
204
|
export function toRpc(receipt) {
|
|
199
205
|
return {
|
|
206
|
+
...(receipt.frameReceipts
|
|
207
|
+
? { frameReceipts: receipt.frameReceipts.map(FrameReceipt.toRpc) }
|
|
208
|
+
: {}),
|
|
209
|
+
...(receipt.payer ? { payer: receipt.payer } : {}),
|
|
200
210
|
blobGasPrice: receipt.blobGasPrice
|
|
201
211
|
? Hex.fromNumber(receipt.blobGasPrice)
|
|
202
212
|
: undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionReceipt.js","sourceRoot":"","sources":["../../core/TransactionReceipt.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAE/B,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"TransactionReceipt.js","sourceRoot":"","sources":["../../core/TransactionReceipt.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AACjD,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAE/B,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAmH/B,oCAAoC;AACpC,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,KAAK,EAAE,UAAU;IACjB,KAAK,EAAE,SAAS;CACR,CAAA;AAEV,oCAAoC;AACpC,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,QAAQ,EAAE,KAAK;IACf,OAAO,EAAE,KAAK;CACN,CAAA;AAEV,gCAAgC;AAChC,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,KAAK,EAAE,QAAQ;IACf,KAAK,EAAE,SAAS;IAChB,KAAK,EAAE,SAAS;IAChB,KAAK,EAAE,SAAS;IAChB,KAAK,EAAE,SAAS;IAChB,KAAK,EAAE,SAAS;CACR,CAAA;AAEV,gCAAgC;AAChC,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,MAAM,EAAE,KAAK;IACb,OAAO,EAAE,KAAK;IACd,OAAO,EAAE,KAAK;IACd,OAAO,EAAE,KAAK;IACd,OAAO,EAAE,KAAK;IACd,OAAO,EAAE,KAAK;CACN,CAAA;AAEV;;;;;;;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C5B,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC;QACnC,EAAE,EAAE,OAAO,CAAC,EAAE;QACd,eAAe,EAAE,OAAO,CAAC,eAAe;QACxC,gBAAgB,EAAE,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,gBAAgB,CAAC;QAC1D,IAAI,EAAG,SAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI;KACvD,CAAA;AACH,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import * as Authorization from './Authorization.js';
|
|
2
|
+
import * as Frame from './Frame.js';
|
|
3
|
+
import * as FrameSignature from './FrameSignature.js';
|
|
2
4
|
import * as Hex from './Hex.js';
|
|
3
5
|
import * as Transaction from './Transaction.js';
|
|
4
6
|
/**
|
|
@@ -18,11 +20,15 @@ import * as Transaction from './Transaction.js';
|
|
|
18
20
|
* @returns A transaction request.
|
|
19
21
|
*/
|
|
20
22
|
export function fromRpc(request) {
|
|
21
|
-
const request_ = request;
|
|
23
|
+
const request_ = { ...request };
|
|
22
24
|
if (typeof request.authorizationList !== 'undefined')
|
|
23
25
|
request_.authorizationList = Authorization.fromRpcList(request.authorizationList);
|
|
24
26
|
if (typeof request.chainId !== 'undefined')
|
|
25
27
|
request_.chainId = Hex.toNumber(request.chainId);
|
|
28
|
+
if (request.frames)
|
|
29
|
+
request_.frames = request.frames.map(Frame.fromRpc);
|
|
30
|
+
if (request.signatures)
|
|
31
|
+
request_.signatures = request.signatures.map(FrameSignature.fromRpc);
|
|
26
32
|
if (typeof request.gas !== 'undefined')
|
|
27
33
|
request_.gas = Hex.toBigInt(request.gas);
|
|
28
34
|
if (typeof request.gasPrice !== 'undefined')
|
|
@@ -103,6 +109,10 @@ export function toRpc(request) {
|
|
|
103
109
|
}
|
|
104
110
|
if (typeof request.from !== 'undefined')
|
|
105
111
|
request_rpc.from = request.from;
|
|
112
|
+
if (request.frames)
|
|
113
|
+
request_rpc.frames = request.frames.map(Frame.toRpc);
|
|
114
|
+
if (request.signatures)
|
|
115
|
+
request_rpc.signatures = request.signatures.map(FrameSignature.toRpc);
|
|
106
116
|
if (typeof request.gas !== 'undefined')
|
|
107
117
|
request_rpc.gas = Hex.fromNumber(request.gas);
|
|
108
118
|
if (typeof request.gasPrice !== 'undefined')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionRequest.js","sourceRoot":"","sources":["../../core/TransactionRequest.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AAEnD,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAE/B,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"TransactionRequest.js","sourceRoot":"","sources":["../../core/TransactionRequest.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AAEnD,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AACrD,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAE/B,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AA6D/C;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,OAAO,CAAC,OAAY;IAClC,MAAM,QAAQ,GAAG,EAAE,GAAG,OAAO,EAAmC,CAAA;IAEhE,IAAI,OAAO,OAAO,CAAC,iBAAiB,KAAK,WAAW;QAClD,QAAQ,CAAC,iBAAiB,GAAG,aAAa,CAAC,WAAW,CACpD,OAAO,CAAC,iBAAiB,CAC1B,CAAA;IACH,IAAI,OAAO,OAAO,CAAC,OAAO,KAAK,WAAW;QACxC,QAAQ,CAAC,OAAO,GAAG,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAClD,IAAI,OAAO,CAAC,MAAM;QAAE,QAAQ,CAAC,M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