ox 1.8.13 → 1.8.15
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 +52 -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/TypedData.d.ts.map +1 -1
- package/dist/core/TypedData.js +13 -9
- 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 +5 -3
- package/dist/core/internal/abiItem.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/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/SignatureEnvelope.d.ts +4 -4
- 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/Tick.d.ts.map +1 -1
- package/dist/tempo/Tick.js +4 -3
- package/dist/tempo/Tick.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/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 +6 -1
- 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/TypedData.ts +14 -9
- 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 +155 -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/RpcTransport.test.ts +47 -0
- package/src/core/_test/Siwe.test.ts +28 -0
- package/src/core/_test/TypedData.test.ts +17 -2
- package/src/core/internal/abiItem.ts +16 -7
- package/src/core/internal/caches.ts +12 -0
- package/src/core/internal/frameNonce.ts +3 -4
- 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/SignatureEnvelope.test.ts +12 -0
- package/src/tempo/SignatureEnvelope.ts +4 -4
- 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/Tick.test.ts +10 -0
- package/src/tempo/Tick.ts +5 -3
- package/src/tempo/index.ts +26 -0
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FrameRequest.d.ts","sourceRoot":"","sources":["../../src/zod/FrameRequest.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"FrameRequest.d.ts","sourceRoot":"","sources":["../../src/zod/FrameRequest.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAA;AA6B7B,mFAAmF;AACnF,eAAO,MAAM,YAAY;;;;;;;;mOAGvB,CAAA;AAEF,yEAAyE;AACzE,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;kBAG5B,CAAA"}
|
package/dist/zod/FrameRequest.js
CHANGED
|
@@ -4,7 +4,8 @@ import * as z_Address from './Address.js';
|
|
|
4
4
|
import * as z_Frame from './Frame.js';
|
|
5
5
|
import * as z_Hex from './Hex.js';
|
|
6
6
|
import * as z from 'zod/mini';
|
|
7
|
-
const
|
|
7
|
+
const quantityRegex = /^0x(0|[1-9a-f][0-9a-f]*)$/;
|
|
8
|
+
const quantity = z_Hex.Hex.check(z.refine((value) => quantityRegex.test(value), 'Invalid RPC quantity'));
|
|
8
9
|
const rpc = z
|
|
9
10
|
.object({
|
|
10
11
|
data: z.optional(z_Hex.Hex),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FrameRequest.js","sourceRoot":"","sources":["../../src/zod/FrameRequest.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,OAAO,KAAK,iBAAiB,MAAM,yBAAyB,CAAA;AAC5D,OAAO,KAAK,SAAS,MAAM,cAAc,CAAA;AACzC,OAAO,KAAK,OAAO,MAAM,YAAY,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,UAAU,CAAA;AACjC,OAAO,KAAK,CAAC,MAAM,UAAU,CAAA;AAE7B,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAC9B,CAAC,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"FrameRequest.js","sourceRoot":"","sources":["../../src/zod/FrameRequest.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,OAAO,KAAK,iBAAiB,MAAM,yBAAyB,CAAA;AAC5D,OAAO,KAAK,SAAS,MAAM,cAAc,CAAA;AACzC,OAAO,KAAK,OAAO,MAAM,YAAY,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,UAAU,CAAA;AACjC,OAAO,KAAK,CAAC,MAAM,UAAU,CA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MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,YAAY,EAAE;IAClE,MAAM,EAAE,iBAAiB,CAAC,OAAO;IACjC,MAAM,EAAE,iBAAiB,CAAC,KAAK;CAChC,CAAC,CAAA"}
|
package/dist/zod/Hex.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Hex.d.ts","sourceRoot":"","sources":["../../src/zod/Hex.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"Hex.d.ts","sourceRoot":"","sources":["../../src/zod/Hex.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAA;AAI7B,yBAAyB;AACzB,eAAO,MAAM,GAAG,yCAEmD,CAAA;AAEnE,8CAA8C;AAC9C,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,2CAOpC;AAED,gCAAgC;AAChC,eAAO,MAAM,IAAI,yCAAc,CAAA;AAC/B,gCAAgC;AAChC,eAAO,MAAM,IAAI,yCAAc,CAAA;AAC/B,iCAAiC;AACjC,eAAO,MAAM,KAAK,yCAAe,CAAA;AACjC,iCAAiC;AACjC,eAAO,MAAM,KAAK,yCAAe,CAAA;AACjC,iCAAiC;AACjC,eAAO,MAAM,KAAK,yCAAe,CAAA;AACjC,iCAAiC;AACjC,eAAO,MAAM,KAAK,yCAAe,CAAA;AACjC,iCAAiC;AACjC,eAAO,MAAM,KAAK,yCAAe,CAAA;AACjC,iCAAiC;AACjC,eAAO,MAAM,KAAK,yCAAe,CAAA;AACjC,iCAAiC;AACjC,eAAO,MAAM,KAAK,yCAAe,CAAA;AACjC,iCAAiC;AACjC,eAAO,MAAM,KAAK,yCAAe,CAAA;AACjC,iCAAiC;AACjC,eAAO,MAAM,KAAK,yCAAe,CAAA;AACjC,iCAAiC;AACjC,eAAO,MAAM,KAAK,yCAAe,CAAA;AACjC,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ANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/* eslint-disable jsdoc-js/require-jsdoc, jsdoc-js/require-description, jsdoc-js/require-example */
|
|
2
2
|
import * as core_Hex from '../core/Hex.js';
|
|
3
3
|
import * as z from 'zod/mini';
|
|
4
|
+
const hexRegex = /^0x[0-9a-fA-F]*$/;
|
|
4
5
|
/** Hex string schema. */
|
|
5
6
|
export const Hex = z
|
|
6
7
|
.templateLiteral([z.literal('0x'), z.string()])
|
|
7
|
-
.check(z.refine((value) =>
|
|
8
|
+
.check(z.refine((value) => hexRegex.test(value), 'expected hex'));
|
|
8
9
|
/** Returns a byte-sized hex string schema. */
|
|
9
10
|
export function sizedHex(size) {
|
|
10
11
|
return Hex.check(z.refine((value) => core_Hex.size(value) === size, `expected ${size} bytes`));
|
package/dist/zod/Hex.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Hex.js","sourceRoot":"","sources":["../../src/zod/Hex.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAA;AAC1C,OAAO,KAAK,CAAC,MAAM,UAAU,CAAA;AAE7B,yBAAyB;AACzB,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC;KACjB,eAAe,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;KAC9C,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"Hex.js","sourceRoot":"","sources":["../../src/zod/Hex.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAA;AAC1C,OAAO,KAAK,CAAC,MAAM,UAAU,CAAA;AAE7B,MAAM,QAAQ,GAAG,kBAAkB,CAAA;AAEnC,yBAAyB;AACzB,MAAM,CAAC,MAAM,GAAG,GAAG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,kCAAkC;AAClC,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAA;AACnC,kCAAkC;AAClC,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAA;AACnC,kCAAkC;AAClC,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAA;AACnC,kCAAkC;AAClC,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAA;AACnC,kCAAkC;AAClC,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAA;AACnC,kCAAkC;AAClC,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAA;AACnC,kCAAkC;AAClC,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAA;AACnC,kCAAkC;AAClC,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAA;AACnC,kCAAkC;AAClC,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAA;AACnC,kCAAkC;AAClC,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAA;AACnC,kCAAkC;AAClC,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Solidity.d.ts","sourceRoot":"","sources":["../../src/zod/Solidity.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"Solidity.d.ts","sourceRoot":"","sources":["../../src/zod/Solidity.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAA;AAU7B,eAAO,MAAM,UAAU,yBAIpB,CAAA;AAEH,eAAO,MAAM,OAAO,6BAAuB,CAAA;AAC3C,eAAO,MAAM,IAAI,0BAAoB,CAAA;AACrC,eAAO,MAAM,KAAK,yBAOf,CAAA;AACH,eAAO,MAAM,QAAQ,8BAAwB,CAAA;AAC7C,eAAO,MAAM,MAAM,4BAAsB,CAAA;AACzC,eAAO,MAAM,KAAK,2BAAqB,CAAA;AACvC,eAAO,MAAM,GAAG,yBAOb,CAAA;AACH,eAAO,MAAM,iBAAiB,yBAQ3B,CAAA;AACH,eAAO,MAAM,cAAc,yBAQxB,CAAA;AACH,eAAO,MAAM,KAAK,6EAA+C,CAAA;AAEjE,eAAO,MAAM,IAAI,sSASf,CAAA;AAEF,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,WASlC"}
|
package/dist/zod/Solidity.js
CHANGED
|
@@ -1,24 +1,29 @@
|
|
|
1
1
|
import * as z from 'zod/mini';
|
|
2
|
+
const identifierRegex = /^[a-zA-Z$_][a-zA-Z0-9$_]*$/;
|
|
3
|
+
const bytesRegex = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/;
|
|
4
|
+
const intRegex = /^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;
|
|
5
|
+
const arrayWithoutTupleRegex = /^(address|bool|function|string|bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?|u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?)(\[[0-9]{0,}\])+$/;
|
|
6
|
+
const arrayWithTupleRegex = /^tuple(\[[0-9]{0,}\])+$/;
|
|
2
7
|
export const Identifier = z
|
|
3
8
|
.string()
|
|
4
|
-
.check(z.refine((value) =>
|
|
9
|
+
.check(z.refine((value) => identifierRegex.test(value), 'expected identifier'));
|
|
5
10
|
export const Address = z.literal('address');
|
|
6
11
|
export const Bool = z.literal('bool');
|
|
7
12
|
export const Bytes = z
|
|
8
13
|
.string()
|
|
9
|
-
.check(z.refine((value) =>
|
|
14
|
+
.check(z.refine((value) => bytesRegex.test(value), 'expected Solidity bytes type'));
|
|
10
15
|
export const Function = z.literal('function');
|
|
11
16
|
export const String = z.literal('string');
|
|
12
17
|
export const Tuple = z.literal('tuple');
|
|
13
18
|
export const Int = z
|
|
14
19
|
.string()
|
|
15
|
-
.check(z.refine((value) =>
|
|
20
|
+
.check(z.refine((value) => intRegex.test(value), 'expected Solidity integer type'));
|
|
16
21
|
export const ArrayWithoutTuple = z
|
|
17
22
|
.string()
|
|
18
|
-
.check(z.refine((value) =>
|
|
23
|
+
.check(z.refine((value) => arrayWithoutTupleRegex.test(value), 'expected Solidity array type'));
|
|
19
24
|
export const ArrayWithTuple = z
|
|
20
25
|
.string()
|
|
21
|
-
.check(z.refine((value) =>
|
|
26
|
+
.check(z.refine((value) => arrayWithTupleRegex.test(value), 'expected Solidity tuple array type'));
|
|
22
27
|
export const Array = z.union([ArrayWithTuple, ArrayWithoutTuple]);
|
|
23
28
|
export const Type = z.union([
|
|
24
29
|
Address,
|
|
@@ -35,7 +40,7 @@ export function isType(type) {
|
|
|
35
40
|
type === 'bool' ||
|
|
36
41
|
type === 'function' ||
|
|
37
42
|
type === 'string' ||
|
|
38
|
-
|
|
39
|
-
|
|
43
|
+
bytesRegex.test(type) ||
|
|
44
|
+
intRegex.test(type));
|
|
40
45
|
}
|
|
41
46
|
//# sourceMappingURL=Solidity.js.map
|
package/dist/zod/Solidity.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Solidity.js","sourceRoot":"","sources":["../../src/zod/Solidity.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAA;AAE7B,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC;KACxB,MAAM,EAAE;KACR,KAAK,CACJ,CAAC,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"Solidity.js","sourceRoot":"","sources":["../../src/zod/Solidity.ts"],"names":[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jC,CACF,CAAA;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC;KAC/B,MAAM,EAAE;KACR,KAAK,CACJ,CAAC,CAAC,MAAM,CACN,CAAC,KAAK,EAA8C,EAAE,CACpD,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,EACpC,8BAA8B,CAC/B,CACF,CAAA;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC;KAC5B,MAAM,EAAE;KACR,KAAK,CACJ,CAAC,CAAC,MAAM,CACN,CAAC,KAAK,EAA2C,EAAE,CACjD,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,EACjC,oCAAoC,CACrC,CACF,CAAA;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAC,CAAA;AAEjE,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC;IAC1B,OAAO;IACP,IAAI;IACJ,KAAK;IACL,QAAQ;IACR,MAAM;IACN,KAAK;IACL,GAAG;IACH,KAAK;CACN,CAAC,CAAA;AAEF,MAAM,UAAU,MAAM,CAAC,IAAY;IACjC,OAAO,CACL,IAAI,KAAK,SAAS;QAClB,IAAI,KAAK,MAAM;QACf,IAAI,KAAK,UAAU;QACnB,IAAI,KAAK,QAAQ;QACjB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;QACrB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CACpB,CAAA;AACH,CAAC"}
|
package/dist/zod/TypedData.d.ts
CHANGED
|
@@ -36,11 +36,12 @@ export declare const TypedData: z.ZodMiniPipe<z.ZodMiniRecord<z.ZodMiniString<st
|
|
|
36
36
|
[x: `bytes5[${string}]`]: undefined;
|
|
37
37
|
[x: `bytes3[${string}]`]: undefined;
|
|
38
38
|
[x: `bytes20[${string}]`]: undefined;
|
|
39
|
+
[x: `bytes15[${string}]`]: undefined;
|
|
40
|
+
[x: `bytes26[${string}]`]: undefined;
|
|
39
41
|
[x: `bytes11[${string}]`]: undefined;
|
|
40
42
|
[x: `bytes12[${string}]`]: undefined;
|
|
41
43
|
[x: `bytes13[${string}]`]: undefined;
|
|
42
44
|
[x: `bytes14[${string}]`]: undefined;
|
|
43
|
-
[x: `bytes15[${string}]`]: undefined;
|
|
44
45
|
[x: `bytes17[${string}]`]: undefined;
|
|
45
46
|
[x: `bytes18[${string}]`]: undefined;
|
|
46
47
|
[x: `bytes19[${string}]`]: undefined;
|
|
@@ -49,7 +50,6 @@ export declare const TypedData: z.ZodMiniPipe<z.ZodMiniRecord<z.ZodMiniString<st
|
|
|
49
50
|
[x: `bytes23[${string}]`]: undefined;
|
|
50
51
|
[x: `bytes24[${string}]`]: undefined;
|
|
51
52
|
[x: `bytes25[${string}]`]: undefined;
|
|
52
|
-
[x: `bytes26[${string}]`]: undefined;
|
|
53
53
|
[x: `bytes27[${string}]`]: undefined;
|
|
54
54
|
[x: `bytes28[${string}]`]: undefined;
|
|
55
55
|
[x: `bytes29[${string}]`]: undefined;
|
|
@@ -62,10 +62,10 @@ export declare const TypedData: z.ZodMiniPipe<z.ZodMiniRecord<z.ZodMiniString<st
|
|
|
62
62
|
[x: `int120[${string}]`]: undefined;
|
|
63
63
|
[x: `int128[${string}]`]: undefined;
|
|
64
64
|
[x: `int8[${string}]`]: undefined;
|
|
65
|
-
[x: `
|
|
65
|
+
[x: `int64[${string}]`]: undefined;
|
|
66
66
|
[x: `int40[${string}]`]: undefined;
|
|
67
|
+
[x: `int24[${string}]`]: undefined;
|
|
67
68
|
[x: `int56[${string}]`]: undefined;
|
|
68
|
-
[x: `int64[${string}]`]: undefined;
|
|
69
69
|
[x: `int72[${string}]`]: undefined;
|
|
70
70
|
[x: `int80[${string}]`]: undefined;
|
|
71
71
|
[x: `int88[${string}]`]: undefined;
|
|
@@ -94,10 +94,10 @@ export declare const TypedData: z.ZodMiniPipe<z.ZodMiniRecord<z.ZodMiniString<st
|
|
|
94
94
|
[x: `uint120[${string}]`]: undefined;
|
|
95
95
|
[x: `uint128[${string}]`]: undefined;
|
|
96
96
|
[x: `uint8[${string}]`]: undefined;
|
|
97
|
-
[x: `
|
|
97
|
+
[x: `uint64[${string}]`]: undefined;
|
|
98
98
|
[x: `uint40[${string}]`]: undefined;
|
|
99
|
+
[x: `uint24[${string}]`]: undefined;
|
|
99
100
|
[x: `uint56[${string}]`]: undefined;
|
|
100
|
-
[x: `uint64[${string}]`]: undefined;
|
|
101
101
|
[x: `uint72[${string}]`]: undefined;
|
|
102
102
|
[x: `uint80[${string}]`]: undefined;
|
|
103
103
|
[x: `uint88[${string}]`]: undefined;
|
|
@@ -136,11 +136,12 @@ export declare const TypedData: z.ZodMiniPipe<z.ZodMiniRecord<z.ZodMiniString<st
|
|
|
136
136
|
bytes5?: undefined;
|
|
137
137
|
bytes3?: undefined;
|
|
138
138
|
bytes20?: undefined;
|
|
139
|
+
bytes15?: undefined;
|
|
140
|
+
bytes26?: undefined;
|
|
139
141
|
bytes11?: undefined;
|
|
140
142
|
bytes12?: undefined;
|
|
141
143
|
bytes13?: undefined;
|
|
142
144
|
bytes14?: undefined;
|
|
143
|
-
bytes15?: undefined;
|
|
144
145
|
bytes17?: undefined;
|
|
145
146
|
bytes18?: undefined;
|
|
146
147
|
bytes19?: undefined;
|
|
@@ -149,7 +150,6 @@ export declare const TypedData: z.ZodMiniPipe<z.ZodMiniRecord<z.ZodMiniString<st
|
|
|
149
150
|
bytes23?: undefined;
|
|
150
151
|
bytes24?: undefined;
|
|
151
152
|
bytes25?: undefined;
|
|
152
|
-
bytes26?: undefined;
|
|
153
153
|
bytes27?: undefined;
|
|
154
154
|
bytes28?: undefined;
|
|
155
155
|
bytes29?: undefined;
|
|
@@ -162,10 +162,10 @@ export declare const TypedData: z.ZodMiniPipe<z.ZodMiniRecord<z.ZodMiniString<st
|
|
|
162
162
|
int120?: undefined;
|
|
163
163
|
int128?: undefined;
|
|
164
164
|
int8?: undefined;
|
|
165
|
-
|
|
165
|
+
int64?: undefined;
|
|
166
166
|
int40?: undefined;
|
|
167
|
+
int24?: undefined;
|
|
167
168
|
int56?: undefined;
|
|
168
|
-
int64?: undefined;
|
|
169
169
|
int72?: undefined;
|
|
170
170
|
int80?: undefined;
|
|
171
171
|
int88?: undefined;
|
|
@@ -194,10 +194,10 @@ export declare const TypedData: z.ZodMiniPipe<z.ZodMiniRecord<z.ZodMiniString<st
|
|
|
194
194
|
uint120?: undefined;
|
|
195
195
|
uint128?: undefined;
|
|
196
196
|
uint8?: undefined;
|
|
197
|
-
|
|
197
|
+
uint64?: undefined;
|
|
198
198
|
uint40?: undefined;
|
|
199
|
+
uint24?: undefined;
|
|
199
200
|
uint56?: undefined;
|
|
200
|
-
uint64?: undefined;
|
|
201
201
|
uint72?: undefined;
|
|
202
202
|
uint80?: undefined;
|
|
203
203
|
uint88?: undefined;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "ox",
|
|
3
3
|
"description": "Ethereum Standard Library",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "1.8.
|
|
5
|
+
"version": "1.8.15",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"sideEffects": false,
|
|
8
8
|
"license": "MIT",
|
|
@@ -662,6 +662,11 @@
|
|
|
662
662
|
"types": "./dist/tempo/SignatureEnvelope.d.ts",
|
|
663
663
|
"default": "./dist/tempo/SignatureEnvelope.js"
|
|
664
664
|
},
|
|
665
|
+
"./tempo/SignaturePreAuthorized": {
|
|
666
|
+
"src": "./src/tempo/SignaturePreAuthorized.ts",
|
|
667
|
+
"types": "./dist/tempo/SignaturePreAuthorized.d.ts",
|
|
668
|
+
"default": "./dist/tempo/SignaturePreAuthorized.js"
|
|
669
|
+
},
|
|
665
670
|
"./tempo/Tick": {
|
|
666
671
|
"src": "./src/tempo/Tick.ts",
|
|
667
672
|
"types": "./dist/tempo/Tick.d.ts",
|
package/src/core/AbiError.ts
CHANGED
|
@@ -216,14 +216,17 @@ export function decode(
|
|
|
216
216
|
}
|
|
217
217
|
return parameters as [AbiError, Hex.Hex, decode.Options | undefined]
|
|
218
218
|
})()
|
|
219
|
+
const { overloads } = abiError as AbiError
|
|
220
|
+
|
|
219
221
|
if (Hex.size(data) < 4) throw new AbiItem.InvalidSelectorSizeError({ data })
|
|
220
|
-
if (abiError.inputs?.length === 0) return undefined
|
|
221
222
|
|
|
222
|
-
const
|
|
223
|
-
abiError
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
)
|
|
223
|
+
const item = overloads
|
|
224
|
+
? (fromAbi([abiError, ...overloads], data as never) as AbiError)
|
|
225
|
+
: abiError
|
|
226
|
+
|
|
227
|
+
if (item.inputs?.length === 0) return undefined
|
|
228
|
+
|
|
229
|
+
const values = AbiParameters.decode(item.inputs, Hex.slice(data, 4), options)
|
|
227
230
|
if (values && Object.keys(values).length === 1) {
|
|
228
231
|
if (Array.isArray(values)) return values[0]
|
|
229
232
|
return Object.values(values)[0]
|
|
@@ -252,22 +255,30 @@ export declare namespace decode {
|
|
|
252
255
|
as extends 'Object' | 'Array' = 'Array',
|
|
253
256
|
> =
|
|
254
257
|
IsNarrowable<abiError, AbiError> extends true
|
|
255
|
-
?
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
?
|
|
267
|
-
:
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
258
|
+
? // distribute over the error and its overloads
|
|
259
|
+
| abiError
|
|
260
|
+
| (abiError['overloads'] extends readonly AbiError[]
|
|
261
|
+
? abiError['overloads'][number]
|
|
262
|
+
: never) extends infer item extends AbiError
|
|
263
|
+
? item extends AbiError
|
|
264
|
+
? item['inputs'] extends readonly []
|
|
265
|
+
? undefined
|
|
266
|
+
: item['inputs'] extends readonly [
|
|
267
|
+
infer type extends abitype.AbiParameter,
|
|
268
|
+
]
|
|
269
|
+
? abitype.AbiParameterToPrimitiveType<type>
|
|
270
|
+
: AbiParameters.decode.ReturnType<
|
|
271
|
+
item['inputs'],
|
|
272
|
+
as
|
|
273
|
+
> extends infer types
|
|
274
|
+
? types extends readonly []
|
|
275
|
+
? undefined
|
|
276
|
+
: types extends readonly [infer type]
|
|
277
|
+
? type
|
|
278
|
+
: types
|
|
279
|
+
: never
|
|
280
|
+
: never
|
|
281
|
+
: never
|
|
271
282
|
: unknown | readonly unknown[] | undefined
|
|
272
283
|
|
|
273
284
|
type ErrorType =
|
package/src/core/AbiEvent.ts
CHANGED
|
@@ -58,13 +58,16 @@ function encodePrimitiveTopic(
|
|
|
58
58
|
const signed = type[0] === 'i'
|
|
59
59
|
const sizeStr = signed ? type.slice(3) : type.slice(4)
|
|
60
60
|
const size = sizeStr === '' ? 256 : Number(sizeStr)
|
|
61
|
-
|
|
61
|
+
// Narrower widths go through `AbiParameters.encode`, which range-checks them.
|
|
62
|
+
if (size !== 256) return undefined
|
|
62
63
|
return Hex.fromNumber(value as number | bigint, { size: 32, signed })
|
|
63
64
|
}
|
|
64
|
-
// `bytesN` (fixed):
|
|
65
|
+
// `bytesN` (fixed): a 32-byte `bytes32` is already its own topic.
|
|
65
66
|
if (type.startsWith('bytes') && type.length > 5) {
|
|
66
67
|
if (typeof value !== 'string') return undefined
|
|
67
|
-
|
|
68
|
+
// Other sizes go through `AbiParameters.encode`, which checks the length.
|
|
69
|
+
if (type !== 'bytes32' || value.length !== 66) return undefined
|
|
70
|
+
return value as Hex.Hex
|
|
68
71
|
}
|
|
69
72
|
return undefined
|
|
70
73
|
}
|
|
@@ -272,6 +275,13 @@ function assertMatchingArgs(
|
|
|
272
275
|
Solidity.bytesRegex.test(input.type)
|
|
273
276
|
)
|
|
274
277
|
return value.toLowerCase() === arg.toLowerCase()
|
|
278
|
+
// Small integers decode as numbers, so match a number or bigint either way.
|
|
279
|
+
if (
|
|
280
|
+
(typeof value === 'bigint' || Number.isInteger(value)) &&
|
|
281
|
+
(typeof arg === 'bigint' || Number.isInteger(arg)) &&
|
|
282
|
+
Solidity.integerRegex.test(input.type)
|
|
283
|
+
)
|
|
284
|
+
return BigInt(value as bigint | number) === BigInt(arg as bigint | number)
|
|
275
285
|
return value === arg
|
|
276
286
|
}
|
|
277
287
|
|
|
@@ -684,8 +694,40 @@ export function decodeLog<const abi extends Abi.Abi | readonly unknown[]>(
|
|
|
684
694
|
options?: decodeLog.Options,
|
|
685
695
|
): decodeLog.ReturnType<decodeLog.ExtractEvent<abi>> {
|
|
686
696
|
const selector = log.topics[0]
|
|
697
|
+
const abiEvents = (abi as Abi.Abi).filter(
|
|
698
|
+
(item): item is AbiEvent => item.type === 'event',
|
|
699
|
+
)
|
|
700
|
+
// Anonymous events omit the signature topic, so they are never matched by
|
|
701
|
+
// `topics[0]`.
|
|
702
|
+
const named = abiEvents.filter((item) => item.anonymous !== true)
|
|
703
|
+
|
|
704
|
+
// Nothing in a log identifies an anonymous event, so any log with the same
|
|
705
|
+
// topic count fits it. Anonymous events are only considered when every
|
|
706
|
+
// event in the ABI is anonymous. For a mixed ABI, decode with the event
|
|
707
|
+
// itself through `AbiEvent.decode`.
|
|
708
|
+
const hasSelectorMatch =
|
|
709
|
+
selector !== undefined &&
|
|
710
|
+
named.some((item) => getSelector(item) === selector)
|
|
711
|
+
if (
|
|
712
|
+
!hasSelectorMatch &&
|
|
713
|
+
abiEvents.length > 0 &&
|
|
714
|
+
abiEvents.every((item) => item.anonymous === true)
|
|
715
|
+
) {
|
|
716
|
+
const candidates = abiEvents.filter(
|
|
717
|
+
(item) => indexedCount(item) === log.topics.length,
|
|
718
|
+
)
|
|
719
|
+
if (candidates.length > 1)
|
|
720
|
+
throw new AnonymousEventAmbiguityError({ abiEvents: candidates })
|
|
721
|
+
const abiEvent = candidates[0] as decodeLog.ExtractEvent<abi> | undefined
|
|
722
|
+
if (abiEvent)
|
|
723
|
+
return {
|
|
724
|
+
event: abiEvent,
|
|
725
|
+
args: decode(abiEvent, log, options),
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
|
|
687
729
|
if (!selector) throw new SelectorTopicNotFoundError()
|
|
688
|
-
const abiEvent = fromAbi(
|
|
730
|
+
const abiEvent = fromAbi(named, selector) as decodeLog.ExtractEvent<abi>
|
|
689
731
|
return {
|
|
690
732
|
event: abiEvent,
|
|
691
733
|
args: decode(abiEvent, log, options),
|
|
@@ -706,6 +748,7 @@ export declare namespace decodeLog {
|
|
|
706
748
|
}
|
|
707
749
|
|
|
708
750
|
type ErrorType =
|
|
751
|
+
| AnonymousEventAmbiguityError
|
|
709
752
|
| decode.ErrorType
|
|
710
753
|
| fromAbi.ErrorType
|
|
711
754
|
| SelectorTopicNotFoundError
|
|
@@ -780,13 +823,40 @@ export function extractLogs<
|
|
|
780
823
|
const abiEvents = (abi as Abi.Abi).filter(
|
|
781
824
|
(item): item is AbiEvent => item.type === 'event',
|
|
782
825
|
)
|
|
826
|
+
// Nothing in a log identifies an anonymous event, so any log with the same
|
|
827
|
+
// topic count fits it. Anonymous events are only considered when requested:
|
|
828
|
+
// `eventName` names one, or every event in the ABI is anonymous. Otherwise a
|
|
829
|
+
// log from another contract is extracted as the anonymous event.
|
|
830
|
+
const anonymousEvents = (() => {
|
|
831
|
+
if (eventName)
|
|
832
|
+
return abiEvents.filter(
|
|
833
|
+
(item) => item.anonymous === true && eventName.includes(item.name),
|
|
834
|
+
)
|
|
835
|
+
if (abiEvents.every((item) => item.anonymous === true)) return abiEvents
|
|
836
|
+
return []
|
|
837
|
+
})()
|
|
783
838
|
const out: extractLogs.ReturnType[] = []
|
|
784
839
|
for (const log of logs) {
|
|
785
840
|
const log_ = formatExtractLog(log)
|
|
786
841
|
const selector = log_.topics[0]
|
|
787
|
-
if (!selector) continue
|
|
788
842
|
|
|
789
|
-
const items =
|
|
843
|
+
const items = (() => {
|
|
844
|
+
// A signature match wins, so an anonymous event never claims a log
|
|
845
|
+
// whose signature is known.
|
|
846
|
+
const bySelector = selector
|
|
847
|
+
? abiEvents.filter(
|
|
848
|
+
(item) => item.anonymous !== true && getSelector(item) === selector,
|
|
849
|
+
)
|
|
850
|
+
: []
|
|
851
|
+
if (bySelector.length > 0) return bySelector
|
|
852
|
+
// A dynamic ABI value can decode as a static type without throwing, so
|
|
853
|
+
// several anonymous events with the same topic count are not guessed.
|
|
854
|
+
const candidates = anonymousEvents.filter(
|
|
855
|
+
(item) => indexedCount(item) === log_.topics.length,
|
|
856
|
+
)
|
|
857
|
+
if (candidates.length === 1) return candidates
|
|
858
|
+
return []
|
|
859
|
+
})()
|
|
790
860
|
if (items.length === 0) continue
|
|
791
861
|
|
|
792
862
|
let event:
|
|
@@ -809,7 +879,9 @@ export function extractLogs<
|
|
|
809
879
|
} catch {}
|
|
810
880
|
}
|
|
811
881
|
|
|
812
|
-
|
|
882
|
+
// An anonymous event that fails to decode is not identified, so the
|
|
883
|
+
// non-strict fallback only applies to a signature match.
|
|
884
|
+
if (!event && !strict && items[0]!.anonymous !== true) {
|
|
813
885
|
const item = items[0]!
|
|
814
886
|
try {
|
|
815
887
|
event = {
|
|
@@ -940,19 +1012,22 @@ function decodeForExtract(
|
|
|
940
1012
|
const { data, topics } = log
|
|
941
1013
|
const { strict } = options
|
|
942
1014
|
|
|
943
|
-
const
|
|
944
|
-
if (
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
1015
|
+
const isAnonymous = abiEvent.anonymous === true
|
|
1016
|
+
if (!isAnonymous) {
|
|
1017
|
+
const selector = topics[0]
|
|
1018
|
+
if (selector !== getSelector(abiEvent))
|
|
1019
|
+
throw new SelectorTopicMismatchError({
|
|
1020
|
+
abiEvent,
|
|
1021
|
+
actual: selector,
|
|
1022
|
+
expected: getSelector(abiEvent),
|
|
1023
|
+
})
|
|
1024
|
+
}
|
|
950
1025
|
|
|
951
1026
|
const { inputs } = abiEvent
|
|
952
1027
|
const isUnnamed = inputs.some((x) => !('name' in x && x.name))
|
|
953
1028
|
const args: any = isUnnamed ? [] : {}
|
|
954
1029
|
|
|
955
|
-
const argTopics = topics.slice(1)
|
|
1030
|
+
const argTopics = isAnonymous ? topics : topics.slice(1)
|
|
956
1031
|
const indexedInputs: [abitype.AbiEventParameter, number][] = []
|
|
957
1032
|
const nonIndexedInputs: abitype.AbiEventParameter[] = []
|
|
958
1033
|
const missingIndexedInputs: [abitype.AbiEventParameter, number][] = []
|
|
@@ -1074,6 +1149,10 @@ function formatExtractLog<const log extends extractLogs.Log>(log: log) {
|
|
|
1074
1149
|
}
|
|
1075
1150
|
}
|
|
1076
1151
|
|
|
1152
|
+
function indexedCount(abiEvent: AbiEvent) {
|
|
1153
|
+
return abiEvent.inputs.filter((input) => input.indexed).length
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1077
1156
|
function includesArgs(
|
|
1078
1157
|
abiEvent: AbiEvent,
|
|
1079
1158
|
args: unknown,
|
|
@@ -1082,11 +1161,12 @@ function includesArgs(
|
|
|
1082
1161
|
) {
|
|
1083
1162
|
try {
|
|
1084
1163
|
if (!matchArgs) return true
|
|
1085
|
-
// Topics hold the selector, then indexed inputs in order.
|
|
1086
|
-
// decoding reads indexed inputs without
|
|
1164
|
+
// Topics hold the selector, then indexed inputs in order. Anonymous events
|
|
1165
|
+
// have no selector topic. Non-strict decoding reads indexed inputs without
|
|
1166
|
+
// a topic from data.
|
|
1087
1167
|
const topicInputs = abiEvent.inputs
|
|
1088
1168
|
.filter((input) => input.indexed)
|
|
1089
|
-
.slice(0, topics.length - 1)
|
|
1169
|
+
.slice(0, abiEvent.anonymous === true ? topics.length : topics.length - 1)
|
|
1090
1170
|
assertMatchingArgs(abiEvent, args, matchArgs, topicInputs)
|
|
1091
1171
|
return true
|
|
1092
1172
|
} catch {
|
|
@@ -2019,3 +2099,82 @@ export class FilterTypeNotSupportedError extends Errors.BaseError {
|
|
|
2019
2099
|
super(`Filter type "${type}" is not supported.`)
|
|
2020
2100
|
}
|
|
2021
2101
|
}
|
|
2102
|
+
|
|
2103
|
+
/**
|
|
2104
|
+
* Thrown when a log fits more than one anonymous event in an ABI. An anonymous
|
|
2105
|
+
* log has no selector topic, so anonymous events with the same number of
|
|
2106
|
+
* indexed inputs cannot be told apart.
|
|
2107
|
+
*
|
|
2108
|
+
* @example
|
|
2109
|
+
* ```ts twoslash
|
|
2110
|
+
* import { Abi, AbiEvent } from 'ox'
|
|
2111
|
+
*
|
|
2112
|
+
* const abi = Abi.from([
|
|
2113
|
+
* {
|
|
2114
|
+
* anonymous: true,
|
|
2115
|
+
* inputs: [
|
|
2116
|
+
* { indexed: true, name: 'from', type: 'address' },
|
|
2117
|
+
* { name: 'value', type: 'uint256' }
|
|
2118
|
+
* ],
|
|
2119
|
+
* name: 'Count',
|
|
2120
|
+
* type: 'event'
|
|
2121
|
+
* },
|
|
2122
|
+
* {
|
|
2123
|
+
* anonymous: true,
|
|
2124
|
+
* inputs: [
|
|
2125
|
+
* { indexed: true, name: 'from', type: 'address' },
|
|
2126
|
+
* { name: 'note', type: 'string' }
|
|
2127
|
+
* ],
|
|
2128
|
+
* name: 'Message',
|
|
2129
|
+
* type: 'event'
|
|
2130
|
+
* }
|
|
2131
|
+
* ])
|
|
2132
|
+
*
|
|
2133
|
+
* AbiEvent.decodeLog(abi, {
|
|
2134
|
+
* data: '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2135
|
+
* topics: [
|
|
2136
|
+
* '0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ac'
|
|
2137
|
+
* ]
|
|
2138
|
+
* })
|
|
2139
|
+
* // @error: AbiEvent.AnonymousEventAmbiguityError: Found ambiguous anonymous events for the log.
|
|
2140
|
+
* ```
|
|
2141
|
+
*
|
|
2142
|
+
* ### Solution
|
|
2143
|
+
*
|
|
2144
|
+
* Decode the log with the intended event.
|
|
2145
|
+
*
|
|
2146
|
+
* ```ts twoslash
|
|
2147
|
+
* import { AbiEvent } from 'ox'
|
|
2148
|
+
*
|
|
2149
|
+
* const count = AbiEvent.from({
|
|
2150
|
+
* anonymous: true,
|
|
2151
|
+
* inputs: [
|
|
2152
|
+
* { indexed: true, name: 'from', type: 'address' },
|
|
2153
|
+
* { name: 'value', type: 'uint256' }
|
|
2154
|
+
* ],
|
|
2155
|
+
* name: 'Count',
|
|
2156
|
+
* type: 'event'
|
|
2157
|
+
* })
|
|
2158
|
+
*
|
|
2159
|
+
* AbiEvent.decode(count, {
|
|
2160
|
+
* data: '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2161
|
+
* topics: [
|
|
2162
|
+
* '0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ac'
|
|
2163
|
+
* ]
|
|
2164
|
+
* })
|
|
2165
|
+
* ```
|
|
2166
|
+
*/
|
|
2167
|
+
export class AnonymousEventAmbiguityError extends Errors.BaseError {
|
|
2168
|
+
override readonly name = 'AbiEvent.AnonymousEventAmbiguityError'
|
|
2169
|
+
|
|
2170
|
+
constructor({ abiEvents }: { abiEvents: readonly AbiEvent[] }) {
|
|
2171
|
+
super('Found ambiguous anonymous events for the log.', {
|
|
2172
|
+
metaMessages: [
|
|
2173
|
+
...abiEvents.map((abiEvent) => `- \`${format(abiEvent)}\``),
|
|
2174
|
+
'',
|
|
2175
|
+
'These events take the same number of indexed topics.',
|
|
2176
|
+
'Decode the log with `AbiEvent.decode` and the intended event.',
|
|
2177
|
+
],
|
|
2178
|
+
})
|
|
2179
|
+
}
|
|
2180
|
+
}
|
package/src/core/AbiFunction.ts
CHANGED
|
@@ -199,19 +199,18 @@ export function decodeData(
|
|
|
199
199
|
const { overloads } = abiFunction
|
|
200
200
|
|
|
201
201
|
if (Hex.size(data) < 4) throw new AbiItem.InvalidSelectorSizeError({ data })
|
|
202
|
-
if (abiFunction.inputs?.length === 0) return undefined
|
|
203
202
|
|
|
204
203
|
const item = overloads
|
|
205
204
|
? fromAbi([abiFunction, ...overloads], data as never)
|
|
206
205
|
: abiFunction
|
|
207
206
|
|
|
208
|
-
if (item.inputs.length
|
|
207
|
+
if (item.inputs.length === 0) return undefined
|
|
208
|
+
if (Hex.size(data) <= 4)
|
|
209
209
|
throw new AbiParameters.DataSizeTooSmallError({
|
|
210
210
|
data,
|
|
211
211
|
parameters: item.inputs as never,
|
|
212
212
|
size: Math.max(0, Hex.size(data) - 4),
|
|
213
213
|
})
|
|
214
|
-
if (Hex.size(data) <= 4) return undefined
|
|
215
214
|
return AbiParameters.decode(item.inputs, Hex.slice(data, 4), options)
|
|
216
215
|
}
|
|
217
216
|
|
|
@@ -239,15 +238,19 @@ export declare namespace decodeData {
|
|
|
239
238
|
|
|
240
239
|
type ReturnType<abiFunction extends AbiFunction = AbiFunction> =
|
|
241
240
|
IsNarrowable<abiFunction, AbiFunction> extends true
|
|
242
|
-
? abiFunction
|
|
243
|
-
?
|
|
244
|
-
|
|
245
|
-
|
|
241
|
+
? abiFunction extends AbiFunction
|
|
242
|
+
?
|
|
243
|
+
| (abiFunction['inputs'] extends readonly []
|
|
244
|
+
? undefined
|
|
245
|
+
: AbiParameters_internal.ToPrimitiveTypes<
|
|
246
|
+
abiFunction['inputs']
|
|
247
|
+
>)
|
|
246
248
|
| (abiFunction['overloads'] extends readonly AbiFunction[]
|
|
247
249
|
? AbiParameters_internal.ToPrimitiveTypes<
|
|
248
250
|
abiFunction['overloads'][number]['inputs']
|
|
249
251
|
>
|
|
250
252
|
: never)
|
|
253
|
+
: never
|
|
251
254
|
: unknown
|
|
252
255
|
|
|
253
256
|
type ErrorType =
|