@wagmi/core 0.5.7 → 0.6.0
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/chains/dist/wagmi-core-chains.cjs.dev.js +2 -2
- package/chains/dist/wagmi-core-chains.cjs.prod.js +2 -2
- package/chains/dist/wagmi-core-chains.esm.js +2 -2
- package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.dev.js +11 -12
- package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.prod.js +11 -12
- package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.esm.js +11 -12
- package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.cjs.dev.js +4 -3
- package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.cjs.prod.js +4 -3
- package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.esm.js +4 -3
- package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.dev.js +9 -13
- package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.prod.js +9 -13
- package/connectors/mock/dist/wagmi-core-connectors-mock.esm.js +9 -13
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.dev.js +9 -11
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.prod.js +9 -11
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.esm.js +9 -11
- package/dist/{chains-8c76af1b.esm.js → chains-2970e5fa.esm.js} +17 -11
- package/dist/{chains-ec1de502.cjs.dev.js → chains-45d5aa86.cjs.prod.js} +17 -11
- package/dist/{chains-789e0c2e.cjs.prod.js → chains-524f4950.cjs.dev.js} +17 -11
- package/dist/declarations/src/actions/accounts/fetchBalance.d.ts +4 -4
- package/dist/declarations/src/actions/accounts/fetchSigner.d.ts +5 -1
- package/dist/declarations/src/actions/accounts/index.d.ts +1 -1
- package/dist/declarations/src/actions/accounts/signMessage.d.ts +3 -5
- package/dist/declarations/src/actions/accounts/signTypedData.d.ts +19 -20
- package/dist/declarations/src/actions/accounts/watchSigner.d.ts +5 -3
- package/dist/declarations/src/actions/contracts/fetchToken.d.ts +5 -5
- package/dist/declarations/src/actions/contracts/getContract.d.ts +111 -8
- package/dist/declarations/src/actions/contracts/index.d.ts +5 -4
- package/dist/declarations/src/actions/contracts/multicall.d.ts +11 -15
- package/dist/declarations/src/actions/contracts/prepareWriteContract.d.ts +26 -16
- package/dist/declarations/src/actions/contracts/readContract.d.ts +12 -14
- package/dist/declarations/src/actions/contracts/readContracts.d.ts +25 -16
- package/dist/declarations/src/actions/contracts/watchContractEvent.d.ts +22 -8
- package/dist/declarations/src/actions/contracts/watchMulticall.d.ts +10 -0
- package/dist/declarations/src/actions/contracts/watchReadContract.d.ts +4 -3
- package/dist/declarations/src/actions/contracts/watchReadContracts.d.ts +7 -3
- package/dist/declarations/src/actions/contracts/writeContract.d.ts +43 -23
- package/dist/declarations/src/actions/ens/fetchEnsAddress.d.ts +1 -1
- package/dist/declarations/src/actions/ens/fetchEnsName.d.ts +2 -1
- package/dist/declarations/src/actions/index.d.ts +3 -3
- package/dist/declarations/src/actions/network-status/watchBlockNumber.d.ts +1 -0
- package/dist/declarations/src/actions/transactions/index.d.ts +0 -1
- package/dist/declarations/src/actions/transactions/prepareSendTransaction.d.ts +5 -4
- package/dist/declarations/src/actions/transactions/sendTransaction.d.ts +3 -2
- package/dist/declarations/src/actions/transactions/waitForTransaction.d.ts +2 -1
- package/dist/declarations/src/connectors/base.d.ts +6 -4
- package/dist/declarations/src/connectors/coinbaseWallet.d.ts +5 -3
- package/dist/declarations/src/connectors/injected.d.ts +10 -9
- package/dist/declarations/src/connectors/metaMask.d.ts +1 -1
- package/dist/declarations/src/connectors/mock/connector.d.ts +1 -1
- package/dist/declarations/src/connectors/mock/provider.d.ts +1 -1
- package/dist/declarations/src/connectors/walletConnect.d.ts +2 -2
- package/dist/declarations/src/constants/abis.d.ts +569 -2
- package/dist/declarations/src/constants/blockExplorers.d.ts +1 -1
- package/dist/declarations/src/constants/index.d.ts +1 -2
- package/dist/declarations/src/errors.d.ts +8 -8
- package/dist/declarations/src/index.d.ts +4 -3
- package/dist/declarations/src/internal.d.ts +2 -0
- package/dist/declarations/src/types/contracts.d.ts +241 -0
- package/dist/declarations/src/types/index.d.ts +31 -9
- package/dist/declarations/src/types/utils.d.ts +103 -0
- package/dist/declarations/src/utils/assertActiveChain.d.ts +3 -0
- package/dist/declarations/src/utils/configureChains.d.ts +3 -5
- package/dist/declarations/src/utils/index.d.ts +2 -0
- package/dist/declarations/src/utils/minimizeContractInterface.d.ts +5 -5
- package/dist/declarations/src/utils/normalizeFunctionName.d.ts +17 -0
- package/dist/declarations/src/utils/parseContractResult.d.ts +4 -4
- package/dist/{getProvider-f1dfc7e3.esm.js → getProvider-24ec6544.esm.js} +49 -50
- package/dist/{getProvider-1b3eeda8.cjs.dev.js → getProvider-ed469b94.cjs.prod.js} +48 -49
- package/dist/{getProvider-ad4ce6a4.cjs.prod.js → getProvider-f6f17fa1.cjs.dev.js} +48 -49
- package/dist/{rpcs-d2cd65f1.cjs.dev.js → rpcs-0d21dfe8.cjs.dev.js} +5 -5
- package/dist/{rpcs-8d636858.esm.js → rpcs-b4aa70b9.esm.js} +6 -6
- package/dist/{rpcs-edec227e.cjs.prod.js → rpcs-c62bf9b0.cjs.prod.js} +5 -5
- package/dist/wagmi-core.cjs.dev.js +1096 -421
- package/dist/wagmi-core.cjs.prod.js +1096 -421
- package/dist/wagmi-core.esm.js +1098 -423
- package/package.json +3 -2
- package/providers/alchemy/dist/wagmi-core-providers-alchemy.cjs.dev.js +2 -2
- package/providers/alchemy/dist/wagmi-core-providers-alchemy.cjs.prod.js +2 -2
- package/providers/alchemy/dist/wagmi-core-providers-alchemy.esm.js +2 -2
- package/providers/infura/dist/wagmi-core-providers-infura.cjs.dev.js +2 -2
- package/providers/infura/dist/wagmi-core-providers-infura.cjs.prod.js +2 -2
- package/providers/infura/dist/wagmi-core-providers-infura.esm.js +2 -2
- package/dist/declarations/src/actions/contracts/deprecatedWriteContract.d.ts +0 -16
- package/dist/declarations/src/actions/transactions/deprecatedSendTransaction.d.ts +0 -12
- package/dist/declarations/src/constants/multicall.d.ts +0 -25
- package/providers/coinbaseNode/dist/wagmi-core-providers-coinbaseNode.cjs.d.ts +0 -11
- package/providers/coinbaseNode/dist/wagmi-core-providers-coinbaseNode.cjs.js +0 -16
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { l as Connector, _ as _classPrivateMethodInitSpec, t as _defineProperty,
|
|
1
|
+
import { l as Connector, _ as _classPrivateMethodInitSpec, t as _defineProperty, v as _classPrivateFieldInitSpec, n as normalizeChainId, g as getClient, u as _classPrivateMethodGet, U as UserRejectedRequestError, x as _classPrivateFieldGet, w as _classPrivateFieldSet, q as SwitchChainError } from '../../../dist/getProvider-24ec6544.esm.js';
|
|
2
2
|
import { providers } from 'ethers';
|
|
3
3
|
import { getAddress, hexValue } from 'ethers/lib/utils';
|
|
4
4
|
import 'zustand/middleware';
|
|
5
5
|
import 'zustand/vanilla';
|
|
6
6
|
import 'eventemitter3';
|
|
7
|
-
import '../../../dist/chains-
|
|
8
|
-
import '../../../dist/rpcs-
|
|
7
|
+
import '../../../dist/chains-2970e5fa.esm.js';
|
|
8
|
+
import '../../../dist/rpcs-b4aa70b9.esm.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Wallets that support chain switching through WalletConnect
|
|
@@ -65,7 +65,7 @@ class WalletConnectConnector extends Connector {
|
|
|
65
65
|
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
66
66
|
|
|
67
67
|
try {
|
|
68
|
-
var _provider$connector
|
|
68
|
+
var _provider$connector, _provider$connector$p;
|
|
69
69
|
|
|
70
70
|
let targetChainId = chainId;
|
|
71
71
|
|
|
@@ -91,7 +91,7 @@ class WalletConnectConnector extends Connector {
|
|
|
91
91
|
const unsupported = this.isChainUnsupported(id); // Not all WalletConnect options support programmatic chain switching
|
|
92
92
|
// Only enable for wallet options that do
|
|
93
93
|
|
|
94
|
-
const walletName = (
|
|
94
|
+
const walletName = ((_provider$connector = provider.connector) === null || _provider$connector === void 0 ? void 0 : (_provider$connector$p = _provider$connector.peerMeta) === null || _provider$connector$p === void 0 ? void 0 : _provider$connector$p.name) ?? '';
|
|
95
95
|
if (switchChainAllowedRegex.test(walletName)) this.switchChain = _classPrivateMethodGet(this, _switchChain, _switchChain2);
|
|
96
96
|
return {
|
|
97
97
|
account,
|
|
@@ -162,7 +162,7 @@ class WalletConnectConnector extends Connector {
|
|
|
162
162
|
const [provider, account] = await Promise.all([this.getProvider({
|
|
163
163
|
chainId
|
|
164
164
|
}), this.getAccount()]);
|
|
165
|
-
return new providers.Web3Provider(provider).getSigner(account);
|
|
165
|
+
return new providers.Web3Provider(provider, chainId).getSigner(account);
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
async isAuthorized() {
|
|
@@ -181,18 +181,16 @@ async function _switchChain2(chainId) {
|
|
|
181
181
|
const id = hexValue(chainId);
|
|
182
182
|
|
|
183
183
|
try {
|
|
184
|
-
var _this$chains$find;
|
|
185
|
-
|
|
186
184
|
await provider.request({
|
|
187
185
|
method: 'wallet_switchEthereumChain',
|
|
188
186
|
params: [{
|
|
189
187
|
chainId: id
|
|
190
188
|
}]
|
|
191
189
|
});
|
|
192
|
-
return
|
|
190
|
+
return this.chains.find(x => x.id === chainId) ?? {
|
|
193
191
|
id: chainId,
|
|
194
|
-
name:
|
|
195
|
-
network:
|
|
192
|
+
name: `Chain ${id}`,
|
|
193
|
+
network: `${id}`,
|
|
196
194
|
rpcUrls: {
|
|
197
195
|
default: ''
|
|
198
196
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as alchemyRpcUrls, p as publicRpcUrls, i as infuraRpcUrls } from './rpcs-
|
|
1
|
+
import { a as alchemyRpcUrls, p as publicRpcUrls, i as infuraRpcUrls } from './rpcs-b4aa70b9.esm.js';
|
|
2
2
|
|
|
3
3
|
const etherscanBlockExplorers = {
|
|
4
4
|
mainnet: {
|
|
@@ -48,6 +48,10 @@ const etherscanBlockExplorers = {
|
|
|
48
48
|
arbitrumRinkeby: {
|
|
49
49
|
name: 'Arbiscan',
|
|
50
50
|
url: 'https://testnet.arbiscan.io'
|
|
51
|
+
},
|
|
52
|
+
arbitrumGoerli: {
|
|
53
|
+
name: 'Arbiscan',
|
|
54
|
+
url: 'https://goerli.arbiscan.io'
|
|
51
55
|
}
|
|
52
56
|
};
|
|
53
57
|
|
|
@@ -57,18 +61,18 @@ const chainId = {
|
|
|
57
61
|
rinkeby: 4,
|
|
58
62
|
goerli: 5,
|
|
59
63
|
kovan: 42,
|
|
60
|
-
sepolia:
|
|
64
|
+
sepolia: 11_155_111,
|
|
61
65
|
optimism: 10,
|
|
62
66
|
optimismKovan: 69,
|
|
63
67
|
optimismGoerli: 420,
|
|
64
68
|
polygon: 137,
|
|
65
|
-
polygonMumbai:
|
|
66
|
-
arbitrum:
|
|
67
|
-
arbitrumRinkeby:
|
|
68
|
-
arbitrumGoerli:
|
|
69
|
-
localhost:
|
|
70
|
-
hardhat:
|
|
71
|
-
foundry:
|
|
69
|
+
polygonMumbai: 80_001,
|
|
70
|
+
arbitrum: 42_161,
|
|
71
|
+
arbitrumRinkeby: 421_611,
|
|
72
|
+
arbitrumGoerli: 421_613,
|
|
73
|
+
localhost: 1_337,
|
|
74
|
+
hardhat: 31_337,
|
|
75
|
+
foundry: 31_337
|
|
72
76
|
};
|
|
73
77
|
const mainnet = {
|
|
74
78
|
id: chainId.mainnet,
|
|
@@ -428,10 +432,12 @@ const arbitrumGoerli = {
|
|
|
428
432
|
public: publicRpcUrls.arbitrumGoerli
|
|
429
433
|
},
|
|
430
434
|
blockExplorers: {
|
|
431
|
-
|
|
435
|
+
arbitrum: {
|
|
432
436
|
name: 'Arbitrum Explorer',
|
|
433
437
|
url: 'https://goerli-rollup-explorer.arbitrum.io'
|
|
434
|
-
}
|
|
438
|
+
},
|
|
439
|
+
etherscan: etherscanBlockExplorers.arbitrumGoerli,
|
|
440
|
+
default: etherscanBlockExplorers.arbitrumGoerli
|
|
435
441
|
},
|
|
436
442
|
multicall: {
|
|
437
443
|
address: '0xca11bde05977b3631167028862be2a173976ca11',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var rpcs = require('./rpcs-
|
|
3
|
+
var rpcs = require('./rpcs-c62bf9b0.cjs.prod.js');
|
|
4
4
|
|
|
5
5
|
const etherscanBlockExplorers = {
|
|
6
6
|
mainnet: {
|
|
@@ -50,6 +50,10 @@ const etherscanBlockExplorers = {
|
|
|
50
50
|
arbitrumRinkeby: {
|
|
51
51
|
name: 'Arbiscan',
|
|
52
52
|
url: 'https://testnet.arbiscan.io'
|
|
53
|
+
},
|
|
54
|
+
arbitrumGoerli: {
|
|
55
|
+
name: 'Arbiscan',
|
|
56
|
+
url: 'https://goerli.arbiscan.io'
|
|
53
57
|
}
|
|
54
58
|
};
|
|
55
59
|
|
|
@@ -59,18 +63,18 @@ const chainId = {
|
|
|
59
63
|
rinkeby: 4,
|
|
60
64
|
goerli: 5,
|
|
61
65
|
kovan: 42,
|
|
62
|
-
sepolia:
|
|
66
|
+
sepolia: 11_155_111,
|
|
63
67
|
optimism: 10,
|
|
64
68
|
optimismKovan: 69,
|
|
65
69
|
optimismGoerli: 420,
|
|
66
70
|
polygon: 137,
|
|
67
|
-
polygonMumbai:
|
|
68
|
-
arbitrum:
|
|
69
|
-
arbitrumRinkeby:
|
|
70
|
-
arbitrumGoerli:
|
|
71
|
-
localhost:
|
|
72
|
-
hardhat:
|
|
73
|
-
foundry:
|
|
71
|
+
polygonMumbai: 80_001,
|
|
72
|
+
arbitrum: 42_161,
|
|
73
|
+
arbitrumRinkeby: 421_611,
|
|
74
|
+
arbitrumGoerli: 421_613,
|
|
75
|
+
localhost: 1_337,
|
|
76
|
+
hardhat: 31_337,
|
|
77
|
+
foundry: 31_337
|
|
74
78
|
};
|
|
75
79
|
const mainnet = {
|
|
76
80
|
id: chainId.mainnet,
|
|
@@ -430,10 +434,12 @@ const arbitrumGoerli = {
|
|
|
430
434
|
public: rpcs.publicRpcUrls.arbitrumGoerli
|
|
431
435
|
},
|
|
432
436
|
blockExplorers: {
|
|
433
|
-
|
|
437
|
+
arbitrum: {
|
|
434
438
|
name: 'Arbitrum Explorer',
|
|
435
439
|
url: 'https://goerli-rollup-explorer.arbitrum.io'
|
|
436
|
-
}
|
|
440
|
+
},
|
|
441
|
+
etherscan: etherscanBlockExplorers.arbitrumGoerli,
|
|
442
|
+
default: etherscanBlockExplorers.arbitrumGoerli
|
|
437
443
|
},
|
|
438
444
|
multicall: {
|
|
439
445
|
address: '0xca11bde05977b3631167028862be2a173976ca11',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var rpcs = require('./rpcs-
|
|
3
|
+
var rpcs = require('./rpcs-0d21dfe8.cjs.dev.js');
|
|
4
4
|
|
|
5
5
|
const etherscanBlockExplorers = {
|
|
6
6
|
mainnet: {
|
|
@@ -50,6 +50,10 @@ const etherscanBlockExplorers = {
|
|
|
50
50
|
arbitrumRinkeby: {
|
|
51
51
|
name: 'Arbiscan',
|
|
52
52
|
url: 'https://testnet.arbiscan.io'
|
|
53
|
+
},
|
|
54
|
+
arbitrumGoerli: {
|
|
55
|
+
name: 'Arbiscan',
|
|
56
|
+
url: 'https://goerli.arbiscan.io'
|
|
53
57
|
}
|
|
54
58
|
};
|
|
55
59
|
|
|
@@ -59,18 +63,18 @@ const chainId = {
|
|
|
59
63
|
rinkeby: 4,
|
|
60
64
|
goerli: 5,
|
|
61
65
|
kovan: 42,
|
|
62
|
-
sepolia:
|
|
66
|
+
sepolia: 11_155_111,
|
|
63
67
|
optimism: 10,
|
|
64
68
|
optimismKovan: 69,
|
|
65
69
|
optimismGoerli: 420,
|
|
66
70
|
polygon: 137,
|
|
67
|
-
polygonMumbai:
|
|
68
|
-
arbitrum:
|
|
69
|
-
arbitrumRinkeby:
|
|
70
|
-
arbitrumGoerli:
|
|
71
|
-
localhost:
|
|
72
|
-
hardhat:
|
|
73
|
-
foundry:
|
|
71
|
+
polygonMumbai: 80_001,
|
|
72
|
+
arbitrum: 42_161,
|
|
73
|
+
arbitrumRinkeby: 421_611,
|
|
74
|
+
arbitrumGoerli: 421_613,
|
|
75
|
+
localhost: 1_337,
|
|
76
|
+
hardhat: 31_337,
|
|
77
|
+
foundry: 31_337
|
|
74
78
|
};
|
|
75
79
|
const mainnet = {
|
|
76
80
|
id: chainId.mainnet,
|
|
@@ -430,10 +434,12 @@ const arbitrumGoerli = {
|
|
|
430
434
|
public: rpcs.publicRpcUrls.arbitrumGoerli
|
|
431
435
|
},
|
|
432
436
|
blockExplorers: {
|
|
433
|
-
|
|
437
|
+
arbitrum: {
|
|
434
438
|
name: 'Arbitrum Explorer',
|
|
435
439
|
url: 'https://goerli-rollup-explorer.arbitrum.io'
|
|
436
|
-
}
|
|
440
|
+
},
|
|
441
|
+
etherscan: etherscanBlockExplorers.arbitrumGoerli,
|
|
442
|
+
default: etherscanBlockExplorers.arbitrumGoerli
|
|
437
443
|
},
|
|
438
444
|
multicall: {
|
|
439
445
|
address: '0xca11bde05977b3631167028862be2a173976ca11',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Address, ResolvedConfig } from 'abitype';
|
|
2
2
|
import { Unit } from '../../types';
|
|
3
3
|
export declare type FetchBalanceArgs = {
|
|
4
4
|
/** Address or ENS name */
|
|
@@ -8,12 +8,12 @@ export declare type FetchBalanceArgs = {
|
|
|
8
8
|
/** Units for formatting output */
|
|
9
9
|
formatUnits?: Unit | number;
|
|
10
10
|
/** ERC-20 address */
|
|
11
|
-
token?:
|
|
11
|
+
token?: Address;
|
|
12
12
|
};
|
|
13
13
|
export declare type FetchBalanceResult = {
|
|
14
|
-
decimals:
|
|
14
|
+
decimals: ResolvedConfig['IntType'];
|
|
15
15
|
formatted: string;
|
|
16
16
|
symbol: string;
|
|
17
|
-
value:
|
|
17
|
+
value: ResolvedConfig['BigIntType'];
|
|
18
18
|
};
|
|
19
19
|
export declare function fetchBalance({ addressOrName, chainId, formatUnits: unit, token, }: FetchBalanceArgs): Promise<FetchBalanceResult>;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import { Signer } from '../../types';
|
|
2
|
+
export declare type FetchSignerArgs = {
|
|
3
|
+
/** Chain ID to use for signer */
|
|
4
|
+
chainId?: number;
|
|
5
|
+
};
|
|
2
6
|
export declare type FetchSignerResult<TSigner extends Signer = Signer> = TSigner | null;
|
|
3
|
-
export declare function fetchSigner<TSigner extends Signer = Signer>(): Promise<FetchSignerResult<TSigner>>;
|
|
7
|
+
export declare function fetchSigner<TSigner extends Signer = Signer>({ chainId, }?: FetchSignerArgs): Promise<FetchSignerResult<TSigner>>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { connect, type ConnectArgs, type ConnectResult } from './connect';
|
|
2
2
|
export { disconnect } from './disconnect';
|
|
3
3
|
export { fetchBalance, type FetchBalanceArgs, type FetchBalanceResult, } from './fetchBalance';
|
|
4
|
-
export { fetchSigner, type FetchSignerResult } from './fetchSigner';
|
|
4
|
+
export { fetchSigner, type FetchSignerArgs, type FetchSignerResult, } from './fetchSigner';
|
|
5
5
|
export { getAccount, type GetAccountResult } from './getAccount';
|
|
6
6
|
export { getNetwork, type GetNetworkResult } from './getNetwork';
|
|
7
7
|
export { signMessage, type SignMessageArgs, type SignMessageResult, } from './signMessage';
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ResolvedConfig } from 'abitype';
|
|
2
2
|
export declare type SignMessageArgs = {
|
|
3
3
|
/** Message to sign with wallet */
|
|
4
|
-
message:
|
|
4
|
+
message: string | Uint8Array;
|
|
5
5
|
};
|
|
6
|
-
declare type
|
|
7
|
-
export declare type SignMessageResult = Signature;
|
|
6
|
+
export declare type SignMessageResult = ResolvedConfig['BytesType'];
|
|
8
7
|
export declare function signMessage(args: SignMessageArgs): Promise<SignMessageResult>;
|
|
9
|
-
export {};
|
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare type SignTypedDataArgs = {
|
|
1
|
+
import { Narrow, TypedData, TypedDataDomain, TypedDataToPrimitiveTypes } from 'abitype';
|
|
2
|
+
export declare type SignTypedDataArgs<TTypedData = unknown> = {
|
|
3
3
|
/** Domain or domain signature for origin or contract */
|
|
4
|
-
domain:
|
|
5
|
-
name?: string;
|
|
6
|
-
version?: string;
|
|
7
|
-
/**
|
|
8
|
-
* Chain permitted for signing
|
|
9
|
-
* If signer is not active on this chain, it will attempt to programmatically switch
|
|
10
|
-
*/
|
|
11
|
-
chainId?: string | number | bigint;
|
|
12
|
-
verifyingContract?: string;
|
|
13
|
-
salt?: BytesLike;
|
|
14
|
-
};
|
|
4
|
+
domain: TypedDataDomain;
|
|
15
5
|
/** Named list of all type definitions */
|
|
16
|
-
types:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
types: Narrow<TTypedData>;
|
|
7
|
+
} & (TTypedData extends TypedData ? TypedDataToPrimitiveTypes<TTypedData> extends infer TSchema ? TSchema[keyof TSchema] extends infer TValue ? {
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
} extends TValue ? {
|
|
10
|
+
/**
|
|
11
|
+
* Data to sign
|
|
12
|
+
*
|
|
13
|
+
* Use a [const assertion](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#const-assertions) on {@link types} for type inference.
|
|
14
|
+
*/
|
|
15
|
+
value: {
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
};
|
|
18
|
+
} : {
|
|
20
19
|
/** Data to sign */
|
|
21
|
-
value:
|
|
22
|
-
};
|
|
20
|
+
value: TValue;
|
|
21
|
+
} : never : never : never);
|
|
23
22
|
export declare type SignTypedDataResult = string;
|
|
24
|
-
export declare function signTypedData({ domain, types, value, }: SignTypedDataArgs): Promise<SignTypedDataResult>;
|
|
23
|
+
export declare function signTypedData<TTypedData extends TypedData>({ domain, types, value, }: SignTypedDataArgs<TTypedData>): Promise<SignTypedDataResult>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare
|
|
1
|
+
import { Signer } from '../../types';
|
|
2
|
+
import { FetchSignerArgs, FetchSignerResult } from './fetchSigner';
|
|
3
|
+
export declare type WatchSignerArgs = FetchSignerArgs;
|
|
4
|
+
export declare type WatchSignerCallback<TSigner extends Signer = Signer> = (data: FetchSignerResult<TSigner>) => void;
|
|
5
|
+
export declare function watchSigner<TSigner extends Signer = Signer>({ chainId }: WatchSignerArgs, callback: WatchSignerCallback<TSigner>): () => void;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Address, ResolvedConfig } from 'abitype';
|
|
2
2
|
import { Unit } from '../../types';
|
|
3
3
|
export declare type FetchTokenArgs = {
|
|
4
4
|
/** Address of ERC-20 token */
|
|
5
|
-
address:
|
|
5
|
+
address: Address;
|
|
6
6
|
/** Chain id to use for provider */
|
|
7
7
|
chainId?: number;
|
|
8
8
|
/** Units for formatting output */
|
|
9
9
|
formatUnits?: Unit | number;
|
|
10
10
|
};
|
|
11
11
|
export declare type FetchTokenResult = {
|
|
12
|
-
address:
|
|
13
|
-
decimals:
|
|
12
|
+
address: Address;
|
|
13
|
+
decimals: ResolvedConfig['IntType'];
|
|
14
14
|
name: string;
|
|
15
15
|
symbol: string;
|
|
16
16
|
totalSupply: {
|
|
17
17
|
formatted: string;
|
|
18
|
-
value:
|
|
18
|
+
value: ResolvedConfig['BigIntType'];
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
21
|
export declare function fetchToken({ address, chainId, formatUnits: units, }: FetchTokenArgs): Promise<FetchTokenResult>;
|
|
@@ -1,10 +1,113 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { Abi, AbiEvent, AbiFunction, AbiParameter, AbiParameterToPrimitiveType, AbiParametersToPrimitiveTypes, Address, ExtractAbiEvent, ExtractAbiEventNames, Narrow, ResolvedConfig } from 'abitype';
|
|
2
|
+
import { Contract as EthersContract, Signer, ethers, providers } from 'ethers';
|
|
3
|
+
import { AbiEventParametersToPrimitiveTypes, AbiItemName, Event, GetOverridesForAbiStateMutability } from '../../types/contracts';
|
|
4
|
+
import { CountOccurrences, IsUnknown, UnionToIntersection } from '../../types/utils';
|
|
5
|
+
export declare type GetContractArgs<TAbi extends Abi | readonly unknown[] = Abi> = {
|
|
6
|
+
/** Contract address */
|
|
7
|
+
address: string;
|
|
8
|
+
/** Contract ABI */
|
|
9
|
+
abi: Narrow<TAbi>;
|
|
7
10
|
/** Signer or provider to attach to contract */
|
|
8
|
-
signerOrProvider?: Signer | providers.Provider
|
|
11
|
+
signerOrProvider?: Signer | providers.Provider;
|
|
9
12
|
};
|
|
10
|
-
export declare
|
|
13
|
+
export declare type GetContractResult<TAbi = unknown> = TAbi extends Abi ? Contract<TAbi> & EthersContract : EthersContract;
|
|
14
|
+
export declare function getContract<TAbi extends Abi | readonly unknown[]>({ address, abi, signerOrProvider, }: GetContractArgs<TAbi>): GetContractResult<TAbi>;
|
|
15
|
+
declare type PropertyKeys = 'address' | 'attach' | 'connect' | 'deployed' | 'interface' | 'resolvedAddress';
|
|
16
|
+
declare type FunctionKeys = 'callStatic' | 'estimateGas' | 'functions' | 'populateTransaction';
|
|
17
|
+
declare type EventKeys = 'emit' | 'filters' | 'listenerCount' | 'listeners' | 'off' | 'on' | 'once' | 'queryFilter' | 'removeAllListeners' | 'removeListener';
|
|
18
|
+
declare type BaseContract<TContract extends Record<keyof Pick<EthersContract, PropertyKeys | FunctionKeys | EventKeys>, unknown>> = Omit<EthersContract, PropertyKeys | FunctionKeys | EventKeys> & TContract;
|
|
19
|
+
declare type InterfaceKeys = 'events' | 'functions';
|
|
20
|
+
declare type BaseInterface<Interface extends Record<keyof Pick<ethers.utils.Interface, InterfaceKeys>, unknown>> = Omit<ethers.utils.Interface, InterfaceKeys> & Interface;
|
|
21
|
+
export declare type Contract<TAbi extends Abi, _Functions = Functions<TAbi>> = _Functions & BaseContract<{
|
|
22
|
+
address: Address;
|
|
23
|
+
resolvedAddress: Promise<Address>;
|
|
24
|
+
attach(addressOrName: Address | string): Contract<TAbi>;
|
|
25
|
+
connect(signerOrProvider: ethers.Signer | ethers.providers.Provider | string): Contract<TAbi>;
|
|
26
|
+
deployed(): Promise<Contract<TAbi>>;
|
|
27
|
+
interface: BaseInterface<{
|
|
28
|
+
events: InterfaceEvents<TAbi>;
|
|
29
|
+
functions: InterfaceFunctions<TAbi>;
|
|
30
|
+
}>;
|
|
31
|
+
callStatic: _Functions;
|
|
32
|
+
estimateGas: Functions<TAbi, {
|
|
33
|
+
ReturnType: ResolvedConfig['BigIntType'];
|
|
34
|
+
}>;
|
|
35
|
+
functions: Functions<TAbi, {
|
|
36
|
+
ReturnTypeAsArray: true;
|
|
37
|
+
}>;
|
|
38
|
+
populateTransaction: Functions<TAbi, {
|
|
39
|
+
ReturnType: ethers.PopulatedTransaction;
|
|
40
|
+
}>;
|
|
41
|
+
emit<TEventName extends ExtractAbiEventNames<TAbi> | ethers.EventFilter>(eventName: TEventName, ...args: AbiEventParametersToPrimitiveTypes<ExtractAbiEvent<TAbi, TEventName extends string ? TEventName : ExtractAbiEventNames<TAbi>>['inputs']> extends infer TArgs extends readonly unknown[] ? TArgs : never): boolean;
|
|
42
|
+
filters: Filters<TAbi>;
|
|
43
|
+
listenerCount(): number;
|
|
44
|
+
listenerCount<TEventName extends ExtractAbiEventNames<TAbi>>(eventName: TEventName): number;
|
|
45
|
+
listenerCount(eventFilter: ethers.EventFilter): number;
|
|
46
|
+
listeners(): Array<(...args: any[]) => void>;
|
|
47
|
+
listeners<TEventName extends ExtractAbiEventNames<TAbi>>(eventName: TEventName): Array<Listener<TAbi, TEventName>>;
|
|
48
|
+
listeners(eventFilter: ethers.EventFilter): Array<Listener<TAbi, ExtractAbiEventNames<TAbi>>>;
|
|
49
|
+
off: EventListener<TAbi>;
|
|
50
|
+
on: EventListener<TAbi>;
|
|
51
|
+
once: EventListener<TAbi>;
|
|
52
|
+
queryFilter<TEventName extends ExtractAbiEventNames<TAbi>>(event: TEventName, fromBlockOrBlockhash?: string | number, toBlock?: string | number): Promise<Array<ethers.Event>>;
|
|
53
|
+
queryFilter(eventFilter: ethers.EventFilter, fromBlockOrBlockhash?: string | number, toBlock?: string | number): Promise<Array<ethers.Event>>;
|
|
54
|
+
removeAllListeners(eventName?: ExtractAbiEventNames<TAbi>): Contract<TAbi>;
|
|
55
|
+
removeAllListeners(eventFilter: ethers.EventFilter): Contract<TAbi>;
|
|
56
|
+
removeListener: EventListener<TAbi>;
|
|
57
|
+
}>;
|
|
58
|
+
declare type Functions<TAbi extends Abi, Options extends {
|
|
59
|
+
ReturnType?: any;
|
|
60
|
+
ReturnTypeAsArray?: boolean;
|
|
61
|
+
} = {
|
|
62
|
+
ReturnTypeAsArray: false;
|
|
63
|
+
}> = UnionToIntersection<{
|
|
64
|
+
[K in keyof TAbi]: TAbi[K] extends infer TAbiFunction extends AbiFunction & {
|
|
65
|
+
type: 'function';
|
|
66
|
+
} ? {
|
|
67
|
+
[K in CountOccurrences<TAbi, {
|
|
68
|
+
name: TAbiFunction['name'];
|
|
69
|
+
}> extends 1 ? AbiItemName<TAbiFunction> : AbiItemName<TAbiFunction, true>]: (...args: [
|
|
70
|
+
...args: TAbiFunction['inputs'] extends infer TInputs extends readonly AbiParameter[] ? AbiParametersToPrimitiveTypes<TInputs> : never,
|
|
71
|
+
overrides?: GetOverridesForAbiStateMutability<TAbiFunction['stateMutability']>
|
|
72
|
+
]) => Promise<IsUnknown<Options['ReturnType']> extends true ? AbiFunctionReturnType<TAbiFunction> extends infer TAbiFunctionReturnType ? Options['ReturnTypeAsArray'] extends true ? [TAbiFunctionReturnType] : TAbiFunctionReturnType : never : Options['ReturnType']>;
|
|
73
|
+
} : never;
|
|
74
|
+
}[number]>;
|
|
75
|
+
declare type AbiFunctionReturnType<TAbiFunction extends AbiFunction & {
|
|
76
|
+
type: 'function';
|
|
77
|
+
}> = ({
|
|
78
|
+
payable: ethers.ContractTransaction;
|
|
79
|
+
nonpayable: ethers.ContractTransaction;
|
|
80
|
+
} & {
|
|
81
|
+
[_ in 'pure' | 'view']: TAbiFunction['outputs']['length'] extends infer TLength ? TLength extends 0 ? void : TLength extends 1 ? AbiParameterToPrimitiveType<TAbiFunction['outputs'][0]> : {
|
|
82
|
+
[Output in TAbiFunction['outputs'][number] as Output['name'] extends '' ? never : Output['name']]: AbiParameterToPrimitiveType<Output>;
|
|
83
|
+
} & AbiParametersToPrimitiveTypes<TAbiFunction['outputs']> : never;
|
|
84
|
+
})[TAbiFunction['stateMutability']];
|
|
85
|
+
declare type InterfaceFunctions<TAbi extends Abi> = UnionToIntersection<{
|
|
86
|
+
[K in keyof TAbi]: TAbi[K] extends infer TAbiFunction extends AbiFunction & {
|
|
87
|
+
type: 'function';
|
|
88
|
+
} ? {
|
|
89
|
+
[K in AbiItemName<TAbiFunction, true>]: ethers.utils.FunctionFragment;
|
|
90
|
+
} : never;
|
|
91
|
+
}[number]>;
|
|
92
|
+
declare type InterfaceEvents<TAbi extends Abi> = UnionToIntersection<{
|
|
93
|
+
[K in keyof TAbi]: TAbi[K] extends infer TAbiEvent extends AbiEvent ? {
|
|
94
|
+
[K in AbiItemName<TAbiEvent, true>]: ethers.utils.EventFragment;
|
|
95
|
+
} : never;
|
|
96
|
+
}[number]>;
|
|
97
|
+
interface EventListener<TAbi extends Abi> {
|
|
98
|
+
<TEventName extends ExtractAbiEventNames<TAbi>>(eventName: TEventName, listener: Listener<TAbi, TEventName>): Contract<TAbi>;
|
|
99
|
+
(eventFilter: ethers.EventFilter, listener: Listener<TAbi, ExtractAbiEventNames<TAbi>>): Contract<TAbi>;
|
|
100
|
+
}
|
|
101
|
+
declare type Listener<TAbi extends Abi, TEventName extends string, TAbiEvent extends AbiEvent = ExtractAbiEvent<TAbi, TEventName>> = AbiEventParametersToPrimitiveTypes<TAbiEvent['inputs']> extends infer TArgs extends readonly unknown[] ? (...args: [...args: TArgs, event: Event<TAbiEvent>]) => void : never;
|
|
102
|
+
declare type Filters<TAbi extends Abi> = UnionToIntersection<{
|
|
103
|
+
[K in keyof TAbi]: TAbi[K] extends infer TAbiEvent extends AbiEvent ? {
|
|
104
|
+
[K in CountOccurrences<TAbi, {
|
|
105
|
+
name: TAbiEvent['name'];
|
|
106
|
+
}> extends 1 ? AbiItemName<TAbiEvent> : AbiItemName<TAbiEvent, true>]: (...args: TAbiEvent['inputs'] extends infer TAbiParameters extends readonly (AbiParameter & {
|
|
107
|
+
indexed?: boolean;
|
|
108
|
+
})[] ? AbiEventParametersToPrimitiveTypes<TAbiParameters, {
|
|
109
|
+
AllowNull: true;
|
|
110
|
+
}> : never) => ethers.EventFilter;
|
|
111
|
+
} : never;
|
|
112
|
+
}[number]>;
|
|
113
|
+
export {};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
export { deprecatedWriteContract, type DeprecatedWriteContractConfig, type DeprecatedWriteContractResult, } from './deprecatedWriteContract';
|
|
2
1
|
export { fetchToken, type FetchTokenArgs, type FetchTokenResult, } from './fetchToken';
|
|
3
2
|
export { prepareWriteContract, type PrepareWriteContractConfig, type PrepareWriteContractResult, } from './prepareWriteContract';
|
|
4
|
-
export { getContract, type GetContractArgs } from './getContract';
|
|
3
|
+
export { getContract, type GetContractArgs, type GetContractResult, } from './getContract';
|
|
4
|
+
export { multicall, type MulticallConfig, type MulticallResult, } from './multicall';
|
|
5
5
|
export { readContract, type ReadContractConfig, type ReadContractResult, } from './readContract';
|
|
6
6
|
export { readContracts, type ReadContractsConfig, type ReadContractsResult, } from './readContracts';
|
|
7
7
|
export { watchContractEvent } from './watchContractEvent';
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
8
|
+
export { watchMulticall, type WatchMulticallConfig, type WatchMulticallCallback, } from './watchMulticall';
|
|
9
|
+
export { watchReadContract, type WatchReadContractConfig, type WatchReadContractCallback, } from './watchReadContract';
|
|
10
|
+
export { watchReadContracts, type WatchReadContractsConfig, type WatchReadContractsCallback, } from './watchReadContracts';
|
|
10
11
|
export { writeContract, type WriteContractArgs, type WriteContractPreparedArgs, type WriteContractResult, type WriteContractUnpreparedArgs, } from './writeContract';
|
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
declare type MulticallContract = {
|
|
5
|
-
addressOrName: ReadContractConfig['addressOrName'];
|
|
6
|
-
args?: ReadContractConfig['args'];
|
|
7
|
-
contractInterface: ReadContractConfig['contractInterface'];
|
|
8
|
-
functionName: ReadContractConfig['functionName'];
|
|
9
|
-
};
|
|
10
|
-
export declare type MulticallConfig = {
|
|
1
|
+
import { Abi } from 'abitype';
|
|
2
|
+
import { ContractsConfig, ContractsResult, GetOverridesForAbiStateMutability } from '../../types/contracts';
|
|
3
|
+
export declare type MulticallConfig<TContracts extends unknown[]> = {
|
|
11
4
|
/** Failures in the multicall will fail silently */
|
|
12
5
|
allowFailure?: boolean;
|
|
13
6
|
/** Chain id to use for provider */
|
|
14
7
|
chainId?: number;
|
|
15
|
-
|
|
8
|
+
/** Contracts to query */
|
|
9
|
+
contracts: readonly [...ContractsConfig<TContracts>];
|
|
16
10
|
/** Call overrides */
|
|
17
|
-
overrides?:
|
|
11
|
+
overrides?: GetOverridesForAbiStateMutability<'pure'> | GetOverridesForAbiStateMutability<'view'>;
|
|
18
12
|
};
|
|
19
|
-
export declare type MulticallResult<
|
|
20
|
-
export declare function multicall<
|
|
21
|
-
|
|
13
|
+
export declare type MulticallResult<TContracts extends unknown[]> = ContractsResult<TContracts>;
|
|
14
|
+
export declare function multicall<TAbi extends Abi | readonly unknown[], TFunctionName extends string, TContracts extends {
|
|
15
|
+
abi: TAbi;
|
|
16
|
+
functionName: TFunctionName;
|
|
17
|
+
}[]>({ allowFailure, chainId, contracts, overrides, }: MulticallConfig<TContracts>): Promise<MulticallResult<TContracts>>;
|
|
@@ -1,23 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { Abi, Address, ExtractAbiFunction } from 'abitype';
|
|
2
|
+
import { PopulatedTransaction } from 'ethers/lib/ethers';
|
|
3
|
+
import { Signer } from '../../types';
|
|
4
|
+
import { DefaultOptions, GetConfig, GetOverridesForAbiStateMutability, Options } from '../../types/contracts';
|
|
5
|
+
export declare type PrepareWriteContractConfig<TAbi = Abi, TFunctionName = string, TSigner extends Signer = Signer, TOptions extends Options = DefaultOptions> = GetConfig<{
|
|
6
|
+
abi: TAbi;
|
|
7
|
+
functionName: TFunctionName;
|
|
8
|
+
/** Chain id to use for provider */
|
|
6
9
|
chainId?: number;
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
/** Overrides */
|
|
11
|
+
overrides?: GetOverridesForAbiStateMutability<[
|
|
12
|
+
TAbi,
|
|
13
|
+
TFunctionName
|
|
14
|
+
] extends [
|
|
15
|
+
infer TAbi_ extends Abi,
|
|
16
|
+
infer TFunctionName_ extends string
|
|
17
|
+
] ? ExtractAbiFunction<TAbi_, TFunctionName_>['stateMutability'] : 'nonpayable' | 'payable'>;
|
|
18
|
+
/** Custom signer */
|
|
12
19
|
signer?: TSigner | null;
|
|
13
|
-
}
|
|
14
|
-
export declare type PrepareWriteContractResult<
|
|
20
|
+
}, 'nonpayable' | 'payable', TOptions>;
|
|
21
|
+
export declare type PrepareWriteContractResult<TAbi = Abi, TFunctionName extends string = string> = {
|
|
22
|
+
abi: TAbi extends Abi ? [ExtractAbiFunction<TAbi, TFunctionName>] : readonly unknown[];
|
|
23
|
+
address: string;
|
|
15
24
|
chainId?: number;
|
|
25
|
+
functionName: TFunctionName;
|
|
26
|
+
mode: 'prepared';
|
|
16
27
|
request: PopulatedTransaction & {
|
|
17
28
|
to: Address;
|
|
18
29
|
gasLimit: NonNullable<PopulatedTransaction['gasLimit']>;
|
|
19
30
|
};
|
|
20
|
-
mode: 'prepared';
|
|
21
31
|
};
|
|
22
32
|
/**
|
|
23
33
|
* @description Prepares the parameters required for a contract write transaction.
|
|
@@ -28,10 +38,10 @@ export declare type PrepareWriteContractResult<TSigner extends Signer = Signer>
|
|
|
28
38
|
* import { prepareWriteContract, writeContract } from '@wagmi/core'
|
|
29
39
|
*
|
|
30
40
|
* const config = await prepareWriteContract({
|
|
31
|
-
*
|
|
32
|
-
*
|
|
41
|
+
* address: '0x...',
|
|
42
|
+
* abi: wagmiAbi,
|
|
33
43
|
* functionName: 'mint',
|
|
34
44
|
* })
|
|
35
45
|
* const result = await writeContract(config)
|
|
36
46
|
*/
|
|
37
|
-
export declare function prepareWriteContract<
|
|
47
|
+
export declare function prepareWriteContract<TAbi extends Abi | readonly unknown[], TFunctionName extends string, TSigner extends Signer = Signer>({ abi, address, args, chainId, functionName, overrides, signer: signer_, }: PrepareWriteContractConfig<TAbi, TFunctionName, TSigner>): Promise<PrepareWriteContractResult<TAbi, TFunctionName>>;
|