viem 1.19.9 → 1.19.11
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 +425 -407
- package/README.md +46 -46
- package/_cjs/accounts/utils/signTransaction.js.map +1 -1
- package/_cjs/actions/public/createContractEventFilter.js.map +1 -1
- package/_cjs/actions/public/estimateMaxPriorityFeePerGas.js +1 -1
- package/_cjs/actions/public/estimateMaxPriorityFeePerGas.js.map +1 -1
- package/_cjs/actions/public/waitForTransactionReceipt.js +8 -1
- package/_cjs/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/_cjs/chains/celo/serializers.js +3 -7
- package/_cjs/chains/celo/serializers.js.map +1 -1
- package/_cjs/chains/definitions/confluxESpace.js +2 -0
- package/_cjs/chains/definitions/confluxESpace.js.map +1 -1
- package/_cjs/chains/definitions/confluxESpaceTestnet.js +34 -0
- package/_cjs/chains/definitions/confluxESpaceTestnet.js.map +1 -0
- package/_cjs/chains/definitions/sapphire.js +33 -0
- package/_cjs/chains/definitions/sapphire.js.map +1 -0
- package/_cjs/chains/definitions/sapphireTestnet.js +28 -0
- package/_cjs/chains/definitions/sapphireTestnet.js.map +1 -0
- package/_cjs/chains/index.js +10 -4
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/errors/base.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/errors/version.js.map +1 -1
- package/_cjs/utils/abi/encodeEventTopics.js.map +1 -1
- package/_cjs/utils/ccip.js +3 -1
- package/_cjs/utils/ccip.js.map +1 -1
- package/_cjs/utils/encoding/toBytes.js +2 -2
- package/_cjs/utils/encoding/toBytes.js.map +1 -1
- package/_cjs/utils/ens/avatar/utils.js +1 -1
- package/_cjs/utils/ens/avatar/utils.js.map +1 -1
- package/_cjs/utils/errors/getContractError.js.map +1 -1
- package/_cjs/utils/errors/getNodeError.js +11 -11
- package/_cjs/utils/errors/getNodeError.js.map +1 -1
- package/_cjs/utils/transaction/getTransactionType.js.map +1 -1
- package/_cjs/utils/transaction/serializeTransaction.js.map +1 -1
- package/_esm/accounts/utils/signTransaction.js.map +1 -1
- package/_esm/actions/ens/getEnsAddress.js +2 -2
- package/_esm/actions/ens/getEnsAvatar.js +2 -2
- package/_esm/actions/ens/getEnsName.js +2 -2
- package/_esm/actions/ens/getEnsResolver.js +2 -2
- package/_esm/actions/ens/getEnsText.js +2 -2
- package/_esm/actions/public/createContractEventFilter.js.map +1 -1
- package/_esm/actions/public/estimateMaxPriorityFeePerGas.js +1 -1
- package/_esm/actions/public/estimateMaxPriorityFeePerGas.js.map +1 -1
- package/_esm/actions/public/getBlock.js +1 -1
- package/_esm/actions/public/getBlockNumber.js +1 -1
- package/_esm/actions/public/getLogs.js +1 -1
- package/_esm/actions/public/getTransaction.js +1 -1
- package/_esm/actions/public/getTransactionConfirmations.js +1 -1
- package/_esm/actions/public/getTransactionReceipt.js +1 -1
- package/_esm/actions/public/readContract.js +1 -1
- package/_esm/actions/public/simulateContract.js +1 -1
- package/_esm/actions/public/waitForTransactionReceipt.js +12 -2
- package/_esm/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/_esm/actions/public/watchBlockNumber.js +1 -1
- package/_esm/actions/public/watchBlocks.js +1 -1
- package/_esm/actions/wallet/deployContract.js +1 -1
- package/_esm/actions/wallet/sendTransaction.js +1 -1
- package/_esm/actions/wallet/writeContract.js +1 -1
- package/_esm/chains/celo/serializers.js +3 -7
- package/_esm/chains/celo/serializers.js.map +1 -1
- package/_esm/chains/definitions/confluxESpace.js +2 -0
- package/_esm/chains/definitions/confluxESpace.js.map +1 -1
- package/_esm/chains/definitions/confluxESpaceTestnet.js +31 -0
- package/_esm/chains/definitions/confluxESpaceTestnet.js.map +1 -0
- package/_esm/chains/definitions/sapphire.js +30 -0
- package/_esm/chains/definitions/sapphire.js.map +1 -0
- package/_esm/chains/definitions/sapphireTestnet.js +25 -0
- package/_esm/chains/definitions/sapphireTestnet.js.map +1 -0
- package/_esm/chains/index.js +3 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/errors/base.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/errors/version.js.map +1 -1
- package/_esm/utils/abi/encodeEventTopics.js.map +1 -1
- package/_esm/utils/ccip.js +3 -1
- package/_esm/utils/ccip.js.map +1 -1
- package/_esm/utils/encoding/toBytes.js +2 -2
- package/_esm/utils/encoding/toBytes.js.map +1 -1
- package/_esm/utils/ens/avatar/utils.js +1 -1
- package/_esm/utils/ens/avatar/utils.js.map +1 -1
- package/_esm/utils/ens/namehash.js +1 -1
- package/_esm/utils/ens/normalize.js +2 -2
- package/_esm/utils/errors/getContractError.js.map +1 -1
- package/_esm/utils/errors/getNodeError.js +11 -11
- package/_esm/utils/errors/getNodeError.js.map +1 -1
- package/_esm/utils/transaction/getTransactionType.js.map +1 -1
- package/_esm/utils/transaction/serializeTransaction.js.map +1 -1
- package/_types/accounts/utils/signTransaction.d.ts.map +1 -1
- package/_types/actions/ens/getEnsAddress.d.ts +2 -2
- package/_types/actions/ens/getEnsAvatar.d.ts +2 -2
- package/_types/actions/ens/getEnsName.d.ts +2 -2
- package/_types/actions/ens/getEnsResolver.d.ts +2 -2
- package/_types/actions/ens/getEnsText.d.ts +2 -2
- package/_types/actions/public/createContractEventFilter.d.ts.map +1 -1
- package/_types/actions/public/estimateMaxPriorityFeePerGas.d.ts.map +1 -1
- package/_types/actions/public/getBlock.d.ts +1 -1
- package/_types/actions/public/getBlockNumber.d.ts +1 -1
- package/_types/actions/public/getLogs.d.ts +1 -1
- package/_types/actions/public/getTransaction.d.ts +1 -1
- package/_types/actions/public/getTransactionConfirmations.d.ts +1 -1
- package/_types/actions/public/getTransactionReceipt.d.ts +1 -1
- package/_types/actions/public/readContract.d.ts +1 -1
- package/_types/actions/public/simulateContract.d.ts +1 -1
- package/_types/actions/public/waitForTransactionReceipt.d.ts +1 -1
- package/_types/actions/public/waitForTransactionReceipt.d.ts.map +1 -1
- package/_types/actions/public/watchBlockNumber.d.ts +1 -1
- package/_types/actions/public/watchBlocks.d.ts +1 -1
- package/_types/actions/wallet/deployContract.d.ts +1 -1
- package/_types/actions/wallet/sendTransaction.d.ts +1 -1
- package/_types/actions/wallet/writeContract.d.ts +1 -1
- package/_types/chains/celo/serializers.d.ts.map +1 -1
- package/_types/chains/definitions/confluxESpace.d.ts +2 -0
- package/_types/chains/definitions/confluxESpace.d.ts.map +1 -1
- package/_types/chains/definitions/confluxESpaceTestnet.d.ts +34 -0
- package/_types/chains/definitions/confluxESpaceTestnet.d.ts.map +1 -0
- package/_types/chains/definitions/sapphire.d.ts +33 -0
- package/_types/chains/definitions/sapphire.d.ts.map +1 -0
- package/_types/chains/definitions/sapphireTestnet.d.ts +28 -0
- package/_types/chains/definitions/sapphireTestnet.d.ts.map +1 -0
- package/_types/chains/index.d.ts +3 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/clients/decorators/public.d.ts +21 -21
- package/_types/clients/decorators/wallet.d.ts +3 -3
- package/_types/errors/version.d.ts +1 -1
- package/_types/errors/version.d.ts.map +1 -1
- package/_types/types/contract.d.ts.map +1 -1
- package/_types/types/filter.d.ts.map +1 -1
- package/_types/types/log.d.ts.map +1 -1
- package/_types/types/multicall.d.ts.map +1 -1
- package/_types/types/transaction.d.ts.map +1 -1
- package/_types/types/typedData.d.ts.map +1 -1
- package/_types/types/utils.d.ts.map +1 -1
- package/_types/utils/abi/decodeFunctionResult.d.ts.map +1 -1
- package/_types/utils/abi/encodeErrorResult.d.ts.map +1 -1
- package/_types/utils/abi/encodeEventTopics.d.ts.map +1 -1
- package/_types/utils/abi/encodeFunctionData.d.ts.map +1 -1
- package/_types/utils/abi/encodeFunctionResult.d.ts.map +1 -1
- package/_types/utils/ccip.d.ts.map +1 -1
- package/_types/utils/encoding/fromBytes.d.ts.map +1 -1
- package/_types/utils/encoding/fromHex.d.ts.map +1 -1
- package/_types/utils/ens/avatar/utils.d.ts.map +1 -1
- package/_types/utils/ens/namehash.d.ts +1 -1
- package/_types/utils/ens/normalize.d.ts +2 -2
- package/_types/utils/errors/getNodeError.d.ts.map +1 -1
- package/_types/utils/transaction/getSerializedTransactionType.d.ts.map +1 -1
- package/_types/utils/transaction/getTransactionType.d.ts.map +1 -1
- package/_types/utils/transaction/serializeTransaction.d.ts.map +1 -1
- package/accounts/utils/signTransaction.ts +4 -2
- package/actions/ens/getEnsAddress.ts +3 -3
- package/actions/ens/getEnsAvatar.ts +2 -2
- package/actions/ens/getEnsName.ts +2 -2
- package/actions/ens/getEnsResolver.ts +2 -2
- package/actions/ens/getEnsText.ts +2 -2
- package/actions/public/call.ts +1 -1
- package/actions/public/createContractEventFilter.ts +11 -9
- package/actions/public/estimateMaxPriorityFeePerGas.ts +3 -1
- package/actions/public/getBlock.ts +1 -1
- package/actions/public/getBlockNumber.ts +1 -1
- package/actions/public/getLogs.ts +1 -1
- package/actions/public/getTransaction.ts +1 -1
- package/actions/public/getTransactionConfirmations.ts +1 -1
- package/actions/public/getTransactionReceipt.ts +1 -1
- package/actions/public/readContract.ts +1 -1
- package/actions/public/simulateContract.ts +1 -1
- package/actions/public/verifyHash.ts +1 -1
- package/actions/public/verifyMessage.ts +1 -1
- package/actions/public/verifyTypedData.ts +1 -1
- package/actions/public/waitForTransactionReceipt.ts +24 -9
- package/actions/public/watchBlockNumber.ts +1 -1
- package/actions/public/watchBlocks.ts +1 -1
- package/actions/wallet/deployContract.ts +1 -1
- package/actions/wallet/sendRawTransaction.ts +1 -1
- package/actions/wallet/sendTransaction.ts +1 -1
- package/actions/wallet/writeContract.ts +1 -1
- package/chains/celo/serializers.ts +3 -7
- package/chains/definitions/confluxESpace.ts +2 -0
- package/chains/definitions/confluxESpaceTestnet.ts +31 -0
- package/chains/definitions/sapphire.ts +30 -0
- package/chains/definitions/sapphireTestnet.ts +25 -0
- package/chains/index.ts +3 -0
- package/clients/decorators/public.ts +21 -21
- package/clients/decorators/wallet.ts +3 -3
- package/errors/base.ts +2 -2
- package/errors/version.ts +1 -1
- package/package.json +3 -3
- package/types/contract.ts +63 -64
- package/types/filter.ts +12 -12
- package/types/log.ts +4 -4
- package/types/multicall.ts +65 -57
- package/types/transaction.ts +4 -4
- package/types/typedData.ts +12 -12
- package/types/utils.ts +6 -7
- package/utils/abi/decodeFunctionResult.ts +2 -2
- package/utils/abi/encodeErrorResult.ts +2 -2
- package/utils/abi/encodeEventTopics.ts +6 -6
- package/utils/abi/encodeFunctionData.ts +2 -2
- package/utils/abi/encodeFunctionResult.ts +5 -5
- package/utils/ccip.ts +4 -2
- package/utils/encoding/fromBytes.ts +8 -8
- package/utils/encoding/fromHex.ts +8 -8
- package/utils/encoding/toBytes.ts +2 -2
- package/utils/ens/avatar/utils.ts +3 -1
- package/utils/ens/namehash.ts +1 -1
- package/utils/ens/normalize.ts +2 -2
- package/utils/errors/getContractError.ts +2 -2
- package/utils/errors/getNodeError.ts +12 -11
- package/utils/rpc.ts +1 -1
- package/utils/transaction/getSerializedTransactionType.ts +2 -2
- package/utils/transaction/getTransactionType.ts +2 -1
- package/utils/transaction/serializeTransaction.ts +6 -3
package/types/contract.ts
CHANGED
@@ -58,10 +58,10 @@ export type ContractFunctionResult<
|
|
58
58
|
> = true extends FailedToParseArgs
|
59
59
|
? unknown
|
60
60
|
: TArgs extends readonly []
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
61
|
+
? void
|
62
|
+
: TArgs extends readonly [infer Arg]
|
63
|
+
? Arg
|
64
|
+
: TArgs
|
65
65
|
|
66
66
|
export type GetValue<
|
67
67
|
TAbi extends Abi | readonly unknown[],
|
@@ -75,8 +75,8 @@ export type GetValue<
|
|
75
75
|
? TAbiFunction['stateMutability'] extends 'payable'
|
76
76
|
? { value?: NoUndefined<TValueType> }
|
77
77
|
: TAbiFunction['payable'] extends true
|
78
|
-
|
79
|
-
|
78
|
+
? { value?: NoUndefined<TValueType> }
|
79
|
+
: { value?: never }
|
80
80
|
: { value?: TValueType }
|
81
81
|
|
82
82
|
export type MaybeAbiEventName<TAbiEvent extends AbiEvent | undefined> =
|
@@ -170,10 +170,10 @@ export type GetFunctionArgs<
|
|
170
170
|
args?: readonly unknown[]
|
171
171
|
}
|
172
172
|
: TArgs extends readonly []
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
173
|
+
? { args?: never }
|
174
|
+
: {
|
175
|
+
/** Arguments to pass contract method */ args: TArgs
|
176
|
+
}
|
177
177
|
|
178
178
|
export type GetConstructorArgs<
|
179
179
|
TAbi extends Abi | readonly unknown[],
|
@@ -194,10 +194,10 @@ export type GetConstructorArgs<
|
|
194
194
|
args?: readonly unknown[]
|
195
195
|
}
|
196
196
|
: TArgs extends readonly []
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
197
|
+
? { args?: never }
|
198
|
+
: {
|
199
|
+
/** Arguments to pass contract constructor */ args: TArgs
|
200
|
+
}
|
201
201
|
|
202
202
|
export type GetErrorArgs<
|
203
203
|
TAbi extends Abi | readonly unknown[],
|
@@ -219,10 +219,10 @@ export type GetErrorArgs<
|
|
219
219
|
args?: readonly unknown[]
|
220
220
|
}
|
221
221
|
: TArgs extends readonly []
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
222
|
+
? { args?: never }
|
223
|
+
: {
|
224
|
+
/** Arguments to pass contract method */ args: TArgs
|
225
|
+
}
|
226
226
|
|
227
227
|
export type GetEventArgs<
|
228
228
|
TAbi extends Abi | readonly unknown[],
|
@@ -296,10 +296,10 @@ export type LogTopicType<
|
|
296
296
|
> = TTopic extends Hex
|
297
297
|
? TPrimitiveType
|
298
298
|
: TTopic extends Hex[]
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
299
|
+
? TPrimitiveType[]
|
300
|
+
: TTopic extends null
|
301
|
+
? null
|
302
|
+
: never
|
303
303
|
|
304
304
|
/**
|
305
305
|
* @internal
|
@@ -328,46 +328,45 @@ export type AbiEventParametersToPrimitiveTypes<
|
|
328
328
|
> = TAbiParameters extends readonly []
|
329
329
|
? readonly []
|
330
330
|
: Filter<
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
331
|
+
TAbiParameters,
|
332
|
+
Options['IndexedOnly'] extends true ? { indexed: true } : object
|
333
|
+
> extends infer Filtered extends readonly AbiParameter[]
|
334
|
+
? _HasUnnamedAbiParameter<Filtered> extends true
|
335
|
+
? // Has unnamed tuple parameters so return as array
|
336
|
+
| readonly [
|
337
|
+
...{
|
338
|
+
[K in keyof Filtered]: AbiEventParameterToPrimitiveType<
|
339
|
+
Filtered[K],
|
340
|
+
Options
|
341
|
+
>
|
342
|
+
},
|
343
|
+
]
|
344
|
+
// Distribute over tuple to represent optional parameters
|
345
|
+
| (Options['Required'] extends true
|
346
|
+
? never
|
347
|
+
: // Distribute over tuple to represent optional parameters
|
348
|
+
Filtered extends readonly [
|
349
|
+
...infer Head extends readonly AbiParameter[],
|
350
|
+
infer _,
|
351
|
+
]
|
352
|
+
? AbiEventParametersToPrimitiveTypes<
|
353
|
+
readonly [...{ [K in keyof Head]: Omit<Head[K], 'name'> }],
|
354
|
+
Options
|
355
|
+
>
|
356
|
+
: never)
|
357
|
+
: // All tuple parameters are named so return as object
|
358
|
+
{
|
359
|
+
[Parameter in Filtered[number] as Parameter extends {
|
360
|
+
name: infer Name extends string
|
361
|
+
}
|
362
|
+
? Name
|
363
|
+
: never]?: AbiEventParameterToPrimitiveType<Parameter, Options>
|
364
|
+
} extends infer Mapped
|
365
|
+
? Prettify<
|
366
|
+
MaybeRequired<
|
367
|
+
Mapped,
|
368
|
+
Options['Required'] extends boolean ? Options['Required'] : false
|
369
|
+
>
|
370
|
+
>
|
371
|
+
: never
|
372
372
|
: never
|
373
|
-
: never
|
package/types/filter.ts
CHANGED
@@ -42,18 +42,18 @@ export type Filter<
|
|
42
42
|
strict: TStrict
|
43
43
|
}
|
44
44
|
: TArgs extends MaybeExtractEventArgsFromAbi<TAbi, TEventName>
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
45
|
+
? {
|
46
|
+
abi: TAbi
|
47
|
+
args: TArgs
|
48
|
+
eventName: TEventName
|
49
|
+
strict: TStrict
|
50
|
+
}
|
51
|
+
: {
|
52
|
+
abi: TAbi
|
53
|
+
args?: never
|
54
|
+
eventName: TEventName
|
55
|
+
strict: TStrict
|
56
|
+
}
|
57
57
|
: {
|
58
58
|
abi?: never
|
59
59
|
args?: never
|
package/types/log.ts
CHANGED
@@ -75,10 +75,10 @@ type GetTopics<
|
|
75
75
|
> = true extends _FailedToParseArgs
|
76
76
|
? [Hex, ...Hex[]] | []
|
77
77
|
: TAbiEvent extends AbiEvent
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
78
|
+
? Topics<TAbiEvent['inputs']>
|
79
|
+
: _AbiEvent extends AbiEvent
|
80
|
+
? Topics<_AbiEvent['inputs']>
|
81
|
+
: [Hex, ...Hex[]] | []
|
82
82
|
|
83
83
|
type GetInferredLogValues<
|
84
84
|
TAbiEvent extends AbiEvent | undefined = undefined,
|
package/types/multicall.ts
CHANGED
@@ -23,32 +23,37 @@ export type MulticallContracts<
|
|
23
23
|
> = Depth['length'] extends MAXIMUM_DEPTH
|
24
24
|
? (ContractFunctionConfig & TProperties)[]
|
25
25
|
: TContracts extends []
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
26
|
+
? []
|
27
|
+
: TContracts extends [infer Head extends MulticallContract]
|
28
|
+
? [
|
29
|
+
...Result,
|
30
|
+
ContractFunctionConfig<Head['abi'], Head['functionName']> &
|
31
|
+
TProperties,
|
32
|
+
]
|
33
|
+
: TContracts extends [
|
34
|
+
infer Head extends MulticallContract,
|
35
|
+
...infer Tail extends readonly MulticallContract[],
|
36
|
+
]
|
37
|
+
? MulticallContracts<
|
38
|
+
[...Tail],
|
39
|
+
TProperties,
|
40
|
+
[
|
41
|
+
...Result,
|
42
|
+
ContractFunctionConfig<Head['abi'], Head['functionName']> &
|
43
|
+
TProperties,
|
44
|
+
],
|
45
|
+
[...Depth, 1]
|
46
|
+
>
|
47
|
+
: unknown[] extends TContracts
|
48
|
+
? TContracts
|
49
|
+
: // If `TContracts` is *some* array but we couldn't assign `unknown[]` to it, then it must hold some known/homogenous type!
|
50
|
+
// use this to infer the param types in the case of Array.map() argument
|
51
|
+
TContracts extends ContractFunctionConfig<
|
52
|
+
infer TAbi,
|
53
|
+
infer TFunctionName
|
54
|
+
>[]
|
55
|
+
? (ContractFunctionConfig<TAbi, TFunctionName> & TProperties)[]
|
56
|
+
: (ContractFunctionConfig & TProperties)[]
|
52
57
|
|
53
58
|
export type MulticallResult<
|
54
59
|
Result,
|
@@ -75,34 +80,37 @@ export type MulticallResults<
|
|
75
80
|
> = Depth['length'] extends MAXIMUM_DEPTH
|
76
81
|
? MulticallResult<ContractFunctionResult, TAllowFailure>[]
|
77
82
|
: TContracts extends []
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
83
|
+
? []
|
84
|
+
: TContracts extends [infer Head extends MulticallContract]
|
85
|
+
? [
|
86
|
+
...Result,
|
87
|
+
MulticallResult<
|
88
|
+
ContractFunctionResult<Head['abi'], Head['functionName']>,
|
89
|
+
TAllowFailure
|
90
|
+
>,
|
91
|
+
]
|
92
|
+
: TContracts extends [
|
93
|
+
infer Head extends MulticallContract,
|
94
|
+
...infer Tail extends readonly MulticallContract[],
|
95
|
+
]
|
96
|
+
? MulticallResults<
|
97
|
+
[...Tail],
|
98
|
+
TAllowFailure,
|
99
|
+
[
|
100
|
+
...Result,
|
101
|
+
MulticallResult<
|
102
|
+
ContractFunctionResult<Head['abi'], Head['functionName']>,
|
103
|
+
TAllowFailure
|
104
|
+
>,
|
105
|
+
],
|
106
|
+
[...Depth, 1]
|
107
|
+
>
|
108
|
+
: TContracts extends ContractFunctionConfig<
|
109
|
+
infer TAbi,
|
110
|
+
infer TFunctionName
|
111
|
+
>[]
|
112
|
+
? MulticallResult<
|
113
|
+
ContractFunctionResult<TAbi, TFunctionName>,
|
114
|
+
TAllowFailure
|
115
|
+
>[]
|
116
|
+
: MulticallResult<ContractFunctionResult, TAllowFailure>[]
|
package/types/transaction.ts
CHANGED
@@ -186,10 +186,10 @@ export type TransactionSerialized<TType extends TransactionType = 'legacy'> =
|
|
186
186
|
TType extends 'eip1559'
|
187
187
|
? TransactionSerializedEIP1559
|
188
188
|
: TType extends 'eip2930'
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
189
|
+
? TransactionSerializedEIP2930
|
190
|
+
: TType extends 'legacy'
|
191
|
+
? TransactionSerializedLegacy
|
192
|
+
: TransactionSerializedGeneric
|
193
193
|
|
194
194
|
export type TransactionSerializableBase<
|
195
195
|
TQuantity = bigint,
|
package/types/typedData.ts
CHANGED
@@ -42,18 +42,18 @@ export type GetTypedDataMessage<
|
|
42
42
|
> = TPrimaryType extends 'EIP712Domain'
|
43
43
|
? {}
|
44
44
|
: { [key_3: string]: any } extends TMessage // Check if we were able to infer the shape of typed data
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
45
|
+
? {
|
46
|
+
/**
|
47
|
+
* Data to sign
|
48
|
+
*
|
49
|
+
* Use a [const assertion](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#const-assertions) on {@link types} for type inference.
|
50
|
+
*/
|
51
|
+
message: { [key_4: string]: unknown }
|
52
|
+
}
|
53
|
+
: {
|
54
|
+
/** Data to sign */
|
55
|
+
message: TMessage
|
56
|
+
}
|
57
57
|
|
58
58
|
export type GetTypedDataPrimaryType<
|
59
59
|
TTypedData extends TypedData | { [key: string]: unknown } = TypedData,
|
package/types/utils.ts
CHANGED
@@ -54,7 +54,7 @@ export type IsNever<T> = [T] extends [never] ? true : false
|
|
54
54
|
* type Result = Or<[false, false, false]>
|
55
55
|
* // ^? type Result = false
|
56
56
|
*/
|
57
|
-
export type Or<T extends readonly unknown[]
|
57
|
+
export type Or<T extends readonly unknown[]> = T extends readonly [
|
58
58
|
infer Head,
|
59
59
|
...infer Tail,
|
60
60
|
]
|
@@ -125,12 +125,11 @@ export type MaybeUndefined<
|
|
125
125
|
* @private Helper for `Assign`. This is a workaround for tsc generating errorneous type definitions.
|
126
126
|
*/
|
127
127
|
export type Assign_<T, U> = {
|
128
|
-
[K in
|
129
|
-
|
130
|
-
?
|
131
|
-
|
132
|
-
|
133
|
-
: K]: K extends keyof U ? U[K] : T[K]
|
128
|
+
[K in keyof T as K extends keyof U
|
129
|
+
? U[K] extends void
|
130
|
+
? never
|
131
|
+
: K
|
132
|
+
: K]: K extends keyof U ? U[K] : T[K]
|
134
133
|
}
|
135
134
|
|
136
135
|
/**
|
@@ -37,8 +37,8 @@ export type DecodeFunctionResultParameters<
|
|
37
37
|
} & (TFunctionName extends string
|
38
38
|
? { abi: TAbi } & Partial<GetFunctionArgs<TAbi, TFunctionName>>
|
39
39
|
: _FunctionName extends string
|
40
|
-
|
41
|
-
|
40
|
+
? { abi: [TAbi[number]] } & Partial<GetFunctionArgs<TAbi, _FunctionName>>
|
41
|
+
: never)
|
42
42
|
|
43
43
|
export type DecodeFunctionResultReturnType<
|
44
44
|
TAbi extends Abi | readonly unknown[] = Abi,
|
@@ -39,8 +39,8 @@ export type EncodeErrorResultParameters<
|
|
39
39
|
} & (TErrorName extends string
|
40
40
|
? { abi: TAbi } & GetErrorArgs<TAbi, TErrorName>
|
41
41
|
: _ErrorName extends string
|
42
|
-
|
43
|
-
|
42
|
+
? { abi: [TAbi[number]] } & GetErrorArgs<TAbi, _ErrorName>
|
43
|
+
: never)
|
44
44
|
|
45
45
|
export type EncodeErrorResultErrorType =
|
46
46
|
| GetAbiItemErrorType
|
@@ -39,8 +39,8 @@ export type EncodeEventTopicsParameters<
|
|
39
39
|
} & (TEventName extends string
|
40
40
|
? { abi: TAbi; args?: GetEventArgs<TAbi, TEventName> }
|
41
41
|
: _EventName extends string
|
42
|
-
|
43
|
-
|
42
|
+
? { abi: [TAbi[number]]; args?: GetEventArgs<TAbi, _EventName> }
|
43
|
+
: never)
|
44
44
|
|
45
45
|
export type EncodeEventTopicsErrorType =
|
46
46
|
| AbiEventNotFoundErrorType
|
@@ -82,8 +82,8 @@ export function encodeEventTopics<
|
|
82
82
|
const args_ = Array.isArray(args)
|
83
83
|
? args
|
84
84
|
: Object.values(args).length > 0
|
85
|
-
|
86
|
-
|
85
|
+
? indexedInputs?.map((x: any) => (args as any)[x.name]) ?? []
|
86
|
+
: []
|
87
87
|
|
88
88
|
if (args_.length > 0) {
|
89
89
|
topics =
|
@@ -93,8 +93,8 @@ export function encodeEventTopics<
|
|
93
93
|
encodeArg({ param, value: args_[i][j] }),
|
94
94
|
)
|
95
95
|
: args_[i]
|
96
|
-
|
97
|
-
|
96
|
+
? encodeArg({ param, value: args_[i] })
|
97
|
+
: null,
|
98
98
|
) ?? []
|
99
99
|
}
|
100
100
|
}
|
@@ -36,8 +36,8 @@ export type EncodeFunctionDataParameters<
|
|
36
36
|
} & (TFunctionName extends string
|
37
37
|
? { abi: TAbi } & GetFunctionArgs<TAbi, TFunctionName>
|
38
38
|
: _FunctionName extends string
|
39
|
-
|
40
|
-
|
39
|
+
? { abi: [TAbi[number]] } & GetFunctionArgs<TAbi, _FunctionName>
|
40
|
+
: never)
|
41
41
|
|
42
42
|
export type EncodeFunctionDataErrorType =
|
43
43
|
| AbiFunctionNotFoundErrorType
|
@@ -32,11 +32,11 @@ export type EncodeFunctionResultParameters<
|
|
32
32
|
} & (TFunctionName extends string
|
33
33
|
? { abi: TAbi; result?: ContractFunctionResult<TAbi, TFunctionName> }
|
34
34
|
: _FunctionName extends string
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
35
|
+
? {
|
36
|
+
abi: [TAbi[number]]
|
37
|
+
result?: ContractFunctionResult<TAbi, _FunctionName>
|
38
|
+
}
|
39
|
+
: never)
|
40
40
|
|
41
41
|
export type EncodeFunctionResultErrorType =
|
42
42
|
| AbiFunctionOutputsNotFoundError
|
package/utils/ccip.ts
CHANGED
@@ -52,7 +52,7 @@ export const offchainLookupAbiItem = {
|
|
52
52
|
|
53
53
|
export type OffchainLookupErrorType = ErrorType
|
54
54
|
|
55
|
-
export async function offchainLookup<TChain extends Chain | undefined
|
55
|
+
export async function offchainLookup<TChain extends Chain | undefined>(
|
56
56
|
client: Client<Transport, TChain>,
|
57
57
|
{
|
58
58
|
blockNumber,
|
@@ -140,7 +140,9 @@ export async function ccipFetch({
|
|
140
140
|
if (!response.ok) {
|
141
141
|
error = new HttpRequestError({
|
142
142
|
body,
|
143
|
-
details:
|
143
|
+
details: result?.error
|
144
|
+
? stringify(result.error)
|
145
|
+
: response.statusText,
|
144
146
|
headers: response.headers,
|
145
147
|
status: response.status,
|
146
148
|
url,
|
@@ -27,14 +27,14 @@ export type FromBytesParameters<
|
|
27
27
|
export type FromBytesReturnType<TTo> = TTo extends 'string'
|
28
28
|
? string
|
29
29
|
: TTo extends 'hex'
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
30
|
+
? Hex
|
31
|
+
: TTo extends 'bigint'
|
32
|
+
? bigint
|
33
|
+
: TTo extends 'number'
|
34
|
+
? number
|
35
|
+
: TTo extends 'boolean'
|
36
|
+
? boolean
|
37
|
+
: never
|
38
38
|
|
39
39
|
export type FromBytesErrorType =
|
40
40
|
| BytesToHexErrorType
|
@@ -41,14 +41,14 @@ export type FromHexParameters<
|
|
41
41
|
export type FromHexReturnType<TTo> = TTo extends 'string'
|
42
42
|
? string
|
43
43
|
: TTo extends 'bigint'
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
44
|
+
? bigint
|
45
|
+
: TTo extends 'number'
|
46
|
+
? number
|
47
|
+
: TTo extends 'bytes'
|
48
|
+
? ByteArray
|
49
|
+
: TTo extends 'boolean'
|
50
|
+
? boolean
|
51
|
+
: never
|
52
52
|
|
53
53
|
export type FromHexErrorType =
|
54
54
|
| HexToNumberErrorType
|
@@ -114,9 +114,9 @@ const charCodeMap = {
|
|
114
114
|
function charCodeToBase16(char: number) {
|
115
115
|
if (char >= charCodeMap.zero && char <= charCodeMap.nine)
|
116
116
|
return char - charCodeMap.zero
|
117
|
-
|
117
|
+
if (char >= charCodeMap.A && char <= charCodeMap.F)
|
118
118
|
return char - (charCodeMap.A - 10)
|
119
|
-
|
119
|
+
if (char >= charCodeMap.a && char <= charCodeMap.f)
|
120
120
|
return char - (charCodeMap.a - 10)
|
121
121
|
return undefined
|
122
122
|
}
|
@@ -117,7 +117,9 @@ export function resolveAvatarUri({
|
|
117
117
|
isOnChain: false,
|
118
118
|
isEncoded: false,
|
119
119
|
}
|
120
|
-
}
|
120
|
+
}
|
121
|
+
|
122
|
+
if (protocol === 'ar:/' && target) {
|
121
123
|
return {
|
122
124
|
uri: `${arweaveGateway}/${target}${subtarget || ''}`,
|
123
125
|
isOnChain: false,
|
package/utils/ens/namehash.ts
CHANGED
@@ -28,7 +28,7 @@ export type NamehashErrorType =
|
|
28
28
|
* - Since ENS names prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to [normalize ENS names](https://docs.ens.domains/contract-api-reference/name-processing#normalising-names) with [UTS-46 normalization](https://unicode.org/reports/tr46) before passing them to `namehash`. You can use the built-in [`normalize`](https://viem.sh/docs/ens/utilities/normalize.html) function for this.
|
29
29
|
*
|
30
30
|
* @example
|
31
|
-
* namehash('
|
31
|
+
* namehash('wevm.eth')
|
32
32
|
* '0xf246651c1b9a6b141d19c2604e9a58f567973833990f830d882534a747801359'
|
33
33
|
*
|
34
34
|
* @link https://eips.ethereum.org/EIPS/eip-137
|
package/utils/ens/normalize.ts
CHANGED
@@ -7,8 +7,8 @@ export type NormalizeErrorType = ErrorType
|
|
7
7
|
* @description Normalizes ENS name according to ENSIP-15.
|
8
8
|
*
|
9
9
|
* @example
|
10
|
-
* normalize('
|
11
|
-
* '
|
10
|
+
* normalize('wevm.eth')
|
11
|
+
* 'wevm.eth'
|
12
12
|
*
|
13
13
|
* @see https://docs.ens.domains/contract-api-reference/name-processing#normalising-names
|
14
14
|
* @see https://github.com/ensdomains/docs/blob/9edf9443de4333a0ea7ec658a870672d5d180d53/ens-improvement-proposals/ensip-15-normalization-standard.md
|
@@ -48,8 +48,8 @@ export function getContractError<err extends ErrorType<string>>(
|
|
48
48
|
err instanceof RawContractError
|
49
49
|
? err
|
50
50
|
: err instanceof BaseError
|
51
|
-
|
52
|
-
|
51
|
+
? err.walk((err) => 'data' in (err as Error)) || err.walk()
|
52
|
+
: {}
|
53
53
|
) as RawContractError
|
54
54
|
|
55
55
|
const cause = (() => {
|