ox 0.9.5 → 0.9.6

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/_cjs/core/AbiConstructor.js +16 -2
  3. package/_cjs/core/AbiConstructor.js.map +1 -1
  4. package/_cjs/core/AbiError.js.map +1 -1
  5. package/_cjs/core/AbiEvent.js.map +1 -1
  6. package/_cjs/core/AbiFunction.js.map +1 -1
  7. package/_cjs/core/AbiItem.js +24 -3
  8. package/_cjs/core/AbiItem.js.map +1 -1
  9. package/_cjs/version.js +1 -1
  10. package/_esm/core/Abi.js +2 -2
  11. package/_esm/core/Abi.js.map +1 -1
  12. package/_esm/core/AbiConstructor.js +18 -56
  13. package/_esm/core/AbiConstructor.js.map +1 -1
  14. package/_esm/core/AbiError.js.map +1 -1
  15. package/_esm/core/AbiEvent.js.map +1 -1
  16. package/_esm/core/AbiFunction.js.map +1 -1
  17. package/_esm/core/AbiItem.js +27 -93
  18. package/_esm/core/AbiItem.js.map +1 -1
  19. package/_esm/erc6492/SignatureErc6492.js +2 -2
  20. package/_esm/erc6492/index.js +2 -2
  21. package/_esm/erc8010/SignatureErc8010.js +2 -2
  22. package/_esm/erc8010/index.js +2 -2
  23. package/_esm/version.js +1 -1
  24. package/_types/core/AbiConstructor.d.ts +43 -4
  25. package/_types/core/AbiConstructor.d.ts.map +1 -1
  26. package/_types/core/AbiError.d.ts +20 -29
  27. package/_types/core/AbiError.d.ts.map +1 -1
  28. package/_types/core/AbiEvent.d.ts +58 -0
  29. package/_types/core/AbiEvent.d.ts.map +1 -1
  30. package/_types/core/AbiFunction.d.ts +49 -6
  31. package/_types/core/AbiFunction.d.ts.map +1 -1
  32. package/_types/core/AbiItem.d.ts +36 -0
  33. package/_types/core/AbiItem.d.ts.map +1 -1
  34. package/_types/erc6492/SignatureErc6492.d.ts +2 -2
  35. package/_types/erc6492/index.d.ts +2 -2
  36. package/_types/erc8010/SignatureErc8010.d.ts +2 -2
  37. package/_types/erc8010/index.d.ts +2 -2
  38. package/_types/version.d.ts +1 -1
  39. package/core/Abi.ts +2 -2
  40. package/core/AbiConstructor.ts +96 -12
  41. package/core/AbiError.ts +20 -29
  42. package/core/AbiEvent.ts +58 -0
  43. package/core/AbiFunction.ts +49 -6
  44. package/core/AbiItem.ts +87 -3
  45. package/erc6492/SignatureErc6492.ts +2 -2
  46. package/erc6492/index.ts +2 -2
  47. package/erc8010/SignatureErc8010.ts +2 -2
  48. package/erc8010/index.ts +2 -2
  49. package/package.json +1 -1
  50. package/version.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"AbiItem.d.ts","sourceRoot":"","sources":["../../core/AbiItem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAClC,OAAO,KAAK,KAAK,GAAG,MAAM,UAAU,CAAA;AACpC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,QAAQ,MAAM,uBAAuB,CAAA;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAEvD,sDAAsD;AACtD,MAAM,MAAM,OAAO,GAAG,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;AAErC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,OAAO,CACjB,GAAG,SAAS,GAAG,CAAC,GAAG,EACnB,IAAI,SAAS,YAAY,CAAC,GAAG,CAAC,IAC5B,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC,CAAA;AAExC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,IAAI,CAAC,GAAG,SAAS,GAAG,CAAC,GAAG,GAAG,SAAS,OAAO,EAAE,G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,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAC7C,CAAC,EAAE;QAAE,OAAO,EAAE,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE;CAahD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,qBAAa,aAAc,SAAQ,MAAM,CAAC,SAAS;IACjD,SAAkB,IAAI,2BAA0B;gBACpC,EACV,IAAI,EACJ,IAAI,EACJ,IAAa,GACd,EAAE;QACD,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;QACzB,IAAI,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAC1B;CAQF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,wBAAyB,SAAQ,MAAM,CAAC,SAAS;IAC5D,SAAkB,IAAI,sCAAqC;gBAC/C,EAAE,IAAI,EAAE,EAAE;QAAE,IAAI,EAAE,GAAG,CAAC,GAAG,CAAA;KAAE;CAKxC"}
@@ -132,7 +132,7 @@ export declare namespace unwrap {
132
132
  *
133
133
  * @example
134
134
  * ```ts twoslash
135
- * import { Secp256k1 } from 'ox'
135
+ * import { Secp256k1, Signature } from 'ox'
136
136
  * import { SignatureErc6492 } from 'ox/erc6492' // [!code focus]
137
137
  *
138
138
  * const signature = Secp256k1.sign({
@@ -142,7 +142,7 @@ export declare namespace unwrap {
142
142
  *
143
143
  * const wrapped = SignatureErc6492.wrap({ // [!code focus]
144
144
  * data: '0xdeadbeef', // [!code focus]
145
- * signature, // [!code focus]
145
+ * signature: Signature.toHex(signature), // [!code focus]
146
146
  * to: '0x00000000219ab540356cBB839Cbe05303d7705Fa', // [!code focus]
147
147
  * }) // [!code focus]
148
148
  * ```
@@ -5,7 +5,7 @@ export type {};
5
5
  *
6
6
  * @example
7
7
  * ```ts twoslash
8
- * import { Secp256k1, PersonalMessage } from 'ox'
8
+ * import { PersonalMessage, Secp256k1, Signature } from 'ox'
9
9
  * import { SignatureErc6492 } from 'ox/erc6492' // [!code focus]
10
10
  *
11
11
  * const signature = Secp256k1.sign({
@@ -15,7 +15,7 @@ export type {};
15
15
  *
16
16
  * const wrapped = SignatureErc6492.wrap({ // [!code focus]
17
17
  * data: '0xcafebabe', // [!code focus]
18
- * signature, // [!code focus]
18
+ * signature: Signature.toHex(signature), // [!code focus]
19
19
  * to: '0xcafebabecafebabecafebabecafebabecafebabe', // [!code focus]
20
20
  * }) // [!code focus]
21
21
  * // @log: '0x000000000000000000000000cafebabecafebabecafebabecafebabecafebabe000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000004deadbeef000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041fa78c5905fb0b9d6066ef531f962a62bc6ef0d5eb59ecb134056d206f75aaed7780926ff2601a935c2c79707d9e1799948c9f19dcdde1e090e903b19a07923d01c000000000000000000000000000000000000000000000000000000000000006492649264926492649264926492649264926492649264926492649264926492'
@@ -122,7 +122,7 @@ export declare namespace unwrap {
122
122
  * @example
123
123
  * ```ts twoslash
124
124
  * // @noErrors
125
- * import { Secp256k1 } from 'ox'
125
+ * import { Secp256k1, Signature } from 'ox'
126
126
  * import { SignatureErc8010 } from 'ox/erc8010' // [!code focus]
127
127
  *
128
128
  * const signature = Secp256k1.sign({
@@ -133,7 +133,7 @@ export declare namespace unwrap {
133
133
  * const wrapped = SignatureErc8010.wrap({ // [!code focus]
134
134
  * authorization: { ... }, // [!code focus]
135
135
  * data: '0xdeadbeef', // [!code focus]
136
- * signature, // [!code focus]
136
+ * signature: Signature.toHex(signature), // [!code focus]
137
137
  * }) // [!code focus]
138
138
  * ```
139
139
  *
@@ -5,7 +5,7 @@ export type {};
5
5
  *
6
6
  * @example
7
7
  * ```ts twoslash
8
- * import { Authorization, Secp256k1, PersonalMessage } from 'ox'
8
+ * import { Authorization, PersonalMessage, Secp256k1, Signature } from 'ox'
9
9
  * import { SignatureErc8010 } from 'ox/erc8010' // [!code focus]
10
10
  *
11
11
  * const authorization = Authorization.from({
@@ -31,7 +31,7 @@ export type {};
31
31
  * const wrapped = SignatureErc8010.wrap({ // [!code focus]
32
32
  * authorization: authorizationSigned, // [!code focus]
33
33
  * data: '0xcafebabe', // [!code focus]
34
- * signature, // [!code focus]
34
+ * signature: Signature.toHex(signature), // [!code focus]
35
35
  * }) // [!code focus]
36
36
  * // @log: '0x000000000000000000000000cafebabecafebabecafebabecafebabecafebabe000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000004deadbeef000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041fa78c5905fb0b9d6066ef531f962a62bc6ef0d5eb59ecb134056d206f75aaed7780926ff2601a935c2c79707d9e1799948c9f19dcdde1e090e903b19a07923d01c000000000000000000000000000000000000000000000000000000000000008010801080108010801080108010801080108010801080108010801080108010'
37
37
  * ```
@@ -1,3 +1,3 @@
1
1
  /** @internal */
2
- export declare const version = "0.9.5";
2
+ export declare const version = "0.9.6";
3
3
  //# sourceMappingURL=version.d.ts.map
package/core/Abi.ts CHANGED
@@ -43,7 +43,7 @@ export function format<const abi extends Abi>(abi: abi): format.ReturnType<abi>
43
43
  * @returns The formatted ABI.
44
44
  */
45
45
  export function format(abi: Abi | readonly unknown[]): readonly string[]
46
- /** @internal */
46
+ // eslint-disable-next-line jsdoc/require-jsdoc
47
47
  export function format(abi: Abi | readonly unknown[]): format.ReturnType {
48
48
  return abitype.formatAbi(abi) as never
49
49
  }
@@ -140,7 +140,7 @@ export function from<const abi extends Abi | readonly string[]>(
140
140
  * @returns The typed ABI.
141
141
  */
142
142
  export function from(abi: Abi | readonly string[]): Abi
143
- /** @internal */
143
+ // eslint-disable-next-line jsdoc/require-jsdoc
144
144
  export function from(abi: Abi | readonly string[]): from.ReturnType {
145
145
  if (internal.isSignatures(abi)) return abitype.parseAbi(abi)
146
146
  return abi
@@ -10,11 +10,6 @@ import type { IsNarrowable } from './internal/types.js'
10
10
  /** Root type for an {@link ox#AbiItem.AbiItem} with a `constructor` type. */
11
11
  export type AbiConstructor = abitype.AbiConstructor
12
12
 
13
- /** @internal */
14
- export function decode<const abiConstructor extends AbiConstructor>(
15
- abiConstructor: abiConstructor,
16
- options: decode.Options,
17
- ): decode.ReturnType<abiConstructor>
18
13
  /**
19
14
  * ABI-decodes the provided constructor input (`inputs`).
20
15
  *
@@ -37,19 +32,63 @@ export function decode<const abiConstructor extends AbiConstructor>(
37
32
  * }) // [!code focus]
38
33
  * ```
39
34
  *
35
+ * @example
36
+ * ### ABI-shorthand
37
+ *
38
+ * You can also specify an entire ABI object as a parameter to `AbiConstructor.decode`.
39
+ *
40
+ * ```ts twoslash
41
+ * // @noErrors
42
+ * import { Abi, AbiConstructor } from 'ox'
43
+ *
44
+ * const abi = Abi.from([...])
45
+ *
46
+ * const data = AbiConstructor.encode(abi, {
47
+ * bytecode: '0x...',
48
+ * args: ['0xd8da6bf26964af9d7eed9e03e53415d37aa96045', 123n],
49
+ * })
50
+ *
51
+ * const decoded = AbiConstructor.decode(abi, { // [!code focus]
52
+ * bytecode: '0x...', // [!code focus]
53
+ * data, // [!code focus]
54
+ * }) // [!code focus]
55
+ * ```
56
+ *
40
57
  * @param abiConstructor - The ABI Constructor to decode.
41
58
  * @param options - Decoding options.
42
59
  * @returns The decoded constructor inputs.
43
60
  */
44
- export function decode(
45
- abiConstructor: AbiConstructor,
61
+ export function decode<
62
+ const abi extends Abi.Abi | readonly unknown[],
63
+ abiConstructor extends
64
+ AbiConstructor = fromAbi.ReturnType<abi> extends AbiConstructor
65
+ ? fromAbi.ReturnType<abi>
66
+ : never,
67
+ >(
68
+ abi: abi | Abi.Abi | readonly unknown[],
46
69
  options: decode.Options,
47
- ): readonly unknown[] | undefined
48
- /** @internal */
49
- export function decode(
50
- abiConstructor: AbiConstructor,
70
+ ): decode.ReturnType<abiConstructor>
71
+ export function decode<const abiConstructor extends AbiConstructor>(
72
+ abiConstructor: abiConstructor | AbiConstructor,
51
73
  options: decode.Options,
74
+ ): decode.ReturnType<abiConstructor>
75
+ // eslint-disable-next-line jsdoc/require-jsdoc
76
+ export function decode(
77
+ ...parameters:
78
+ | [abi: Abi.Abi | readonly unknown[], options: decode.Options]
79
+ | [abiConstructor: AbiConstructor, options: decode.Options]
52
80
  ): decode.ReturnType {
81
+ const [abiConstructor, options] = (() => {
82
+ if (Array.isArray(parameters[0])) {
83
+ const [abi, options] = parameters as [
84
+ Abi.Abi | readonly unknown[],
85
+ decode.Options,
86
+ ]
87
+ return [fromAbi(abi), options] as [AbiConstructor, decode.Options]
88
+ }
89
+ return parameters as [AbiConstructor, decode.Options]
90
+ })()
91
+
53
92
  const { bytecode } = options
54
93
  if (abiConstructor.inputs.length === 0) return undefined
55
94
  const data = options.data.replace(bytecode, '0x') as Hex.Hex
@@ -91,6 +130,23 @@ export declare namespace decode {
91
130
  * ```
92
131
  *
93
132
  * @example
133
+ * ### ABI-shorthand
134
+ *
135
+ * You can also specify an entire ABI object as a parameter to `AbiConstructor.encode`.
136
+ *
137
+ * ```ts twoslash
138
+ * // @noErrors
139
+ * import { Abi, AbiConstructor } from 'ox'
140
+ *
141
+ * const abi = Abi.from([...])
142
+ *
143
+ * const data = AbiConstructor.encode(abi, { // [!code focus]
144
+ * bytecode: '0x...', // [!code focus]
145
+ * args: ['0xd8da6bf26964af9d7eed9e03e53415d37aa96045', 123n], // [!code focus]
146
+ * }) // [!code focus]
147
+ * ```
148
+ *
149
+ * @example
94
150
  * ### End-to-end
95
151
  *
96
152
  * Below is an end-to-end example of using `AbiConstructor.encode` to encode the constructor of a contract and deploy it.
@@ -128,10 +184,38 @@ export declare namespace decode {
128
184
  * @param options - Encoding options.
129
185
  * @returns The encoded constructor.
130
186
  */
187
+ export function encode<
188
+ const abi extends Abi.Abi | readonly unknown[],
189
+ abiConstructor extends
190
+ AbiConstructor = fromAbi.ReturnType<abi> extends AbiConstructor
191
+ ? fromAbi.ReturnType<abi>
192
+ : never,
193
+ >(
194
+ abi: abi | Abi.Abi | readonly unknown[],
195
+ options: encode.Options<abiConstructor>,
196
+ ): encode.ReturnType
131
197
  export function encode<const abiConstructor extends AbiConstructor>(
132
- abiConstructor: abiConstructor,
198
+ abiConstructor: abiConstructor | AbiConstructor,
133
199
  options: encode.Options<abiConstructor>,
200
+ ): encode.ReturnType
201
+ // eslint-disable-next-line jsdoc/require-jsdoc
202
+ export function encode(
203
+ ...parameters:
204
+ | [abi: Abi.Abi | readonly unknown[], options: encode.Options]
205
+ | [abiConstructor: AbiConstructor, options: encode.Options]
134
206
  ): encode.ReturnType {
207
+ const [abiConstructor, options] = (() => {
208
+ if (Array.isArray(parameters[0])) {
209
+ const [abi, options] = parameters as [
210
+ Abi.Abi | readonly unknown[],
211
+ encode.Options,
212
+ ]
213
+ return [fromAbi(abi), options] as [AbiConstructor, encode.Options]
214
+ }
215
+
216
+ return parameters as [AbiConstructor, encode.Options]
217
+ })()
218
+
135
219
  const { bytecode, args } = options
136
220
  return Hex.concat(
137
221
  bytecode,
package/core/AbiError.ts CHANGED
@@ -59,35 +59,37 @@ export function decode<
59
59
  * ```
60
60
  *
61
61
  * @example
62
- * Or define the ABI and error name as parameters to {@link ox#AbiError.(decode:function)}:
62
+ * You can pass the error `data` to the `name` property of {@link ox#AbiError.(fromAbi:function)} to extract and infer the error by its 4-byte selector:
63
63
  *
64
64
  * ```ts twoslash
65
65
  * // @noErrors
66
66
  * import { Abi, AbiError } from 'ox'
67
67
  *
68
+ * const data = '0xecde634900000000000000000000000000000000000000000000000000000000000001a400000000000000000000000000000000000000000000000000000000000000450000000000000000000000000000000000000000000000000000000000000001'
69
+ *
68
70
  * const abi = Abi.from([...])
71
+ * const error = AbiError.fromAbi(abi, data) // [!code hl]
69
72
  *
70
- * const value = AbiError.decode(
71
- * abi, // [!code hl]
72
- * 'InvalidSignature', // [!code hl]
73
- * '0x...'
74
- * )
73
+ * const value = AbiError.decode(error, data)
75
74
  * // @log: [420n, 69n, 1]
76
75
  * ```
77
76
  *
78
77
  * @example
79
- * You can pass the error `data` to the `name` property of {@link ox#AbiError.(fromAbi:function)} to extract and infer the error by its 4-byte selector:
78
+ * ### ABI-shorthand
79
+ *
80
+ * You can also specify an entire ABI object as a parameter to {@link ox#AbiError.(decode:function)}:
80
81
  *
81
82
  * ```ts twoslash
82
83
  * // @noErrors
83
84
  * import { Abi, AbiError } from 'ox'
84
85
  *
85
- * const data = '0xecde634900000000000000000000000000000000000000000000000000000000000001a400000000000000000000000000000000000000000000000000000000000000450000000000000000000000000000000000000000000000000000000000000001'
86
- *
87
86
  * const abi = Abi.from([...])
88
- * const error = AbiError.fromAbi(abi, data) // [!code hl]
89
87
  *
90
- * const value = AbiError.decode(error, data)
88
+ * const value = AbiError.decode(
89
+ * abi, // [!code hl]
90
+ * 'InvalidSignature', // [!code hl]
91
+ * '0x...'
92
+ * )
91
93
  * // @log: [420n, 69n, 1]
92
94
  * ```
93
95
  *
@@ -281,32 +283,21 @@ export declare namespace decode {
281
283
  * ```
282
284
  *
283
285
  * @example
284
- * You can extract an ABI Error from a JSON ABI with {@link ox#AbiError.(fromAbi:function)}:
286
+ * ### ABI-shorthand
287
+ *
288
+ * You can also specify an entire ABI object and an error name as parameters to `AbiError.encode`.
285
289
  *
286
290
  * ```ts twoslash
287
291
  * // @noErrors
288
292
  * import { Abi, AbiError } from 'ox'
289
293
  *
290
- * const abi = Abi.from([ // [!code hl]
291
- * // ... // [!code hl]
292
- * { // [!code hl]
293
- * name: 'InvalidSignature', // [!code hl]
294
- * type: 'error', // [!code hl]
295
- * inputs: [ // [!code hl]
296
- * { name: 'r', type: 'uint256' }, // [!code hl]
297
- * { name: 's', type: 'uint256' }, // [!code hl]
298
- * { name: 'yParity', type: 'uint8' }, // [!code hl]
299
- * ], // [!code hl]
300
- * }, // [!code hl]
301
- * // ... // [!code hl]
302
- * ]) // [!code hl]
303
- * const error = AbiError.fromAbi(abi, 'InvalidSignature') // [!code hl]
294
+ * const abi = Abi.from([...])
304
295
  *
305
296
  * const data = AbiError.encode(
306
- * error,
307
- * ['0xd8da6bf26964af9d7eed9e03e53415d37aa96045', 69420n]
297
+ * abi, // [!code hl]
298
+ * 'InvalidSignature', // [!code hl]
299
+ * [1n, 2n, 0]
308
300
  * )
309
- * // @log: '0x095ea7b3000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa960450000000000000000000000000000000000000000000000000000000000010f2c'
310
301
  * ```
311
302
  *
312
303
  * @param abiError - ABI Error to encode
package/core/AbiEvent.ts CHANGED
@@ -237,6 +237,38 @@ export declare namespace assertArgs {
237
237
  * ```
238
238
  *
239
239
  * @example
240
+ * ### ABI-shorthand
241
+ *
242
+ * You can also specify an entire ABI object and an event name as parameters to {@link ox#AbiEvent.(decode:function)}:
243
+ *
244
+ * ```ts twoslash
245
+ * // @noErrors
246
+ * import { Abi, AbiEvent } from 'ox'
247
+ *
248
+ * const abi = Abi.from([...])
249
+ * const log = {
250
+ * // ...
251
+ * data: '0x0000000000000000000000000000000000000000000000000000000000000001',
252
+ * topics: [
253
+ * '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
254
+ * '0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ac',
255
+ * '0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ac',
256
+ * ],
257
+ * } as const
258
+ *
259
+ * const decoded = AbiEvent.decode(
260
+ * abi, // [!code focus]
261
+ * 'Transfer', // [!code focus]
262
+ * log
263
+ * )
264
+ * // @log: {
265
+ * // @log: from: '0xa5cc3c03994db5b0d9a5eedd10cabab0813678ac',
266
+ * // @log: to: '0xa5cc3c03994db5b0d9a5eedd10cabab0813678ac',
267
+ * // @log: value: 1n
268
+ * // @log: }
269
+ * ```
270
+ *
271
+ * @example
240
272
  * ### End-to-end
241
273
  *
242
274
  * Below is an end-to-end example of using `AbiEvent.decode` to decode the topics of a `Transfer` event on the [Wagmi Mint Example contract](https://etherscan.io/address/0xfba3912ca04dd458c843e2ee08967fc04f3579c2).
@@ -490,6 +522,32 @@ export declare namespace decode {
490
522
  * ```
491
523
  *
492
524
  * @example
525
+ * ### ABI-shorthand
526
+ *
527
+ * You can also specify an entire ABI object and an event name as parameters to {@link ox#AbiEvent.(encode:function)}:
528
+ *
529
+ * ```ts twoslash
530
+ * // @noErrors
531
+ * import { Abi, AbiEvent } from 'ox'
532
+ *
533
+ * const abi = Abi.from([...])
534
+ *
535
+ * const { topics } = AbiEvent.encode(
536
+ * abi, // [!code focus]
537
+ * 'Transfer', // [!code focus]
538
+ * {
539
+ * from: '0xf39fd6e51aad88f6f4ce6ab882779cfffb92266', // [!code focus]
540
+ * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
541
+ * }
542
+ * )
543
+ * // @log: [
544
+ * // @log: '0x406dade31f7ae4b5dbc276258c28dde5ae6d5c2773c5745802c493a2360e55e0',
545
+ * // @log: '0x00000000000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266',
546
+ * // @log: '0x0000000000000000000000000000000070997970c51812dc3a010c7d01b50e0d17dc79c8'
547
+ * // @log: ]
548
+ * ```
549
+ *
550
+ * @example
493
551
  * ### End-to-end
494
552
  *
495
553
  * Below is an end-to-end example of using `AbiEvent.encode` to encode the topics of a `Transfer` event and query for events matching the encoded topics on the [Wagmi Mint Example contract](https://etherscan.io/address/0xfba3912ca04dd458c843e2ee08967fc04f3579c2).
@@ -90,6 +90,26 @@ export type ExtractNames<
90
90
  * // @log: ['0xd8da6bf26964af9d7eed9e03e53415d37aa96045', 69420n]
91
91
  * ```
92
92
  *
93
+ * @example
94
+ * ### ABI-shorthand
95
+ *
96
+ * You can also specify an entire ABI object and a function name as parameters to {@link ox#AbiFunction.(decodeData:function)}:
97
+ *
98
+ * ```ts twoslash
99
+ * // @noErrors
100
+ * import { Abi, AbiFunction } from 'ox'
101
+ *
102
+ * const abi = Abi.from([...])
103
+ * const data = '0x...
104
+ *
105
+ * const input = AbiFunction.decodeData(
106
+ * abi, // [!code focus]
107
+ * 'approve', // [!code focus]
108
+ * data
109
+ * )
110
+ * // @log: ['0xd8da6bf26964af9d7eed9e03e53415d37aa96045', 69420n]
111
+ * ```
112
+ *
93
113
  * @param abiFunction - The ABI Item to decode.
94
114
  * @param data - The data to decode.
95
115
  */
@@ -211,7 +231,9 @@ export declare namespace decodeData {
211
231
  * ```
212
232
  *
213
233
  * @example
214
- * Or define the ABI and function name as parameters to {@link ox#AbiFunction.(decodeResult:function)}:
234
+ * ### ABI-shorthand
235
+ *
236
+ * You can also specify an entire ABI object and a function name as parameters to {@link ox#AbiFunction.(decodeResult:function)}:
215
237
  *
216
238
  * ```ts twoslash
217
239
  * // @noErrors
@@ -222,8 +244,8 @@ export declare namespace decodeData {
222
244
  * const erc20Abi = Abi.from([...])
223
245
  *
224
246
  * const output = AbiFunction.decodeResult(
225
- * erc20Abi, // [!code hl]
226
- * 'totalSupply', // [!code hl]
247
+ * erc20Abi, // [!code focus]
248
+ * 'totalSupply', // [!code focus]
227
249
  * data
228
250
  * )
229
251
  * // @log: 42n
@@ -433,7 +455,9 @@ export declare namespace decodeResult {
433
455
  * ```
434
456
  *
435
457
  * @example
436
- * Or define the ABI and function name as parameters to {@link ox#AbiFunction.(encodeData:function)}:
458
+ * ### ABI-shorthand
459
+ *
460
+ * You can specify an entire ABI object and a function name as parameters to {@link ox#AbiFunction.(encodeData:function)}:
437
461
  *
438
462
  * ```ts twoslash
439
463
  * // @noErrors
@@ -442,8 +466,8 @@ export declare namespace decodeResult {
442
466
  * const erc20Abi = Abi.from([...])
443
467
  *
444
468
  * const data = AbiFunction.encodeData(
445
- * erc20Abi, // [!code hl]
446
- * 'approve', // [!code hl]
469
+ * erc20Abi, // [!code focus]
470
+ * 'approve', // [!code focus]
447
471
  * ['0xd8da6bf26964af9d7eed9e03e53415d37aa96045', 69420n]
448
472
  * )
449
473
  * ```
@@ -603,6 +627,25 @@ export declare namespace encodeData {
603
627
  * // @log: '0x000000000000000000000000000000000000000000000000000000000000002a'
604
628
  * ```
605
629
  *
630
+ * @example
631
+ * ### ABI-shorthand
632
+ *
633
+ * You can also specify an entire ABI object and a function name as parameters to {@link ox#AbiFunction.(encodeResult:function)}:
634
+ *
635
+ * ```ts twoslash
636
+ * // @noErrors
637
+ * import { Abi, AbiFunction } from 'ox'
638
+ *
639
+ * const abi = Abi.from([...])
640
+ *
641
+ * const data = AbiFunction.encodeResult(
642
+ * abi, // [!code focus]
643
+ * 'totalSupply', // [!code focus]
644
+ * 42n
645
+ * )
646
+ * // @log: '0x000000000000000000000000000000000000000000000000000000000000002a'
647
+ * ```
648
+ *
606
649
  * @param abiFunction - The ABI item to encode the function output for.
607
650
  * @param output - The function output to encode.
608
651
  * @param options - Encoding options.
package/core/AbiItem.ts CHANGED
@@ -493,6 +493,17 @@ export declare namespace fromAbi {
493
493
  *
494
494
  * @example
495
495
  * ```ts twoslash
496
+ * // @noErrors
497
+ * import { Abi, AbiItem } from 'ox'
498
+ *
499
+ * const erc20Abi = Abi.from([...])
500
+ *
501
+ * const selector = AbiItem.getSelector(erc20Abi, 'ownerOf')
502
+ * // @log: '0x6352211e'
503
+ * ```
504
+ *
505
+ * @example
506
+ * ```ts twoslash
496
507
  * import { AbiItem } from 'ox'
497
508
  *
498
509
  * const selector = AbiItem.getSelector({
@@ -508,7 +519,24 @@ export declare namespace fromAbi {
508
519
  * @param abiItem - The ABI item to compute the selector for. Can be a signature or an ABI item for an error, event, function, etc.
509
520
  * @returns The first 4 bytes of the {@link ox#Hash.(keccak256:function)} hash of the function signature.
510
521
  */
511
- export function getSelector(abiItem: string | AbiItem): Hex.Hex {
522
+ export function getSelector<
523
+ abi extends Abi.Abi | readonly unknown[],
524
+ name extends Name<abi>,
525
+ >(abi: abi | Abi.Abi | readonly unknown[], name: name): Hex.Hex
526
+ export function getSelector(abiItem: string | AbiItem): Hex.Hex
527
+ // eslint-disable-next-line jsdoc/require-jsdoc
528
+ export function getSelector(
529
+ ...parameters:
530
+ | [abi: Abi.Abi | readonly unknown[], name: string]
531
+ | [string | AbiItem]
532
+ ): Hex.Hex {
533
+ const abiItem = (() => {
534
+ if (Array.isArray(parameters[0])) {
535
+ const [abi, name] = parameters as [Abi.Abi | readonly unknown[], string]
536
+ return fromAbi(abi, name)
537
+ }
538
+ return parameters[0] as string | AbiItem
539
+ })()
512
540
  return Hex.slice(getSignatureHash(abiItem), 0, 4)
513
541
  }
514
542
 
@@ -532,6 +560,17 @@ export declare namespace getSelector {
532
560
  *
533
561
  * @example
534
562
  * ```ts twoslash
563
+ * // @noErrors
564
+ * import { Abi, AbiItem } from 'ox'
565
+ *
566
+ * const erc20Abi = Abi.from([...])
567
+ *
568
+ * const signature = AbiItem.getSignature(erc20Abi, 'ownerOf')
569
+ * // @log: 'ownerOf(uint256)'
570
+ * ```
571
+ *
572
+ * @example
573
+ * ```ts twoslash
535
574
  * import { AbiItem } from 'ox'
536
575
  *
537
576
  * const signature = AbiItem.getSignature({
@@ -547,7 +586,24 @@ export declare namespace getSelector {
547
586
  * @param abiItem - The ABI Item to compute the signature for.
548
587
  * @returns The stringified signature of the ABI Item.
549
588
  */
550
- export function getSignature(abiItem: string | AbiItem): string {
589
+ export function getSignature<
590
+ abi extends Abi.Abi | readonly unknown[],
591
+ name extends Name<abi>,
592
+ >(abi: abi | Abi.Abi | readonly unknown[], name: name): string
593
+ export function getSignature(abiItem: string | AbiItem): string
594
+ // eslint-disable-next-line jsdoc/require-jsdoc
595
+ export function getSignature(
596
+ ...parameters:
597
+ | [abi: Abi.Abi | readonly unknown[], name: string]
598
+ | [string | AbiItem]
599
+ ): string {
600
+ const abiItem = (() => {
601
+ if (Array.isArray(parameters[0])) {
602
+ const [abi, name] = parameters as [Abi.Abi | readonly unknown[], string]
603
+ return fromAbi(abi, name)
604
+ }
605
+ return parameters[0] as string | AbiItem
606
+ })()
551
607
  const signature = (() => {
552
608
  if (typeof abiItem === 'string') return abiItem
553
609
  return abitype.formatAbiItem(abiItem)
@@ -576,6 +632,17 @@ export declare namespace getSignature {
576
632
  *
577
633
  * @example
578
634
  * ```ts twoslash
635
+ * // @noErrors
636
+ * import { Abi, AbiItem } from 'ox'
637
+ *
638
+ * const erc20Abi = Abi.from([...])
639
+ *
640
+ * const hash = AbiItem.getSignatureHash(erc20Abi, 'Transfer')
641
+ * // @log: '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'
642
+ * ```
643
+ *
644
+ * @example
645
+ * ```ts twoslash
579
646
  * import { AbiItem } from 'ox'
580
647
  *
581
648
  * const hash = AbiItem.getSignatureHash({
@@ -593,7 +660,24 @@ export declare namespace getSignature {
593
660
  * @param abiItem - The ABI Item to compute the signature hash for.
594
661
  * @returns The {@link ox#Hash.(keccak256:function)} hash of the ABI item's signature.
595
662
  */
596
- export function getSignatureHash(abiItem: string | AbiItem): Hex.Hex {
663
+ export function getSignatureHash<
664
+ abi extends Abi.Abi | readonly unknown[],
665
+ name extends Name<abi>,
666
+ >(abi: abi | Abi.Abi | readonly unknown[], name: name): Hex.Hex
667
+ export function getSignatureHash(abiItem: string | AbiItem): Hex.Hex
668
+ // eslint-disable-next-line jsdoc/require-jsdoc
669
+ export function getSignatureHash(
670
+ ...parameters:
671
+ | [abi: Abi.Abi | readonly unknown[], name: string]
672
+ | [string | AbiItem]
673
+ ): Hex.Hex {
674
+ const abiItem = (() => {
675
+ if (Array.isArray(parameters[0])) {
676
+ const [abi, name] = parameters as [Abi.Abi | readonly unknown[], string]
677
+ return fromAbi(abi, name)
678
+ }
679
+ return parameters[0] as string | AbiItem
680
+ })()
597
681
  if (typeof abiItem !== 'string' && 'hash' in abiItem && abiItem.hash)
598
682
  return abiItem.hash as Hex.Hex
599
683
  return Hash.keccak256(Hex.fromString(getSignature(abiItem)))