ox 1.8.12 → 1.8.14
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 +62 -0
- package/dist/core/AbiError.d.ts +2 -2
- package/dist/core/AbiError.d.ts.map +1 -1
- package/dist/core/AbiError.js +6 -2
- package/dist/core/AbiError.js.map +1 -1
- package/dist/core/AbiEvent.d.ts +71 -1
- package/dist/core/AbiEvent.d.ts.map +1 -1
- package/dist/core/AbiEvent.js +160 -19
- package/dist/core/AbiEvent.js.map +1 -1
- package/dist/core/AbiFunction.d.ts +1 -1
- package/dist/core/AbiFunction.d.ts.map +1 -1
- package/dist/core/AbiFunction.js +3 -5
- package/dist/core/AbiFunction.js.map +1 -1
- package/dist/core/AbiItem.d.ts.map +1 -1
- package/dist/core/AbiItem.js +18 -8
- package/dist/core/AbiItem.js.map +1 -1
- package/dist/core/Base32.d.ts +3 -3
- package/dist/core/Base32.d.ts.map +1 -1
- package/dist/core/Base32.js +5 -2
- package/dist/core/Base32.js.map +1 -1
- package/dist/core/Bytes.d.ts.map +1 -1
- package/dist/core/Bytes.js +4 -3
- package/dist/core/Bytes.js.map +1 -1
- package/dist/core/Caches.d.ts +1 -2
- package/dist/core/Caches.d.ts.map +1 -1
- package/dist/core/Caches.js +1 -4
- package/dist/core/Caches.js.map +1 -1
- package/dist/core/Cbor.d.ts.map +1 -1
- package/dist/core/Cbor.js +16 -2
- package/dist/core/Cbor.js.map +1 -1
- package/dist/core/CompactSize.d.ts +8 -1
- package/dist/core/CompactSize.d.ts.map +1 -1
- package/dist/core/CompactSize.js +9 -0
- package/dist/core/CompactSize.js.map +1 -1
- package/dist/core/Hex.d.ts.map +1 -1
- package/dist/core/Hex.js +9 -4
- package/dist/core/Hex.js.map +1 -1
- package/dist/core/Rlp.d.ts +9 -2
- package/dist/core/Rlp.d.ts.map +1 -1
- package/dist/core/Rlp.js +51 -8
- package/dist/core/Rlp.js.map +1 -1
- package/dist/core/RpcTransport.d.ts.map +1 -1
- package/dist/core/RpcTransport.js +11 -4
- package/dist/core/RpcTransport.js.map +1 -1
- package/dist/core/Siwe.d.ts.map +1 -1
- package/dist/core/Siwe.js +24 -9
- package/dist/core/Siwe.js.map +1 -1
- package/dist/core/TxEnvelope.d.ts.map +1 -1
- package/dist/core/TxEnvelope.js +5 -3
- package/dist/core/TxEnvelope.js.map +1 -1
- package/dist/core/TxEnvelopeEip1559.d.ts.map +1 -1
- package/dist/core/TxEnvelopeEip1559.js +6 -2
- package/dist/core/TxEnvelopeEip1559.js.map +1 -1
- package/dist/core/TxEnvelopeEip4844.d.ts.map +1 -1
- package/dist/core/TxEnvelopeEip4844.js +4 -0
- package/dist/core/TxEnvelopeEip4844.js.map +1 -1
- package/dist/core/TxEnvelopeEip7702.d.ts.map +1 -1
- package/dist/core/TxEnvelopeEip7702.js +4 -0
- package/dist/core/TxEnvelopeEip7702.js.map +1 -1
- package/dist/core/TypedData.d.ts +8 -1
- package/dist/core/TypedData.d.ts.map +1 -1
- package/dist/core/TypedData.js +55 -14
- package/dist/core/TypedData.js.map +1 -1
- package/dist/core/Value.d.ts.map +1 -1
- package/dist/core/Value.js +5 -3
- package/dist/core/Value.js.map +1 -1
- package/dist/core/internal/abiItem.d.ts +3 -1
- package/dist/core/internal/abiItem.d.ts.map +1 -1
- package/dist/core/internal/abiItem.js +46 -13
- package/dist/core/internal/abiItem.js.map +1 -1
- package/dist/core/internal/abiParameters.d.ts +2 -2
- package/dist/core/internal/abiParameters.d.ts.map +1 -1
- package/dist/core/internal/abiParameters.js +24 -7
- package/dist/core/internal/abiParameters.js.map +1 -1
- package/dist/core/internal/caches.d.ts +10 -0
- package/dist/core/internal/caches.d.ts.map +1 -0
- package/dist/core/internal/caches.js +10 -0
- package/dist/core/internal/caches.js.map +1 -0
- package/dist/core/internal/frameNonce.d.ts.map +1 -1
- package/dist/core/internal/frameNonce.js +2 -2
- package/dist/core/internal/frameNonce.js.map +1 -1
- package/dist/core/internal/rpcSchemas/eth.d.ts +3 -2
- package/dist/core/internal/rpcSchemas/eth.d.ts.map +1 -1
- package/dist/erc4337/UserOperation.d.ts +15 -2
- package/dist/erc4337/UserOperation.d.ts.map +1 -1
- package/dist/erc4337/UserOperation.js +8 -2
- package/dist/erc4337/UserOperation.js.map +1 -1
- package/dist/erc8021/Attribution.d.ts.map +1 -1
- package/dist/erc8021/Attribution.js +12 -3
- package/dist/erc8021/Attribution.js.map +1 -1
- package/dist/tempo/AccountOperation.d.ts +8 -0
- package/dist/tempo/AccountOperation.d.ts.map +1 -1
- package/dist/tempo/AccountOperation.js +26 -6
- package/dist/tempo/AccountOperation.js.map +1 -1
- package/dist/tempo/KeyAuthorization.d.ts +21 -6
- package/dist/tempo/KeyAuthorization.d.ts.map +1 -1
- package/dist/tempo/KeyAuthorization.js +7 -4
- package/dist/tempo/KeyAuthorization.js.map +1 -1
- package/dist/tempo/SignatureEnvelope.d.ts +4 -4
- package/dist/tempo/Tick.d.ts.map +1 -1
- package/dist/tempo/Tick.js +4 -3
- package/dist/tempo/Tick.js.map +1 -1
- package/dist/tempo/TxEnvelopeTempo.d.ts.map +1 -1
- package/dist/tempo/TxEnvelopeTempo.js +6 -2
- package/dist/tempo/TxEnvelopeTempo.js.map +1 -1
- package/dist/zod/Address.d.ts.map +1 -1
- package/dist/zod/Address.js +2 -1
- package/dist/zod/Address.js.map +1 -1
- package/dist/zod/FrameRequest.d.ts.map +1 -1
- package/dist/zod/FrameRequest.js +2 -1
- package/dist/zod/FrameRequest.js.map +1 -1
- package/dist/zod/Hex.d.ts.map +1 -1
- package/dist/zod/Hex.js +2 -1
- package/dist/zod/Hex.js.map +1 -1
- package/dist/zod/Solidity.d.ts.map +1 -1
- package/dist/zod/Solidity.js +12 -7
- package/dist/zod/Solidity.js.map +1 -1
- package/dist/zod/TypedData.d.ts +12 -12
- package/package.json +5 -2
- package/src/core/AbiError.ts +33 -22
- package/src/core/AbiEvent.ts +177 -18
- package/src/core/AbiFunction.ts +10 -7
- package/src/core/AbiItem.ts +17 -8
- package/src/core/Base32.ts +8 -3
- package/src/core/Bytes.ts +4 -3
- package/src/core/Caches.ts +1 -6
- package/src/core/Cbor.ts +20 -2
- package/src/core/CompactSize.ts +13 -0
- package/src/core/Hex.ts +10 -5
- package/src/core/Rlp.ts +55 -5
- package/src/core/RpcTransport.ts +11 -4
- package/src/core/Siwe.ts +26 -11
- package/src/core/TxEnvelope.ts +5 -3
- package/src/core/TxEnvelopeEip1559.ts +8 -2
- package/src/core/TxEnvelopeEip4844.ts +6 -0
- package/src/core/TxEnvelopeEip7702.ts +6 -0
- package/src/core/TypedData.ts +62 -13
- package/src/core/Value.ts +6 -3
- package/src/core/_test/AbiError.test-d.ts +10 -0
- package/src/core/_test/AbiError.test.ts +73 -0
- package/src/core/_test/AbiEvent.fuzz.ts +260 -0
- package/src/core/_test/AbiEvent.snap-d.ts +9 -0
- package/src/core/_test/AbiEvent.test.ts +421 -0
- package/src/core/_test/AbiFunction.snap-d.ts +25 -0
- package/src/core/_test/AbiFunction.test.ts +101 -18
- package/src/core/_test/AbiItem.snap-d.ts +11 -0
- package/src/core/_test/AbiItem.test.ts +393 -5
- package/src/core/_test/AbiParameters.decode.test.ts +140 -1
- package/src/core/_test/Base32.test.ts +16 -0
- package/src/core/_test/Bytes.test.ts +15 -0
- package/src/core/_test/Caches.test.ts +10 -1
- package/src/core/_test/Cbor.test.ts +23 -0
- package/src/core/_test/CompactSize.test.ts +14 -0
- package/src/core/_test/Hex.test.ts +25 -0
- package/src/core/_test/Rlp.test.ts +51 -0
- package/src/core/_test/RpcSchema.test-d.ts +23 -1
- package/src/core/_test/RpcTransport.test.ts +47 -0
- package/src/core/_test/Siwe.test.ts +28 -0
- package/src/core/_test/TransactionEnvelopeEip1559.test.ts +24 -0
- package/src/core/_test/TransactionEnvelopeEip4844.test.ts +13 -0
- package/src/core/_test/TransactionEnvelopeEip7702.test.ts +13 -0
- package/src/core/_test/TypedData.test.ts +203 -1
- package/src/core/internal/abiItem.ts +58 -18
- package/src/core/internal/abiParameters.ts +26 -8
- package/src/core/internal/caches.ts +12 -0
- package/src/core/internal/frameNonce.ts +3 -4
- package/src/core/internal/rpcSchemas/eth.ts +2 -1
- package/src/erc4337/UserOperation.ts +30 -3
- package/src/erc4337/_test/UserOperation.test.ts +132 -35
- package/src/erc8021/Attribution.ts +9 -7
- package/src/erc8021/_test/Attribution.test.ts +37 -0
- package/src/tempo/AccountOperation.test.ts +116 -0
- package/src/tempo/AccountOperation.ts +38 -5
- package/src/tempo/AccountSimulation.test.ts +1 -1
- package/src/tempo/KeyAuthorization.test.ts +6 -4
- package/src/tempo/KeyAuthorization.ts +26 -8
- package/src/tempo/SignatureEnvelope.test.ts +12 -0
- package/src/tempo/SignatureEnvelope.ts +4 -4
- package/src/tempo/Tick.test.ts +10 -0
- package/src/tempo/Tick.ts +5 -3
- package/src/tempo/TxEnvelopeTempo.test.ts +26 -0
- package/src/tempo/TxEnvelopeTempo.ts +8 -2
- package/src/tempo/e2e.test.ts +73 -17
- package/src/version.ts +1 -1
- package/src/zod/Address.ts +3 -3
- package/src/zod/FrameRequest.ts +3 -4
- package/src/zod/Hex.ts +3 -1
- package/src/zod/Solidity.ts +15 -18
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
AbiItem,
|
|
6
6
|
AbiParameters,
|
|
7
7
|
Bytes,
|
|
8
|
+
Caches,
|
|
9
|
+
Engine,
|
|
8
10
|
type Hex,
|
|
9
11
|
} from 'ox'
|
|
10
12
|
import { describe, expect, test } from 'vp/test'
|
|
@@ -18,6 +20,7 @@ import {
|
|
|
18
20
|
isArgOfType,
|
|
19
21
|
normalizeSignature,
|
|
20
22
|
} from '../internal/abiItem.js'
|
|
23
|
+
import { caches } from '../internal/caches.js'
|
|
21
24
|
|
|
22
25
|
describe('format', () => {
|
|
23
26
|
test('default', () => {
|
|
@@ -398,6 +401,19 @@ describe('fromAbi', () => {
|
|
|
398
401
|
"inputs": [],
|
|
399
402
|
"name": "foo",
|
|
400
403
|
"outputs": [],
|
|
404
|
+
"overloads": [
|
|
405
|
+
{
|
|
406
|
+
"inputs": [
|
|
407
|
+
{
|
|
408
|
+
"type": "uint256",
|
|
409
|
+
},
|
|
410
|
+
],
|
|
411
|
+
"name": "foo",
|
|
412
|
+
"outputs": [],
|
|
413
|
+
"stateMutability": "nonpayable",
|
|
414
|
+
"type": "function",
|
|
415
|
+
},
|
|
416
|
+
],
|
|
401
417
|
"stateMutability": "nonpayable",
|
|
402
418
|
"type": "function",
|
|
403
419
|
}
|
|
@@ -417,6 +433,19 @@ describe('fromAbi', () => {
|
|
|
417
433
|
"inputs": [],
|
|
418
434
|
"name": "foo",
|
|
419
435
|
"outputs": [],
|
|
436
|
+
"overloads": [
|
|
437
|
+
{
|
|
438
|
+
"inputs": [
|
|
439
|
+
{
|
|
440
|
+
"type": "uint256",
|
|
441
|
+
},
|
|
442
|
+
],
|
|
443
|
+
"name": "foo",
|
|
444
|
+
"outputs": [],
|
|
445
|
+
"stateMutability": "nonpayable",
|
|
446
|
+
"type": "function",
|
|
447
|
+
},
|
|
448
|
+
],
|
|
420
449
|
"stateMutability": "nonpayable",
|
|
421
450
|
"type": "function",
|
|
422
451
|
}
|
|
@@ -524,6 +553,30 @@ describe('fromAbi', () => {
|
|
|
524
553
|
"inputs": [],
|
|
525
554
|
"name": "mint",
|
|
526
555
|
"outputs": [],
|
|
556
|
+
"overloads": [
|
|
557
|
+
{
|
|
558
|
+
"inputs": [
|
|
559
|
+
{
|
|
560
|
+
"type": "uint256",
|
|
561
|
+
},
|
|
562
|
+
],
|
|
563
|
+
"name": "mint",
|
|
564
|
+
"outputs": [],
|
|
565
|
+
"stateMutability": "nonpayable",
|
|
566
|
+
"type": "function",
|
|
567
|
+
},
|
|
568
|
+
{
|
|
569
|
+
"inputs": [
|
|
570
|
+
{
|
|
571
|
+
"type": "string",
|
|
572
|
+
},
|
|
573
|
+
],
|
|
574
|
+
"name": "mint",
|
|
575
|
+
"outputs": [],
|
|
576
|
+
"stateMutability": "nonpayable",
|
|
577
|
+
"type": "function",
|
|
578
|
+
},
|
|
579
|
+
],
|
|
527
580
|
"stateMutability": "nonpayable",
|
|
528
581
|
"type": "function",
|
|
529
582
|
}
|
|
@@ -1021,7 +1074,263 @@ describe('fromAbi', () => {
|
|
|
1021
1074
|
`)
|
|
1022
1075
|
})
|
|
1023
1076
|
|
|
1077
|
+
test('behavior: overloads: bytes32 vs bytes', () => {
|
|
1078
|
+
expect(() =>
|
|
1079
|
+
AbiItem.fromAbi(
|
|
1080
|
+
Abi.from([
|
|
1081
|
+
'function isValidSignature(bytes32 hash, bytes signature)',
|
|
1082
|
+
'function isValidSignature(bytes data, bytes signature)',
|
|
1083
|
+
]),
|
|
1084
|
+
'isValidSignature',
|
|
1085
|
+
{
|
|
1086
|
+
args: [
|
|
1087
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1088
|
+
'0x1234',
|
|
1089
|
+
],
|
|
1090
|
+
},
|
|
1091
|
+
),
|
|
1092
|
+
).toThrowErrorMatchingInlineSnapshot(`
|
|
1093
|
+
[AbiItem.AmbiguityError: Found ambiguous types in overloaded ABI Items.
|
|
1094
|
+
|
|
1095
|
+
\`bytes\` in \`isValidSignature(bytes,bytes)\`, and
|
|
1096
|
+
\`bytes32\` in \`isValidSignature(bytes32,bytes)\`
|
|
1097
|
+
|
|
1098
|
+
These types encode differently and cannot be distinguished at runtime.
|
|
1099
|
+
Remove one of the ambiguous items in the ABI.]
|
|
1100
|
+
`)
|
|
1101
|
+
})
|
|
1102
|
+
|
|
1103
|
+
test('behavior: overloads: string vs bytes', () => {
|
|
1104
|
+
const results = (
|
|
1105
|
+
[
|
|
1106
|
+
['bytes', 'string'],
|
|
1107
|
+
['string', 'bytes'],
|
|
1108
|
+
] as const
|
|
1109
|
+
).map(([first, second]) => [
|
|
1110
|
+
AbiItem.format(
|
|
1111
|
+
AbiItem.fromAbi(
|
|
1112
|
+
Abi.from([`function foo(${first})`, `function foo(${second})`]),
|
|
1113
|
+
'foo',
|
|
1114
|
+
{ args: ['hello'] },
|
|
1115
|
+
),
|
|
1116
|
+
),
|
|
1117
|
+
AbiItem.format(
|
|
1118
|
+
AbiItem.fromAbi(
|
|
1119
|
+
Abi.from([`function foo(${first}[])`, `function foo(${second}[])`]),
|
|
1120
|
+
'foo',
|
|
1121
|
+
{ args: [['hello', 'world']] },
|
|
1122
|
+
),
|
|
1123
|
+
),
|
|
1124
|
+
AbiItem.format(
|
|
1125
|
+
AbiItem.fromAbi(
|
|
1126
|
+
Abi.from([`function foo((${first}))`, `function foo((${second}))`]),
|
|
1127
|
+
'foo',
|
|
1128
|
+
{ args: [['hello']] },
|
|
1129
|
+
),
|
|
1130
|
+
),
|
|
1131
|
+
])
|
|
1132
|
+
|
|
1133
|
+
expect(results).toMatchInlineSnapshot(`
|
|
1134
|
+
[
|
|
1135
|
+
[
|
|
1136
|
+
"function foo(string)",
|
|
1137
|
+
"function foo(string[])",
|
|
1138
|
+
"function foo((string))",
|
|
1139
|
+
],
|
|
1140
|
+
[
|
|
1141
|
+
"function foo(string)",
|
|
1142
|
+
"function foo(string[])",
|
|
1143
|
+
"function foo((string))",
|
|
1144
|
+
],
|
|
1145
|
+
]
|
|
1146
|
+
`)
|
|
1147
|
+
|
|
1148
|
+
expect(() =>
|
|
1149
|
+
AbiItem.fromAbi(
|
|
1150
|
+
Abi.from(['function foo(bytes)', 'function foo(string)']),
|
|
1151
|
+
'foo',
|
|
1152
|
+
{ args: ['0x1234'] },
|
|
1153
|
+
),
|
|
1154
|
+
).toThrowErrorMatchingInlineSnapshot(`
|
|
1155
|
+
[AbiItem.AmbiguityError: Found ambiguous types in overloaded ABI Items.
|
|
1156
|
+
|
|
1157
|
+
\`string\` in \`foo(string)\`, and
|
|
1158
|
+
\`bytes\` in \`foo(bytes)\`
|
|
1159
|
+
|
|
1160
|
+
These types encode differently and cannot be distinguished at runtime.
|
|
1161
|
+
Remove one of the ambiguous items in the ABI.]
|
|
1162
|
+
`)
|
|
1163
|
+
})
|
|
1164
|
+
|
|
1165
|
+
test('behavior: overloads: uint256 vs int256', () => {
|
|
1166
|
+
expect(() =>
|
|
1167
|
+
AbiItem.fromAbi(
|
|
1168
|
+
Abi.from(['function foo(uint256 x)', 'function foo(int256 x)']),
|
|
1169
|
+
'foo',
|
|
1170
|
+
{ args: [1n] },
|
|
1171
|
+
),
|
|
1172
|
+
).toThrowErrorMatchingInlineSnapshot(`
|
|
1173
|
+
[AbiItem.AmbiguityError: Found ambiguous types in overloaded ABI Items.
|
|
1174
|
+
|
|
1175
|
+
\`int256\` in \`foo(int256)\`, and
|
|
1176
|
+
\`uint256\` in \`foo(uint256)\`
|
|
1177
|
+
|
|
1178
|
+
These types encode differently and cannot be distinguished at runtime.
|
|
1179
|
+
Remove one of the ambiguous items in the ABI.]
|
|
1180
|
+
`)
|
|
1181
|
+
|
|
1182
|
+
expect(
|
|
1183
|
+
AbiItem.fromAbi(
|
|
1184
|
+
Abi.from(['function foo(uint256 x)', 'function foo(int256 x)']),
|
|
1185
|
+
'foo',
|
|
1186
|
+
{ args: [-1n] },
|
|
1187
|
+
).inputs,
|
|
1188
|
+
).toMatchInlineSnapshot(`
|
|
1189
|
+
[
|
|
1190
|
+
{
|
|
1191
|
+
"name": "x",
|
|
1192
|
+
"type": "int256",
|
|
1193
|
+
},
|
|
1194
|
+
]
|
|
1195
|
+
`)
|
|
1196
|
+
})
|
|
1197
|
+
|
|
1198
|
+
test('behavior: overloads: uint256[] vs uint256[2]', () => {
|
|
1199
|
+
expect(() =>
|
|
1200
|
+
AbiItem.fromAbi(
|
|
1201
|
+
Abi.from(['function foo(uint256[] x)', 'function foo(uint256[2] x)']),
|
|
1202
|
+
'foo',
|
|
1203
|
+
{ args: [[1n, 1n]] },
|
|
1204
|
+
),
|
|
1205
|
+
).toThrowErrorMatchingInlineSnapshot(`
|
|
1206
|
+
[AbiItem.AmbiguityError: Found ambiguous types in overloaded ABI Items.
|
|
1207
|
+
|
|
1208
|
+
\`uint256[2]\` in \`foo(uint256[2])\`, and
|
|
1209
|
+
\`uint256[]\` in \`foo(uint256[])\`
|
|
1210
|
+
|
|
1211
|
+
These types encode differently and cannot be distinguished at runtime.
|
|
1212
|
+
Remove one of the ambiguous items in the ABI.]
|
|
1213
|
+
`)
|
|
1214
|
+
|
|
1215
|
+
expect(
|
|
1216
|
+
AbiItem.fromAbi(
|
|
1217
|
+
Abi.from(['function foo(uint256[] x)', 'function foo(uint256[2] x)']),
|
|
1218
|
+
'foo',
|
|
1219
|
+
{ args: [[1n, 1n, 1n]] },
|
|
1220
|
+
).inputs,
|
|
1221
|
+
).toMatchInlineSnapshot(`
|
|
1222
|
+
[
|
|
1223
|
+
{
|
|
1224
|
+
"name": "x",
|
|
1225
|
+
"type": "uint256[]",
|
|
1226
|
+
},
|
|
1227
|
+
]
|
|
1228
|
+
`)
|
|
1229
|
+
})
|
|
1230
|
+
|
|
1231
|
+
test('behavior: overloads: uint256[2][] vs uint256[][2]', () => {
|
|
1232
|
+
expect(() =>
|
|
1233
|
+
AbiItem.fromAbi(
|
|
1234
|
+
Abi.from([
|
|
1235
|
+
'function foo(uint256[2][] x)',
|
|
1236
|
+
'function foo(uint256[][2] x)',
|
|
1237
|
+
]),
|
|
1238
|
+
'foo',
|
|
1239
|
+
{
|
|
1240
|
+
args: [
|
|
1241
|
+
[
|
|
1242
|
+
[1n, 1n],
|
|
1243
|
+
[1n, 1n],
|
|
1244
|
+
],
|
|
1245
|
+
],
|
|
1246
|
+
},
|
|
1247
|
+
),
|
|
1248
|
+
).toThrowErrorMatchingInlineSnapshot(`
|
|
1249
|
+
[AbiItem.AmbiguityError: Found ambiguous types in overloaded ABI Items.
|
|
1250
|
+
|
|
1251
|
+
\`uint256[]\` in \`foo(uint256[][2])\`, and
|
|
1252
|
+
\`uint256[2]\` in \`foo(uint256[2][])\`
|
|
1253
|
+
|
|
1254
|
+
These types encode differently and cannot be distinguished at runtime.
|
|
1255
|
+
Remove one of the ambiguous items in the ABI.]
|
|
1256
|
+
`)
|
|
1257
|
+
})
|
|
1258
|
+
|
|
1259
|
+
test('behavior: overloads: selector chooses one of two matches', () => {
|
|
1260
|
+
expect(
|
|
1261
|
+
AbiItem.fromAbi(
|
|
1262
|
+
Abi.from([
|
|
1263
|
+
'function isValidSignature(bytes32 hash, bytes signature)',
|
|
1264
|
+
'function isValidSignature(bytes data, bytes signature)',
|
|
1265
|
+
]),
|
|
1266
|
+
'0x1626ba7e',
|
|
1267
|
+
{
|
|
1268
|
+
args: [
|
|
1269
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1270
|
+
'0x1234',
|
|
1271
|
+
],
|
|
1272
|
+
},
|
|
1273
|
+
).inputs,
|
|
1274
|
+
).toMatchInlineSnapshot(`
|
|
1275
|
+
[
|
|
1276
|
+
{
|
|
1277
|
+
"name": "hash",
|
|
1278
|
+
"type": "bytes32",
|
|
1279
|
+
},
|
|
1280
|
+
{
|
|
1281
|
+
"name": "signature",
|
|
1282
|
+
"type": "bytes",
|
|
1283
|
+
},
|
|
1284
|
+
]
|
|
1285
|
+
`)
|
|
1286
|
+
})
|
|
1287
|
+
|
|
1024
1288
|
describe('getAmbiguousTypes', () => {
|
|
1289
|
+
test('bytes', () => {
|
|
1290
|
+
expect(
|
|
1291
|
+
getAmbiguousTypes(
|
|
1292
|
+
AbiParameters.from('bytes32'),
|
|
1293
|
+
AbiParameters.from('bytes'),
|
|
1294
|
+
[
|
|
1295
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1296
|
+
],
|
|
1297
|
+
),
|
|
1298
|
+
).toMatchInlineSnapshot(`
|
|
1299
|
+
[
|
|
1300
|
+
"bytes32",
|
|
1301
|
+
"bytes",
|
|
1302
|
+
]
|
|
1303
|
+
`)
|
|
1304
|
+
})
|
|
1305
|
+
|
|
1306
|
+
test('integers', () => {
|
|
1307
|
+
expect(
|
|
1308
|
+
getAmbiguousTypes(
|
|
1309
|
+
AbiParameters.from('uint256'),
|
|
1310
|
+
AbiParameters.from('int256'),
|
|
1311
|
+
[1n],
|
|
1312
|
+
),
|
|
1313
|
+
).toMatchInlineSnapshot(`
|
|
1314
|
+
[
|
|
1315
|
+
"uint256",
|
|
1316
|
+
"int256",
|
|
1317
|
+
]
|
|
1318
|
+
`)
|
|
1319
|
+
|
|
1320
|
+
expect(
|
|
1321
|
+
getAmbiguousTypes(
|
|
1322
|
+
AbiParameters.from('uint256'),
|
|
1323
|
+
AbiParameters.from('uint128'),
|
|
1324
|
+
[69420n],
|
|
1325
|
+
),
|
|
1326
|
+
).toMatchInlineSnapshot(`
|
|
1327
|
+
[
|
|
1328
|
+
"uint256",
|
|
1329
|
+
"uint128",
|
|
1330
|
+
]
|
|
1331
|
+
`)
|
|
1332
|
+
})
|
|
1333
|
+
|
|
1025
1334
|
test('string/address', () => {
|
|
1026
1335
|
expect(
|
|
1027
1336
|
getAmbiguousTypes(
|
|
@@ -1163,7 +1472,7 @@ describe('fromAbi', () => {
|
|
|
1163
1472
|
expect(
|
|
1164
1473
|
getAmbiguousTypes(
|
|
1165
1474
|
AbiParameters.from('uint256, (address)'),
|
|
1166
|
-
AbiParameters.from('
|
|
1475
|
+
AbiParameters.from('uint256, (bytes20)'),
|
|
1167
1476
|
[69420n, ['0xA0Cf798816D4b9b9866b5330EEa46a18382f251e']],
|
|
1168
1477
|
),
|
|
1169
1478
|
).toMatchInlineSnapshot(`
|
|
@@ -1175,7 +1484,7 @@ describe('fromAbi', () => {
|
|
|
1175
1484
|
expect(
|
|
1176
1485
|
getAmbiguousTypes(
|
|
1177
1486
|
AbiParameters.from('uint256, (string, (address))'),
|
|
1178
|
-
AbiParameters.from('
|
|
1487
|
+
AbiParameters.from('uint256, (string, (bytes20))'),
|
|
1179
1488
|
[69420n, ['foo', ['0xA0Cf798816D4b9b9866b5330EEa46a18382f251e']]],
|
|
1180
1489
|
),
|
|
1181
1490
|
).toMatchInlineSnapshot(`
|
|
@@ -1187,7 +1496,7 @@ describe('fromAbi', () => {
|
|
|
1187
1496
|
expect(
|
|
1188
1497
|
getAmbiguousTypes(
|
|
1189
1498
|
AbiParameters.from('uint256, (string, (address, bytes))'),
|
|
1190
|
-
AbiParameters.from('
|
|
1499
|
+
AbiParameters.from('uint256, (string, (bytes20, address))'),
|
|
1191
1500
|
[
|
|
1192
1501
|
123n,
|
|
1193
1502
|
[
|
|
@@ -1359,8 +1668,21 @@ describe('fromAbi', () => {
|
|
|
1359
1668
|
{ arg: false, abiParameter: { type: 'bool' }, expected: true },
|
|
1360
1669
|
{ arg: 'true', abiParameter: { type: 'bool' }, expected: false },
|
|
1361
1670
|
// bytes
|
|
1362
|
-
{ arg: 'foo', abiParameter: { type: 'bytes' }, expected:
|
|
1363
|
-
{ arg: '
|
|
1671
|
+
{ arg: 'foo', abiParameter: { type: 'bytes' }, expected: false },
|
|
1672
|
+
{ arg: '0x1234', abiParameter: { type: 'bytes' }, expected: true },
|
|
1673
|
+
{ arg: 'foo', abiParameter: { type: 'bytes32' }, expected: false },
|
|
1674
|
+
{ arg: '0x1234', abiParameter: { type: 'bytes2' }, expected: true },
|
|
1675
|
+
{ arg: '0x1234', abiParameter: { type: 'bytes4' }, expected: false },
|
|
1676
|
+
{
|
|
1677
|
+
arg: Bytes.fromString('foo'),
|
|
1678
|
+
abiParameter: { type: 'bytes3' },
|
|
1679
|
+
expected: true,
|
|
1680
|
+
},
|
|
1681
|
+
{
|
|
1682
|
+
arg: Bytes.fromString('foo'),
|
|
1683
|
+
abiParameter: { type: 'bytes4' },
|
|
1684
|
+
expected: false,
|
|
1685
|
+
},
|
|
1364
1686
|
{
|
|
1365
1687
|
arg: Bytes.fromString('foo'),
|
|
1366
1688
|
abiParameter: { type: 'bytes' },
|
|
@@ -1377,10 +1699,42 @@ describe('fromAbi', () => {
|
|
|
1377
1699
|
{ arg: 1, abiParameter: { type: 'uint' }, expected: true },
|
|
1378
1700
|
{ arg: 1n, abiParameter: { type: 'uint' }, expected: true },
|
|
1379
1701
|
{ arg: 1n, abiParameter: { type: 'uint' }, expected: true },
|
|
1702
|
+
{ arg: 2n ** 256n - 1n, abiParameter: { type: 'uint' }, expected: true },
|
|
1703
|
+
{ arg: 2n ** 256n, abiParameter: { type: 'uint' }, expected: false },
|
|
1704
|
+
{ arg: -(2n ** 255n), abiParameter: { type: 'int' }, expected: true },
|
|
1705
|
+
{ arg: 2n ** 255n, abiParameter: { type: 'int' }, expected: false },
|
|
1380
1706
|
{ arg: 1, abiParameter: { type: 'int256' }, expected: true },
|
|
1381
1707
|
{ arg: 1, abiParameter: { type: 'uint256' }, expected: true },
|
|
1382
1708
|
{ arg: 1, abiParameter: { type: 'int69' }, expected: false },
|
|
1383
1709
|
{ arg: 1, abiParameter: { type: 'uint69' }, expected: false },
|
|
1710
|
+
{ arg: -129, abiParameter: { type: 'int8' }, expected: false },
|
|
1711
|
+
{ arg: -128, abiParameter: { type: 'int8' }, expected: true },
|
|
1712
|
+
{ arg: 127, abiParameter: { type: 'int8' }, expected: true },
|
|
1713
|
+
{ arg: 128, abiParameter: { type: 'int8' }, expected: false },
|
|
1714
|
+
{ arg: -1n, abiParameter: { type: 'uint8' }, expected: false },
|
|
1715
|
+
{ arg: 0n, abiParameter: { type: 'uint8' }, expected: true },
|
|
1716
|
+
{ arg: 255n, abiParameter: { type: 'uint8' }, expected: true },
|
|
1717
|
+
{ arg: 256n, abiParameter: { type: 'uint8' }, expected: false },
|
|
1718
|
+
{ arg: 2n ** 256n - 1n, abiParameter: { type: 'uint256' }, expected: true },
|
|
1719
|
+
{ arg: 2n ** 256n, abiParameter: { type: 'uint256' }, expected: false },
|
|
1720
|
+
{ arg: -(2n ** 255n), abiParameter: { type: 'int256' }, expected: true },
|
|
1721
|
+
{
|
|
1722
|
+
arg: -(2n ** 255n) - 1n,
|
|
1723
|
+
abiParameter: { type: 'int256' },
|
|
1724
|
+
expected: false,
|
|
1725
|
+
},
|
|
1726
|
+
{ arg: Number.NaN, abiParameter: { type: 'uint256' }, expected: false },
|
|
1727
|
+
{
|
|
1728
|
+
arg: Number.POSITIVE_INFINITY,
|
|
1729
|
+
abiParameter: { type: 'uint256' },
|
|
1730
|
+
expected: false,
|
|
1731
|
+
},
|
|
1732
|
+
{ arg: 1.5, abiParameter: { type: 'uint256' }, expected: false },
|
|
1733
|
+
{
|
|
1734
|
+
arg: Number.MAX_SAFE_INTEGER + 1,
|
|
1735
|
+
abiParameter: { type: 'uint256' },
|
|
1736
|
+
expected: true,
|
|
1737
|
+
},
|
|
1384
1738
|
// string
|
|
1385
1739
|
{ arg: 'foo', abiParameter: { type: 'string' }, expected: true },
|
|
1386
1740
|
{ arg: 1, abiParameter: { type: 'string' }, expected: false },
|
|
@@ -2252,6 +2606,40 @@ describe('getSignature', () => {
|
|
|
2252
2606
|
})
|
|
2253
2607
|
|
|
2254
2608
|
describe('getSignatureHash', () => {
|
|
2609
|
+
test('behavior: caches by normalized signature', () => {
|
|
2610
|
+
Caches.clear()
|
|
2611
|
+
const hash = AbiItem.getSignatureHash('function ownerOf(uint256 tokenId)')
|
|
2612
|
+
expect(
|
|
2613
|
+
AbiItem.getSignatureHash({
|
|
2614
|
+
inputs: [{ name: 'id', type: 'uint256' }],
|
|
2615
|
+
name: 'ownerOf',
|
|
2616
|
+
outputs: [],
|
|
2617
|
+
stateMutability: 'view',
|
|
2618
|
+
type: 'function',
|
|
2619
|
+
}),
|
|
2620
|
+
).toBe(hash)
|
|
2621
|
+
expect([...caches.signatureHash]).toMatchInlineSnapshot(`
|
|
2622
|
+
[
|
|
2623
|
+
[
|
|
2624
|
+
"ownerOf(uint256)",
|
|
2625
|
+
"0x6352211e6566aa027e75ac9dbf2423197fbd9b82b9d981a3ab367d355866aa1c",
|
|
2626
|
+
],
|
|
2627
|
+
]
|
|
2628
|
+
`)
|
|
2629
|
+
})
|
|
2630
|
+
|
|
2631
|
+
test('behavior: recomputes after an engine change', () => {
|
|
2632
|
+
const hash = AbiItem.getSignatureHash('function ownerOf(uint256)')
|
|
2633
|
+
expect(
|
|
2634
|
+
Engine.with({ Hash: { keccak256: () => new Uint8Array(32) } }, () =>
|
|
2635
|
+
AbiItem.getSignatureHash('function ownerOf(uint256)'),
|
|
2636
|
+
),
|
|
2637
|
+
).toMatchInlineSnapshot(
|
|
2638
|
+
`"0x0000000000000000000000000000000000000000000000000000000000000000"`,
|
|
2639
|
+
)
|
|
2640
|
+
expect(AbiItem.getSignatureHash('function ownerOf(uint256)')).toBe(hash)
|
|
2641
|
+
})
|
|
2642
|
+
|
|
2255
2643
|
test('hashes functions', () => {
|
|
2256
2644
|
expect(AbiItem.getSignatureHash('function ownerOf(uint256)')).toEqual(
|
|
2257
2645
|
'0x6352211e6566aa027e75ac9dbf2423197fbd9b82b9d981a3ab367d355866aa1c',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AbiItem, AbiParameters,
|
|
1
|
+
import { AbiItem, AbiParameters, Address, Bytes, Hex } from 'ox'
|
|
2
2
|
import { assertType, describe, expect, test } from 'vp/test'
|
|
3
3
|
|
|
4
4
|
import {
|
|
@@ -1887,3 +1887,142 @@ describe('zero-width types', () => {
|
|
|
1887
1887
|
}
|
|
1888
1888
|
})
|
|
1889
1889
|
})
|
|
1890
|
+
|
|
1891
|
+
describe('integer range', () => {
|
|
1892
|
+
test('uint8: max', () => {
|
|
1893
|
+
expect(
|
|
1894
|
+
AbiParameters.decode(
|
|
1895
|
+
AbiParameters.from('uint8'),
|
|
1896
|
+
'0x00000000000000000000000000000000000000000000000000000000000000ff',
|
|
1897
|
+
),
|
|
1898
|
+
).toEqual([255])
|
|
1899
|
+
})
|
|
1900
|
+
|
|
1901
|
+
test('uint8: above max', () => {
|
|
1902
|
+
expect(() =>
|
|
1903
|
+
AbiParameters.decode(
|
|
1904
|
+
AbiParameters.from('uint8'),
|
|
1905
|
+
'0x0000000000000000000000000000000000000000000000000000000000000100',
|
|
1906
|
+
),
|
|
1907
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
1908
|
+
`[Hex.IntegerOutOfRangeError: Number \`256\` is not in safe 8-bit unsigned integer range (\`0\` to \`255\`)]`,
|
|
1909
|
+
)
|
|
1910
|
+
})
|
|
1911
|
+
|
|
1912
|
+
test('int8: -1', () => {
|
|
1913
|
+
expect(
|
|
1914
|
+
AbiParameters.decode(
|
|
1915
|
+
AbiParameters.from('int8'),
|
|
1916
|
+
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
|
1917
|
+
),
|
|
1918
|
+
).toEqual([-1])
|
|
1919
|
+
})
|
|
1920
|
+
|
|
1921
|
+
test('int8: missing sign extension', () => {
|
|
1922
|
+
expect(() =>
|
|
1923
|
+
AbiParameters.decode(
|
|
1924
|
+
AbiParameters.from('int8'),
|
|
1925
|
+
'0x0000000000000000000000000000000000000000000000000000000000000080',
|
|
1926
|
+
),
|
|
1927
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
1928
|
+
`[Hex.IntegerOutOfRangeError: Number \`128\` is not in safe 8-bit signed integer range (\`-128\` to \`127\`)]`,
|
|
1929
|
+
)
|
|
1930
|
+
})
|
|
1931
|
+
|
|
1932
|
+
test('int8: below min', () => {
|
|
1933
|
+
expect(() =>
|
|
1934
|
+
AbiParameters.decode(
|
|
1935
|
+
AbiParameters.from('int8'),
|
|
1936
|
+
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f',
|
|
1937
|
+
),
|
|
1938
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
1939
|
+
`[Hex.IntegerOutOfRangeError: Number \`-129\` is not in safe 8-bit signed integer range (\`-128\` to \`127\`)]`,
|
|
1940
|
+
)
|
|
1941
|
+
})
|
|
1942
|
+
|
|
1943
|
+
test('uint8[]: element above max', () => {
|
|
1944
|
+
expect(() =>
|
|
1945
|
+
AbiParameters.decode(
|
|
1946
|
+
AbiParameters.from('uint8[]'),
|
|
1947
|
+
'0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000100',
|
|
1948
|
+
),
|
|
1949
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
1950
|
+
`[Hex.IntegerOutOfRangeError: Number \`256\` is not in safe 8-bit unsigned integer range (\`0\` to \`255\`)]`,
|
|
1951
|
+
)
|
|
1952
|
+
})
|
|
1953
|
+
|
|
1954
|
+
test('uint16: 2^64', () => {
|
|
1955
|
+
expect(() =>
|
|
1956
|
+
AbiParameters.decode(
|
|
1957
|
+
AbiParameters.from('uint16'),
|
|
1958
|
+
'0x0000000000000000000000000000000000000000000000010000000000000000',
|
|
1959
|
+
),
|
|
1960
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
1961
|
+
`[Hex.IntegerOutOfRangeError: Number \`18446744073709551616\` is not in safe 16-bit unsigned integer range (\`0\` to \`65535\`)]`,
|
|
1962
|
+
)
|
|
1963
|
+
})
|
|
1964
|
+
|
|
1965
|
+
test('every size: min and max round-trip, out of range throws', () => {
|
|
1966
|
+
for (let size = 8; size <= 256; size += 8) {
|
|
1967
|
+
for (const signed of [false, true]) {
|
|
1968
|
+
const type = (signed ? 'int' : 'uint') + size
|
|
1969
|
+
const parameters = AbiParameters.from(type)
|
|
1970
|
+
const max = (1n << BigInt(signed ? size - 1 : size)) - 1n
|
|
1971
|
+
const min = signed ? -max - 1n : 0n
|
|
1972
|
+
const cast = (value: bigint) => (size > 48 ? value : Number(value))
|
|
1973
|
+
|
|
1974
|
+
for (const value of [min, max])
|
|
1975
|
+
expect(
|
|
1976
|
+
AbiParameters.decode(
|
|
1977
|
+
parameters,
|
|
1978
|
+
AbiParameters.encode(parameters, [cast(value)] as never),
|
|
1979
|
+
),
|
|
1980
|
+
).toEqual([cast(value)])
|
|
1981
|
+
|
|
1982
|
+
if (size === 256) continue
|
|
1983
|
+
const word = (value: bigint) =>
|
|
1984
|
+
Hex.fromNumber(BigInt.asUintN(256, value), { size: 32 })
|
|
1985
|
+
expect(() => AbiParameters.decode(parameters, word(max + 1n))).toThrow(
|
|
1986
|
+
Hex.IntegerOutOfRangeError,
|
|
1987
|
+
)
|
|
1988
|
+
if (signed)
|
|
1989
|
+
expect(() =>
|
|
1990
|
+
AbiParameters.decode(parameters, word(min - 1n)),
|
|
1991
|
+
).toThrow(Hex.IntegerOutOfRangeError)
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1994
|
+
})
|
|
1995
|
+
})
|
|
1996
|
+
|
|
1997
|
+
describe('address padding', () => {
|
|
1998
|
+
test('dirty high bytes', () => {
|
|
1999
|
+
expect(() =>
|
|
2000
|
+
AbiParameters.decode(
|
|
2001
|
+
AbiParameters.from('address'),
|
|
2002
|
+
'0x00000000000000000000000114dc79964da2c08b23698b3d3cc7ca32193d9955',
|
|
2003
|
+
),
|
|
2004
|
+
).toThrowErrorMatchingInlineSnapshot(`
|
|
2005
|
+
[Address.InvalidAddressError: Address "0x00000000000000000000000114dc79964da2c08b23698b3d3cc7ca32193d9955" is invalid.
|
|
2006
|
+
|
|
2007
|
+
Details: Address is not a 20 byte (40 hexadecimal character) value.]
|
|
2008
|
+
`)
|
|
2009
|
+
})
|
|
2010
|
+
|
|
2011
|
+
test('dirty first byte', () => {
|
|
2012
|
+
expect(() =>
|
|
2013
|
+
AbiParameters.decode(
|
|
2014
|
+
AbiParameters.from('address'),
|
|
2015
|
+
'0xff000000000000000000000014dc79964da2c08b23698b3d3cc7ca32193d9955',
|
|
2016
|
+
),
|
|
2017
|
+
).toThrow(Address.InvalidAddressError)
|
|
2018
|
+
})
|
|
2019
|
+
|
|
2020
|
+
test('address[2]: second element dirty', () => {
|
|
2021
|
+
expect(() =>
|
|
2022
|
+
AbiParameters.decode(
|
|
2023
|
+
AbiParameters.from('address[2]'),
|
|
2024
|
+
'0x00000000000000000000000014dc79964da2c08b23698b3d3cc7ca32193d99550000000000000000000000ff14dc79964da2c08b23698b3d3cc7ca32193d9955',
|
|
2025
|
+
),
|
|
2026
|
+
).toThrow(Address.InvalidAddressError)
|
|
2027
|
+
})
|
|
2028
|
+
})
|
|
@@ -44,6 +44,22 @@ describe('toBytes', () => {
|
|
|
44
44
|
`[Base32.InvalidCharacterError: Invalid bech32 base32 character: "b".]`,
|
|
45
45
|
)
|
|
46
46
|
})
|
|
47
|
+
|
|
48
|
+
test('error: non-zero trailing bits', () => {
|
|
49
|
+
// `qrlsq` encodes 0x00ff00; `qrlsp` sets a trailing bit below the byte boundary.
|
|
50
|
+
expect(() => Base32.toBytes('qrlsp')).toThrowErrorMatchingInlineSnapshot(
|
|
51
|
+
`[Base32.InvalidPaddingError: Non-canonical trailing bits in Base32 input.]`,
|
|
52
|
+
)
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
test('error: invalid length', () => {
|
|
56
|
+
expect(() => Base32.toBytes('q')).toThrowErrorMatchingInlineSnapshot(
|
|
57
|
+
`[Base32.InvalidPaddingError: Non-canonical trailing bits in Base32 input.]`,
|
|
58
|
+
)
|
|
59
|
+
expect(() => Base32.toBytes('qqq')).toThrowErrorMatchingInlineSnapshot(
|
|
60
|
+
`[Base32.InvalidPaddingError: Non-canonical trailing bits in Base32 input.]`,
|
|
61
|
+
)
|
|
62
|
+
})
|
|
47
63
|
})
|
|
48
64
|
|
|
49
65
|
describe('toHex', () => {
|
|
@@ -293,6 +293,21 @@ describe('fromHex', () => {
|
|
|
293
293
|
)
|
|
294
294
|
})
|
|
295
295
|
|
|
296
|
+
test('behavior: odd length with size', () => {
|
|
297
|
+
expect(Bytes.fromHex('0x1', { size: 2 })).toMatchInlineSnapshot(`
|
|
298
|
+
Uint8Array [
|
|
299
|
+
1,
|
|
300
|
+
0,
|
|
301
|
+
]
|
|
302
|
+
`)
|
|
303
|
+
expect(Bytes.fromHex('0xabc', { size: 2 })).toMatchInlineSnapshot(`
|
|
304
|
+
Uint8Array [
|
|
305
|
+
10,
|
|
306
|
+
188,
|
|
307
|
+
]
|
|
308
|
+
`)
|
|
309
|
+
})
|
|
310
|
+
|
|
296
311
|
test('error: size overflow', () => {
|
|
297
312
|
expect(() =>
|
|
298
313
|
Bytes.fromHex('0x48656c6c6f20576f726c6421', { size: 8 }),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Caches } from 'ox'
|
|
1
|
+
import { AbiItem, Caches } from 'ox'
|
|
2
2
|
import { expect, test } from 'vp/test'
|
|
3
|
+
import { caches } from '../internal/caches.js'
|
|
3
4
|
|
|
4
5
|
test('exports', () => {
|
|
5
6
|
expect(Object.keys(Caches)).toMatchInlineSnapshot(`
|
|
@@ -18,3 +19,11 @@ test('default', () => {
|
|
|
18
19
|
Caches.clear()
|
|
19
20
|
expect(Caches.checksum.size).toBe(0)
|
|
20
21
|
})
|
|
22
|
+
|
|
23
|
+
test('behavior: clears signature hashes', () => {
|
|
24
|
+
Caches.clear()
|
|
25
|
+
AbiItem.getSignatureHash('function ownerOf(uint256)')
|
|
26
|
+
expect(caches.signatureHash.size).toBe(1)
|
|
27
|
+
Caches.clear()
|
|
28
|
+
expect(caches.signatureHash.size).toBe(0)
|
|
29
|
+
})
|