@wagmi/core 0.7.6 → 0.7.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/{base-5bd9b5ed.d.ts → base-a32d0b91.d.ts} +2 -2
- package/dist/chains.d.ts +1 -1
- package/dist/{chunk-MS4CUBFJ.js → chunk-HEIMP7HQ.js} +131 -31
- package/dist/connectors/coinbaseWallet.d.ts +3 -3
- package/dist/connectors/coinbaseWallet.js +1 -1
- package/dist/connectors/metaMask.d.ts +4 -6
- package/dist/connectors/metaMask.js +36 -43
- package/dist/connectors/mock/index.d.ts +5 -5
- package/dist/connectors/mock/index.js +1 -1
- package/dist/connectors/walletConnect.d.ts +4 -4
- package/dist/connectors/walletConnect.js +13 -5
- package/dist/{contracts-3c4d70a1.d.ts → contracts-3880ee54.d.ts} +24 -24
- package/dist/{index-bacc1c49.d.ts → index-58cffc47.d.ts} +23 -23
- package/dist/index.d.ts +133 -112
- package/dist/index.js +5 -1
- package/dist/{injected-6980e5c3.d.ts → injected-82510902.d.ts} +12 -4
- package/dist/internal.d.ts +2 -2
- package/dist/internal.js +1 -1
- package/dist/providers/alchemy.d.ts +2 -2
- package/dist/providers/infura.d.ts +2 -2
- package/dist/providers/jsonRpc.d.ts +2 -2
- package/dist/providers/public.d.ts +2 -2
- package/package.json +2 -2
|
@@ -11,7 +11,7 @@ import { ethers } from 'ethers';
|
|
|
11
11
|
* @example
|
|
12
12
|
* type Result = CountOccurrences<['foo', 'bar', 'foo'], 'foo'>
|
|
13
13
|
*/
|
|
14
|
-
|
|
14
|
+
type CountOccurrences<TArray extends readonly unknown[], TType> = FilterNever<[
|
|
15
15
|
...{
|
|
16
16
|
[K in keyof TArray]: TArray[K] extends TType ? TArray[K] : never;
|
|
17
17
|
}
|
|
@@ -25,7 +25,7 @@ declare type CountOccurrences<TArray extends readonly unknown[], TType> = Filter
|
|
|
25
25
|
* @example
|
|
26
26
|
* type Result = FilterNever<[1, 2, never, 3, never, 4]>
|
|
27
27
|
*/
|
|
28
|
-
|
|
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
29
|
/**
|
|
30
30
|
* Check if {@link T} is `never`
|
|
31
31
|
*
|
|
@@ -35,7 +35,7 @@ declare type FilterNever<TArray extends readonly unknown[]> = TArray['length'] e
|
|
|
35
35
|
* @example
|
|
36
36
|
* type Result = IsNever<'foo'>
|
|
37
37
|
*/
|
|
38
|
-
|
|
38
|
+
type IsNever<T> = [T] extends [never] ? true : false;
|
|
39
39
|
/**
|
|
40
40
|
* Checks if {@link T} is `unknown`
|
|
41
41
|
*
|
|
@@ -45,7 +45,7 @@ declare type IsNever<T> = [T] extends [never] ? true : false;
|
|
|
45
45
|
* @example
|
|
46
46
|
* type Result = IsUnknown<unknown>
|
|
47
47
|
*/
|
|
48
|
-
|
|
48
|
+
type IsUnknown<T> = unknown extends T ? true : false;
|
|
49
49
|
/**
|
|
50
50
|
* Joins {@link Items} into string separated by {@link Separator}
|
|
51
51
|
*
|
|
@@ -56,7 +56,7 @@ declare type IsUnknown<T> = unknown extends T ? true : false;
|
|
|
56
56
|
* @example
|
|
57
57
|
* type Result = Join<['foo', 'bar'], '-'>
|
|
58
58
|
*/
|
|
59
|
-
|
|
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
60
|
/**
|
|
61
61
|
* Check if {@link T} and {@link U} are equal
|
|
62
62
|
*
|
|
@@ -67,7 +67,7 @@ declare type Join<Items extends string[], Separator extends string | number> = I
|
|
|
67
67
|
* @example
|
|
68
68
|
* type Result = NotEqual<'foo', 'bar'>
|
|
69
69
|
*/
|
|
70
|
-
|
|
70
|
+
type NotEqual<T, U> = [T] extends [U] ? false : true;
|
|
71
71
|
/**
|
|
72
72
|
* Convert {@link TKeys} of {@link TObject} to optional properties
|
|
73
73
|
*
|
|
@@ -78,7 +78,7 @@ declare type NotEqual<T, U> = [T] extends [U] ? false : true;
|
|
|
78
78
|
* @example
|
|
79
79
|
* type Result = Optional<{ foo: string; bar: number }, 'foo'>
|
|
80
80
|
*/
|
|
81
|
-
|
|
81
|
+
type Optional<TObject, TKeys extends keyof TObject> = {
|
|
82
82
|
[K in keyof TObject as K extends TKeys ? never : K]: TObject[K];
|
|
83
83
|
} & {
|
|
84
84
|
[K in keyof TObject as K extends TKeys ? K : never]?: TObject[K];
|
|
@@ -93,7 +93,7 @@ declare type Optional<TObject, TKeys extends keyof TObject> = {
|
|
|
93
93
|
* @example
|
|
94
94
|
* type Result = Or<true, false>
|
|
95
95
|
*/
|
|
96
|
-
|
|
96
|
+
type Or<T, U> = T extends true ? true : U extends true ? true : false;
|
|
97
97
|
/**
|
|
98
98
|
* Converts {@link Union} to intersection
|
|
99
99
|
*
|
|
@@ -103,13 +103,13 @@ declare type Or<T, U> = T extends true ? true : U extends true ? true : false;
|
|
|
103
103
|
* @example
|
|
104
104
|
* type Result = UnionToIntersection<'foo' | 'bar'>
|
|
105
105
|
*/
|
|
106
|
-
|
|
106
|
+
type UnionToIntersection<Union> = (Union extends unknown ? (arg: Union) => unknown : never) extends (arg: infer R) => unknown ? R : never;
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
type AbiParameter = AbiParameter$1;
|
|
109
109
|
/**
|
|
110
110
|
* Configuration options for contract types
|
|
111
111
|
*/
|
|
112
|
-
|
|
112
|
+
type Options = {
|
|
113
113
|
/** Flag for making `abi` optional */
|
|
114
114
|
isAbiOptional?: boolean;
|
|
115
115
|
/** Flag for making `address` optional */
|
|
@@ -122,7 +122,7 @@ declare type Options = {
|
|
|
122
122
|
/**
|
|
123
123
|
* Default {@link Options}
|
|
124
124
|
*/
|
|
125
|
-
|
|
125
|
+
type DefaultOptions = {
|
|
126
126
|
isAbiOptional: false;
|
|
127
127
|
isAddressOptional: false;
|
|
128
128
|
isArgsOptional: false;
|
|
@@ -139,7 +139,7 @@ declare type DefaultOptions = {
|
|
|
139
139
|
* @example
|
|
140
140
|
* type Result = GetArgs<[…], 'tokenURI'>
|
|
141
141
|
*/
|
|
142
|
-
|
|
142
|
+
type GetArgs<TAbi extends Abi | readonly unknown[], TFunction extends AbiFunction & {
|
|
143
143
|
type: 'function';
|
|
144
144
|
}, TOptions extends Options = DefaultOptions> = TFunction['inputs'] extends infer TInputs extends readonly AbiParameter[] ? Or<IsNever<TInputs>, NotEqual<TAbi, Abi>> extends true ? {
|
|
145
145
|
/**
|
|
@@ -160,7 +160,7 @@ declare type GetArgs<TAbi extends Abi | readonly unknown[], TFunction extends Ab
|
|
|
160
160
|
/**
|
|
161
161
|
* Contract configuration object for inferring function name and arguments based on {@link TAbi}.
|
|
162
162
|
*/
|
|
163
|
-
|
|
163
|
+
type ContractConfig<TContract = {
|
|
164
164
|
[key: string]: unknown;
|
|
165
165
|
}, TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string, TFunction extends AbiFunction & {
|
|
166
166
|
type: 'function';
|
|
@@ -183,7 +183,7 @@ declare type ContractConfig<TContract = {
|
|
|
183
183
|
/** Function to invoke on the contract */
|
|
184
184
|
functionName: IsNever<TFunctionName> extends true ? string : TFunctionName;
|
|
185
185
|
}) & GetArgs<TAbi, TFunction, TOptions> & TContract;
|
|
186
|
-
|
|
186
|
+
type OmitConfigProperties = 'abi' | 'args' | 'functionName';
|
|
187
187
|
/**
|
|
188
188
|
* Gets configuration type of contract function
|
|
189
189
|
*
|
|
@@ -195,7 +195,7 @@ declare type OmitConfigProperties = 'abi' | 'args' | 'functionName';
|
|
|
195
195
|
* @example
|
|
196
196
|
* type Result = GetConfig<{ abi: […], functionName: 'tokenURI' }, 'view'>
|
|
197
197
|
*/
|
|
198
|
-
|
|
198
|
+
type GetConfig<TContract = unknown, TAbiStateMutibility extends AbiStateMutability = AbiStateMutability, TOptions extends Options = DefaultOptions> = TContract extends {
|
|
199
199
|
abi: infer TAbi extends Abi;
|
|
200
200
|
functionName: infer TFunctionName extends string;
|
|
201
201
|
} ? ContractConfig<Omit<TContract, OmitConfigProperties>, TAbi, ExtractAbiFunctionNames<TAbi, TAbiStateMutibility>, ExtractAbiFunction<TAbi, TFunctionName>, TOptions> : TContract extends {
|
|
@@ -212,7 +212,7 @@ declare type GetConfig<TContract = unknown, TAbiStateMutibility extends AbiState
|
|
|
212
212
|
* @example
|
|
213
213
|
* type Result = GetResult<[…], 'tokenURI'>
|
|
214
214
|
*/
|
|
215
|
-
|
|
215
|
+
type GetResult<TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string, TFunction extends AbiFunction & {
|
|
216
216
|
type: 'function';
|
|
217
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
218
|
* Return output as array assigned to an object with named keys
|
|
@@ -235,21 +235,21 @@ declare type GetResult<TAbi extends Abi | readonly unknown[] = Abi, TFunctionNam
|
|
|
235
235
|
* @example
|
|
236
236
|
* type Result = GetReturnType<{ abi: […], functionName: 'tokenURI' }>
|
|
237
237
|
*/
|
|
238
|
-
|
|
238
|
+
type GetReturnType<TContract = unknown> = TContract extends {
|
|
239
239
|
abi: infer TAbi extends Abi;
|
|
240
240
|
functionName: infer TFunctionName extends string;
|
|
241
241
|
} ? GetResult<TAbi, TFunctionName, ExtractAbiFunction<TAbi, TFunctionName>> : TContract extends {
|
|
242
242
|
abi: infer TAbi extends readonly unknown[];
|
|
243
243
|
functionName: infer TFunctionName extends string;
|
|
244
244
|
} ? GetResult<TAbi, TFunctionName> : GetResult;
|
|
245
|
-
|
|
245
|
+
type MAXIMUM_DEPTH = 20;
|
|
246
246
|
/**
|
|
247
247
|
* ContractsConfig reducer recursively unwraps function arguments to infer/enforce type param
|
|
248
248
|
*
|
|
249
249
|
* @param TContracts - Array of contracts in shape of {@link ContractConfig}
|
|
250
250
|
* @returns Array of inferred contract configurations
|
|
251
251
|
*/
|
|
252
|
-
|
|
252
|
+
type ContractsConfig<TContracts extends unknown[], TContractProperties extends {
|
|
253
253
|
[key: string]: unknown;
|
|
254
254
|
} = {
|
|
255
255
|
[key: string]: unknown;
|
|
@@ -271,7 +271,7 @@ declare type ContractsConfig<TContracts extends unknown[], TContractProperties e
|
|
|
271
271
|
* @param TContracts - Array of contracts in shape of {@link ContractConfig}
|
|
272
272
|
* @returns Array of inferred contract results
|
|
273
273
|
*/
|
|
274
|
-
|
|
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
275
|
abi: TAbi;
|
|
276
276
|
functionName: TFunctionName;
|
|
277
277
|
}>[] : GetReturnType[];
|
|
@@ -285,7 +285,7 @@ declare type ContractsResult<TContracts extends unknown[], Result extends any[]
|
|
|
285
285
|
* @example
|
|
286
286
|
* type Result = AbiItemName<{ type: 'function'; name: 'Foo'; … }>
|
|
287
287
|
*/
|
|
288
|
-
|
|
288
|
+
type AbiItemName<TAbiItem extends (AbiFunction & {
|
|
289
289
|
type: 'function';
|
|
290
290
|
}) | AbiEvent, IsSignature extends boolean = false> = IsSignature extends true ? TAbiItem['inputs'] extends infer TAbiParameters extends readonly AbiParameter[] ? `${TAbiItem['name']}(${Join<[
|
|
291
291
|
...{
|
|
@@ -301,7 +301,7 @@ declare type AbiItemName<TAbiItem extends (AbiFunction & {
|
|
|
301
301
|
* @example
|
|
302
302
|
* type Result = GetOverridesForAbiStateMutability<'pure'>
|
|
303
303
|
*/
|
|
304
|
-
|
|
304
|
+
type GetOverridesForAbiStateMutability<TAbiStateMutability extends AbiStateMutability> = {
|
|
305
305
|
nonpayable: Overrides & {
|
|
306
306
|
from?: Address;
|
|
307
307
|
};
|
|
@@ -325,7 +325,7 @@ interface CallOverrides extends PayableOverrides {
|
|
|
325
325
|
blockTag?: ethers.CallOverrides['blockTag'];
|
|
326
326
|
from?: Address;
|
|
327
327
|
}
|
|
328
|
-
|
|
328
|
+
type Event<TAbiEvent extends AbiEvent> = Omit<ethers.Event, 'args' | 'event' | 'eventSignature'> & {
|
|
329
329
|
args: AbiParametersToPrimitiveTypes<TAbiEvent['inputs']>;
|
|
330
330
|
event: TAbiEvent['name'];
|
|
331
331
|
eventSignature: AbiItemName<TAbiEvent, true>;
|
|
@@ -15,7 +15,7 @@ declare const chainId: {
|
|
|
15
15
|
readonly hardhat: 31337;
|
|
16
16
|
readonly foundry: 31337;
|
|
17
17
|
};
|
|
18
|
-
|
|
18
|
+
type ChainName = keyof typeof chainId;
|
|
19
19
|
declare const mainnet: Chain;
|
|
20
20
|
declare const goerli: Chain;
|
|
21
21
|
declare const sepolia: Chain;
|
|
@@ -50,20 +50,20 @@ declare const allChains: Chain[];
|
|
|
50
50
|
declare const defaultChains: Chain[];
|
|
51
51
|
declare const defaultL2Chains: Chain[];
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
type BlockExplorerName = 'etherscan';
|
|
54
|
+
type BlockExplorer = {
|
|
55
55
|
name: string;
|
|
56
56
|
url: string;
|
|
57
57
|
};
|
|
58
|
-
|
|
58
|
+
type EtherscanChains = Extract<ChainName, 'mainnet' | 'goerli' | 'sepolia' | 'optimism' | 'optimismGoerli' | 'polygon' | 'polygonMumbai' | 'arbitrum' | 'arbitrumGoerli'>;
|
|
59
59
|
declare const etherscanBlockExplorers: Record<EtherscanChains, BlockExplorer>;
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
type RpcProviderName = 'alchemy' | 'infura' | 'public';
|
|
62
|
+
type AlchemyChains = Extract<ChainName, 'mainnet' | 'goerli' | 'optimism' | 'optimismGoerli' | 'polygon' | 'polygonMumbai' | 'arbitrum' | 'arbitrumGoerli'>;
|
|
63
63
|
declare const alchemyRpcUrls: Record<AlchemyChains, string>;
|
|
64
|
-
|
|
64
|
+
type InfuraChains = Extract<ChainName, 'mainnet' | 'goerli' | 'sepolia' | 'optimism' | 'optimismGoerli' | 'polygon' | 'polygonMumbai' | 'arbitrum' | 'arbitrumGoerli'>;
|
|
65
65
|
declare const infuraRpcUrls: Record<InfuraChains, string>;
|
|
66
|
-
|
|
66
|
+
type PublicChains = Extract<ChainName, 'mainnet' | 'goerli' | 'sepolia' | 'optimism' | 'optimismGoerli' | 'polygon' | 'polygonMumbai' | 'arbitrum' | 'arbitrumGoerli'>;
|
|
67
67
|
declare const publicRpcUrls: Record<PublicChains, string>;
|
|
68
68
|
|
|
69
69
|
declare const units: readonly ["wei", "kwei", "mwei", "gwei", "szabo", "finney", "ether"];
|
|
@@ -87,8 +87,8 @@ declare module 'ethers/lib/utils.js' {
|
|
|
87
87
|
v?: number;
|
|
88
88
|
} | ResolvedConfig['BytesType'] | string): string;
|
|
89
89
|
}
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
type Hash = `0x${string}`;
|
|
91
|
+
type Chain = {
|
|
92
92
|
/** ID in number form */
|
|
93
93
|
id: number;
|
|
94
94
|
/** Human-readable name */
|
|
@@ -125,22 +125,22 @@ declare type Chain = {
|
|
|
125
125
|
/** Flag for test networks */
|
|
126
126
|
testnet?: boolean;
|
|
127
127
|
};
|
|
128
|
-
|
|
128
|
+
type ChainProviderFn<TProvider extends Provider = providers.BaseProvider, TWebSocketProvider extends WebSocketProvider = providers.WebSocketProvider, TChain extends Chain = Chain> = (chain: TChain) => {
|
|
129
129
|
chain: TChain;
|
|
130
130
|
provider: () => ProviderWithFallbackConfig<TProvider>;
|
|
131
131
|
webSocketProvider?: () => TWebSocketProvider;
|
|
132
132
|
} | null;
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
type FallbackProviderConfig = Omit<providers.FallbackProviderConfig, 'provider'>;
|
|
134
|
+
type ProviderWithFallbackConfig<TProvider extends Provider = Provider> = TProvider & FallbackProviderConfig;
|
|
135
|
+
type Provider = providers.BaseProvider & {
|
|
136
136
|
chains?: Chain[];
|
|
137
137
|
};
|
|
138
|
-
|
|
138
|
+
type WebSocketProvider = providers.WebSocketProvider & {
|
|
139
139
|
chains?: Chain[];
|
|
140
140
|
};
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
type Signer = Signer$1;
|
|
142
|
+
type Unit = typeof units[number];
|
|
143
|
+
type AddEthereumChainParameter = {
|
|
144
144
|
/** A 0x-prefixed hexadecimal string */
|
|
145
145
|
chainId: string;
|
|
146
146
|
chainName: string;
|
|
@@ -155,18 +155,18 @@ declare type AddEthereumChainParameter = {
|
|
|
155
155
|
/** Currently ignored. */
|
|
156
156
|
iconUrls?: string[];
|
|
157
157
|
};
|
|
158
|
-
|
|
158
|
+
type WalletPermissionCaveat = {
|
|
159
159
|
type: string;
|
|
160
160
|
value: any;
|
|
161
161
|
};
|
|
162
|
-
|
|
162
|
+
type WalletPermission = {
|
|
163
163
|
caveats: WalletPermissionCaveat[];
|
|
164
164
|
date: number;
|
|
165
165
|
id: string;
|
|
166
166
|
invoker: `http://${string}` | `https://${string}`;
|
|
167
167
|
parentCapability: 'eth_accounts' | string;
|
|
168
168
|
};
|
|
169
|
-
|
|
169
|
+
type WatchAssetParams = {
|
|
170
170
|
/** In the future, other standards will be supported */
|
|
171
171
|
type: 'ERC20';
|
|
172
172
|
options: {
|
|
@@ -180,7 +180,7 @@ declare type WatchAssetParams = {
|
|
|
180
180
|
symbol: string;
|
|
181
181
|
};
|
|
182
182
|
};
|
|
183
|
-
|
|
183
|
+
type InjectedProviderFlags = {
|
|
184
184
|
isAvalanche?: true;
|
|
185
185
|
isBitKeep?: true;
|
|
186
186
|
isBraveWallet?: true;
|
|
@@ -200,7 +200,7 @@ declare type InjectedProviderFlags = {
|
|
|
200
200
|
isTrust?: true;
|
|
201
201
|
isTrustWallet?: true;
|
|
202
202
|
};
|
|
203
|
-
|
|
203
|
+
type InjectedProviders = InjectedProviderFlags & {
|
|
204
204
|
isMetaMask: true;
|
|
205
205
|
/** Only exists in MetaMask as of 2022/04/03 */
|
|
206
206
|
_events: {
|