@wagmi/core 0.8.7 → 0.8.8
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/dist/{chunk-VR4LK7Q2.js → chunk-VRBYTA34.js} +8 -5
- package/dist/contracts-9eb7706c.d.ts +199 -0
- package/dist/index.d.ts +75 -91
- package/dist/index.js +1 -1
- package/dist/internal/index.d.ts +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/test.js +1 -1
- package/package.json +1 -1
- package/dist/contracts-3880ee54.d.ts +0 -334
|
@@ -2106,11 +2106,11 @@ function getContract({
|
|
|
2106
2106
|
async function prepareWriteContract({
|
|
2107
2107
|
abi,
|
|
2108
2108
|
address,
|
|
2109
|
-
args,
|
|
2110
2109
|
chainId,
|
|
2111
2110
|
functionName,
|
|
2112
2111
|
overrides,
|
|
2113
|
-
signer: signer_
|
|
2112
|
+
signer: signer_,
|
|
2113
|
+
...config
|
|
2114
2114
|
}) {
|
|
2115
2115
|
const signer = signer_ ?? await fetchSigner({ chainId });
|
|
2116
2116
|
if (!signer)
|
|
@@ -2122,6 +2122,7 @@ async function prepareWriteContract({
|
|
|
2122
2122
|
abi,
|
|
2123
2123
|
signerOrProvider: signer
|
|
2124
2124
|
});
|
|
2125
|
+
const args = config.args;
|
|
2125
2126
|
const normalizedFunctionName = normalizeFunctionName({
|
|
2126
2127
|
contract,
|
|
2127
2128
|
functionName,
|
|
@@ -2260,11 +2261,12 @@ async function multicall({
|
|
|
2260
2261
|
...params
|
|
2261
2262
|
);
|
|
2262
2263
|
return results.map(({ returnData, success }, i) => {
|
|
2263
|
-
const { address, abi,
|
|
2264
|
+
const { address, abi, functionName, ...rest } = contracts[i];
|
|
2264
2265
|
const contract = getContract({
|
|
2265
2266
|
address,
|
|
2266
2267
|
abi
|
|
2267
2268
|
});
|
|
2269
|
+
const args = rest.args;
|
|
2268
2270
|
const normalizedFunctionName = normalizeFunctionName({
|
|
2269
2271
|
contract,
|
|
2270
2272
|
functionName,
|
|
@@ -2328,11 +2330,11 @@ async function multicall({
|
|
|
2328
2330
|
// src/actions/contracts/readContract.ts
|
|
2329
2331
|
async function readContract({
|
|
2330
2332
|
address,
|
|
2331
|
-
args,
|
|
2332
2333
|
chainId,
|
|
2333
2334
|
abi,
|
|
2334
2335
|
functionName,
|
|
2335
|
-
overrides
|
|
2336
|
+
overrides,
|
|
2337
|
+
...config
|
|
2336
2338
|
}) {
|
|
2337
2339
|
const provider = getProvider({ chainId });
|
|
2338
2340
|
const contract = getContract({
|
|
@@ -2340,6 +2342,7 @@ async function readContract({
|
|
|
2340
2342
|
abi,
|
|
2341
2343
|
signerOrProvider: provider
|
|
2342
2344
|
});
|
|
2345
|
+
const args = config.args;
|
|
2343
2346
|
const normalizedFunctionName = normalizeFunctionName({
|
|
2344
2347
|
contract,
|
|
2345
2348
|
functionName,
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { Abi, AbiStateMutability, Narrow, Address, ExtractAbiFunctionNames, AbiFunction, ExtractAbiFunction, AbiParametersToPrimitiveTypes, AbiParameterToPrimitiveType, AbiEvent, AbiParameter, ResolvedConfig } from 'abitype';
|
|
2
|
+
import { ethers } from 'ethers';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Count occurrences of {@link TType} in {@link TArray}
|
|
6
|
+
*
|
|
7
|
+
* @param TArray - Array to count occurrences in
|
|
8
|
+
* @param TType - Type to count occurrences of
|
|
9
|
+
* @returns Number of occurrences of {@link TType} in {@link TArray}
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* type Result = CountOccurrences<['foo', 'bar', 'foo'], 'foo'>
|
|
13
|
+
*/
|
|
14
|
+
type CountOccurrences<TArray extends readonly unknown[], TType> = FilterNever<[
|
|
15
|
+
...{
|
|
16
|
+
[K in keyof TArray]: TArray[K] extends TType ? TArray[K] : never;
|
|
17
|
+
}
|
|
18
|
+
]>['length'];
|
|
19
|
+
/**
|
|
20
|
+
* Removes all occurrences of `never` from {@link TArray}
|
|
21
|
+
*
|
|
22
|
+
* @param TArray - Array to filter
|
|
23
|
+
* @returns Array with `never` removed
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* type Result = FilterNever<[1, 2, never, 3, never, 4]>
|
|
27
|
+
*/
|
|
28
|
+
type FilterNever<TArray extends readonly unknown[]> = TArray['length'] extends 0 ? [] : TArray extends [infer THead, ...infer TRest] ? IsNever<THead> extends true ? FilterNever<TRest> : [THead, ...FilterNever<TRest>] : never;
|
|
29
|
+
/**
|
|
30
|
+
* Check if {@link T} is `never`
|
|
31
|
+
*
|
|
32
|
+
* @param T - Type to check
|
|
33
|
+
* @returns `true` if {@link T} is `never`, otherwise `false`
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* type Result = IsNever<'foo'>
|
|
37
|
+
*/
|
|
38
|
+
type IsNever<T> = [T] extends [never] ? true : false;
|
|
39
|
+
/**
|
|
40
|
+
* Checks if {@link T} is `unknown`
|
|
41
|
+
*
|
|
42
|
+
* @param T - Type to check
|
|
43
|
+
* @returns `true` if {@link T} is `unknown`, otherwise `false`
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* type Result = IsUnknown<unknown>
|
|
47
|
+
*/
|
|
48
|
+
type IsUnknown<T> = unknown extends T ? true : false;
|
|
49
|
+
/**
|
|
50
|
+
* Joins {@link Items} into string separated by {@link Separator}
|
|
51
|
+
*
|
|
52
|
+
* @param Items - Items to join
|
|
53
|
+
* @param Separator - Separator to use
|
|
54
|
+
* @returns Joined string
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* type Result = Join<['foo', 'bar'], '-'>
|
|
58
|
+
*/
|
|
59
|
+
type Join<Items extends string[], Separator extends string | number> = Items extends [infer First, ...infer Rest] ? First extends string ? Rest extends string[] ? Rest extends [] ? `${First}` : `${First}${Separator}${Join<Rest, Separator>}` : never : never : '';
|
|
60
|
+
/**
|
|
61
|
+
* Converts {@link Union} to intersection
|
|
62
|
+
*
|
|
63
|
+
* @param Union - Union to convert
|
|
64
|
+
* @returns Intersection of {@link Union}
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* type Result = UnionToIntersection<'foo' | 'bar'>
|
|
68
|
+
*/
|
|
69
|
+
type UnionToIntersection<Union> = (Union extends unknown ? (arg: Union) => unknown : never) extends (arg: infer R) => unknown ? R : never;
|
|
70
|
+
|
|
71
|
+
type Contract<TAbi extends Abi | readonly unknown[] = Abi | readonly unknown[], TFunctionName extends string = string> = {
|
|
72
|
+
abi: TAbi;
|
|
73
|
+
functionName: TFunctionName;
|
|
74
|
+
};
|
|
75
|
+
type GetConfig<TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string, TAbiStateMutability extends AbiStateMutability = AbiStateMutability> = {
|
|
76
|
+
/** Contract ABI */
|
|
77
|
+
abi: Narrow<TAbi>;
|
|
78
|
+
/** Contract address */
|
|
79
|
+
address: Address;
|
|
80
|
+
/** Function to invoke on the contract */
|
|
81
|
+
functionName: GetFunctionName<TAbi, TFunctionName, TAbiStateMutability>;
|
|
82
|
+
} & GetArgs<TAbi, TFunctionName>;
|
|
83
|
+
type GetFunctionName<TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string, TAbiStateMutability extends AbiStateMutability = AbiStateMutability> = TAbi extends Abi ? ExtractAbiFunctionNames<TAbi, TAbiStateMutability> extends infer AbiFunctionNames ? AbiFunctionNames | (TFunctionName extends AbiFunctionNames ? TFunctionName : never) | (Abi extends TAbi ? string : never) : never : TFunctionName;
|
|
84
|
+
type GetArgs<TAbi extends Abi | readonly unknown[], TFunctionName extends string, TAbiFunction extends AbiFunction & {
|
|
85
|
+
type: 'function';
|
|
86
|
+
} = TAbi extends Abi ? ExtractAbiFunction<TAbi, TFunctionName> : AbiFunction & {
|
|
87
|
+
type: 'function';
|
|
88
|
+
}, TArgs = AbiParametersToPrimitiveTypes<TAbiFunction['inputs']>, FailedToParseArgs = ([TArgs] extends [never] ? true : false) | (readonly unknown[] extends TArgs ? true : false)> = true extends FailedToParseArgs ? {
|
|
89
|
+
/**
|
|
90
|
+
* Arguments to pass contract method
|
|
91
|
+
*
|
|
92
|
+
* Use a [const assertion](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#const-assertions) on {@link abi} for type inference.
|
|
93
|
+
*/
|
|
94
|
+
args?: readonly unknown[];
|
|
95
|
+
} : TArgs extends readonly [] ? {
|
|
96
|
+
args?: never;
|
|
97
|
+
} : {
|
|
98
|
+
/** Arguments to pass contract method */ args: TArgs;
|
|
99
|
+
};
|
|
100
|
+
type GetReturnType<TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string, TAbiFunction extends AbiFunction & {
|
|
101
|
+
type: 'function';
|
|
102
|
+
} = TAbi extends Abi ? ExtractAbiFunction<TAbi, TFunctionName> : AbiFunction & {
|
|
103
|
+
type: 'function';
|
|
104
|
+
}, TArgs = AbiParametersToPrimitiveTypes<TAbiFunction['outputs']>, FailedToParseArgs = ([TArgs] extends [never] ? true : false) | (readonly unknown[] extends TArgs ? true : false)> = true extends FailedToParseArgs ? unknown : TArgs extends readonly [] ? void : TArgs extends readonly [infer Arg] ? Arg : TArgs & {
|
|
105
|
+
[Output in TAbiFunction['outputs'][number] as Output extends {
|
|
106
|
+
name: infer Name extends string;
|
|
107
|
+
} ? Name extends '' ? never : Name : never]: AbiParameterToPrimitiveType<Output>;
|
|
108
|
+
};
|
|
109
|
+
type MAXIMUM_DEPTH = 20;
|
|
110
|
+
/**
|
|
111
|
+
* ContractsConfig reducer recursively unwraps function arguments to infer/enforce type param
|
|
112
|
+
*/
|
|
113
|
+
type ContractsConfig<TContracts extends Contract[], TProperties extends Record<string, any> = object, Result extends any[] = [], Depth extends ReadonlyArray<number> = []> = Depth['length'] extends MAXIMUM_DEPTH ? (GetConfig & TProperties)[] : TContracts extends [] ? [] : TContracts extends [infer Head extends Contract] ? [
|
|
114
|
+
...Result,
|
|
115
|
+
GetConfig<Head['abi'], Head['functionName'], 'pure' | 'view'> & TProperties
|
|
116
|
+
] : TContracts extends [
|
|
117
|
+
infer Head extends Contract,
|
|
118
|
+
...infer Tail extends Contract[]
|
|
119
|
+
] ? ContractsConfig<[
|
|
120
|
+
...Tail
|
|
121
|
+
], TProperties, [
|
|
122
|
+
...Result,
|
|
123
|
+
GetConfig<Head['abi'], Head['functionName'], 'pure' | 'view'> & TProperties
|
|
124
|
+
], [
|
|
125
|
+
...Depth,
|
|
126
|
+
1
|
|
127
|
+
]> : unknown[] extends TContracts ? TContracts : TContracts extends GetConfig<infer TAbi, infer TFunctionName>[] ? (GetConfig<TAbi, TFunctionName> & TProperties)[] : (GetConfig & TProperties)[];
|
|
128
|
+
/**
|
|
129
|
+
* ContractsResult reducer recursively maps type param to results
|
|
130
|
+
*/
|
|
131
|
+
type ContractsResult<TContracts extends Contract[], Result extends any[] = [], Depth extends ReadonlyArray<number> = []> = Depth['length'] extends MAXIMUM_DEPTH ? GetReturnType[] : TContracts extends [] ? [] : TContracts extends [infer Head extends Contract] ? [...Result, GetReturnType<Head['abi'], Head['functionName']>] : TContracts extends [
|
|
132
|
+
infer Head extends Contract,
|
|
133
|
+
...infer Tail extends Contract[]
|
|
134
|
+
] ? ContractsResult<[
|
|
135
|
+
...Tail
|
|
136
|
+
], [
|
|
137
|
+
...Result,
|
|
138
|
+
GetReturnType<Head['abi'], Head['functionName']>
|
|
139
|
+
], [
|
|
140
|
+
...Depth,
|
|
141
|
+
1
|
|
142
|
+
]> : TContracts extends GetConfig<infer TAbi, infer TFunctionName>[] ? GetReturnType<TAbi, TFunctionName>[] : GetReturnType[];
|
|
143
|
+
/**
|
|
144
|
+
* Get name for {@link AbiFunction} or {@link AbiEvent}
|
|
145
|
+
*
|
|
146
|
+
* @param TAbiItem - {@link AbiFunction} or {@link AbiEvent}
|
|
147
|
+
* @param IsSignature - Whether to return the signature instead of the name
|
|
148
|
+
* @returns Name or signature of function or event
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* type Result = AbiItemName<{ type: 'function'; name: 'Foo'; … }>
|
|
152
|
+
*/
|
|
153
|
+
type AbiItemName<TAbiItem extends (AbiFunction & {
|
|
154
|
+
type: 'function';
|
|
155
|
+
}) | AbiEvent, IsSignature extends boolean = false> = IsSignature extends true ? TAbiItem['inputs'] extends infer TAbiParameters extends readonly AbiParameter[] ? `${TAbiItem['name']}(${Join<[
|
|
156
|
+
...{
|
|
157
|
+
[K in keyof TAbiParameters]: TAbiParameters[K]['type'];
|
|
158
|
+
}
|
|
159
|
+
], ','>})` : never : TAbiItem['name'];
|
|
160
|
+
/**
|
|
161
|
+
* Get overrides for {@link AbiStateMutability}
|
|
162
|
+
*
|
|
163
|
+
* @param TAbiStateMutability - {@link AbiStateMutability}
|
|
164
|
+
* @returns Overrides for {@link TAbiStateMutability}
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* type Result = GetOverridesForAbiStateMutability<'pure'>
|
|
168
|
+
*/
|
|
169
|
+
type GetOverridesForAbiStateMutability<TAbiStateMutability extends AbiStateMutability> = {
|
|
170
|
+
nonpayable: Overrides & {
|
|
171
|
+
from?: Address;
|
|
172
|
+
};
|
|
173
|
+
payable: PayableOverrides & {
|
|
174
|
+
from?: Address;
|
|
175
|
+
};
|
|
176
|
+
pure: CallOverrides;
|
|
177
|
+
view: CallOverrides;
|
|
178
|
+
}[TAbiStateMutability];
|
|
179
|
+
interface Overrides extends ethers.Overrides {
|
|
180
|
+
gasLimit?: ResolvedConfig['BigIntType'];
|
|
181
|
+
gasPrice?: ResolvedConfig['BigIntType'];
|
|
182
|
+
maxFeePerGas?: ResolvedConfig['BigIntType'];
|
|
183
|
+
maxPriorityFeePerGas?: ResolvedConfig['BigIntType'];
|
|
184
|
+
nonce?: ResolvedConfig['IntType'];
|
|
185
|
+
}
|
|
186
|
+
interface PayableOverrides extends Overrides {
|
|
187
|
+
value?: ResolvedConfig['IntType'] | ResolvedConfig['BigIntType'];
|
|
188
|
+
}
|
|
189
|
+
interface CallOverrides extends PayableOverrides {
|
|
190
|
+
blockTag?: ethers.CallOverrides['blockTag'];
|
|
191
|
+
from?: Address;
|
|
192
|
+
}
|
|
193
|
+
type Event<TAbiEvent extends AbiEvent> = Omit<ethers.Event, 'args' | 'event' | 'eventSignature'> & {
|
|
194
|
+
args: AbiParametersToPrimitiveTypes<TAbiEvent['inputs']>;
|
|
195
|
+
event: TAbiEvent['name'];
|
|
196
|
+
eventSignature: AbiItemName<TAbiEvent, true>;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export { AbiItemName as A, CountOccurrences as C, Event as E, GetConfig as G, IsUnknown as I, UnionToIntersection as U, GetOverridesForAbiStateMutability as a, Contract as b, ContractsConfig as c, ContractsResult as d, GetReturnType as e };
|
package/dist/index.d.ts
CHANGED
|
@@ -6,10 +6,10 @@ import { Connector, ConnectorData } from '@wagmi/connectors';
|
|
|
6
6
|
export { Connector, ConnectorData, ConnectorEvents } from '@wagmi/connectors';
|
|
7
7
|
import { P as Provider, W as WebSocketProvider, U as Unit, S as Signer, H as Hash, C as ChainProviderFn, a as ProviderWithFallbackConfig } from './index-37d6352e.js';
|
|
8
8
|
export { C as ChainProviderFn, E as Ethereum, F as FallbackProviderConfig, H as Hash, P as Provider, a as ProviderWithFallbackConfig, S as Signer, U as Unit, W as WebSocketProvider, u as units } from './index-37d6352e.js';
|
|
9
|
-
import { Address, ResolvedConfig,
|
|
9
|
+
import { Address, ResolvedConfig, TypedData, TypedDataToPrimitiveTypes, TypedDataDomain, Narrow, Abi, ExtractAbiFunction, ExtractAbiEventNames, AbiParametersToPrimitiveTypes, ExtractAbiEvent, AbiFunction, AbiParameter, AbiParameterToPrimitiveType, AbiEvent, ExtractAbiFunctionNames } from 'abitype';
|
|
10
10
|
export { Address } from 'abitype';
|
|
11
11
|
import { PopulatedTransaction, Signer as Signer$1, providers, Contract as Contract$1, ethers, Transaction, ContractInterface } from 'ethers';
|
|
12
|
-
import {
|
|
12
|
+
import { G as GetConfig, a as GetOverridesForAbiStateMutability, U as UnionToIntersection, C as CountOccurrences, A as AbiItemName, I as IsUnknown, E as Event, b as Contract$2, c as ContractsConfig, d as ContractsResult, e as GetReturnType } from './contracts-9eb7706c.js';
|
|
13
13
|
import { TransactionResponse } from '@ethersproject/providers';
|
|
14
14
|
export { InjectedConnector, InjectedConnectorOptions } from '@wagmi/connectors/injected';
|
|
15
15
|
import * as abitype_dist_abi_b1bae27f from 'abitype/dist/abi-b1bae27f';
|
|
@@ -968,12 +968,16 @@ type SignMessageArgs = {
|
|
|
968
968
|
type SignMessageResult = ResolvedConfig['BytesType'];
|
|
969
969
|
declare function signMessage(args: SignMessageArgs): Promise<SignMessageResult>;
|
|
970
970
|
|
|
971
|
-
type SignTypedDataArgs<TTypedData
|
|
971
|
+
type SignTypedDataArgs<TTypedData extends TypedData | {
|
|
972
|
+
[key: string]: unknown;
|
|
973
|
+
} = TypedData, TSchema = TTypedData extends TypedData ? TypedDataToPrimitiveTypes<TTypedData> : {
|
|
974
|
+
[key: string]: any;
|
|
975
|
+
}, TValue = TSchema[keyof TSchema]> = {
|
|
972
976
|
/** Domain or domain signature for origin or contract */
|
|
973
977
|
domain: TypedDataDomain;
|
|
974
978
|
/** Named list of all type definitions */
|
|
975
979
|
types: Narrow<TTypedData>;
|
|
976
|
-
} & (
|
|
980
|
+
} & ({
|
|
977
981
|
[key: string]: any;
|
|
978
982
|
} extends TValue ? {
|
|
979
983
|
/**
|
|
@@ -987,7 +991,7 @@ type SignTypedDataArgs<TTypedData = unknown> = {
|
|
|
987
991
|
} : {
|
|
988
992
|
/** Data to sign */
|
|
989
993
|
value: TValue;
|
|
990
|
-
}
|
|
994
|
+
});
|
|
991
995
|
type SignTypedDataResult = string;
|
|
992
996
|
declare function signTypedData<TTypedData extends TypedData>({ domain, types, value, }: SignTypedDataArgs<TTypedData>): Promise<SignTypedDataResult>;
|
|
993
997
|
|
|
@@ -1040,9 +1044,8 @@ type FetchTokenResult = {
|
|
|
1040
1044
|
};
|
|
1041
1045
|
declare function fetchToken({ address, chainId, formatUnits: units, }: FetchTokenArgs): Promise<FetchTokenResult>;
|
|
1042
1046
|
|
|
1043
|
-
type
|
|
1044
|
-
|
|
1045
|
-
functionName: TFunctionName;
|
|
1047
|
+
type StateMutability$1 = 'nonpayable' | 'payable';
|
|
1048
|
+
type PrepareWriteContractConfig<TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string, TSigner extends Signer = Signer> = GetConfig<TAbi, TFunctionName, StateMutability$1> & {
|
|
1046
1049
|
/** Chain id to use for provider */
|
|
1047
1050
|
chainId?: number;
|
|
1048
1051
|
/** Overrides */
|
|
@@ -1052,20 +1055,21 @@ type PrepareWriteContractConfig<TAbi = Abi, TFunctionName = string, TSigner exte
|
|
|
1052
1055
|
] extends [
|
|
1053
1056
|
infer TAbi_ extends Abi,
|
|
1054
1057
|
infer TFunctionName_ extends string
|
|
1055
|
-
] ? ExtractAbiFunction<TAbi_, TFunctionName_>['stateMutability'] :
|
|
1058
|
+
] ? ExtractAbiFunction<TAbi_, TFunctionName_>['stateMutability'] : StateMutability$1>;
|
|
1056
1059
|
/** Custom signer */
|
|
1057
1060
|
signer?: TSigner | null;
|
|
1058
|
-
}
|
|
1059
|
-
type
|
|
1061
|
+
};
|
|
1062
|
+
type Request$1 = PopulatedTransaction & {
|
|
1063
|
+
to: Address;
|
|
1064
|
+
gasLimit: NonNullable<PopulatedTransaction['gasLimit']>;
|
|
1065
|
+
};
|
|
1066
|
+
type PrepareWriteContractResult<TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string> = {
|
|
1060
1067
|
abi: TAbi extends Abi ? [ExtractAbiFunction<TAbi, TFunctionName>] : TAbi;
|
|
1061
|
-
address:
|
|
1068
|
+
address: Address;
|
|
1062
1069
|
chainId?: number;
|
|
1063
1070
|
functionName: TFunctionName;
|
|
1064
1071
|
mode: 'prepared';
|
|
1065
|
-
request:
|
|
1066
|
-
to: Address;
|
|
1067
|
-
gasLimit: NonNullable<PopulatedTransaction['gasLimit']>;
|
|
1068
|
-
};
|
|
1072
|
+
request: Request$1;
|
|
1069
1073
|
};
|
|
1070
1074
|
/**
|
|
1071
1075
|
* @description Prepares the parameters required for a contract write transaction.
|
|
@@ -1082,7 +1086,7 @@ type PrepareWriteContractResult<TAbi = Abi, TFunctionName extends string = strin
|
|
|
1082
1086
|
* })
|
|
1083
1087
|
* const result = await writeContract(config)
|
|
1084
1088
|
*/
|
|
1085
|
-
declare function prepareWriteContract<TAbi extends Abi | readonly unknown[], TFunctionName extends string, TSigner extends Signer = Signer>({ abi, address,
|
|
1089
|
+
declare function prepareWriteContract<TAbi extends Abi | readonly unknown[], TFunctionName extends string, TSigner extends Signer = Signer>({ abi, address, chainId, functionName, overrides, signer: signer_, ...config }: PrepareWriteContractConfig<TAbi, TFunctionName, TSigner>): Promise<PrepareWriteContractResult<TAbi, TFunctionName>>;
|
|
1086
1090
|
|
|
1087
1091
|
type GetContractArgs<TAbi extends Abi | readonly unknown[] = Abi> = {
|
|
1088
1092
|
/** Contract address */
|
|
@@ -1195,7 +1199,7 @@ type Filters<TAbi extends Abi> = UnionToIntersection<{
|
|
|
1195
1199
|
} : never;
|
|
1196
1200
|
}[number]>;
|
|
1197
1201
|
|
|
1198
|
-
type MulticallConfig<TContracts extends
|
|
1202
|
+
type MulticallConfig<TContracts extends Contract$2[]> = {
|
|
1199
1203
|
/** Failures in the multicall will fail silently */
|
|
1200
1204
|
allowFailure?: boolean;
|
|
1201
1205
|
/** Chain id to use for provider */
|
|
@@ -1203,83 +1207,64 @@ type MulticallConfig<TContracts extends unknown[]> = {
|
|
|
1203
1207
|
/** Contracts to query */
|
|
1204
1208
|
contracts: readonly [...ContractsConfig<TContracts>];
|
|
1205
1209
|
/** Call overrides */
|
|
1206
|
-
overrides?: GetOverridesForAbiStateMutability<'pure'
|
|
1210
|
+
overrides?: GetOverridesForAbiStateMutability<'pure' | 'view'>;
|
|
1207
1211
|
};
|
|
1208
|
-
type MulticallResult<TContracts extends
|
|
1212
|
+
type MulticallResult<TContracts extends Contract$2[]> = ContractsResult<TContracts>;
|
|
1209
1213
|
declare function multicall<TAbi extends Abi | readonly unknown[], TFunctionName extends string, TContracts extends {
|
|
1210
1214
|
abi: TAbi;
|
|
1211
1215
|
functionName: TFunctionName;
|
|
1212
1216
|
}[]>({ allowFailure, chainId, contracts, overrides, }: MulticallConfig<TContracts>): Promise<MulticallResult<TContracts>>;
|
|
1213
1217
|
|
|
1214
|
-
type
|
|
1215
|
-
|
|
1216
|
-
functionName: TFunctionName;
|
|
1218
|
+
type StateMutability = 'pure' | 'view';
|
|
1219
|
+
type ReadContractConfig<TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string> = GetConfig<TAbi, TFunctionName, StateMutability> & {
|
|
1217
1220
|
/** Chain id to use for provider */
|
|
1218
1221
|
chainId?: number;
|
|
1219
1222
|
/** Call overrides */
|
|
1220
|
-
overrides?: GetOverridesForAbiStateMutability<
|
|
1221
|
-
}, 'pure' | 'view', TOptions>;
|
|
1222
|
-
type ReadContractResult<TAbi = Abi, TFunctionName = string> = GetReturnType<{
|
|
1223
|
-
abi: TAbi;
|
|
1224
|
-
functionName: TFunctionName;
|
|
1225
|
-
}>;
|
|
1226
|
-
declare function readContract<TAbi extends Abi | readonly unknown[], TFunctionName extends string>({ address, args, chainId, abi, functionName, overrides, }: ReadContractConfig<TAbi, TFunctionName>): Promise<ReadContractResult<TAbi, TFunctionName>>;
|
|
1227
|
-
|
|
1228
|
-
type Options$1 = Options$2 & {
|
|
1229
|
-
isContractsOptional?: boolean;
|
|
1223
|
+
overrides?: GetOverridesForAbiStateMutability<StateMutability>;
|
|
1230
1224
|
};
|
|
1231
|
-
type
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
}, TOptions>
|
|
1236
|
-
]> = {
|
|
1225
|
+
type ReadContractResult<TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string> = GetReturnType<TAbi, TFunctionName>;
|
|
1226
|
+
declare function readContract<TAbi extends Abi | readonly unknown[], TFunctionName extends string>({ address, chainId, abi, functionName, overrides, ...config }: ReadContractConfig<TAbi, TFunctionName>): Promise<ReadContractResult<TAbi, TFunctionName>>;
|
|
1227
|
+
|
|
1228
|
+
type ReadContractsConfig<TContracts extends Contract$2[]> = {
|
|
1237
1229
|
/** Failures in the multicall will fail silently */
|
|
1238
1230
|
allowFailure?: boolean;
|
|
1231
|
+
/** Contracts to query */
|
|
1232
|
+
contracts: readonly [
|
|
1233
|
+
...ContractsConfig<TContracts, {
|
|
1234
|
+
/** Chain id to use for provider */
|
|
1235
|
+
chainId?: number;
|
|
1236
|
+
}>
|
|
1237
|
+
];
|
|
1239
1238
|
/** Call overrides */
|
|
1240
1239
|
overrides?: GetOverridesForAbiStateMutability<'pure' | 'view'>;
|
|
1241
|
-
}
|
|
1242
|
-
|
|
1243
|
-
contracts?: _Contracts;
|
|
1244
|
-
} : {
|
|
1245
|
-
/** Contracts to query */
|
|
1246
|
-
contracts: _Contracts;
|
|
1247
|
-
});
|
|
1248
|
-
type ReadContractsResult<TContracts extends unknown[]> = ContractsResult<TContracts>;
|
|
1240
|
+
};
|
|
1241
|
+
type ReadContractsResult<TContracts extends Contract$2[]> = ContractsResult<TContracts>;
|
|
1249
1242
|
declare function readContracts<TAbi extends Abi | readonly unknown[], TFunctionName extends string, TContracts extends {
|
|
1250
1243
|
abi: TAbi;
|
|
1251
1244
|
functionName: TFunctionName;
|
|
1252
1245
|
}[]>({ allowFailure, contracts, overrides, }: ReadContractsConfig<TContracts>): Promise<ReadContractsResult<TContracts>>;
|
|
1253
1246
|
|
|
1254
|
-
type
|
|
1255
|
-
/** Contract address */
|
|
1256
|
-
address: string;
|
|
1247
|
+
type WatchContractEventConfig<TAbi extends Abi | readonly unknown[] = Abi, TEventName extends string = string> = {
|
|
1257
1248
|
/** Contract ABI */
|
|
1258
1249
|
abi: Narrow<TAbi>;
|
|
1250
|
+
/** Contract address */
|
|
1251
|
+
address: Address;
|
|
1259
1252
|
/** Chain id to use for provider */
|
|
1260
1253
|
chainId?: number;
|
|
1261
|
-
/**
|
|
1262
|
-
eventName:
|
|
1254
|
+
/** Function to invoke on the contract */
|
|
1255
|
+
eventName: GetEventName<TAbi, TEventName>;
|
|
1263
1256
|
/** Receive only a single event */
|
|
1264
1257
|
once?: boolean;
|
|
1265
1258
|
};
|
|
1266
|
-
type
|
|
1267
|
-
abi: infer TAbi extends Abi;
|
|
1268
|
-
} ? ContractEventConfig<TAbi, ExtractAbiEventNames<TAbi>> : T extends {
|
|
1269
|
-
abi: infer TAbi extends readonly unknown[];
|
|
1270
|
-
eventName: infer TEventName extends string;
|
|
1271
|
-
} ? ContractEventConfig<TAbi, TEventName> : ContractEventConfig;
|
|
1272
|
-
type WatchContractEventConfig<TAbi = Abi, TEventName = string> = GetConfig<{
|
|
1273
|
-
abi: TAbi;
|
|
1274
|
-
eventName: TEventName;
|
|
1275
|
-
}>;
|
|
1276
|
-
type WatchContractEventCallback<TAbi extends Abi | readonly unknown[] = Abi, TEventName extends string = string, TAbiEvent extends AbiEvent = TAbi extends Abi ? ExtractAbiEvent<TAbi, TEventName> : never> = AbiParametersToPrimitiveTypes<TAbiEvent['inputs']> extends infer TArgs extends readonly unknown[] ? Or<IsNever<TArgs>, NotEqual<TAbi, Abi>> extends true ? (...args: any) => void : (...args: [...args: TArgs, event: Event<TAbiEvent>]) => void : never;
|
|
1259
|
+
type WatchContractEventCallback<TAbi extends Abi | readonly unknown[] = Abi, TEventName extends string = string> = GetListener<TAbi, TEventName>;
|
|
1277
1260
|
declare function watchContractEvent<TAbi extends Abi | readonly unknown[], TEventName extends string>({ address, abi, chainId, eventName, once, }: WatchContractEventConfig<TAbi, TEventName>, callback: WatchContractEventCallback<TAbi, TEventName>): () => void;
|
|
1261
|
+
type GetEventName<TAbi extends Abi | readonly unknown[] = Abi, TEventName extends string = string> = TAbi extends Abi ? ExtractAbiEventNames<TAbi> extends infer AbiEventNames ? AbiEventNames | (TEventName extends AbiEventNames ? TEventName : never) | (Abi extends TAbi ? string : never) : never : TEventName;
|
|
1262
|
+
type GetListener<TAbi extends Abi | readonly unknown[], TEventName extends string, TAbiEvent extends AbiEvent = TAbi extends Abi ? ExtractAbiEvent<TAbi, TEventName> : AbiEvent, TArgs = AbiParametersToPrimitiveTypes<TAbiEvent['inputs']>, FailedToParseArgs = ([TArgs] extends [never] ? true : false) | (readonly unknown[] extends TArgs ? true : false)> = true extends FailedToParseArgs ? (...args: readonly unknown[]) => void : (...args: TArgs extends readonly unknown[] ? TArgs : readonly unknown[]) => void;
|
|
1278
1263
|
|
|
1279
|
-
type WatchMulticallConfig<TContracts extends
|
|
1264
|
+
type WatchMulticallConfig<TContracts extends Contract$2[]> = MulticallConfig<TContracts> & {
|
|
1280
1265
|
listenToBlock?: boolean;
|
|
1281
1266
|
};
|
|
1282
|
-
type WatchMulticallCallback<TContracts extends
|
|
1267
|
+
type WatchMulticallCallback<TContracts extends Contract$2[]> = (results: MulticallResult<TContracts>) => void;
|
|
1283
1268
|
declare function watchMulticall<TAbi extends Abi | readonly unknown[], TFunctionName extends string, TContracts extends {
|
|
1284
1269
|
abi: TAbi;
|
|
1285
1270
|
functionName: TFunctionName;
|
|
@@ -1291,10 +1276,10 @@ type WatchReadContractConfig<TAbi extends Abi | readonly unknown[] = Abi, TFunct
|
|
|
1291
1276
|
type WatchReadContractCallback<TAbi extends Abi | readonly unknown[], TFunctionName extends string> = (result: ReadContractResult<TAbi, TFunctionName>) => void;
|
|
1292
1277
|
declare function watchReadContract<TAbi extends Abi | readonly unknown[], TFunctionName extends TAbi extends Abi ? ExtractAbiFunctionNames<TAbi, 'view' | 'pure'> : string>(config: WatchReadContractConfig<TAbi, TFunctionName>, callback: WatchReadContractCallback<TAbi, TFunctionName>): () => void;
|
|
1293
1278
|
|
|
1294
|
-
type WatchReadContractsConfig<TContracts extends
|
|
1279
|
+
type WatchReadContractsConfig<TContracts extends Contract$2[]> = ReadContractsConfig<TContracts> & {
|
|
1295
1280
|
listenToBlock?: boolean;
|
|
1296
1281
|
};
|
|
1297
|
-
type WatchReadContractsCallback<TContracts extends
|
|
1282
|
+
type WatchReadContractsCallback<TContracts extends Contract$2[]> = (results: ReadContractsResult<TContracts>) => void;
|
|
1298
1283
|
declare function watchReadContracts<TAbi extends Abi | readonly unknown[], TFunctionName extends string, TContracts extends {
|
|
1299
1284
|
abi: TAbi;
|
|
1300
1285
|
functionName: TFunctionName;
|
|
@@ -1425,14 +1410,12 @@ type WatchPendingTransactionsArgs = {
|
|
|
1425
1410
|
type WatchPendingTransactionsCallback = (transaction: WatchPendingTransactionsResult) => void;
|
|
1426
1411
|
declare function watchPendingTransactions(args: WatchPendingTransactionsArgs, callback: WatchPendingTransactionsCallback): () => void;
|
|
1427
1412
|
|
|
1428
|
-
type
|
|
1429
|
-
isRequestOptional?: boolean;
|
|
1430
|
-
};
|
|
1413
|
+
type WriteContractMode = 'prepared' | 'recklesslyUnprepared';
|
|
1431
1414
|
type Request = PopulatedTransaction & {
|
|
1432
1415
|
to: Address;
|
|
1433
1416
|
gasLimit: NonNullable<PopulatedTransaction['gasLimit']>;
|
|
1434
1417
|
};
|
|
1435
|
-
type WriteContractPreparedArgs<
|
|
1418
|
+
type WriteContractPreparedArgs<TAbi extends Abi | readonly unknown[], TFunctionName extends string> = {
|
|
1436
1419
|
/**
|
|
1437
1420
|
* `recklesslyUnprepared`: Allow to pass through unprepared config. Note: This has
|
|
1438
1421
|
* [UX pitfalls](https://wagmi.sh/react/prepare-hooks/intro#ux-pitfalls-without-prepare-hooks),
|
|
@@ -1443,21 +1426,26 @@ type WriteContractPreparedArgs<TOptions extends Options = DefaultOptions> = {
|
|
|
1443
1426
|
* via the {@link prepareWriteContract} function
|
|
1444
1427
|
* */
|
|
1445
1428
|
mode: 'prepared';
|
|
1429
|
+
/** Chain id to use for provider */
|
|
1430
|
+
chainId?: number;
|
|
1431
|
+
/** Request to submit transaction for */
|
|
1432
|
+
request: Request;
|
|
1446
1433
|
args?: never;
|
|
1447
1434
|
overrides?: never;
|
|
1448
|
-
} &
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
}
|
|
1455
|
-
|
|
1435
|
+
} & Omit<GetConfig<TAbi, TFunctionName, 'nonpayable' | 'payable'>, 'args'>;
|
|
1436
|
+
type WriteContractUnpreparedArgs<TAbi extends Abi | readonly unknown[], TFunctionName extends string> = {
|
|
1437
|
+
/**
|
|
1438
|
+
* `recklesslyUnprepared`: Allow to pass through unprepared config. Note: This has
|
|
1439
|
+
* [UX pitfalls](https://wagmi.sh/react/prepare-hooks/intro#ux-pitfalls-without-prepare-hooks),
|
|
1440
|
+
* it is highly recommended to not use this and instead prepare the request upfront
|
|
1441
|
+
* using the {@link prepareWriteContract} function.
|
|
1442
|
+
*
|
|
1443
|
+
* `prepared`: The request has been prepared with parameters required for sending a transaction
|
|
1444
|
+
* via the {@link prepareWriteContract} function
|
|
1445
|
+
* */
|
|
1456
1446
|
mode: 'recklesslyUnprepared';
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
abi: TAbi;
|
|
1460
|
-
functionName: TFunctionName;
|
|
1447
|
+
/** Chain id to use for provider */
|
|
1448
|
+
chainId?: number;
|
|
1461
1449
|
/** Call overrides */
|
|
1462
1450
|
overrides?: GetOverridesForAbiStateMutability<[
|
|
1463
1451
|
TAbi,
|
|
@@ -1466,13 +1454,9 @@ type WriteContractUnpreparedArgs<TAbi = Abi, TFunctionName = string, TOptions ex
|
|
|
1466
1454
|
infer TAbi_ extends Abi,
|
|
1467
1455
|
infer TFunctionName_ extends string
|
|
1468
1456
|
] ? ExtractAbiFunction<TAbi_, TFunctionName_>['stateMutability'] : 'nonpayable' | 'payable'>;
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
functionName: TFunctionName;
|
|
1473
|
-
/** Chain id to use for provider */
|
|
1474
|
-
chainId?: number;
|
|
1475
|
-
}, 'nonpayable' | 'payable', TOptions>, 'args'> & (WriteContractUnpreparedArgs<TAbi, TFunctionName, TOptions> | WriteContractPreparedArgs<TOptions>);
|
|
1457
|
+
request?: never;
|
|
1458
|
+
} & GetConfig<TAbi, TFunctionName, 'nonpayable' | 'payable'>;
|
|
1459
|
+
type WriteContractArgs<TAbi extends Abi | readonly unknown[], TFunctionName extends string> = WriteContractUnpreparedArgs<TAbi, TFunctionName> | WriteContractPreparedArgs<TAbi, TFunctionName>;
|
|
1476
1460
|
type WriteContractResult = SendTransactionResult;
|
|
1477
1461
|
/**
|
|
1478
1462
|
* @description Function to call a contract write method.
|
|
@@ -1769,4 +1753,4 @@ type CircularReplacer = (key: string, value: any, referenceKey: string) => any;
|
|
|
1769
1753
|
*/
|
|
1770
1754
|
declare function serialize(value: any, replacer?: StandardReplacer | null | undefined, indent?: number | null | undefined, circularReplacer?: CircularReplacer | null | undefined): string;
|
|
1771
1755
|
|
|
1772
|
-
export { AddChainError, ChainDoesNotSupportMulticallError, ChainMismatchError, ChainNotConfiguredError, Client, ClientConfig, ConfigureChainsConfig, ConnectArgs, ConnectResult, ConnectorAlreadyConnectedError, ConnectorNotFoundError, ContractMethodDoesNotExistError, ContractMethodNoResultError, ContractMethodRevertedError, ContractResultDecodeError, FetchBalanceArgs, FetchBalanceResult, FetchBlockNumberArgs, FetchBlockNumberResult, FetchEnsAddressArgs, FetchEnsAddressResult, FetchEnsAvatarArgs, FetchEnsAvatarResult, FetchEnsNameArgs, FetchEnsNameResult, FetchEnsResolverArgs, FetchEnsResolverResult, FetchFeeDataArgs, FetchFeeDataResult, FetchSignerArgs, FetchSignerResult, FetchTokenArgs, FetchTokenResult, FetchTransactionArgs, FetchTransactionResult, GetAccountResult, GetContractArgs, GetContractResult, GetNetworkResult, GetProviderArgs, GetProviderResult, GetWebSocketProviderArgs, GetWebSocketProviderResult, MulticallConfig, MulticallResult, PrepareSendTransactionArgs, PrepareSendTransactionResult, PrepareWriteContractConfig, PrepareWriteContractResult, ProviderChainsNotFound, ProviderRpcError, ReadContractConfig, ReadContractResult, ReadContractsConfig, ReadContractsResult, ResourceUnavailableError, RpcError, SendTransactionArgs, SendTransactionPreparedRequest, SendTransactionResult, SendTransactionUnpreparedRequest, SignMessageArgs, SignMessageResult, SignTypedDataArgs, SignTypedDataResult, ClientStorage as Storage, SwitchChainError, SwitchChainNotSupportedError, SwitchNetworkArgs, SwitchNetworkResult, UserRejectedRequestError, WaitForTransactionArgs, WaitForTransactionResult, WatchAccountCallback, WatchBlockNumberArgs, WatchBlockNumberCallback, WatchMulticallCallback, WatchMulticallConfig, WatchNetworkCallback, WatchPendingTransactionsArgs, WatchPendingTransactionsCallback, WatchPendingTransactionsResult, WatchProviderCallback, WatchReadContractCallback, WatchReadContractConfig, WatchReadContractsCallback, WatchReadContractsConfig, WatchSignerCallback, WatchWebSocketProviderCallback, WriteContractArgs, WriteContractPreparedArgs, WriteContractResult, WriteContractUnpreparedArgs, configureChains, connect, createClient, createStorage, deepEqual, deserialize, disconnect, erc20ABI, erc4626ABI, erc721ABI, fetchBalance, fetchBlockNumber, fetchEnsAddress, fetchEnsAvatar, fetchEnsName, fetchEnsResolver, fetchFeeData, fetchSigner, fetchToken, fetchTransaction, getAccount, getClient, getContract, getNetwork, getProvider, getWebSocketProvider, minimizeContractInterface, multicall, noopStorage, normalizeChainId, parseContractResult, prepareSendTransaction, prepareWriteContract, readContract, readContracts, sendTransaction, serialize, signMessage, signTypedData, switchNetwork, waitForTransaction, watchAccount, watchBlockNumber, watchContractEvent, watchMulticall, watchNetwork, watchPendingTransactions, watchProvider, watchReadContract, watchReadContracts, watchSigner, watchWebSocketProvider, writeContract };
|
|
1756
|
+
export { AddChainError, ChainDoesNotSupportMulticallError, ChainMismatchError, ChainNotConfiguredError, Client, ClientConfig, ConfigureChainsConfig, ConnectArgs, ConnectResult, ConnectorAlreadyConnectedError, ConnectorNotFoundError, ContractMethodDoesNotExistError, ContractMethodNoResultError, ContractMethodRevertedError, ContractResultDecodeError, FetchBalanceArgs, FetchBalanceResult, FetchBlockNumberArgs, FetchBlockNumberResult, FetchEnsAddressArgs, FetchEnsAddressResult, FetchEnsAvatarArgs, FetchEnsAvatarResult, FetchEnsNameArgs, FetchEnsNameResult, FetchEnsResolverArgs, FetchEnsResolverResult, FetchFeeDataArgs, FetchFeeDataResult, FetchSignerArgs, FetchSignerResult, FetchTokenArgs, FetchTokenResult, FetchTransactionArgs, FetchTransactionResult, GetAccountResult, GetContractArgs, GetContractResult, GetNetworkResult, GetProviderArgs, GetProviderResult, GetWebSocketProviderArgs, GetWebSocketProviderResult, MulticallConfig, MulticallResult, PrepareSendTransactionArgs, PrepareSendTransactionResult, PrepareWriteContractConfig, PrepareWriteContractResult, ProviderChainsNotFound, ProviderRpcError, ReadContractConfig, ReadContractResult, ReadContractsConfig, ReadContractsResult, ResourceUnavailableError, RpcError, SendTransactionArgs, SendTransactionPreparedRequest, SendTransactionResult, SendTransactionUnpreparedRequest, SignMessageArgs, SignMessageResult, SignTypedDataArgs, SignTypedDataResult, ClientStorage as Storage, SwitchChainError, SwitchChainNotSupportedError, SwitchNetworkArgs, SwitchNetworkResult, UserRejectedRequestError, WaitForTransactionArgs, WaitForTransactionResult, WatchAccountCallback, WatchBlockNumberArgs, WatchBlockNumberCallback, WatchContractEventCallback, WatchContractEventConfig, WatchMulticallCallback, WatchMulticallConfig, WatchNetworkCallback, WatchPendingTransactionsArgs, WatchPendingTransactionsCallback, WatchPendingTransactionsResult, WatchProviderCallback, WatchReadContractCallback, WatchReadContractConfig, WatchReadContractsCallback, WatchReadContractsConfig, WatchSignerCallback, WatchWebSocketProviderCallback, WriteContractArgs, WriteContractMode, WriteContractPreparedArgs, WriteContractResult, WriteContractUnpreparedArgs, configureChains, connect, createClient, createStorage, deepEqual, deserialize, disconnect, erc20ABI, erc4626ABI, erc721ABI, fetchBalance, fetchBlockNumber, fetchEnsAddress, fetchEnsAvatar, fetchEnsName, fetchEnsResolver, fetchFeeData, fetchSigner, fetchToken, fetchTransaction, getAccount, getClient, getContract, getNetwork, getProvider, getWebSocketProvider, minimizeContractInterface, multicall, noopStorage, normalizeChainId, parseContractResult, prepareSendTransaction, prepareWriteContract, readContract, readContracts, sendTransaction, serialize, signMessage, signTypedData, switchNetwork, waitForTransaction, watchAccount, watchBlockNumber, watchContractEvent, watchMulticall, watchNetwork, watchPendingTransactions, watchProvider, watchReadContract, watchReadContracts, watchSigner, watchWebSocketProvider, writeContract };
|
package/dist/index.js
CHANGED
package/dist/internal/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { b as Contract, c as ContractsConfig } from '../contracts-9eb7706c.js';
|
|
2
2
|
import '../index-37d6352e.js';
|
|
3
3
|
import 'abitype';
|
|
4
4
|
import 'ethers';
|
package/dist/internal/index.js
CHANGED
package/dist/internal/test.js
CHANGED
package/package.json
CHANGED
|
@@ -1,334 +0,0 @@
|
|
|
1
|
-
import { AbiParameter as AbiParameter$1, Abi, AbiFunction, AbiParametersToPrimitiveTypes, ExtractAbiFunction, Narrow, AbiStateMutability, ExtractAbiFunctionNames, AbiEvent, AbiParameterToPrimitiveType, Address, ResolvedConfig } from 'abitype';
|
|
2
|
-
import { ethers } from 'ethers';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Count occurrences of {@link TType} in {@link TArray}
|
|
6
|
-
*
|
|
7
|
-
* @param TArray - Array to count occurrences in
|
|
8
|
-
* @param TType - Type to count occurrences of
|
|
9
|
-
* @returns Number of occurrences of {@link TType} in {@link TArray}
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* type Result = CountOccurrences<['foo', 'bar', 'foo'], 'foo'>
|
|
13
|
-
*/
|
|
14
|
-
type CountOccurrences<TArray extends readonly unknown[], TType> = FilterNever<[
|
|
15
|
-
...{
|
|
16
|
-
[K in keyof TArray]: TArray[K] extends TType ? TArray[K] : never;
|
|
17
|
-
}
|
|
18
|
-
]>['length'];
|
|
19
|
-
/**
|
|
20
|
-
* Removes all occurrences of `never` from {@link TArray}
|
|
21
|
-
*
|
|
22
|
-
* @param TArray - Array to filter
|
|
23
|
-
* @returns Array with `never` removed
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* type Result = FilterNever<[1, 2, never, 3, never, 4]>
|
|
27
|
-
*/
|
|
28
|
-
type FilterNever<TArray extends readonly unknown[]> = TArray['length'] extends 0 ? [] : TArray extends [infer THead, ...infer TRest] ? IsNever<THead> extends true ? FilterNever<TRest> : [THead, ...FilterNever<TRest>] : never;
|
|
29
|
-
/**
|
|
30
|
-
* Check if {@link T} is `never`
|
|
31
|
-
*
|
|
32
|
-
* @param T - Type to check
|
|
33
|
-
* @returns `true` if {@link T} is `never`, otherwise `false`
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* type Result = IsNever<'foo'>
|
|
37
|
-
*/
|
|
38
|
-
type IsNever<T> = [T] extends [never] ? true : false;
|
|
39
|
-
/**
|
|
40
|
-
* Checks if {@link T} is `unknown`
|
|
41
|
-
*
|
|
42
|
-
* @param T - Type to check
|
|
43
|
-
* @returns `true` if {@link T} is `unknown`, otherwise `false`
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* type Result = IsUnknown<unknown>
|
|
47
|
-
*/
|
|
48
|
-
type IsUnknown<T> = unknown extends T ? true : false;
|
|
49
|
-
/**
|
|
50
|
-
* Joins {@link Items} into string separated by {@link Separator}
|
|
51
|
-
*
|
|
52
|
-
* @param Items - Items to join
|
|
53
|
-
* @param Separator - Separator to use
|
|
54
|
-
* @returns Joined string
|
|
55
|
-
*
|
|
56
|
-
* @example
|
|
57
|
-
* type Result = Join<['foo', 'bar'], '-'>
|
|
58
|
-
*/
|
|
59
|
-
type Join<Items extends string[], Separator extends string | number> = Items extends [infer First, ...infer Rest] ? First extends string ? Rest extends string[] ? Rest extends [] ? `${First}` : `${First}${Separator}${Join<Rest, Separator>}` : never : never : '';
|
|
60
|
-
/**
|
|
61
|
-
* Check if {@link T} and {@link U} are equal
|
|
62
|
-
*
|
|
63
|
-
* @param T
|
|
64
|
-
* @param U
|
|
65
|
-
* @returns `true` if {@link T} and {@link U} are not equal, otherwise `false`
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* type Result = NotEqual<'foo', 'bar'>
|
|
69
|
-
*/
|
|
70
|
-
type NotEqual<T, U> = [T] extends [U] ? false : true;
|
|
71
|
-
/**
|
|
72
|
-
* Convert {@link TKeys} of {@link TObject} to optional properties
|
|
73
|
-
*
|
|
74
|
-
* @param TObject
|
|
75
|
-
* @param TKeys
|
|
76
|
-
* @returns {@link TObject} with {@link TKeys} converted to optional properties
|
|
77
|
-
*
|
|
78
|
-
* @example
|
|
79
|
-
* type Result = Optional<{ foo: string; bar: number }, 'foo'>
|
|
80
|
-
*/
|
|
81
|
-
type Optional<TObject, TKeys extends keyof TObject> = {
|
|
82
|
-
[K in keyof TObject as K extends TKeys ? never : K]: TObject[K];
|
|
83
|
-
} & {
|
|
84
|
-
[K in keyof TObject as K extends TKeys ? K : never]?: TObject[K];
|
|
85
|
-
};
|
|
86
|
-
/**
|
|
87
|
-
* Boolean "or" operator
|
|
88
|
-
*
|
|
89
|
-
* @param T
|
|
90
|
-
* @param U
|
|
91
|
-
* @returns `true` if either {@link T} or {@link U} are `true`, otherwise `false`
|
|
92
|
-
*
|
|
93
|
-
* @example
|
|
94
|
-
* type Result = Or<true, false>
|
|
95
|
-
*/
|
|
96
|
-
type Or<T, U> = T extends true ? true : U extends true ? true : false;
|
|
97
|
-
/**
|
|
98
|
-
* Converts {@link Union} to intersection
|
|
99
|
-
*
|
|
100
|
-
* @param Union - Union to convert
|
|
101
|
-
* @returns Intersection of {@link Union}
|
|
102
|
-
*
|
|
103
|
-
* @example
|
|
104
|
-
* type Result = UnionToIntersection<'foo' | 'bar'>
|
|
105
|
-
*/
|
|
106
|
-
type UnionToIntersection<Union> = (Union extends unknown ? (arg: Union) => unknown : never) extends (arg: infer R) => unknown ? R : never;
|
|
107
|
-
|
|
108
|
-
type AbiParameter = AbiParameter$1;
|
|
109
|
-
/**
|
|
110
|
-
* Configuration options for contract types
|
|
111
|
-
*/
|
|
112
|
-
type Options = {
|
|
113
|
-
/** Flag for making `abi` optional */
|
|
114
|
-
isAbiOptional?: boolean;
|
|
115
|
-
/** Flag for making `address` optional */
|
|
116
|
-
isAddressOptional?: boolean;
|
|
117
|
-
/** Flag for making `args` optional */
|
|
118
|
-
isArgsOptional?: boolean;
|
|
119
|
-
/** Flag for making `functionName` optional */
|
|
120
|
-
isFunctionNameOptional?: boolean;
|
|
121
|
-
};
|
|
122
|
-
/**
|
|
123
|
-
* Default {@link Options}
|
|
124
|
-
*/
|
|
125
|
-
type DefaultOptions = {
|
|
126
|
-
isAbiOptional: false;
|
|
127
|
-
isAddressOptional: false;
|
|
128
|
-
isArgsOptional: false;
|
|
129
|
-
isFunctionNameOptional: false;
|
|
130
|
-
};
|
|
131
|
-
/**
|
|
132
|
-
* Gets arguments of contract function
|
|
133
|
-
*
|
|
134
|
-
* @param TAbi - Contract {@link Abi}
|
|
135
|
-
* @param TFunctionName - Name of contract function
|
|
136
|
-
* @param TOptions - Options for configuring arguments. Defaults to {@link DefaultOptions}.
|
|
137
|
-
* @returns Inferred args of contract function
|
|
138
|
-
*
|
|
139
|
-
* @example
|
|
140
|
-
* type Result = GetArgs<[…], 'tokenURI'>
|
|
141
|
-
*/
|
|
142
|
-
type GetArgs<TAbi extends Abi | readonly unknown[], TFunction extends AbiFunction & {
|
|
143
|
-
type: 'function';
|
|
144
|
-
}, TOptions extends Options = DefaultOptions> = TFunction['inputs'] extends infer TInputs extends readonly AbiParameter[] ? Or<IsNever<TInputs>, NotEqual<TAbi, Abi>> extends true ? {
|
|
145
|
-
/**
|
|
146
|
-
* Arguments to pass contract method
|
|
147
|
-
*
|
|
148
|
-
* Use a [const assertion](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#const-assertions) on {@link abi} for type inference.
|
|
149
|
-
*/
|
|
150
|
-
args?: readonly unknown[];
|
|
151
|
-
} : TInputs['length'] extends 0 ? {
|
|
152
|
-
args?: never;
|
|
153
|
-
} : AbiParametersToPrimitiveTypes<TInputs> extends infer TArgs ? TOptions['isArgsOptional'] extends true ? {
|
|
154
|
-
/** Arguments to pass contract method */
|
|
155
|
-
args?: TArgs;
|
|
156
|
-
} : {
|
|
157
|
-
/** Arguments to pass contract method */
|
|
158
|
-
args: TArgs;
|
|
159
|
-
} : never : never;
|
|
160
|
-
/**
|
|
161
|
-
* Contract configuration object for inferring function name and arguments based on {@link TAbi}.
|
|
162
|
-
*/
|
|
163
|
-
type ContractConfig<TContract = {
|
|
164
|
-
[key: string]: unknown;
|
|
165
|
-
}, TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string, TFunction extends AbiFunction & {
|
|
166
|
-
type: 'function';
|
|
167
|
-
} = TAbi extends Abi ? ExtractAbiFunction<TAbi, TFunctionName> : never, TOptions extends Options = DefaultOptions> = (TOptions['isAbiOptional'] extends true ? {
|
|
168
|
-
/** Contract ABI */
|
|
169
|
-
abi?: Narrow<TAbi>;
|
|
170
|
-
} : {
|
|
171
|
-
/** Contract ABI */
|
|
172
|
-
abi: Narrow<TAbi>;
|
|
173
|
-
}) & (TOptions['isAddressOptional'] extends true ? {
|
|
174
|
-
/** Contract address */
|
|
175
|
-
address?: string;
|
|
176
|
-
} : {
|
|
177
|
-
/** Contract address */
|
|
178
|
-
address: string;
|
|
179
|
-
}) & (TOptions['isFunctionNameOptional'] extends true ? {
|
|
180
|
-
/** Function to invoke on the contract */
|
|
181
|
-
functionName?: IsNever<TFunctionName> extends true ? string : TFunctionName;
|
|
182
|
-
} : {
|
|
183
|
-
/** Function to invoke on the contract */
|
|
184
|
-
functionName: IsNever<TFunctionName> extends true ? string : TFunctionName;
|
|
185
|
-
}) & GetArgs<TAbi, TFunction, TOptions> & TContract;
|
|
186
|
-
type OmitConfigProperties = 'abi' | 'args' | 'functionName';
|
|
187
|
-
/**
|
|
188
|
-
* Gets configuration type of contract function
|
|
189
|
-
*
|
|
190
|
-
* @param TContract - Contract config in `{ abi: Abi, functionName: string }` format
|
|
191
|
-
* @param TAbiStateMutibility - State mutability of contract function
|
|
192
|
-
* @param TOptions - Options for configuring arguments. Defaults to {@link DefaultOptions}.
|
|
193
|
-
* @returns Inferred configuration type of contract function
|
|
194
|
-
*
|
|
195
|
-
* @example
|
|
196
|
-
* type Result = GetConfig<{ abi: […], functionName: 'tokenURI' }, 'view'>
|
|
197
|
-
*/
|
|
198
|
-
type GetConfig<TContract = unknown, TAbiStateMutibility extends AbiStateMutability = AbiStateMutability, TOptions extends Options = DefaultOptions> = TContract extends {
|
|
199
|
-
abi: infer TAbi extends Abi;
|
|
200
|
-
functionName: infer TFunctionName extends string;
|
|
201
|
-
} ? ContractConfig<Omit<TContract, OmitConfigProperties>, TAbi, ExtractAbiFunctionNames<TAbi, TAbiStateMutibility>, ExtractAbiFunction<TAbi, TFunctionName>, TOptions> : TContract extends {
|
|
202
|
-
abi: infer TAbi extends readonly unknown[];
|
|
203
|
-
functionName: infer TFunctionName extends string;
|
|
204
|
-
} ? ContractConfig<Omit<TContract, OmitConfigProperties>, TAbi, TFunctionName, never, TOptions> : ContractConfig<Omit<TContract, OmitConfigProperties>, Abi, string, never, TOptions>;
|
|
205
|
-
/**
|
|
206
|
-
* Unwraps return type of contract function
|
|
207
|
-
*
|
|
208
|
-
* @param TAbi - Contract {@link Abi}
|
|
209
|
-
* @param TFunctionName - Name of contract function
|
|
210
|
-
* @returns Inferred return type of contract function
|
|
211
|
-
*
|
|
212
|
-
* @example
|
|
213
|
-
* type Result = GetResult<[…], 'tokenURI'>
|
|
214
|
-
*/
|
|
215
|
-
type GetResult<TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string, TFunction extends AbiFunction & {
|
|
216
|
-
type: 'function';
|
|
217
|
-
} = TAbi extends Abi ? ExtractAbiFunction<TAbi, TFunctionName> : never> = TFunction['outputs'] extends infer TOutputs extends readonly AbiParameter[] ? Or<IsNever<TOutputs>, NotEqual<TAbi, Abi>> extends true ? unknown : TOutputs['length'] extends infer TLength ? TLength extends 0 ? void : TLength extends 1 ? AbiParameterToPrimitiveType<TOutputs[0]> : TOutputs extends readonly [...infer _] ? /**
|
|
218
|
-
* Return output as array assigned to an object with named keys
|
|
219
|
-
*
|
|
220
|
-
* | Outputs | Result |
|
|
221
|
-
* | --------------------------------------------------------------------- | ---------------------------------------------------------- |
|
|
222
|
-
* | `[{ name: 'foo', type: 'uint256' }, { name: 'bar', type: 'string' }]` | `readonly [bigint, string] & { foo: bigint; bar: string }` |
|
|
223
|
-
* | `[{ name: 'foo', type: 'uint256' }, { name: '', type: 'string' }]` | `readonly [bigint, string] & { foo: bigint }` |
|
|
224
|
-
*/ {
|
|
225
|
-
[Output in TOutputs[number] as Output extends {
|
|
226
|
-
name: string;
|
|
227
|
-
} ? Output['name'] extends '' ? never : Output['name'] : never]: AbiParameterToPrimitiveType<Output>;
|
|
228
|
-
} & AbiParametersToPrimitiveTypes<TOutputs> : unknown : never : never;
|
|
229
|
-
/**
|
|
230
|
-
* Gets return type of contract function
|
|
231
|
-
*
|
|
232
|
-
* @param TContract - Contract config in `{ abi: Abi, functionName: string }` format
|
|
233
|
-
* @returns Inferred return type of contract function
|
|
234
|
-
*
|
|
235
|
-
* @example
|
|
236
|
-
* type Result = GetReturnType<{ abi: […], functionName: 'tokenURI' }>
|
|
237
|
-
*/
|
|
238
|
-
type GetReturnType<TContract = unknown> = TContract extends {
|
|
239
|
-
abi: infer TAbi extends Abi;
|
|
240
|
-
functionName: infer TFunctionName extends string;
|
|
241
|
-
} ? GetResult<TAbi, TFunctionName, ExtractAbiFunction<TAbi, TFunctionName>> : TContract extends {
|
|
242
|
-
abi: infer TAbi extends readonly unknown[];
|
|
243
|
-
functionName: infer TFunctionName extends string;
|
|
244
|
-
} ? GetResult<TAbi, TFunctionName> : GetResult;
|
|
245
|
-
type MAXIMUM_DEPTH = 20;
|
|
246
|
-
/**
|
|
247
|
-
* ContractsConfig reducer recursively unwraps function arguments to infer/enforce type param
|
|
248
|
-
*
|
|
249
|
-
* @param TContracts - Array of contracts in shape of {@link ContractConfig}
|
|
250
|
-
* @returns Array of inferred contract configurations
|
|
251
|
-
*/
|
|
252
|
-
type ContractsConfig<TContracts extends unknown[], TContractProperties extends {
|
|
253
|
-
[key: string]: unknown;
|
|
254
|
-
} = {
|
|
255
|
-
[key: string]: unknown;
|
|
256
|
-
}, TOptions extends Options = DefaultOptions, Result extends any[] = [], Depth extends ReadonlyArray<number> = []> = Depth['length'] extends MAXIMUM_DEPTH ? GetConfig<TContractProperties, 'pure' | 'view', TOptions>[] : TContracts extends [] ? [] : TContracts extends [infer Head] ? [
|
|
257
|
-
...Result,
|
|
258
|
-
GetConfig<Head & TContractProperties, 'pure' | 'view', TOptions>
|
|
259
|
-
] : TContracts extends [infer Head, ...infer Tail] ? ContractsConfig<[
|
|
260
|
-
...Tail
|
|
261
|
-
], TContractProperties, TOptions, [
|
|
262
|
-
...Result,
|
|
263
|
-
GetConfig<Head & TContractProperties, 'pure' | 'view', TOptions>
|
|
264
|
-
], [
|
|
265
|
-
...Depth,
|
|
266
|
-
1
|
|
267
|
-
]> : unknown[] extends TContracts ? TContracts : TContracts extends ContractConfig<infer TContract, infer TAbi, infer TFunctionName, infer TFunction>[] ? ContractConfig<Omit<TContract & TContractProperties, OmitConfigProperties>, TAbi, TFunctionName, TFunction, TOptions>[] : GetConfig<TContractProperties, 'pure' | 'view', TOptions>[];
|
|
268
|
-
/**
|
|
269
|
-
* ContractsResult reducer recursively maps type param to results
|
|
270
|
-
*
|
|
271
|
-
* @param TContracts - Array of contracts in shape of {@link ContractConfig}
|
|
272
|
-
* @returns Array of inferred contract results
|
|
273
|
-
*/
|
|
274
|
-
type ContractsResult<TContracts extends unknown[], Result extends any[] = [], Depth extends ReadonlyArray<number> = []> = Depth['length'] extends MAXIMUM_DEPTH ? GetReturnType[] : TContracts extends [] ? [] : TContracts extends [infer Head] ? [...Result, GetReturnType<Head>] : TContracts extends [infer Head, ...infer Tail] ? ContractsResult<[...Tail], [...Result, GetReturnType<Head>], [...Depth, 1]> : TContracts extends ContractConfig<infer _TContract, infer TAbi, infer TFunctionName>[] ? GetReturnType<{
|
|
275
|
-
abi: TAbi;
|
|
276
|
-
functionName: TFunctionName;
|
|
277
|
-
}>[] : GetReturnType[];
|
|
278
|
-
/**
|
|
279
|
-
* Get name for {@link AbiFunction} or {@link AbiEvent}
|
|
280
|
-
*
|
|
281
|
-
* @param TAbiItem - {@link AbiFunction} or {@link AbiEvent}
|
|
282
|
-
* @param IsSignature - Whether to return the signature instead of the name
|
|
283
|
-
* @returns Name or signature of function or event
|
|
284
|
-
*
|
|
285
|
-
* @example
|
|
286
|
-
* type Result = AbiItemName<{ type: 'function'; name: 'Foo'; … }>
|
|
287
|
-
*/
|
|
288
|
-
type AbiItemName<TAbiItem extends (AbiFunction & {
|
|
289
|
-
type: 'function';
|
|
290
|
-
}) | AbiEvent, IsSignature extends boolean = false> = IsSignature extends true ? TAbiItem['inputs'] extends infer TAbiParameters extends readonly AbiParameter[] ? `${TAbiItem['name']}(${Join<[
|
|
291
|
-
...{
|
|
292
|
-
[K in keyof TAbiParameters]: TAbiParameters[K]['type'];
|
|
293
|
-
}
|
|
294
|
-
], ','>})` : never : TAbiItem['name'];
|
|
295
|
-
/**
|
|
296
|
-
* Get overrides for {@link AbiStateMutability}
|
|
297
|
-
*
|
|
298
|
-
* @param TAbiStateMutability - {@link AbiStateMutability}
|
|
299
|
-
* @returns Overrides for {@link TAbiStateMutability}
|
|
300
|
-
*
|
|
301
|
-
* @example
|
|
302
|
-
* type Result = GetOverridesForAbiStateMutability<'pure'>
|
|
303
|
-
*/
|
|
304
|
-
type GetOverridesForAbiStateMutability<TAbiStateMutability extends AbiStateMutability> = {
|
|
305
|
-
nonpayable: Overrides & {
|
|
306
|
-
from?: Address;
|
|
307
|
-
};
|
|
308
|
-
payable: PayableOverrides & {
|
|
309
|
-
from?: Address;
|
|
310
|
-
};
|
|
311
|
-
pure: CallOverrides;
|
|
312
|
-
view: CallOverrides;
|
|
313
|
-
}[TAbiStateMutability];
|
|
314
|
-
interface Overrides extends ethers.Overrides {
|
|
315
|
-
gasLimit?: ResolvedConfig['BigIntType'];
|
|
316
|
-
gasPrice?: ResolvedConfig['BigIntType'];
|
|
317
|
-
maxFeePerGas?: ResolvedConfig['BigIntType'];
|
|
318
|
-
maxPriorityFeePerGas?: ResolvedConfig['BigIntType'];
|
|
319
|
-
nonce?: ResolvedConfig['IntType'];
|
|
320
|
-
}
|
|
321
|
-
interface PayableOverrides extends Overrides {
|
|
322
|
-
value?: ResolvedConfig['IntType'] | ResolvedConfig['BigIntType'];
|
|
323
|
-
}
|
|
324
|
-
interface CallOverrides extends PayableOverrides {
|
|
325
|
-
blockTag?: ethers.CallOverrides['blockTag'];
|
|
326
|
-
from?: Address;
|
|
327
|
-
}
|
|
328
|
-
type Event<TAbiEvent extends AbiEvent> = Omit<ethers.Event, 'args' | 'event' | 'eventSignature'> & {
|
|
329
|
-
args: AbiParametersToPrimitiveTypes<TAbiEvent['inputs']>;
|
|
330
|
-
event: TAbiEvent['name'];
|
|
331
|
-
eventSignature: AbiItemName<TAbiEvent, true>;
|
|
332
|
-
};
|
|
333
|
-
|
|
334
|
-
export { AbiItemName as A, CountOccurrences as C, DefaultOptions as D, Event as E, GetConfig as G, IsUnknown as I, NotEqual as N, Options as O, UnionToIntersection as U, GetOverridesForAbiStateMutability as a, ContractsConfig as b, ContractsResult as c, GetReturnType as d, Or as e, IsNever as f, AbiParameter as g, ContractConfig as h, GetArgs as i, Optional as j };
|