@wagmi/core 0.5.8 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/chains/dist/wagmi-core-chains.cjs.dev.js +2 -2
  2. package/chains/dist/wagmi-core-chains.cjs.prod.js +2 -2
  3. package/chains/dist/wagmi-core-chains.esm.js +2 -2
  4. package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.dev.js +11 -12
  5. package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.prod.js +11 -12
  6. package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.esm.js +11 -12
  7. package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.cjs.dev.js +4 -3
  8. package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.cjs.prod.js +4 -3
  9. package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.esm.js +4 -3
  10. package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.dev.js +9 -13
  11. package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.prod.js +9 -13
  12. package/connectors/mock/dist/wagmi-core-connectors-mock.esm.js +9 -13
  13. package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.dev.js +9 -11
  14. package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.prod.js +9 -11
  15. package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.esm.js +9 -11
  16. package/dist/{chains-8c76af1b.esm.js → chains-2970e5fa.esm.js} +17 -11
  17. package/dist/{chains-ec1de502.cjs.dev.js → chains-45d5aa86.cjs.prod.js} +17 -11
  18. package/dist/{chains-789e0c2e.cjs.prod.js → chains-524f4950.cjs.dev.js} +17 -11
  19. package/dist/declarations/src/actions/accounts/fetchBalance.d.ts +4 -4
  20. package/dist/declarations/src/actions/accounts/fetchSigner.d.ts +5 -1
  21. package/dist/declarations/src/actions/accounts/index.d.ts +1 -1
  22. package/dist/declarations/src/actions/accounts/signMessage.d.ts +3 -5
  23. package/dist/declarations/src/actions/accounts/signTypedData.d.ts +19 -20
  24. package/dist/declarations/src/actions/accounts/watchSigner.d.ts +5 -3
  25. package/dist/declarations/src/actions/contracts/fetchToken.d.ts +5 -5
  26. package/dist/declarations/src/actions/contracts/getContract.d.ts +111 -8
  27. package/dist/declarations/src/actions/contracts/index.d.ts +5 -4
  28. package/dist/declarations/src/actions/contracts/multicall.d.ts +11 -15
  29. package/dist/declarations/src/actions/contracts/prepareWriteContract.d.ts +26 -16
  30. package/dist/declarations/src/actions/contracts/readContract.d.ts +12 -14
  31. package/dist/declarations/src/actions/contracts/readContracts.d.ts +25 -16
  32. package/dist/declarations/src/actions/contracts/watchContractEvent.d.ts +22 -8
  33. package/dist/declarations/src/actions/contracts/watchMulticall.d.ts +10 -0
  34. package/dist/declarations/src/actions/contracts/watchReadContract.d.ts +4 -3
  35. package/dist/declarations/src/actions/contracts/watchReadContracts.d.ts +7 -3
  36. package/dist/declarations/src/actions/contracts/writeContract.d.ts +43 -23
  37. package/dist/declarations/src/actions/ens/fetchEnsAddress.d.ts +1 -1
  38. package/dist/declarations/src/actions/ens/fetchEnsName.d.ts +2 -1
  39. package/dist/declarations/src/actions/index.d.ts +3 -3
  40. package/dist/declarations/src/actions/transactions/index.d.ts +0 -1
  41. package/dist/declarations/src/actions/transactions/prepareSendTransaction.d.ts +5 -4
  42. package/dist/declarations/src/actions/transactions/sendTransaction.d.ts +3 -2
  43. package/dist/declarations/src/actions/transactions/waitForTransaction.d.ts +2 -1
  44. package/dist/declarations/src/connectors/base.d.ts +5 -4
  45. package/dist/declarations/src/connectors/coinbaseWallet.d.ts +5 -3
  46. package/dist/declarations/src/connectors/injected.d.ts +10 -9
  47. package/dist/declarations/src/connectors/metaMask.d.ts +1 -1
  48. package/dist/declarations/src/connectors/mock/connector.d.ts +1 -1
  49. package/dist/declarations/src/connectors/mock/provider.d.ts +1 -1
  50. package/dist/declarations/src/connectors/walletConnect.d.ts +2 -2
  51. package/dist/declarations/src/constants/abis.d.ts +421 -2
  52. package/dist/declarations/src/constants/blockExplorers.d.ts +1 -1
  53. package/dist/declarations/src/constants/index.d.ts +1 -2
  54. package/dist/declarations/src/errors.d.ts +8 -8
  55. package/dist/declarations/src/index.d.ts +4 -3
  56. package/dist/declarations/src/internal.d.ts +2 -0
  57. package/dist/declarations/src/types/contracts.d.ts +241 -0
  58. package/dist/declarations/src/types/index.d.ts +31 -9
  59. package/dist/declarations/src/types/utils.d.ts +103 -0
  60. package/dist/declarations/src/utils/assertActiveChain.d.ts +3 -0
  61. package/dist/declarations/src/utils/configureChains.d.ts +3 -5
  62. package/dist/declarations/src/utils/index.d.ts +2 -0
  63. package/dist/declarations/src/utils/minimizeContractInterface.d.ts +5 -5
  64. package/dist/declarations/src/utils/normalizeFunctionName.d.ts +17 -0
  65. package/dist/declarations/src/utils/parseContractResult.d.ts +4 -4
  66. package/dist/{getProvider-5b4b62c3.esm.js → getProvider-24ec6544.esm.js} +49 -50
  67. package/dist/{getProvider-1b3eeda8.cjs.dev.js → getProvider-ed469b94.cjs.prod.js} +48 -49
  68. package/dist/{getProvider-ad4ce6a4.cjs.prod.js → getProvider-f6f17fa1.cjs.dev.js} +48 -49
  69. package/dist/{rpcs-d2cd65f1.cjs.dev.js → rpcs-0d21dfe8.cjs.dev.js} +5 -5
  70. package/dist/{rpcs-8d636858.esm.js → rpcs-b4aa70b9.esm.js} +6 -6
  71. package/dist/{rpcs-edec227e.cjs.prod.js → rpcs-c62bf9b0.cjs.prod.js} +5 -5
  72. package/dist/wagmi-core.cjs.dev.js +847 -395
  73. package/dist/wagmi-core.cjs.prod.js +847 -395
  74. package/dist/wagmi-core.esm.js +849 -397
  75. package/package.json +3 -2
  76. package/providers/alchemy/dist/wagmi-core-providers-alchemy.cjs.dev.js +2 -2
  77. package/providers/alchemy/dist/wagmi-core-providers-alchemy.cjs.prod.js +2 -2
  78. package/providers/alchemy/dist/wagmi-core-providers-alchemy.esm.js +2 -2
  79. package/providers/infura/dist/wagmi-core-providers-infura.cjs.dev.js +2 -2
  80. package/providers/infura/dist/wagmi-core-providers-infura.cjs.prod.js +2 -2
  81. package/providers/infura/dist/wagmi-core-providers-infura.esm.js +2 -2
  82. package/dist/declarations/src/actions/contracts/deprecatedWriteContract.d.ts +0 -16
  83. package/dist/declarations/src/actions/transactions/deprecatedSendTransaction.d.ts +0 -12
  84. package/dist/declarations/src/constants/multicall.d.ts +0 -25
  85. package/providers/coinbaseNode/dist/wagmi-core-providers-coinbaseNode.cjs.d.ts +0 -11
  86. package/providers/coinbaseNode/dist/wagmi-core-providers-coinbaseNode.cjs.js +0 -16
@@ -0,0 +1,241 @@
1
+ import { Abi, AbiEvent, AbiFunction, AbiParameter, AbiParameterToPrimitiveType, AbiParametersToPrimitiveTypes, AbiStateMutability, Address, ExtractAbiFunction, ExtractAbiFunctionNames, Narrow, ResolvedConfig } from 'abitype';
2
+ import { ethers } from 'ethers';
3
+ import { IsNever, Join, NotEqual, Or } from './utils';
4
+ /**
5
+ * Configuration options for contract types
6
+ */
7
+ export declare type Options = {
8
+ /** Flag for making `abi` optional */
9
+ isAbiOptional?: boolean;
10
+ /** Flag for making `address` optional */
11
+ isAddressOptional?: boolean;
12
+ /** Flag for making `args` optional */
13
+ isArgsOptional?: boolean;
14
+ /** Flag for making `functionName` optional */
15
+ isFunctionNameOptional?: boolean;
16
+ };
17
+ /**
18
+ * Default {@link Options}
19
+ */
20
+ export declare type DefaultOptions = {
21
+ isAbiOptional: false;
22
+ isAddressOptional: false;
23
+ isArgsOptional: false;
24
+ isFunctionNameOptional: false;
25
+ };
26
+ /**
27
+ * Gets arguments of contract function
28
+ *
29
+ * @param TAbi - Contract {@link Abi}
30
+ * @param TFunctionName - Name of contract function
31
+ * @param TOptions - Options for configuring arguments. Defaults to {@link DefaultOptions}.
32
+ * @returns Inferred args of contract function
33
+ *
34
+ * @example
35
+ * type Result = GetArgs<[…], 'tokenURI'>
36
+ */
37
+ export declare type GetArgs<TAbi extends Abi | readonly unknown[], TFunction extends AbiFunction & {
38
+ type: 'function';
39
+ }, TOptions extends Options = DefaultOptions> = TFunction['inputs'] extends infer TInputs extends readonly AbiParameter[] ? Or<IsNever<TInputs>, NotEqual<TAbi, Abi>> extends true ? {
40
+ /**
41
+ * Arguments to pass contract method
42
+ *
43
+ * Use a [const assertion](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#const-assertions) on {@link abi} for type inference.
44
+ */
45
+ args?: readonly unknown[];
46
+ } : TInputs['length'] extends 0 ? {
47
+ args?: never;
48
+ } : AbiParametersToPrimitiveTypes<TInputs> extends infer TArgs ? TOptions['isArgsOptional'] extends true ? {
49
+ /** Arguments to pass contract method */
50
+ args?: TArgs;
51
+ } : {
52
+ /** Arguments to pass contract method */
53
+ args: TArgs;
54
+ } : never : never;
55
+ /**
56
+ * Contract configuration object for inferring function name and arguments based on {@link TAbi}.
57
+ */
58
+ export declare type ContractConfig<TContract = {
59
+ [key: string]: unknown;
60
+ }, TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string, TFunction extends AbiFunction & {
61
+ type: 'function';
62
+ } = TAbi extends Abi ? ExtractAbiFunction<TAbi, TFunctionName> : never, TOptions extends Options = DefaultOptions> = (TOptions['isAbiOptional'] extends true ? {
63
+ /** Contract ABI */
64
+ abi?: Narrow<TAbi>;
65
+ } : {
66
+ /** Contract ABI */
67
+ abi: Narrow<TAbi>;
68
+ }) & (TOptions['isAddressOptional'] extends true ? {
69
+ /** Contract address */
70
+ address?: string;
71
+ } : {
72
+ /** Contract address */
73
+ address: string;
74
+ }) & (TOptions['isFunctionNameOptional'] extends true ? {
75
+ /** Function to invoke on the contract */
76
+ functionName?: IsNever<TFunctionName> extends true ? string : TFunctionName;
77
+ } : {
78
+ /** Function to invoke on the contract */
79
+ functionName: IsNever<TFunctionName> extends true ? string : TFunctionName;
80
+ }) & GetArgs<TAbi, TFunction, TOptions> & TContract;
81
+ declare type OmitConfigProperties = 'abi' | 'args' | 'functionName';
82
+ /**
83
+ * Gets configuration type of contract function
84
+ *
85
+ * @param TContract - Contract config in `{ abi: Abi, functionName: string }` format
86
+ * @param TAbiStateMutibility - State mutability of contract function
87
+ * @param TOptions - Options for configuring arguments. Defaults to {@link DefaultOptions}.
88
+ * @returns Inferred configuration type of contract function
89
+ *
90
+ * @example
91
+ * type Result = GetConfig<{ abi: […], functionName: 'tokenURI' }, 'view'>
92
+ */
93
+ export declare type GetConfig<TContract = unknown, TAbiStateMutibility extends AbiStateMutability = AbiStateMutability, TOptions extends Options = DefaultOptions> = TContract extends {
94
+ abi: infer TAbi extends Abi;
95
+ functionName: infer TFunctionName extends string;
96
+ } ? ContractConfig<Omit<TContract, OmitConfigProperties>, TAbi, ExtractAbiFunctionNames<TAbi, TAbiStateMutibility>, ExtractAbiFunction<TAbi, TFunctionName>, TOptions> : TContract extends {
97
+ abi: infer TAbi extends readonly unknown[];
98
+ functionName: infer TFunctionName extends string;
99
+ } ? ContractConfig<Omit<TContract, OmitConfigProperties>, TAbi, TFunctionName, never, TOptions> : ContractConfig<Omit<TContract, OmitConfigProperties>, Abi, string, never, TOptions>;
100
+ /**
101
+ * Unwraps return type of contract function
102
+ *
103
+ * @param TAbi - Contract {@link Abi}
104
+ * @param TFunctionName - Name of contract function
105
+ * @returns Inferred return type of contract function
106
+ *
107
+ * @example
108
+ * type Result = GetResult<[…], 'tokenURI'>
109
+ */
110
+ declare type GetResult<TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string, TFunction extends AbiFunction & {
111
+ type: 'function';
112
+ } = 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 _] ? /**
113
+ * Return output as array assigned to an object with named keys
114
+ *
115
+ * | Outputs | Result |
116
+ * | --------------------------------------------------------------------- | ---------------------------------------------------------- |
117
+ * | `[{ name: 'foo', type: 'uint256' }, { name: 'bar', type: 'string' }]` | `readonly [bigint, string] & { foo: bigint; bar: string }` |
118
+ * | `[{ name: 'foo', type: 'uint256' }, { name: '', type: 'string' }]` | `readonly [bigint, string] & { foo: bigint }` |
119
+ */ {
120
+ [Output in TOutputs[number] as Output['name'] extends '' ? never : Output['name']]: AbiParameterToPrimitiveType<Output>;
121
+ } & AbiParametersToPrimitiveTypes<TOutputs> : unknown : never : never;
122
+ /**
123
+ * Gets return type of contract function
124
+ *
125
+ * @param TContract - Contract config in `{ abi: Abi, functionName: string }` format
126
+ * @returns Inferred return type of contract function
127
+ *
128
+ * @example
129
+ * type Result = GetReturnType<{ abi: […], functionName: 'tokenURI' }>
130
+ */
131
+ export declare type GetReturnType<TContract = unknown> = TContract extends {
132
+ abi: infer TAbi extends Abi;
133
+ functionName: infer TFunctionName extends string;
134
+ } ? GetResult<TAbi, TFunctionName, ExtractAbiFunction<TAbi, TFunctionName>> : TContract extends {
135
+ abi: infer TAbi extends readonly unknown[];
136
+ functionName: infer TFunctionName extends string;
137
+ } ? GetResult<TAbi, TFunctionName> : GetResult;
138
+ declare type MAXIMUM_DEPTH = 20;
139
+ /**
140
+ * ContractsConfig reducer recursively unwraps function arguments to infer/enforce type param
141
+ *
142
+ * @param TContracts - Array of contracts in shape of {@link ContractConfig}
143
+ * @returns Array of inferred contract configurations
144
+ */
145
+ export declare type ContractsConfig<TContracts extends unknown[], TContractProperties extends {
146
+ [key: string]: unknown;
147
+ } = {
148
+ [key: string]: unknown;
149
+ }, 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] ? [
150
+ ...Result,
151
+ GetConfig<Head & TContractProperties, 'pure' | 'view', TOptions>
152
+ ] : TContracts extends [infer Head, ...infer Tail] ? ContractsConfig<[
153
+ ...Tail
154
+ ], TContractProperties, TOptions, [
155
+ ...Result,
156
+ GetConfig<Head & TContractProperties, 'pure' | 'view', TOptions>
157
+ ], [
158
+ ...Depth,
159
+ 1
160
+ ]> : 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>[];
161
+ /**
162
+ * ContractsResult reducer recursively maps type param to results
163
+ *
164
+ * @param TContracts - Array of contracts in shape of {@link ContractConfig}
165
+ * @returns Array of inferred contract results
166
+ */
167
+ export declare 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<{
168
+ abi: TAbi;
169
+ functionName: TFunctionName;
170
+ }>[] : GetReturnType[];
171
+ /**
172
+ * Converts array of {@link AbiEvent} parameters to corresponding TypeScript primitive types.
173
+ *
174
+ * @param TAbiEventParameters - Array of {@link AbiEvent} parameters to convert to TypeScript representations
175
+ * @returns Array of TypeScript primitive types
176
+ */
177
+ export declare type AbiEventParametersToPrimitiveTypes<TAbiEventParameters extends readonly (AbiParameter & {
178
+ indexed?: boolean;
179
+ })[], Options extends {
180
+ AllowNull: boolean;
181
+ } = {
182
+ AllowNull: false;
183
+ }> = {
184
+ [K in keyof TAbiEventParameters]: TAbiEventParameters[K]['indexed'] extends true ? AbiParameterToPrimitiveType<TAbiEventParameters[K]> | (Options['AllowNull'] extends true ? null : never) : null;
185
+ };
186
+ /**
187
+ * Get name for {@link AbiFunction} or {@link AbiEvent}
188
+ *
189
+ * @param TAbiItem - {@link AbiFunction} or {@link AbiEvent}
190
+ * @param IsSignature - Whether to return the signature instead of the name
191
+ * @returns Name or signature of function or event
192
+ *
193
+ * @example
194
+ * type Result = AbiItemName<{ type: 'function'; name: 'Foo'; … }>
195
+ */
196
+ export declare type AbiItemName<TAbiItem extends (AbiFunction & {
197
+ type: 'function';
198
+ }) | AbiEvent, IsSignature extends boolean = false> = IsSignature extends true ? TAbiItem['inputs'] extends infer TAbiParameters extends readonly AbiParameter[] ? `${TAbiItem['name']}(${Join<[
199
+ ...{
200
+ [K in keyof TAbiParameters]: TAbiParameters[K]['type'];
201
+ }
202
+ ], ','>})` : never : TAbiItem['name'];
203
+ /**
204
+ * Get overrides for {@link AbiStateMutability}
205
+ *
206
+ * @param TAbiStateMutability - {@link AbiStateMutability}
207
+ * @returns Overrides for {@link TAbiStateMutability}
208
+ *
209
+ * @example
210
+ * type Result = GetOverridesForAbiStateMutability<'pure'>
211
+ */
212
+ export declare type GetOverridesForAbiStateMutability<TAbiStateMutability extends AbiStateMutability> = {
213
+ nonpayable: Overrides & {
214
+ from?: Address;
215
+ };
216
+ payable: PayableOverrides & {
217
+ from?: Address;
218
+ };
219
+ pure: CallOverrides;
220
+ view: CallOverrides;
221
+ }[TAbiStateMutability];
222
+ export interface Overrides extends ethers.Overrides {
223
+ gasLimit?: ResolvedConfig['BigIntType'];
224
+ gasPrice?: ResolvedConfig['BigIntType'];
225
+ maxFeePerGas?: ResolvedConfig['BigIntType'];
226
+ maxPriorityFeePerGas?: ResolvedConfig['BigIntType'];
227
+ nonce?: ResolvedConfig['IntType'];
228
+ }
229
+ export interface PayableOverrides extends Overrides {
230
+ value?: ResolvedConfig['IntType'] | ResolvedConfig['BigIntType'];
231
+ }
232
+ export interface CallOverrides extends PayableOverrides {
233
+ blockTag?: ethers.CallOverrides['blockTag'];
234
+ from?: Address;
235
+ }
236
+ export declare type Event<TAbiEvent extends AbiEvent> = Omit<ethers.Event, 'args' | 'event' | 'eventSignature'> & {
237
+ args: AbiEventParametersToPrimitiveTypes<TAbiEvent['inputs']>;
238
+ event: TAbiEvent['name'];
239
+ eventSignature: AbiItemName<TAbiEvent, true>;
240
+ };
241
+ export {};
@@ -1,6 +1,25 @@
1
- import { Signer as BaseSigner, providers } from 'ethers';
1
+ import { Address, ResolvedConfig, TypedData, TypedDataDomain, TypedDataToPrimitiveTypes } from 'abitype';
2
+ import { Signer as BaseSigner, BigNumber, providers } from 'ethers';
2
3
  import { BlockExplorer, BlockExplorerName, RpcProviderName, units } from '../constants';
3
- export declare type Address = `0x${string}`;
4
+ declare module 'abitype' {
5
+ interface Config {
6
+ BigIntType: BigNumber;
7
+ IntType: number;
8
+ }
9
+ }
10
+ declare module 'ethers/lib/utils' {
11
+ function getAddress(address: string): Address;
12
+ function isAddress(address: string): address is Address;
13
+ function verifyTypedData<TTypedData extends TypedData, TSchema extends TypedDataToPrimitiveTypes<TTypedData>>(domain: TypedDataDomain, types: TTypedData, value: TSchema[keyof TSchema] extends infer TValue ? {
14
+ [x: string]: any;
15
+ } extends TValue ? Record<string, any> : TValue : never, signature: {
16
+ r: string;
17
+ s?: string;
18
+ _vs?: string;
19
+ recoveryParam?: number;
20
+ v?: number;
21
+ } | ResolvedConfig['BytesType'] | string): string;
22
+ }
4
23
  export declare type Hash = `0x${string}`;
5
24
  export declare type Chain = {
6
25
  /** ID in number form */
@@ -27,11 +46,13 @@ export declare type Chain = {
27
46
  };
28
47
  /** ENS registry */
29
48
  ens?: {
30
- address: string;
49
+ address: Address;
31
50
  };
32
- /** Chain multicall contract */
51
+ /**
52
+ * Chain [multicall3 contract](https://github.com/mds1/multicall)
53
+ */
33
54
  multicall?: {
34
- address: string;
55
+ address: Address;
35
56
  blockCreated: number;
36
57
  };
37
58
  /** Flag for test networks */
@@ -83,9 +104,9 @@ declare type WatchAssetParams = {
83
104
  type: 'ERC20';
84
105
  options: {
85
106
  /** Address of token contract */
86
- address: string;
107
+ address: Address;
87
108
  /** Number of token decimals */
88
- decimals: number;
109
+ decimals: ResolvedConfig['IntType'];
89
110
  /** String url of token logo */
90
111
  image?: string;
91
112
  /** A ticker symbol or shorthand, up to 5 characters */
@@ -107,6 +128,7 @@ declare type InjectedProviderFlags = {
107
128
  isTokenPocket?: true;
108
129
  isTokenary?: true;
109
130
  isTrust?: true;
131
+ isAvalanche?: true;
110
132
  };
111
133
  declare type InjectedProviders = InjectedProviderFlags & {
112
134
  isMetaMask: true;
@@ -141,13 +163,13 @@ export interface Ethereum extends InjectedProviders {
141
163
  */
142
164
  request(args: {
143
165
  method: 'eth_accounts';
144
- }): Promise<string[]>;
166
+ }): Promise<Address[]>;
145
167
  request(args: {
146
168
  method: 'eth_chainId';
147
169
  }): Promise<string>;
148
170
  request(args: {
149
171
  method: 'eth_requestAccounts';
150
- }): Promise<string[]>;
172
+ }): Promise<Address[]>;
151
173
  /**
152
174
  * EIP-1474: Remote procedure call specification
153
175
  * https://eips.ethereum.org/EIPS/eip-1474
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Count occurrences of {@link TType} in {@link TArray}
3
+ *
4
+ * @param TArray - Array to count occurrences in
5
+ * @param TType - Type to count occurrences of
6
+ * @returns Number of occurrences of {@link TType} in {@link TArray}
7
+ *
8
+ * @example
9
+ * type Result = CountOccurrences<['foo', 'bar', 'foo'], 'foo'>
10
+ */
11
+ export declare type CountOccurrences<TArray extends readonly unknown[], TType> = FilterNever<[
12
+ ...{
13
+ [K in keyof TArray]: TArray[K] extends TType ? TArray[K] : never;
14
+ }
15
+ ]>['length'];
16
+ /**
17
+ * Removes all occurrences of `never` from {@link TArray}
18
+ *
19
+ * @param TArray - Array to filter
20
+ * @returns Array with `never` removed
21
+ *
22
+ * @example
23
+ * type Result = FilterNever<[1, 2, never, 3, never, 4]>
24
+ */
25
+ export declare 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;
26
+ /**
27
+ * Check if {@link T} is `never`
28
+ *
29
+ * @param T - Type to check
30
+ * @returns `true` if {@link T} is `never`, otherwise `false`
31
+ *
32
+ * @example
33
+ * type Result = IsNever<'foo'>
34
+ */
35
+ export declare type IsNever<T> = [T] extends [never] ? true : false;
36
+ /**
37
+ * Checks if {@link T} is `unknown`
38
+ *
39
+ * @param T - Type to check
40
+ * @returns `true` if {@link T} is `unknown`, otherwise `false`
41
+ *
42
+ * @example
43
+ * type Result = IsUnknown<unknown>
44
+ */
45
+ export declare type IsUnknown<T> = unknown extends T ? true : false;
46
+ /**
47
+ * Joins {@link Items} into string separated by {@link Separator}
48
+ *
49
+ * @param Items - Items to join
50
+ * @param Separator - Separator to use
51
+ * @returns Joined string
52
+ *
53
+ * @example
54
+ * type Result = Join<['foo', 'bar'], '-'>
55
+ */
56
+ export declare 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 : '';
57
+ /**
58
+ * Check if {@link T} and {@link U} are equal
59
+ *
60
+ * @param T
61
+ * @param U
62
+ * @returns `true` if {@link T} and {@link U} are not equal, otherwise `false`
63
+ *
64
+ * @example
65
+ * type Result = NotEqual<'foo', 'bar'>
66
+ */
67
+ export declare type NotEqual<T, U> = [T] extends [U] ? false : true;
68
+ /**
69
+ * Convert {@link TKeys} of {@link TObject} to optional properties
70
+ *
71
+ * @param TObject
72
+ * @param TKeys
73
+ * @returns {@link TObject} with {@link TKeys} converted to optional properties
74
+ *
75
+ * @example
76
+ * type Result = Optional<{ foo: string; bar: number }, 'foo'>
77
+ */
78
+ export declare type Optional<TObject, TKeys extends keyof TObject> = {
79
+ [K in keyof TObject as K extends TKeys ? never : K]: TObject[K];
80
+ } & {
81
+ [K in keyof TObject as K extends TKeys ? K : never]?: TObject[K];
82
+ };
83
+ /**
84
+ * Boolean "or" operator
85
+ *
86
+ * @param T
87
+ * @param U
88
+ * @returns `true` if either {@link T} or {@link U} are `true`, otherwise `false`
89
+ *
90
+ * @example
91
+ * type Result = Or<true, false>
92
+ */
93
+ export declare type Or<T, U> = T extends true ? true : U extends true ? true : false;
94
+ /**
95
+ * Converts {@link Union} to intersection
96
+ *
97
+ * @param Union - Union to convert
98
+ * @returns Intersection of {@link Union}
99
+ *
100
+ * @example
101
+ * type Result = UnionToIntersection<'foo' | 'bar'>
102
+ */
103
+ export declare type UnionToIntersection<Union> = (Union extends unknown ? (arg: Union) => unknown : never) extends (arg: infer R) => unknown ? R : never;
@@ -0,0 +1,3 @@
1
+ export declare function assertActiveChain({ chainId }: {
2
+ chainId: number;
3
+ }): void;
@@ -1,5 +1,5 @@
1
1
  import { providers } from 'ethers';
2
- import { Chain, ChainProviderFn, Provider, WebSocketProvider } from '../types';
2
+ import { Chain, ChainProviderFn, Provider, ProviderWithFallbackConfig, WebSocketProvider } from '../types';
3
3
  export declare type ConfigureChainsConfig = {
4
4
  pollingInterval?: number;
5
5
  stallTimeout?: number;
@@ -14,12 +14,10 @@ export declare function configureChains<TProvider extends Provider = Provider, T
14
14
  readonly chains: TChain[];
15
15
  readonly provider: ({ chainId }: {
16
16
  chainId?: number | undefined;
17
- }) => (TProvider & {
18
- chains: TChain[];
19
- }) | (providers.FallbackProvider & {
17
+ }) => (ProviderWithFallbackConfig<TProvider> | providers.FallbackProvider) & {
20
18
  chains: TChain[];
21
19
  pollingInterval: number;
22
- });
20
+ };
23
21
  readonly webSocketProvider: ({ chainId }: {
24
22
  chainId?: number | undefined;
25
23
  }) => (TWebSocketProvider & {
@@ -1,7 +1,9 @@
1
1
  export { configureChains } from './configureChains';
2
2
  export type { ConfigureChainsConfig } from './configureChains';
3
+ export { assertActiveChain } from './assertActiveChain';
3
4
  export { debounce } from './debounce';
4
5
  export { deepEqual } from './deepEqual';
6
+ export { normalizeFunctionName } from './normalizeFunctionName';
5
7
  export { getInjectedName } from './getInjectedName';
6
8
  export { logWarn } from './logger';
7
9
  export { minimizeContractInterface } from './minimizeContractInterface';
@@ -1,5 +1,5 @@
1
- import { ContractInterface } from 'ethers/lib/ethers';
2
- export declare function minimizeContractInterface({ contractInterface, functionName, }: {
3
- contractInterface: ContractInterface;
4
- functionName: string;
5
- }): string[];
1
+ import { Abi, ExtractAbiFunctionNames } from 'abitype';
2
+ export declare function minimizeContractInterface<TAbi extends Abi | readonly unknown[]>(config: {
3
+ abi: TAbi;
4
+ functionName: TAbi extends Abi ? ExtractAbiFunctionNames<TAbi> : string;
5
+ }): string[] | (import("abitype").AbiFunction | import("abitype").AbiEvent | import("abitype").AbiError)[];
@@ -0,0 +1,17 @@
1
+ import { AbiParameter } from 'abitype';
2
+ import { Contract } from 'ethers';
3
+ /**
4
+ * Get normalized function name from contract
5
+ *
6
+ * @param contract — Contract
7
+ * @param functionName — Function name
8
+ * @param args — Function arguments (used to disambiguate overloaded functions)
9
+ *
10
+ * @returns Normalized function name
11
+ */
12
+ export declare function normalizeFunctionName({ contract, functionName, args, }: {
13
+ contract: Contract;
14
+ functionName: string;
15
+ args?: readonly unknown[];
16
+ }): string;
17
+ export declare function isArgOfType(arg: unknown, abiParameter: AbiParameter): boolean;
@@ -1,7 +1,7 @@
1
+ import { Abi } from 'abitype';
1
2
  import { ContractInterface } from 'ethers/lib/ethers';
2
- import { Result } from 'ethers/lib/utils';
3
- export declare function parseContractResult({ contractInterface, data, functionName, }: {
4
- contractInterface: ContractInterface;
5
- data: Result;
3
+ export declare function parseContractResult({ abi, data, functionName, }: {
4
+ abi: ContractInterface | Abi | readonly unknown[];
5
+ data: any;
6
6
  functionName: string;
7
7
  }): any;