ox 1.8.14 → 1.8.16
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 +72 -0
- package/dist/core/AbiError.d.ts +52 -6
- package/dist/core/AbiError.d.ts.map +1 -1
- package/dist/core/AbiError.js +60 -4
- package/dist/core/AbiError.js.map +1 -1
- package/dist/core/AbiEvent.d.ts +4 -2
- package/dist/core/AbiEvent.d.ts.map +1 -1
- package/dist/core/AbiEvent.js +62 -36
- package/dist/core/AbiEvent.js.map +1 -1
- package/dist/core/AbiFunction.d.ts +48 -2
- package/dist/core/AbiFunction.d.ts.map +1 -1
- package/dist/core/AbiFunction.js +59 -3
- package/dist/core/AbiFunction.js.map +1 -1
- package/dist/core/Address.d.ts +17 -2
- package/dist/core/Address.d.ts.map +1 -1
- package/dist/core/Address.js +17 -1
- package/dist/core/Address.js.map +1 -1
- package/dist/core/Authorization.d.ts +24 -2
- package/dist/core/Authorization.d.ts.map +1 -1
- package/dist/core/Authorization.js +29 -2
- package/dist/core/Authorization.js.map +1 -1
- package/dist/core/Keystore.d.ts +31 -2
- package/dist/core/Keystore.d.ts.map +1 -1
- package/dist/core/Keystore.js +28 -2
- package/dist/core/Keystore.js.map +1 -1
- package/dist/core/Secp256k1.d.ts.map +1 -1
- package/dist/core/Secp256k1.js +4 -1
- package/dist/core/Secp256k1.js.map +1 -1
- package/dist/core/Signature.d.ts +1 -1
- package/dist/core/Signature.d.ts.map +1 -1
- package/dist/core/Signature.js +4 -2
- package/dist/core/Signature.js.map +1 -1
- package/dist/core/Siwe.d.ts +4 -0
- package/dist/core/Siwe.d.ts.map +1 -1
- package/dist/core/Siwe.js +29 -3
- package/dist/core/Siwe.js.map +1 -1
- package/dist/core/TxEnvelopeEip1559.d.ts.map +1 -1
- package/dist/core/TxEnvelopeEip1559.js +2 -1
- package/dist/core/TxEnvelopeEip1559.js.map +1 -1
- package/dist/core/TxEnvelopeEip2930.d.ts.map +1 -1
- package/dist/core/TxEnvelopeEip2930.js +2 -1
- package/dist/core/TxEnvelopeEip2930.js.map +1 -1
- package/dist/core/TxEnvelopeEip7702.d.ts +1 -1
- package/dist/core/TxEnvelopeEip7702.d.ts.map +1 -1
- package/dist/core/TxEnvelopeEip7702.js +6 -1
- package/dist/core/TxEnvelopeEip7702.js.map +1 -1
- package/dist/core/TxEnvelopeLegacy.d.ts.map +1 -1
- package/dist/core/TxEnvelopeLegacy.js +49 -7
- package/dist/core/TxEnvelopeLegacy.js.map +1 -1
- package/dist/core/TypedData.d.ts +3 -1
- package/dist/core/TypedData.d.ts.map +1 -1
- package/dist/core/TypedData.js +9 -9
- package/dist/core/TypedData.js.map +1 -1
- package/dist/core/Value.d.ts.map +1 -1
- package/dist/core/Value.js +14 -3
- package/dist/core/Value.js.map +1 -1
- package/dist/core/internal/abiParameters.d.ts +1 -1
- package/dist/core/internal/abiParameters.d.ts.map +1 -1
- package/dist/core/internal/abiParameters.js +7 -2
- package/dist/core/internal/abiParameters.js.map +1 -1
- package/dist/core/internal/cursor.d.ts +13 -0
- package/dist/core/internal/cursor.d.ts.map +1 -1
- package/dist/core/internal/cursor.js +27 -0
- package/dist/core/internal/cursor.js.map +1 -1
- package/dist/erc4337/UserOperation.d.ts.map +1 -1
- package/dist/erc4337/UserOperation.js +1 -3
- package/dist/erc4337/UserOperation.js.map +1 -1
- package/dist/erc7821/Execute.d.ts +45 -0
- package/dist/erc7821/Execute.d.ts.map +1 -1
- package/dist/erc7821/Execute.js +70 -2
- package/dist/erc7821/Execute.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/tempo/KeyAuthorization.d.ts +9 -3
- package/dist/tempo/KeyAuthorization.d.ts.map +1 -1
- package/dist/tempo/KeyAuthorization.js +16 -0
- package/dist/tempo/KeyAuthorization.js.map +1 -1
- package/dist/tempo/SignatureEnvelope.d.ts +1 -1
- package/dist/tempo/SignatureEnvelope.d.ts.map +1 -1
- package/dist/tempo/SignatureEnvelope.js +46 -13
- package/dist/tempo/SignatureEnvelope.js.map +1 -1
- package/dist/tempo/SignaturePreAuthorized.d.ts +192 -0
- package/dist/tempo/SignaturePreAuthorized.d.ts.map +1 -0
- package/dist/tempo/SignaturePreAuthorized.js +299 -0
- package/dist/tempo/SignaturePreAuthorized.js.map +1 -0
- package/dist/tempo/TransactionRequest.d.ts +1 -1
- package/dist/tempo/TransactionRequest.d.ts.map +1 -1
- package/dist/tempo/TransactionRequest.js +5 -2
- package/dist/tempo/TransactionRequest.js.map +1 -1
- package/dist/tempo/TxEnvelopeTempo.d.ts +30 -1
- package/dist/tempo/TxEnvelopeTempo.d.ts.map +1 -1
- package/dist/tempo/TxEnvelopeTempo.js +51 -2
- package/dist/tempo/TxEnvelopeTempo.js.map +1 -1
- package/dist/tempo/index.d.ts +26 -0
- package/dist/tempo/index.d.ts.map +1 -1
- package/dist/tempo/index.js +26 -0
- package/dist/tempo/index.js.map +1 -1
- package/dist/webauthn/Registration.d.ts +2 -0
- package/dist/webauthn/Registration.d.ts.map +1 -1
- package/dist/webauthn/Registration.js +2 -6
- package/dist/webauthn/Registration.js.map +1 -1
- package/dist/zod/tempo/KeyAuthorization.d.ts.map +1 -1
- package/dist/zod/tempo/KeyAuthorization.js +4 -2
- package/dist/zod/tempo/KeyAuthorization.js.map +1 -1
- package/dist/zod/tempo/SignatureEnvelope.d.ts.map +1 -1
- package/dist/zod/tempo/SignatureEnvelope.js +24 -14
- package/dist/zod/tempo/SignatureEnvelope.js.map +1 -1
- package/package.json +6 -1
- package/src/core/AbiError.ts +82 -8
- package/src/core/AbiEvent.ts +90 -45
- package/src/core/AbiFunction.ts +76 -4
- package/src/core/Address.ts +18 -1
- package/src/core/Authorization.ts +34 -4
- package/src/core/Keystore.ts +40 -3
- package/src/core/Secp256k1.ts +4 -1
- package/src/core/Signature.ts +7 -3
- package/src/core/Siwe.ts +29 -3
- package/src/core/TxEnvelopeEip1559.ts +4 -1
- package/src/core/TxEnvelopeEip2930.ts +4 -1
- package/src/core/TxEnvelopeEip7702.ts +9 -2
- package/src/core/TxEnvelopeLegacy.ts +58 -7
- package/src/core/TypedData.ts +10 -9
- package/src/core/Value.ts +14 -3
- package/src/core/_test/AbiError.test.ts +105 -2
- package/src/core/_test/AbiEvent.fuzz.ts +1 -1
- package/src/core/_test/AbiEvent.test-d.ts +46 -0
- package/src/core/_test/AbiEvent.test.ts +563 -11
- package/src/core/_test/AbiFunction.test.ts +74 -2
- package/src/core/_test/AbiParameters.adversarial.fuzz.ts +1 -0
- package/src/core/_test/AbiParameters.decode.test.ts +110 -0
- package/src/core/_test/AbiParameters.encode.test.ts +26 -1
- package/src/core/_test/Address.test.ts +41 -0
- package/src/core/_test/Authorization.test.ts +130 -0
- package/src/core/_test/Keystore.test.ts +65 -1
- package/src/core/_test/Secp256k1.test.ts +36 -0
- package/src/core/_test/Signature.test.ts +102 -0
- package/src/core/_test/Siwe.test.ts +123 -0
- package/src/core/_test/TransactionEnvelopeEip1559.test.ts +28 -0
- package/src/core/_test/TransactionEnvelopeEip2930.test.ts +28 -0
- package/src/core/_test/TransactionEnvelopeEip7702.test.ts +133 -0
- package/src/core/_test/TransactionEnvelopeLegacy.test.ts +322 -1
- package/src/core/_test/TypedData.test.ts +178 -0
- package/src/core/_test/Value.test.ts +21 -0
- package/src/core/_test/internal/cursor.test.ts +35 -0
- package/src/core/internal/abiParameters.ts +7 -2
- package/src/core/internal/cursor.ts +36 -0
- package/src/erc4337/UserOperation.ts +3 -4
- package/src/erc4337/_test/UserOperation.test.ts +59 -1
- package/src/erc7821/Execute.ts +83 -2
- package/src/erc7821/_test/Execute.test.ts +217 -1
- package/src/index.ts +1 -1
- package/src/tempo/KeyAuthorization.test.ts +91 -0
- package/src/tempo/KeyAuthorization.ts +32 -3
- package/src/tempo/SignatureEnvelope.test.ts +211 -27
- package/src/tempo/SignatureEnvelope.ts +55 -11
- package/src/tempo/SignaturePreAuthorized.test-d.ts +29 -0
- package/src/tempo/SignaturePreAuthorized.test.ts +410 -0
- package/src/tempo/SignaturePreAuthorized.ts +370 -0
- package/src/tempo/TransactionRequest.test.ts +30 -0
- package/src/tempo/TransactionRequest.ts +7 -2
- package/src/tempo/TxEnvelopeTempo.test.ts +310 -0
- package/src/tempo/TxEnvelopeTempo.ts +64 -1
- package/src/tempo/configurableAccounts.e2e.test.ts +1 -1
- package/src/tempo/index.ts +26 -0
- package/src/version.ts +1 -1
- package/src/webauthn/Registration.ts +4 -6
- package/src/webauthn/_test/Registration.browser.test.ts +14 -0
- package/src/webauthn/_test/Registration.test.ts +60 -0
- package/src/zod/tempo/KeyAuthorization.ts +12 -5
- package/src/zod/tempo/SignatureEnvelope.ts +31 -16
- package/src/zod/tempo/_test/KeyAuthorization.test.ts +36 -0
- package/src/zod/tempo/_test/SignatureEnvelope.test.ts +101 -3
|
@@ -8,10 +8,15 @@ export type Cursor = {
|
|
|
8
8
|
position: number
|
|
9
9
|
/** Lazy: only allocated when slow-path tracking kicks in. */
|
|
10
10
|
positionReadCount: Map<number, number> | undefined
|
|
11
|
+
/** Total number of bytes read. */
|
|
12
|
+
readSize: number
|
|
13
|
+
/** Maximum total number of bytes that can be read. */
|
|
14
|
+
readSizeLimit: number
|
|
11
15
|
recursiveReadCount: number
|
|
12
16
|
recursiveReadLimit: number
|
|
13
17
|
remaining: number
|
|
14
18
|
assertReadLimit(position?: number): void
|
|
19
|
+
assertReadSize(length: number): void
|
|
15
20
|
assertPosition(position: number): void
|
|
16
21
|
decrementPosition(offset: number): void
|
|
17
22
|
getReadCount(position?: number): number
|
|
@@ -43,6 +48,8 @@ const staticCursor: Cursor = {
|
|
|
43
48
|
dataView: new DataView(new ArrayBuffer(0)),
|
|
44
49
|
position: 0,
|
|
45
50
|
positionReadCount: undefined,
|
|
51
|
+
readSize: 0,
|
|
52
|
+
readSizeLimit: Number.POSITIVE_INFINITY,
|
|
46
53
|
recursiveReadCount: 0,
|
|
47
54
|
recursiveReadLimit: Number.POSITIVE_INFINITY,
|
|
48
55
|
assertReadLimit() {
|
|
@@ -52,6 +59,14 @@ const staticCursor: Cursor = {
|
|
|
52
59
|
limit: this.recursiveReadLimit,
|
|
53
60
|
})
|
|
54
61
|
},
|
|
62
|
+
assertReadSize(length) {
|
|
63
|
+
this.readSize += length
|
|
64
|
+
if (this.readSize > this.readSizeLimit)
|
|
65
|
+
throw new ReadSizeLimitExceededError({
|
|
66
|
+
limit: this.readSizeLimit,
|
|
67
|
+
size: this.readSize,
|
|
68
|
+
})
|
|
69
|
+
},
|
|
55
70
|
assertPosition(position) {
|
|
56
71
|
if (position < 0 || position > this.bytes.length - 1)
|
|
57
72
|
throw new PositionOutOfBoundsError({
|
|
@@ -142,6 +157,7 @@ const staticCursor: Cursor = {
|
|
|
142
157
|
this.assertReadLimit()
|
|
143
158
|
this._touch()
|
|
144
159
|
const value = this.inspectByte()
|
|
160
|
+
this.assertReadSize(1)
|
|
145
161
|
this.position++
|
|
146
162
|
return value
|
|
147
163
|
},
|
|
@@ -149,6 +165,7 @@ const staticCursor: Cursor = {
|
|
|
149
165
|
this.assertReadLimit()
|
|
150
166
|
this._touch()
|
|
151
167
|
const value = this.inspectBytes(length)
|
|
168
|
+
this.assertReadSize(length)
|
|
152
169
|
this.position += size ?? length
|
|
153
170
|
return value
|
|
154
171
|
},
|
|
@@ -156,6 +173,7 @@ const staticCursor: Cursor = {
|
|
|
156
173
|
this.assertReadLimit()
|
|
157
174
|
this._touch()
|
|
158
175
|
const value = this.inspectUint8()
|
|
176
|
+
this.assertReadSize(1)
|
|
159
177
|
this.position += 1
|
|
160
178
|
return value
|
|
161
179
|
},
|
|
@@ -163,6 +181,7 @@ const staticCursor: Cursor = {
|
|
|
163
181
|
this.assertReadLimit()
|
|
164
182
|
this._touch()
|
|
165
183
|
const value = this.inspectUint16()
|
|
184
|
+
this.assertReadSize(2)
|
|
166
185
|
this.position += 2
|
|
167
186
|
return value
|
|
168
187
|
},
|
|
@@ -170,6 +189,7 @@ const staticCursor: Cursor = {
|
|
|
170
189
|
this.assertReadLimit()
|
|
171
190
|
this._touch()
|
|
172
191
|
const value = this.inspectUint24()
|
|
192
|
+
this.assertReadSize(3)
|
|
173
193
|
this.position += 3
|
|
174
194
|
return value
|
|
175
195
|
},
|
|
@@ -177,6 +197,7 @@ const staticCursor: Cursor = {
|
|
|
177
197
|
this.assertReadLimit()
|
|
178
198
|
this._touch()
|
|
179
199
|
const value = this.inspectUint32()
|
|
200
|
+
this.assertReadSize(4)
|
|
180
201
|
this.position += 4
|
|
181
202
|
return value
|
|
182
203
|
},
|
|
@@ -212,6 +233,10 @@ export function create(
|
|
|
212
233
|
)
|
|
213
234
|
cursor.positionReadCount = undefined
|
|
214
235
|
cursor.recursiveReadLimit = recursiveReadLimit
|
|
236
|
+
// `recursiveReadLimit` allows one read per position plus that many repeated
|
|
237
|
+
// reads. Allow as many bytes as that number of 32-byte reads, so that reads
|
|
238
|
+
// of any length are bounded by the size of the data as well.
|
|
239
|
+
cursor.readSizeLimit = 32 * (bytes.length + recursiveReadLimit)
|
|
215
240
|
return cursor
|
|
216
241
|
}
|
|
217
242
|
|
|
@@ -242,6 +267,17 @@ export class PositionOutOfBoundsError extends Errors.BaseError {
|
|
|
242
267
|
}
|
|
243
268
|
}
|
|
244
269
|
|
|
270
|
+
/** @internal */
|
|
271
|
+
export class ReadSizeLimitExceededError extends Errors.BaseError {
|
|
272
|
+
override readonly name = 'Cursor.ReadSizeLimitExceededError'
|
|
273
|
+
|
|
274
|
+
constructor({ limit, size }: { limit: number; size: number }) {
|
|
275
|
+
super(
|
|
276
|
+
`Read size limit of \`${limit}\` bytes exceeded (read size: \`${size}\` bytes).`,
|
|
277
|
+
)
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
245
281
|
/** @internal */
|
|
246
282
|
export class RecursiveReadLimitExceededError extends Errors.BaseError {
|
|
247
283
|
override readonly name = 'Cursor.RecursiveReadLimitExceededError'
|
|
@@ -612,10 +612,9 @@ export function hash<
|
|
|
612
612
|
callGasLimit,
|
|
613
613
|
)
|
|
614
614
|
const gasFees = packUint128Pair(maxPriorityFeePerGas, maxFeePerGas)
|
|
615
|
-
const initCode_hashed =
|
|
616
|
-
factory
|
|
617
|
-
|
|
618
|
-
: EMPTY_KECCAK
|
|
615
|
+
const initCode_hashed = Hash.keccak256(
|
|
616
|
+
toInitCode({ factory, factoryData }),
|
|
617
|
+
)
|
|
619
618
|
const paymasterAndData_hashed = paymaster
|
|
620
619
|
? Hash.keccak256(
|
|
621
620
|
Hex.concat(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Hex, Signature } from 'ox'
|
|
1
|
+
import { AbiParameters, Hash, Hex, Signature } from 'ox'
|
|
2
2
|
import { UserOperation } from 'ox/erc4337'
|
|
3
3
|
import { describe, expect, test } from 'vp/test'
|
|
4
4
|
|
|
@@ -552,6 +552,64 @@ describe('hash', () => {
|
|
|
552
552
|
)
|
|
553
553
|
})
|
|
554
554
|
|
|
555
|
+
test('args: factory without factoryData', () => {
|
|
556
|
+
const userOperation = {
|
|
557
|
+
callData: '0x',
|
|
558
|
+
callGasLimit: 6942069n,
|
|
559
|
+
factory: '0x1234567890123456789012345678901234567890',
|
|
560
|
+
maxFeePerGas: 69420n,
|
|
561
|
+
maxPriorityFeePerGas: 69n,
|
|
562
|
+
nonce: 0n,
|
|
563
|
+
preVerificationGas: 6942069n,
|
|
564
|
+
sender: '0x1234567890123456789012345678901234567890',
|
|
565
|
+
signature: '0x',
|
|
566
|
+
verificationGasLimit: 6942069n,
|
|
567
|
+
} as const
|
|
568
|
+
const options = {
|
|
569
|
+
chainId: 1,
|
|
570
|
+
entryPointAddress: '0x1234567890123456789012345678901234567890',
|
|
571
|
+
entryPointVersion: '0.7',
|
|
572
|
+
} as const
|
|
573
|
+
|
|
574
|
+
// EntryPoint 0.7 `getUserOpHash` over the packed user operation.
|
|
575
|
+
const packed = UserOperation.toPacked(userOperation)
|
|
576
|
+
expect(packed.initCode).toBe(userOperation.factory)
|
|
577
|
+
const expected = Hash.keccak256(
|
|
578
|
+
AbiParameters.encode(AbiParameters.from('bytes32, address, uint256'), [
|
|
579
|
+
Hash.keccak256(
|
|
580
|
+
AbiParameters.encode(
|
|
581
|
+
AbiParameters.from(
|
|
582
|
+
'address, uint256, bytes32, bytes32, bytes32, uint256, bytes32, bytes32',
|
|
583
|
+
),
|
|
584
|
+
[
|
|
585
|
+
packed.sender,
|
|
586
|
+
packed.nonce,
|
|
587
|
+
Hash.keccak256(packed.initCode),
|
|
588
|
+
Hash.keccak256(packed.callData),
|
|
589
|
+
packed.accountGasLimits,
|
|
590
|
+
packed.preVerificationGas,
|
|
591
|
+
packed.gasFees,
|
|
592
|
+
Hash.keccak256(packed.paymasterAndData),
|
|
593
|
+
],
|
|
594
|
+
),
|
|
595
|
+
),
|
|
596
|
+
options.entryPointAddress,
|
|
597
|
+
BigInt(options.chainId),
|
|
598
|
+
]),
|
|
599
|
+
)
|
|
600
|
+
expect(expected).toMatchInlineSnapshot(
|
|
601
|
+
`"0x3990ff4fd5d4f830db9a8a7b75c4c20107d60a58d3819caea8eab03d03fe6ae6"`,
|
|
602
|
+
)
|
|
603
|
+
|
|
604
|
+
expect(UserOperation.hash(userOperation, options)).toBe(expected)
|
|
605
|
+
expect(
|
|
606
|
+
UserOperation.hash({ ...userOperation, factoryData: '0x' }, options),
|
|
607
|
+
).toBe(expected)
|
|
608
|
+
expect(
|
|
609
|
+
UserOperation.hash(UserOperation.fromPacked(packed), options),
|
|
610
|
+
).toBe(expected)
|
|
611
|
+
})
|
|
612
|
+
|
|
555
613
|
test('args: paymaster', () => {
|
|
556
614
|
expect(
|
|
557
615
|
UserOperation.hash(
|
package/src/erc7821/Execute.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as AbiFunction from '../core/AbiFunction.js'
|
|
2
|
+
import * as Errors from '../core/Errors.js'
|
|
2
3
|
import * as Hex from '../core/Hex.js'
|
|
3
4
|
import { AbiParameters } from '../index.js'
|
|
4
5
|
import * as Calls from './Calls.js'
|
|
@@ -42,6 +43,10 @@ export const mode = {
|
|
|
42
43
|
/**
|
|
43
44
|
* Decodes calls from ERC-7821 `execute` function data.
|
|
44
45
|
*
|
|
46
|
+
* Decodes the single batch modes only (`mode.default` and `mode.opData`). Throws
|
|
47
|
+
* `Execute.UnsupportedModeError` for the "batch of batches" mode (use
|
|
48
|
+
* {@link ox#Execute.decodeBatchOfBatchesData} instead) and for unknown modes.
|
|
49
|
+
*
|
|
45
50
|
* @example
|
|
46
51
|
* ```ts twoslash
|
|
47
52
|
* import { Execute } from 'ox/erc7821'
|
|
@@ -57,7 +62,13 @@ export function decodeData(data: Hex.Hex): decodeData.ReturnType {
|
|
|
57
62
|
Hex.Hex,
|
|
58
63
|
Hex.Hex,
|
|
59
64
|
]
|
|
60
|
-
|
|
65
|
+
const name = getModeName(m)
|
|
66
|
+
if (name !== 'default' && name !== 'opData')
|
|
67
|
+
throw new UnsupportedModeError({
|
|
68
|
+
mode: m,
|
|
69
|
+
supported: ['default', 'opData'],
|
|
70
|
+
})
|
|
71
|
+
return Calls.decode(executionData, { opData: name === 'opData' })
|
|
61
72
|
}
|
|
62
73
|
|
|
63
74
|
export declare namespace decodeData {
|
|
@@ -65,11 +76,15 @@ export declare namespace decodeData {
|
|
|
65
76
|
calls: Call[]
|
|
66
77
|
opData?: Hex.Hex | undefined
|
|
67
78
|
}
|
|
79
|
+
|
|
80
|
+
type ErrorType = UnsupportedModeError | Errors.GlobalErrorType
|
|
68
81
|
}
|
|
69
82
|
|
|
70
83
|
/**
|
|
71
84
|
* Decodes batches from ERC-7821 `execute` function data in "batch of batches" mode.
|
|
72
85
|
*
|
|
86
|
+
* Throws `Execute.UnsupportedModeError` for any other mode.
|
|
87
|
+
*
|
|
73
88
|
* @example
|
|
74
89
|
* ```ts twoslash
|
|
75
90
|
* import { Execute } from 'ox/erc7821'
|
|
@@ -83,10 +98,12 @@ export declare namespace decodeData {
|
|
|
83
98
|
export function decodeBatchOfBatchesData(
|
|
84
99
|
data: Hex.Hex,
|
|
85
100
|
): decodeBatchOfBatchesData.ReturnType {
|
|
86
|
-
const [, executionData] = AbiFunction.decodeData(abiFunction, data) as [
|
|
101
|
+
const [m, executionData] = AbiFunction.decodeData(abiFunction, data) as [
|
|
87
102
|
Hex.Hex,
|
|
88
103
|
Hex.Hex,
|
|
89
104
|
]
|
|
105
|
+
if (getModeName(m) !== 'batchOfBatches')
|
|
106
|
+
throw new UnsupportedModeError({ mode: m, supported: ['batchOfBatches'] })
|
|
90
107
|
|
|
91
108
|
const [encodedBatches] = AbiParameters.decode(
|
|
92
109
|
batchesParameters,
|
|
@@ -112,6 +129,8 @@ export function decodeBatchOfBatchesData(
|
|
|
112
129
|
|
|
113
130
|
export declare namespace decodeBatchOfBatchesData {
|
|
114
131
|
type ReturnType = Batch[]
|
|
132
|
+
|
|
133
|
+
type ErrorType = UnsupportedModeError | Errors.GlobalErrorType
|
|
115
134
|
}
|
|
116
135
|
|
|
117
136
|
/**
|
|
@@ -195,3 +214,65 @@ export declare namespace encodeData {
|
|
|
195
214
|
opData?: Hex.Hex | undefined
|
|
196
215
|
}
|
|
197
216
|
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Thrown when the mode of ERC-7821 `execute` function data is not supported by the decoder.
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```ts twoslash
|
|
223
|
+
* import { Execute } from 'ox/erc7821'
|
|
224
|
+
*
|
|
225
|
+
* const data = Execute.encodeBatchOfBatchesData([
|
|
226
|
+
* {
|
|
227
|
+
* calls: [
|
|
228
|
+
* {
|
|
229
|
+
* data: '0xcafebabe',
|
|
230
|
+
* to: '0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef',
|
|
231
|
+
* value: 1n
|
|
232
|
+
* }
|
|
233
|
+
* ]
|
|
234
|
+
* }
|
|
235
|
+
* ])
|
|
236
|
+
*
|
|
237
|
+
* Execute.decodeData(data)
|
|
238
|
+
* // @error: Execute.UnsupportedModeError: Execution mode `0x0100000000007821000200000000000000000000000000000000000000000000` is not supported.
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
export class UnsupportedModeError extends Errors.BaseError {
|
|
242
|
+
override readonly name = 'Execute.UnsupportedModeError'
|
|
243
|
+
|
|
244
|
+
constructor({ mode, supported }: UnsupportedModeError.Options) {
|
|
245
|
+
super(`Execution mode \`${mode}\` is not supported.`, {
|
|
246
|
+
metaMessages: [
|
|
247
|
+
`Supported modes: ${supported.map((name) => `\`${name}\``).join(', ')}.`,
|
|
248
|
+
],
|
|
249
|
+
})
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export declare namespace UnsupportedModeError {
|
|
254
|
+
/** Options for {@link ox#Execute.UnsupportedModeError}. */
|
|
255
|
+
type Options = {
|
|
256
|
+
/** Mode of the `execute` function data. */
|
|
257
|
+
mode: Hex.Hex
|
|
258
|
+
/** Names of the modes (keys of `Execute.mode`) the decoder supports. */
|
|
259
|
+
supported: readonly (keyof typeof mode)[]
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Identifies an ERC-7821 execution mode the way the reference implementation
|
|
265
|
+
* (`_executionModeId`) does. Bytes `[0..1]` (call type and execution type) and
|
|
266
|
+
* bytes `[6..9]` (mode selector) identify the mode. Bytes `[2..5]` (reserved by
|
|
267
|
+
* ERC-7579) and bytes `[10..31]` (unused) are ignored.
|
|
268
|
+
*
|
|
269
|
+
* @internal
|
|
270
|
+
*/
|
|
271
|
+
function getModeName(m: Hex.Hex): keyof typeof mode | undefined {
|
|
272
|
+
if (Hex.slice(m, 0, 2) !== '0x0100') return undefined
|
|
273
|
+
const selector = Hex.slice(m, 6, 10)
|
|
274
|
+
if (selector === '0x00000000') return 'default'
|
|
275
|
+
if (selector === '0x78210001') return 'opData'
|
|
276
|
+
if (selector === '0x78210002') return 'batchOfBatches'
|
|
277
|
+
return undefined
|
|
278
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AbiFunction, AbiParameters } from 'ox'
|
|
2
|
+
import { Calls, Execute } from 'ox/erc7821'
|
|
2
3
|
import { describe, expect, test } from 'vp/test'
|
|
3
4
|
|
|
4
5
|
describe('encodeData', () => {
|
|
@@ -251,6 +252,130 @@ describe('decodeData', () => {
|
|
|
251
252
|
|
|
252
253
|
expect(result).toEqual({ calls })
|
|
253
254
|
})
|
|
255
|
+
|
|
256
|
+
test('behavior: ignores reserved and unused mode bytes', () => {
|
|
257
|
+
const calls = [
|
|
258
|
+
{
|
|
259
|
+
data: '0xdeadbeef',
|
|
260
|
+
to: '0xCafEBAbECAFEbAbEcaFEbabECAfebAbEcAFEBaBe',
|
|
261
|
+
value: 1n,
|
|
262
|
+
},
|
|
263
|
+
] as const
|
|
264
|
+
const opData = '0x1234567890abcdef' as const
|
|
265
|
+
|
|
266
|
+
// Bytes [2..5] are reserved by ERC-7579 and bytes [10..31] are unused.
|
|
267
|
+
expect(
|
|
268
|
+
Execute.decodeData(
|
|
269
|
+
AbiFunction.encodeData(Execute.abiFunction, [
|
|
270
|
+
'0x0100deadbeef00000000ffffffffffffffffffffffffffffffffffffffffffff',
|
|
271
|
+
Calls.encode(calls),
|
|
272
|
+
]),
|
|
273
|
+
),
|
|
274
|
+
).toEqual({ calls })
|
|
275
|
+
expect(
|
|
276
|
+
Execute.decodeData(
|
|
277
|
+
AbiFunction.encodeData(Execute.abiFunction, [
|
|
278
|
+
'0x0100deadbeef78210001ffffffffffffffffffffffffffffffffffffffffffff',
|
|
279
|
+
Calls.encode(calls, { opData }),
|
|
280
|
+
]),
|
|
281
|
+
),
|
|
282
|
+
).toEqual({ calls, opData })
|
|
283
|
+
})
|
|
284
|
+
|
|
285
|
+
test('error: batch of batches mode', () => {
|
|
286
|
+
const executionData = Calls.encode(
|
|
287
|
+
[
|
|
288
|
+
{
|
|
289
|
+
data: '0xdeadbeef',
|
|
290
|
+
to: '0xCafEBAbECAFEbAbEcaFEbabECAfebAbEcAFEBaBe',
|
|
291
|
+
value: 1n,
|
|
292
|
+
},
|
|
293
|
+
],
|
|
294
|
+
{ opData: '0x1234567890abcdef' },
|
|
295
|
+
)
|
|
296
|
+
|
|
297
|
+
expect(() =>
|
|
298
|
+
Execute.decodeData(
|
|
299
|
+
AbiFunction.encodeData(Execute.abiFunction, [
|
|
300
|
+
Execute.mode.batchOfBatches,
|
|
301
|
+
executionData,
|
|
302
|
+
]),
|
|
303
|
+
),
|
|
304
|
+
).toThrowErrorMatchingInlineSnapshot(`
|
|
305
|
+
[Execute.UnsupportedModeError: Execution mode \`0x0100000000007821000200000000000000000000000000000000000000000000\` is not supported.
|
|
306
|
+
|
|
307
|
+
Supported modes: \`default\`, \`opData\`.]
|
|
308
|
+
`)
|
|
309
|
+
expect(() =>
|
|
310
|
+
Execute.decodeData(Execute.encodeBatchOfBatchesData([])),
|
|
311
|
+
).toThrow(Execute.UnsupportedModeError)
|
|
312
|
+
})
|
|
313
|
+
|
|
314
|
+
test('error: unknown mode', () => {
|
|
315
|
+
const executionData = Calls.encode(
|
|
316
|
+
[
|
|
317
|
+
{
|
|
318
|
+
data: '0xdeadbeef',
|
|
319
|
+
to: '0xCafEBAbECAFEbAbEcaFEbabECAfebAbEcAFEBaBe',
|
|
320
|
+
value: 1n,
|
|
321
|
+
},
|
|
322
|
+
],
|
|
323
|
+
{ opData: '0x1234567890abcdef' },
|
|
324
|
+
)
|
|
325
|
+
|
|
326
|
+
// Unknown call type.
|
|
327
|
+
expect(() =>
|
|
328
|
+
Execute.decodeData(
|
|
329
|
+
AbiFunction.encodeData(Execute.abiFunction, [
|
|
330
|
+
'0xff00000000000000000000000000000000000000000000000000000000000000',
|
|
331
|
+
executionData,
|
|
332
|
+
]),
|
|
333
|
+
),
|
|
334
|
+
).toThrowErrorMatchingInlineSnapshot(`
|
|
335
|
+
[Execute.UnsupportedModeError: Execution mode \`0xff00000000000000000000000000000000000000000000000000000000000000\` is not supported.
|
|
336
|
+
|
|
337
|
+
Supported modes: \`default\`, \`opData\`.]
|
|
338
|
+
`)
|
|
339
|
+
// Unknown execution type.
|
|
340
|
+
expect(() =>
|
|
341
|
+
Execute.decodeData(
|
|
342
|
+
AbiFunction.encodeData(Execute.abiFunction, [
|
|
343
|
+
'0x0101000000007821000100000000000000000000000000000000000000000000',
|
|
344
|
+
executionData,
|
|
345
|
+
]),
|
|
346
|
+
),
|
|
347
|
+
).toThrowErrorMatchingInlineSnapshot(`
|
|
348
|
+
[Execute.UnsupportedModeError: Execution mode \`0x0101000000007821000100000000000000000000000000000000000000000000\` is not supported.
|
|
349
|
+
|
|
350
|
+
Supported modes: \`default\`, \`opData\`.]
|
|
351
|
+
`)
|
|
352
|
+
// Unknown mode selector.
|
|
353
|
+
expect(() =>
|
|
354
|
+
Execute.decodeData(
|
|
355
|
+
AbiFunction.encodeData(Execute.abiFunction, [
|
|
356
|
+
'0x0100000000007821000300000000000000000000000000000000000000000000',
|
|
357
|
+
executionData,
|
|
358
|
+
]),
|
|
359
|
+
),
|
|
360
|
+
).toThrowErrorMatchingInlineSnapshot(`
|
|
361
|
+
[Execute.UnsupportedModeError: Execution mode \`0x0100000000007821000300000000000000000000000000000000000000000000\` is not supported.
|
|
362
|
+
|
|
363
|
+
Supported modes: \`default\`, \`opData\`.]
|
|
364
|
+
`)
|
|
365
|
+
})
|
|
366
|
+
|
|
367
|
+
test('error: selector mismatch', () => {
|
|
368
|
+
expect(() =>
|
|
369
|
+
Execute.decodeData(
|
|
370
|
+
'0x095ea7b3000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa960450000000000000000000000000000000000000000000000000000000000000001',
|
|
371
|
+
),
|
|
372
|
+
).toThrowErrorMatchingInlineSnapshot(`
|
|
373
|
+
[AbiFunction.SelectorMismatchError: Selector "0x095ea7b3" does not match the expected selector "0xe9ae5c53".
|
|
374
|
+
|
|
375
|
+
Function: function execute(bytes32 mode, bytes executionData) payable
|
|
376
|
+
Selector: 0xe9ae5c53]
|
|
377
|
+
`)
|
|
378
|
+
})
|
|
254
379
|
})
|
|
255
380
|
|
|
256
381
|
describe('encodeBatchOfBatchesData', () => {
|
|
@@ -545,4 +670,95 @@ describe('decodeBatchOfBatchesData', () => {
|
|
|
545
670
|
|
|
546
671
|
expect(result).toEqual(batches)
|
|
547
672
|
})
|
|
673
|
+
|
|
674
|
+
test('behavior: ignores reserved and unused mode bytes', () => {
|
|
675
|
+
const batches = [
|
|
676
|
+
{
|
|
677
|
+
calls: [
|
|
678
|
+
{
|
|
679
|
+
data: '0xdeadbeef',
|
|
680
|
+
to: '0xCafEBAbECAFEbAbEcaFEbabECAfebAbEcAFEBaBe',
|
|
681
|
+
value: 1n,
|
|
682
|
+
},
|
|
683
|
+
],
|
|
684
|
+
},
|
|
685
|
+
] as const
|
|
686
|
+
|
|
687
|
+
const executionData = AbiParameters.encode(AbiParameters.from('bytes[]'), [
|
|
688
|
+
[Calls.encode(batches[0].calls)],
|
|
689
|
+
])
|
|
690
|
+
|
|
691
|
+
// Bytes [2..5] are reserved by ERC-7579 and bytes [10..31] are unused.
|
|
692
|
+
expect(
|
|
693
|
+
Execute.decodeBatchOfBatchesData(
|
|
694
|
+
AbiFunction.encodeData(Execute.abiFunction, [
|
|
695
|
+
'0x0100deadbeef78210002ffffffffffffffffffffffffffffffffffffffffffff',
|
|
696
|
+
executionData,
|
|
697
|
+
]),
|
|
698
|
+
),
|
|
699
|
+
).toEqual(batches)
|
|
700
|
+
})
|
|
701
|
+
|
|
702
|
+
test('error: single batch mode', () => {
|
|
703
|
+
const executionData = AbiParameters.encode(AbiParameters.from('bytes[]'), [
|
|
704
|
+
[],
|
|
705
|
+
])
|
|
706
|
+
|
|
707
|
+
expect(() =>
|
|
708
|
+
Execute.decodeBatchOfBatchesData(
|
|
709
|
+
AbiFunction.encodeData(Execute.abiFunction, [
|
|
710
|
+
Execute.mode.default,
|
|
711
|
+
executionData,
|
|
712
|
+
]),
|
|
713
|
+
),
|
|
714
|
+
).toThrowErrorMatchingInlineSnapshot(`
|
|
715
|
+
[Execute.UnsupportedModeError: Execution mode \`0x0100000000000000000000000000000000000000000000000000000000000000\` is not supported.
|
|
716
|
+
|
|
717
|
+
Supported modes: \`batchOfBatches\`.]
|
|
718
|
+
`)
|
|
719
|
+
expect(() =>
|
|
720
|
+
Execute.decodeBatchOfBatchesData(
|
|
721
|
+
AbiFunction.encodeData(Execute.abiFunction, [
|
|
722
|
+
Execute.mode.opData,
|
|
723
|
+
executionData,
|
|
724
|
+
]),
|
|
725
|
+
),
|
|
726
|
+
).toThrowErrorMatchingInlineSnapshot(`
|
|
727
|
+
[Execute.UnsupportedModeError: Execution mode \`0x0100000000007821000100000000000000000000000000000000000000000000\` is not supported.
|
|
728
|
+
|
|
729
|
+
Supported modes: \`batchOfBatches\`.]
|
|
730
|
+
`)
|
|
731
|
+
})
|
|
732
|
+
|
|
733
|
+
test('error: unknown mode', () => {
|
|
734
|
+
const executionData = AbiParameters.encode(AbiParameters.from('bytes[]'), [
|
|
735
|
+
[],
|
|
736
|
+
])
|
|
737
|
+
|
|
738
|
+
expect(() =>
|
|
739
|
+
Execute.decodeBatchOfBatchesData(
|
|
740
|
+
AbiFunction.encodeData(Execute.abiFunction, [
|
|
741
|
+
'0xff00000000000000000000000000000000000000000000000000000000000000',
|
|
742
|
+
executionData,
|
|
743
|
+
]),
|
|
744
|
+
),
|
|
745
|
+
).toThrowErrorMatchingInlineSnapshot(`
|
|
746
|
+
[Execute.UnsupportedModeError: Execution mode \`0xff00000000000000000000000000000000000000000000000000000000000000\` is not supported.
|
|
747
|
+
|
|
748
|
+
Supported modes: \`batchOfBatches\`.]
|
|
749
|
+
`)
|
|
750
|
+
})
|
|
751
|
+
|
|
752
|
+
test('error: selector mismatch', () => {
|
|
753
|
+
expect(() =>
|
|
754
|
+
Execute.decodeBatchOfBatchesData(
|
|
755
|
+
'0x095ea7b3000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa960450000000000000000000000000000000000000000000000000000000000000001',
|
|
756
|
+
),
|
|
757
|
+
).toThrowErrorMatchingInlineSnapshot(`
|
|
758
|
+
[AbiFunction.SelectorMismatchError: Selector "0x095ea7b3" does not match the expected selector "0xe9ae5c53".
|
|
759
|
+
|
|
760
|
+
Function: function execute(bytes32 mode, bytes executionData) payable
|
|
761
|
+
Selector: 0xe9ae5c53]
|
|
762
|
+
`)
|
|
763
|
+
})
|
|
548
764
|
})
|
package/src/index.ts
CHANGED
|
@@ -205,7 +205,7 @@ export * as AbiConstructor from './core/AbiConstructor.js'
|
|
|
205
205
|
* const abi = Abi.from([...])
|
|
206
206
|
* const error = AbiError.fromAbi(abi, 'InvalidSignature')
|
|
207
207
|
*
|
|
208
|
-
* const value = AbiError.decode(error, '
|
|
208
|
+
* const value = AbiError.decode(error, '0xe466f0a500000000000000000000000000000000000000000000000000000000000001a400000000000000000000000000000000000000000000000000000000000000450000000000000000000000000000000000000000000000000000000000000001') // [!code focus]
|
|
209
209
|
* // @log: [420n, 69n, 1]
|
|
210
210
|
* ```
|
|
211
211
|
*
|
|
@@ -198,6 +198,44 @@ describe('from', () => {
|
|
|
198
198
|
}).toEqual(limitsVectors)
|
|
199
199
|
})
|
|
200
200
|
|
|
201
|
+
test('error: rejects recipients without a selector', () => {
|
|
202
|
+
const base = { address, chainId: 4217n, type: 'secp256k1' } as const
|
|
203
|
+
const recipients = ['0x1111111111111111111111111111111111111111'] as const
|
|
204
|
+
expect(() =>
|
|
205
|
+
KeyAuthorization.from({
|
|
206
|
+
...base,
|
|
207
|
+
scopes: [{ address: token, recipients }],
|
|
208
|
+
}),
|
|
209
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
210
|
+
`[KeyAuthorization.InvalidScopeError: Scope for \`0x20c0000000000000000000000000000000000001\` has \`recipients\` but no \`selector\`; a recipient allowlist requires a selector.]`,
|
|
211
|
+
)
|
|
212
|
+
expect(() =>
|
|
213
|
+
KeyAuthorization.from({
|
|
214
|
+
...base,
|
|
215
|
+
scopes: [
|
|
216
|
+
{ address: token, selector: 'transfer(address,uint256)' },
|
|
217
|
+
{ address: token, recipients },
|
|
218
|
+
],
|
|
219
|
+
}),
|
|
220
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
221
|
+
`[KeyAuthorization.InvalidScopeError: Scope for \`0x20c0000000000000000000000000000000000001\` has \`recipients\` but no \`selector\`; a recipient allowlist requires a selector.]`,
|
|
222
|
+
)
|
|
223
|
+
expect(
|
|
224
|
+
KeyAuthorization.from({
|
|
225
|
+
...base,
|
|
226
|
+
scopes: [{ address: token, recipients: [] }],
|
|
227
|
+
}).scopes,
|
|
228
|
+
).toMatchInlineSnapshot(`
|
|
229
|
+
[
|
|
230
|
+
{
|
|
231
|
+
"address": "0x20c0000000000000000000000000000000000001",
|
|
232
|
+
"recipients": [],
|
|
233
|
+
"selector": undefined,
|
|
234
|
+
},
|
|
235
|
+
]
|
|
236
|
+
`)
|
|
237
|
+
})
|
|
238
|
+
|
|
201
239
|
test('accepts configurable grants and delegates', () => {
|
|
202
240
|
const signed = KeyAuthorization.from(
|
|
203
241
|
{
|
|
@@ -1488,6 +1526,25 @@ describe('serialize', () => {
|
|
|
1488
1526
|
})
|
|
1489
1527
|
|
|
1490
1528
|
describe('toRpc', () => {
|
|
1529
|
+
test('error: rejects recipients without a selector', () => {
|
|
1530
|
+
expect(() =>
|
|
1531
|
+
KeyAuthorization.toRpc({
|
|
1532
|
+
address,
|
|
1533
|
+
chainId: 4217n,
|
|
1534
|
+
scopes: [
|
|
1535
|
+
{
|
|
1536
|
+
address: token,
|
|
1537
|
+
recipients: ['0x1111111111111111111111111111111111111111'],
|
|
1538
|
+
},
|
|
1539
|
+
],
|
|
1540
|
+
signature: SignatureEnvelope.from(signature_secp256k1),
|
|
1541
|
+
type: 'secp256k1',
|
|
1542
|
+
}),
|
|
1543
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
1544
|
+
`[KeyAuthorization.InvalidScopeError: Scope for \`0x20c0000000000000000000000000000000000001\` has \`recipients\` but no \`selector\`; a recipient allowlist requires a selector.]`,
|
|
1545
|
+
)
|
|
1546
|
+
})
|
|
1547
|
+
|
|
1491
1548
|
test('behavior: configurable key type uses the RPC configurableAccount key type', () => {
|
|
1492
1549
|
const authorization = KeyAuthorization.from(
|
|
1493
1550
|
{ account: address, address, chainId: 1n, type: 'configurable' },
|
|
@@ -1770,6 +1827,40 @@ describe('toRpc', () => {
|
|
|
1770
1827
|
})
|
|
1771
1828
|
|
|
1772
1829
|
describe('toTuple', () => {
|
|
1830
|
+
test('error: rejects recipients without a selector', () => {
|
|
1831
|
+
const authorization = {
|
|
1832
|
+
address,
|
|
1833
|
+
chainId: 4217n,
|
|
1834
|
+
scopes: [
|
|
1835
|
+
{
|
|
1836
|
+
address: token,
|
|
1837
|
+
recipients: ['0x1111111111111111111111111111111111111111'],
|
|
1838
|
+
},
|
|
1839
|
+
],
|
|
1840
|
+
type: 'secp256k1',
|
|
1841
|
+
} as const
|
|
1842
|
+
expect(() =>
|
|
1843
|
+
KeyAuthorization.toTuple(authorization),
|
|
1844
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
1845
|
+
`[KeyAuthorization.InvalidScopeError: Scope for \`0x20c0000000000000000000000000000000000001\` has \`recipients\` but no \`selector\`; a recipient allowlist requires a selector.]`,
|
|
1846
|
+
)
|
|
1847
|
+
expect(() =>
|
|
1848
|
+
KeyAuthorization.getSignPayload(authorization),
|
|
1849
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
1850
|
+
`[KeyAuthorization.InvalidScopeError: Scope for \`0x20c0000000000000000000000000000000000001\` has \`recipients\` but no \`selector\`; a recipient allowlist requires a selector.]`,
|
|
1851
|
+
)
|
|
1852
|
+
expect(() =>
|
|
1853
|
+
KeyAuthorization.hash(authorization),
|
|
1854
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
1855
|
+
`[KeyAuthorization.InvalidScopeError: Scope for \`0x20c0000000000000000000000000000000000001\` has \`recipients\` but no \`selector\`; a recipient allowlist requires a selector.]`,
|
|
1856
|
+
)
|
|
1857
|
+
expect(() =>
|
|
1858
|
+
KeyAuthorization.serialize(authorization),
|
|
1859
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
1860
|
+
`[KeyAuthorization.InvalidScopeError: Scope for \`0x20c0000000000000000000000000000000000001\` has \`recipients\` but no \`selector\`; a recipient allowlist requires a selector.]`,
|
|
1861
|
+
)
|
|
1862
|
+
})
|
|
1863
|
+
|
|
1773
1864
|
test('behavior: round-trips Tempo node limits encoding', () => {
|
|
1774
1865
|
for (const { hash, rlp } of Object.values(limitsVectors)) {
|
|
1775
1866
|
const authorization = KeyAuthorization.fromTuple([
|