@wagmi/core 0.4.0-test.2 → 0.4.2
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 +9 -7
- package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.prod.js +9 -7
- package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.esm.js +9 -7
- package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.cjs.dev.js +7 -5
- package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.cjs.prod.js +7 -5
- package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.esm.js +7 -5
- package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.dev.js +12 -8
- package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.prod.js +12 -8
- package/connectors/mock/dist/wagmi-core-connectors-mock.esm.js +7 -7
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.dev.js +19 -18
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.prod.js +19 -18
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.esm.js +19 -18
- package/dist/base-2d484f6c.cjs.prod.js +329 -0
- package/dist/base-e66f9622.esm.js +303 -0
- package/dist/base-e71ae4b2.cjs.dev.js +329 -0
- package/dist/{chains-7e369752.cjs.dev.js → chains-865492ea.cjs.prod.js} +79 -16
- package/dist/{chains-fa406563.esm.js → chains-c389721d.esm.js} +79 -16
- package/dist/{chains-d045862c.cjs.prod.js → chains-d970ee8d.cjs.dev.js} +79 -16
- package/dist/{client-42cf11b7.cjs.dev.js → client-1feb9121.cjs.prod.js} +29 -46
- package/dist/{client-ed3aaa6a.cjs.prod.js → client-53f2119c.cjs.dev.js} +29 -46
- package/dist/{client-60ee0298.esm.js → client-ffba0e25.esm.js} +29 -46
- package/dist/declarations/src/actions/accounts/getAccount.d.ts +31 -2
- package/dist/declarations/src/actions/accounts/getNetwork.d.ts +1 -2
- package/dist/declarations/src/actions/accounts/signTypedData.d.ts +17 -15
- package/dist/declarations/src/actions/accounts/watchAccount.d.ts +9 -1
- package/dist/declarations/src/actions/accounts/watchNetwork.d.ts +8 -1
- package/dist/declarations/src/actions/contracts/index.d.ts +5 -3
- package/dist/declarations/src/actions/contracts/multicall.d.ts +21 -0
- package/dist/declarations/src/actions/contracts/readContract.d.ts +7 -4
- package/dist/declarations/src/actions/contracts/readContracts.d.ts +19 -0
- package/dist/declarations/src/actions/contracts/watchContractEvent.d.ts +3 -3
- package/dist/declarations/src/actions/contracts/watchReadContract.d.ts +2 -3
- package/dist/declarations/src/actions/contracts/watchReadContracts.d.ts +6 -0
- package/dist/declarations/src/actions/contracts/writeContract.d.ts +10 -4
- package/dist/declarations/src/actions/index.d.ts +1 -1
- package/dist/declarations/src/actions/transactions/sendTransaction.d.ts +6 -1
- package/dist/declarations/src/client.d.ts +6 -11
- package/dist/declarations/src/connectors/base.d.ts +4 -3
- package/dist/declarations/src/connectors/mock/connector.d.ts +2 -9
- package/dist/declarations/src/connectors/mock/provider.d.ts +2 -1
- package/dist/declarations/src/connectors/walletConnect.d.ts +5 -4
- package/dist/declarations/src/constants/index.d.ts +2 -1
- package/dist/declarations/src/constants/multicall.d.ts +25 -0
- package/dist/declarations/src/constants/rpcs.d.ts +3 -1
- package/dist/declarations/src/errors.d.ts +27 -5
- package/dist/declarations/src/index.d.ts +5 -5
- package/dist/declarations/src/providers/alchemy.d.ts +2 -2
- package/dist/declarations/src/providers/infura.d.ts +2 -2
- package/dist/declarations/src/providers/jsonRpc.d.ts +2 -2
- package/dist/declarations/src/providers/public.d.ts +2 -2
- package/dist/declarations/src/types/index.d.ts +17 -5
- package/dist/declarations/src/utils/configureChains.d.ts +10 -4
- package/dist/declarations/src/utils/normalizeChainId.d.ts +1 -1
- package/dist/{rpcs-9c4eb960.cjs.dev.js → rpcs-1fd0a12f.cjs.prod.js} +14 -0
- package/dist/{rpcs-7cfbd91c.esm.js → rpcs-b73a8f60.esm.js} +14 -1
- package/dist/{rpcs-b3c52116.cjs.prod.js → rpcs-f1d24f0e.cjs.dev.js} +14 -0
- package/dist/wagmi-core.cjs.dev.js +611 -234
- package/dist/wagmi-core.cjs.prod.js +611 -234
- package/dist/wagmi-core.esm.js +608 -242
- package/package.json +15 -3
- package/providers/alchemy/dist/wagmi-core-providers-alchemy.cjs.dev.js +1 -1
- package/providers/alchemy/dist/wagmi-core-providers-alchemy.cjs.prod.js +1 -1
- package/providers/alchemy/dist/wagmi-core-providers-alchemy.esm.js +1 -1
- package/providers/infura/dist/wagmi-core-providers-infura.cjs.dev.js +1 -1
- package/providers/infura/dist/wagmi-core-providers-infura.cjs.prod.js +1 -1
- package/providers/infura/dist/wagmi-core-providers-infura.esm.js +1 -1
- package/providers/jsonRpc/dist/wagmi-core-providers-jsonRpc.cjs.dev.js +3 -1
- package/providers/jsonRpc/dist/wagmi-core-providers-jsonRpc.cjs.prod.js +3 -1
- package/providers/jsonRpc/dist/wagmi-core-providers-jsonRpc.esm.js +3 -1
- package/connectors/injected/dist/wagmi-core-connectors-injected.cjs.d.ts +0 -1
- package/connectors/injected/dist/wagmi-core-connectors-injected.cjs.dev.js +0 -200
- package/connectors/injected/dist/wagmi-core-connectors-injected.cjs.js +0 -7
- package/connectors/injected/dist/wagmi-core-connectors-injected.cjs.prod.js +0 -200
- package/connectors/injected/dist/wagmi-core-connectors-injected.esm.js +0 -196
- package/connectors/walletLink/dist/wagmi-core-connectors-walletLink.cjs.d.ts +0 -11
- package/connectors/walletLink/dist/wagmi-core-connectors-walletLink.cjs.js +0 -16
- package/dist/base-7f682723.cjs.prod.js +0 -623
- package/dist/base-ae774f26.cjs.dev.js +0 -623
- package/dist/base-c546f171.esm.js +0 -603
- package/dist/declarations/src/utils/eventemitter.d.ts +0 -135
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { providers, getDefaultProvider } from 'ethers';
|
|
1
|
+
import { d as Connector, _ as _classPrivateMethodInitSpec, i as _defineProperty, j as _classPrivateFieldInitSpec, n as normalizeChainId, k as _classPrivateFieldGet, l as _classPrivateFieldSet, b as ConnectorNotFoundError, m as _classPrivateMethodGet, U as UserRejectedRequestError, R as ResourceUnavailableError, e as ChainNotConfiguredError, A as AddChainError, h as SwitchChainError } from './base-e66f9622.esm.js';
|
|
3
2
|
import create from 'zustand/vanilla';
|
|
4
3
|
import { subscribeWithSelector, persist } from 'zustand/middleware';
|
|
4
|
+
import { providers } from 'ethers';
|
|
5
5
|
import { getAddress, hexValue } from 'ethers/lib/utils';
|
|
6
|
-
import { a as allChains } from './chains-fa406563.esm.js';
|
|
7
6
|
|
|
8
7
|
function getInjectedName(ethereum) {
|
|
9
8
|
var _ethereum$providers, _getName;
|
|
@@ -17,6 +16,7 @@ function getInjectedName(ethereum) {
|
|
|
17
16
|
if (provider.isFrame) return 'Frame';
|
|
18
17
|
if (provider.isOpera) return 'Opera';
|
|
19
18
|
if (provider.isTally) return 'Tally';
|
|
19
|
+
if (provider.isTokenPocket) return 'TokenPocket';
|
|
20
20
|
if (provider.isTokenary) return 'Tokenary';
|
|
21
21
|
if (provider.isTrust) return 'Trust Wallet';
|
|
22
22
|
if (provider.isMetaMask) return 'MetaMask';
|
|
@@ -50,14 +50,6 @@ function getInjectedName(ethereum) {
|
|
|
50
50
|
return (_getName = getName(ethereum)) !== null && _getName !== void 0 ? _getName : 'Injected';
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
const cache = new Set();
|
|
54
|
-
function warn(message, id) {
|
|
55
|
-
if (!cache.has(id !== null && id !== void 0 ? id : message)) {
|
|
56
|
-
console.warn(message);
|
|
57
|
-
cache.add(message);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
53
|
const shimKey = 'injected.shimDisconnect';
|
|
62
54
|
|
|
63
55
|
var _provider = /*#__PURE__*/new WeakMap();
|
|
@@ -254,7 +246,7 @@ class InjectedConnector extends Connector {
|
|
|
254
246
|
const id = hexValue(chainId);
|
|
255
247
|
|
|
256
248
|
try {
|
|
257
|
-
var
|
|
249
|
+
var _this$chains$find;
|
|
258
250
|
|
|
259
251
|
await provider.request({
|
|
260
252
|
method: 'wallet_switchEthereumChain',
|
|
@@ -262,8 +254,7 @@ class InjectedConnector extends Connector {
|
|
|
262
254
|
chainId: id
|
|
263
255
|
}]
|
|
264
256
|
});
|
|
265
|
-
|
|
266
|
-
return (_chains$find = chains.find(x => x.id === chainId)) !== null && _chains$find !== void 0 ? _chains$find : {
|
|
257
|
+
return (_this$chains$find = this.chains.find(x => x.id === chainId)) !== null && _this$chains$find !== void 0 ? _this$chains$find : {
|
|
267
258
|
id: chainId,
|
|
268
259
|
name: "Chain ".concat(id),
|
|
269
260
|
network: "".concat(id),
|
|
@@ -272,18 +263,24 @@ class InjectedConnector extends Connector {
|
|
|
272
263
|
}
|
|
273
264
|
};
|
|
274
265
|
} catch (error) {
|
|
266
|
+
var _data, _data$originalError;
|
|
267
|
+
|
|
275
268
|
const chain = this.chains.find(x => x.id === chainId);
|
|
276
269
|
if (!chain) throw new ChainNotConfiguredError(); // Indicates chain is not added to provider
|
|
277
270
|
|
|
278
|
-
if (error.code === 4902
|
|
271
|
+
if (error.code === 4902 || // Unwrapping for MetaMask Mobile
|
|
272
|
+
// https://github.com/MetaMask/metamask-mobile/issues/2944#issuecomment-976988719
|
|
273
|
+
(error === null || error === void 0 ? void 0 : (_data = error.data) === null || _data === void 0 ? void 0 : (_data$originalError = _data.originalError) === null || _data$originalError === void 0 ? void 0 : _data$originalError.code) === 4902) {
|
|
279
274
|
try {
|
|
275
|
+
var _chain$rpcUrls$public;
|
|
276
|
+
|
|
280
277
|
await provider.request({
|
|
281
278
|
method: 'wallet_addEthereumChain',
|
|
282
279
|
params: [{
|
|
283
280
|
chainId: id,
|
|
284
281
|
chainName: chain.name,
|
|
285
282
|
nativeCurrency: chain.nativeCurrency,
|
|
286
|
-
rpcUrls: [chain.rpcUrls.default],
|
|
283
|
+
rpcUrls: [(_chain$rpcUrls$public = chain.rpcUrls.public) !== null && _chain$rpcUrls$public !== void 0 ? _chain$rpcUrls$public : chain.rpcUrls.default],
|
|
287
284
|
blockExplorerUrls: this.getBlockExplorerUrls(chain)
|
|
288
285
|
}]
|
|
289
286
|
});
|
|
@@ -374,22 +371,16 @@ var _lastUsedConnector = /*#__PURE__*/new WeakMap();
|
|
|
374
371
|
var _addEffects = /*#__PURE__*/new WeakSet();
|
|
375
372
|
|
|
376
373
|
class Client {
|
|
377
|
-
constructor() {
|
|
374
|
+
constructor(_ref) {
|
|
378
375
|
let {
|
|
379
376
|
autoConnect = false,
|
|
380
377
|
connectors = [new InjectedConnector()],
|
|
381
|
-
provider: _provider
|
|
382
|
-
try {
|
|
383
|
-
return getDefaultProvider(config.chainId);
|
|
384
|
-
} catch {
|
|
385
|
-
return getDefaultProvider();
|
|
386
|
-
}
|
|
387
|
-
},
|
|
378
|
+
provider: _provider,
|
|
388
379
|
storage = createStorage({
|
|
389
380
|
storage: typeof window !== 'undefined' ? window.localStorage : noopStorage
|
|
390
381
|
}),
|
|
391
382
|
webSocketProvider: _webSocketProvider
|
|
392
|
-
} =
|
|
383
|
+
} = _ref;
|
|
393
384
|
|
|
394
385
|
_classPrivateMethodInitSpec(this, _addEffects);
|
|
395
386
|
|
|
@@ -424,24 +415,18 @@ class Client {
|
|
|
424
415
|
status = data !== null && data !== void 0 && data.account ? 'reconnecting' : 'connecting';
|
|
425
416
|
_chainId = data === null || data === void 0 ? void 0 : (_data$chain = data.chain) === null || _data$chain === void 0 ? void 0 : _data$chain.id; // eslint-disable-next-line no-empty
|
|
426
417
|
} catch (_error) {}
|
|
427
|
-
} //
|
|
418
|
+
} // Create store
|
|
428
419
|
|
|
429
420
|
|
|
430
|
-
const connectors_ = typeof connectors === 'function' ? connectors({
|
|
431
|
-
chainId: _chainId
|
|
432
|
-
}) : connectors;
|
|
433
|
-
const provider_ = typeof _provider === 'function' ? _provider({
|
|
434
|
-
chainId: _chainId
|
|
435
|
-
}) : _provider;
|
|
436
|
-
const webSocketProvider_ = typeof _webSocketProvider === 'function' ? _webSocketProvider({
|
|
437
|
-
chainId: _chainId
|
|
438
|
-
}) : _webSocketProvider; // Create store
|
|
439
|
-
|
|
440
421
|
this.store = create(subscribeWithSelector(persist(() => ({
|
|
441
|
-
connectors:
|
|
442
|
-
provider:
|
|
422
|
+
connectors: typeof connectors === 'function' ? connectors() : connectors,
|
|
423
|
+
provider: typeof _provider === 'function' ? _provider({
|
|
424
|
+
chainId: _chainId
|
|
425
|
+
}) : _provider,
|
|
443
426
|
status,
|
|
444
|
-
webSocketProvider:
|
|
427
|
+
webSocketProvider: typeof _webSocketProvider === 'function' ? _webSocketProvider({
|
|
428
|
+
chainId: _chainId
|
|
429
|
+
}) : _webSocketProvider
|
|
445
430
|
}), {
|
|
446
431
|
name: storeKey,
|
|
447
432
|
getStorage: () => storage,
|
|
@@ -522,7 +507,6 @@ class Client {
|
|
|
522
507
|
|
|
523
508
|
clearState() {
|
|
524
509
|
this.setState(x => ({ ...x,
|
|
525
|
-
chains: undefined,
|
|
526
510
|
connector: undefined,
|
|
527
511
|
data: undefined,
|
|
528
512
|
error: undefined,
|
|
@@ -605,10 +589,10 @@ function _addEffects2() {
|
|
|
605
589
|
}));
|
|
606
590
|
};
|
|
607
591
|
|
|
608
|
-
this.store.subscribe(
|
|
592
|
+
this.store.subscribe(_ref2 => {
|
|
609
593
|
let {
|
|
610
594
|
connector
|
|
611
|
-
} =
|
|
595
|
+
} = _ref2;
|
|
612
596
|
return connector;
|
|
613
597
|
}, (connector, prevConnector) => {
|
|
614
598
|
var _prevConnector$off, _prevConnector$off2, _prevConnector$off3, _connector$on, _connector$on2, _connector$on3;
|
|
@@ -627,12 +611,12 @@ function _addEffects2() {
|
|
|
627
611
|
} = this.config;
|
|
628
612
|
const subscribeProvider = typeof provider === 'function';
|
|
629
613
|
const subscribeWebSocketProvider = typeof webSocketProvider === 'function';
|
|
630
|
-
if (subscribeProvider || subscribeWebSocketProvider) this.store.subscribe(
|
|
614
|
+
if (subscribeProvider || subscribeWebSocketProvider) this.store.subscribe(_ref3 => {
|
|
631
615
|
var _data$chain2;
|
|
632
616
|
|
|
633
617
|
let {
|
|
634
618
|
data
|
|
635
|
-
} =
|
|
619
|
+
} = _ref3;
|
|
636
620
|
return data === null || data === void 0 ? void 0 : (_data$chain2 = data.chain) === null || _data$chain2 === void 0 ? void 0 : _data$chain2.id;
|
|
637
621
|
}, chainId => {
|
|
638
622
|
this.setState(x => ({ ...x,
|
|
@@ -654,8 +638,7 @@ function createClient(config) {
|
|
|
654
638
|
}
|
|
655
639
|
function getClient() {
|
|
656
640
|
if (!client) {
|
|
657
|
-
|
|
658
|
-
return new Client();
|
|
641
|
+
throw new Error('No wagmi client found. Ensure you have set up a client: https://wagmi.sh/docs/client');
|
|
659
642
|
}
|
|
660
643
|
|
|
661
644
|
return client;
|
|
@@ -1,7 +1,36 @@
|
|
|
1
1
|
import { Client, Data } from '../../client';
|
|
2
2
|
import { Provider } from '../../types';
|
|
3
3
|
export declare type GetAccountResult<TProvider extends Provider = Provider> = {
|
|
4
|
-
address
|
|
5
|
-
connector
|
|
4
|
+
address: NonNullable<Data<TProvider>['account']>;
|
|
5
|
+
connector: NonNullable<Client<TProvider>['connector']>;
|
|
6
|
+
isConnected: true;
|
|
7
|
+
isConnecting: false;
|
|
8
|
+
isDisconnected: false;
|
|
9
|
+
isReconnecting: false;
|
|
10
|
+
status: 'connected';
|
|
11
|
+
} | {
|
|
12
|
+
address: Data<TProvider>['account'];
|
|
13
|
+
connector: Client<TProvider>['connector'];
|
|
14
|
+
isConnected: boolean;
|
|
15
|
+
isConnecting: false;
|
|
16
|
+
isDisconnected: false;
|
|
17
|
+
isReconnecting: true;
|
|
18
|
+
status: 'reconnecting';
|
|
19
|
+
} | {
|
|
20
|
+
address: undefined;
|
|
21
|
+
connector: undefined;
|
|
22
|
+
isConnected: false;
|
|
23
|
+
isReconnecting: false;
|
|
24
|
+
isConnecting: true;
|
|
25
|
+
isDisconnected: false;
|
|
26
|
+
status: 'connecting';
|
|
27
|
+
} | {
|
|
28
|
+
address: undefined;
|
|
29
|
+
connector: undefined;
|
|
30
|
+
isConnected: false;
|
|
31
|
+
isReconnecting: false;
|
|
32
|
+
isConnecting: false;
|
|
33
|
+
isDisconnected: true;
|
|
34
|
+
status: 'disconnected';
|
|
6
35
|
};
|
|
7
36
|
export declare function getAccount<TProvider extends Provider>(): GetAccountResult<TProvider>;
|
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface TypedDataDomain {
|
|
3
|
-
name?: string;
|
|
4
|
-
version?: string;
|
|
5
|
-
chainId?: BigNumberish;
|
|
6
|
-
verifyingContract?: string;
|
|
7
|
-
salt?: BytesLike;
|
|
8
|
-
}
|
|
9
|
-
export interface TypedDataField {
|
|
10
|
-
name: string;
|
|
11
|
-
type: string;
|
|
12
|
-
}
|
|
1
|
+
import { BytesLike } from 'ethers';
|
|
13
2
|
export declare type SignTypedDataArgs = {
|
|
14
3
|
/** Domain or domain signature for origin or contract */
|
|
15
|
-
domain:
|
|
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
|
+
};
|
|
16
15
|
/** Named list of all type definitions */
|
|
17
|
-
types: Record<string, Array<
|
|
16
|
+
types: Record<string, Array<{
|
|
17
|
+
name: string;
|
|
18
|
+
type: string;
|
|
19
|
+
}>>;
|
|
18
20
|
/** Data to sign */
|
|
19
21
|
value: Record<string, any>;
|
|
20
22
|
};
|
|
21
23
|
export declare type SignTypedDataResult = string;
|
|
22
|
-
export declare function signTypedData(
|
|
24
|
+
export declare function signTypedData({ domain, types, value, }: SignTypedDataArgs): Promise<SignTypedDataResult>;
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
+
import { Connector } from '../../connectors';
|
|
1
2
|
import { Provider } from '../../types';
|
|
2
3
|
import { GetAccountResult } from './getAccount';
|
|
3
4
|
export declare type WatchAccountCallback<TProvider extends Provider = Provider> = (data: GetAccountResult<TProvider>) => void;
|
|
4
|
-
export declare
|
|
5
|
+
export declare type WatchAccountConfig = {
|
|
6
|
+
selector?({ address, connector, status, }: {
|
|
7
|
+
address?: string;
|
|
8
|
+
connector?: Connector;
|
|
9
|
+
status: GetAccountResult['status'];
|
|
10
|
+
}): any;
|
|
11
|
+
};
|
|
12
|
+
export declare function watchAccount<TProvider extends Provider>(callback: WatchAccountCallback<TProvider>, { selector }?: WatchAccountConfig): () => void;
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import { Chain } from '../../types';
|
|
1
2
|
import { GetNetworkResult } from './getNetwork';
|
|
2
3
|
export declare type WatchNetworkCallback = (data: GetNetworkResult) => void;
|
|
3
|
-
export declare
|
|
4
|
+
export declare type WatchNetworkConfig = {
|
|
5
|
+
selector?({ chainId, chains }: {
|
|
6
|
+
chainId?: number;
|
|
7
|
+
chains?: Chain[];
|
|
8
|
+
}): any;
|
|
9
|
+
};
|
|
10
|
+
export declare function watchNetwork(callback: WatchNetworkCallback, { selector }?: WatchNetworkConfig): () => void;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { getContract, type GetContractArgs } from './getContract';
|
|
2
|
-
export { readContract, type
|
|
2
|
+
export { readContract, type ReadContractConfig, type ReadContractResult, } from './readContract';
|
|
3
|
+
export { readContracts, type ReadContractsConfig, type ReadContractsResult, } from './readContracts';
|
|
3
4
|
export { watchContractEvent } from './watchContractEvent';
|
|
4
|
-
export { watchReadContract, type
|
|
5
|
-
export {
|
|
5
|
+
export { watchReadContract, type WatchReadContractConfig, type WatchReadContractResult, } from './watchReadContract';
|
|
6
|
+
export { watchReadContracts, type WatchReadContractsConfig, type WatchReadContractsResult, } from './watchReadContracts';
|
|
7
|
+
export { writeContract, type WriteContractConfig, type WriteContractResult, } from './writeContract';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CallOverrides } from 'ethers/lib/ethers';
|
|
2
|
+
import { Result } from 'ethers/lib/utils';
|
|
3
|
+
import { ReadContractConfig } from './readContract';
|
|
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 = {
|
|
11
|
+
/** Failures in the multicall will fail silently */
|
|
12
|
+
allowFailure?: boolean;
|
|
13
|
+
/** Chain id to use for provider */
|
|
14
|
+
chainId?: number;
|
|
15
|
+
contracts: MulticallContract[];
|
|
16
|
+
/** Call overrides */
|
|
17
|
+
overrides?: CallOverrides;
|
|
18
|
+
};
|
|
19
|
+
export declare type MulticallResult<Data extends any[] = Result[]> = Data;
|
|
20
|
+
export declare function multicall<Data extends any[] = Result[]>({ allowFailure, chainId, contracts, overrides, }: MulticallConfig): Promise<MulticallResult<Data>>;
|
|
21
|
+
export {};
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import { CallOverrides, Contract
|
|
1
|
+
import { CallOverrides, Contract } from 'ethers/lib/ethers';
|
|
2
2
|
import { Result } from 'ethers/lib/utils';
|
|
3
3
|
import { GetContractArgs } from './getContract';
|
|
4
|
-
export declare type ReadContractArgs = Pick<GetContractArgs, 'addressOrName' | 'contractInterface'>;
|
|
5
4
|
export declare type ReadContractConfig = {
|
|
5
|
+
addressOrName: GetContractArgs['addressOrName'];
|
|
6
6
|
/** Arguments to pass contract method */
|
|
7
7
|
args?: any | any[];
|
|
8
8
|
/** Chain id to use for provider */
|
|
9
9
|
chainId?: number;
|
|
10
|
+
contractInterface: GetContractArgs['contractInterface'];
|
|
11
|
+
/** Function to invoke on the contract */
|
|
12
|
+
functionName: string;
|
|
10
13
|
/** Call overrides */
|
|
11
14
|
overrides?: CallOverrides;
|
|
12
15
|
};
|
|
13
|
-
export declare type ReadContractResult = Result;
|
|
14
|
-
export declare function readContract<
|
|
16
|
+
export declare type ReadContractResult<Data = Result> = Data;
|
|
17
|
+
export declare function readContract<TContract extends Contract = Contract, Data = Result>({ addressOrName, args, chainId, contractInterface, functionName, overrides, }: ReadContractConfig): Promise<ReadContractResult<Data>>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CallOverrides } from 'ethers/lib/ethers';
|
|
2
|
+
import { Result } from 'ethers/lib/utils';
|
|
3
|
+
import { ReadContractConfig } from './readContract';
|
|
4
|
+
export declare type ReadContractsContract = {
|
|
5
|
+
addressOrName: ReadContractConfig['addressOrName'];
|
|
6
|
+
args?: ReadContractConfig['args'];
|
|
7
|
+
chainId?: ReadContractConfig['chainId'];
|
|
8
|
+
contractInterface: ReadContractConfig['contractInterface'];
|
|
9
|
+
functionName: ReadContractConfig['functionName'];
|
|
10
|
+
};
|
|
11
|
+
export declare type ReadContractsConfig = {
|
|
12
|
+
/** Failures will fail silently */
|
|
13
|
+
allowFailure?: boolean;
|
|
14
|
+
contracts: ReadContractsContract[];
|
|
15
|
+
/** Call overrides */
|
|
16
|
+
overrides?: CallOverrides;
|
|
17
|
+
};
|
|
18
|
+
export declare type ReadContractsResult<Data extends any[] = Result[]> = Data;
|
|
19
|
+
export declare function readContracts<Data extends any[] = Result[]>({ allowFailure, contracts, overrides, }: ReadContractsConfig): Promise<ReadContractsResult<Data>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Contract
|
|
1
|
+
import { Contract } from 'ethers/lib/ethers';
|
|
2
2
|
import { GetContractArgs } from './getContract';
|
|
3
3
|
declare type Config = {
|
|
4
4
|
/** Chain id to use for provider */
|
|
@@ -6,9 +6,9 @@ declare type Config = {
|
|
|
6
6
|
/** Receive only a single event */
|
|
7
7
|
once?: boolean;
|
|
8
8
|
};
|
|
9
|
-
export declare function watchContractEvent<
|
|
9
|
+
export declare function watchContractEvent<TContract extends Contract = Contract>(
|
|
10
10
|
/** Contract configuration */
|
|
11
11
|
contractArgs: GetContractArgs,
|
|
12
12
|
/** Event name to listen to */
|
|
13
|
-
eventName: Parameters<
|
|
13
|
+
eventName: Parameters<TContract['on']>[0], callback: Parameters<TContract['on']>[1], { chainId, once }?: Config): () => void;
|
|
14
14
|
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare type WatchReadContractArgs = ReadContractArgs;
|
|
1
|
+
import { ReadContractConfig, ReadContractResult } from './readContract';
|
|
3
2
|
export declare type WatchReadContractConfig = ReadContractConfig & {
|
|
4
3
|
listenToBlock?: boolean;
|
|
5
4
|
};
|
|
6
5
|
export declare type WatchReadContractResult = (result: ReadContractResult) => void;
|
|
7
|
-
export declare function watchReadContract(
|
|
6
|
+
export declare function watchReadContract(config: WatchReadContractConfig, callback: WatchReadContractResult): () => void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ReadContractsConfig, ReadContractsResult } from './readContracts';
|
|
2
|
+
export declare type WatchReadContractsConfig = ReadContractsConfig & {
|
|
3
|
+
listenToBlock?: boolean;
|
|
4
|
+
};
|
|
5
|
+
export declare type WatchReadContractsResult = (result: ReadContractsResult) => void;
|
|
6
|
+
export declare function watchReadContracts(config: WatchReadContractsConfig, callback: WatchReadContractsResult): () => void;
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import { CallOverrides, Contract
|
|
1
|
+
import { CallOverrides, Contract, providers } from 'ethers';
|
|
2
2
|
import { GetContractArgs } from './getContract';
|
|
3
|
-
export declare type
|
|
4
|
-
|
|
3
|
+
export declare type WriteContractConfig = GetContractArgs & {
|
|
4
|
+
/**
|
|
5
|
+
* Chain id to use for write
|
|
6
|
+
* If signer is not active on this chain, it will attempt to programmatically switch
|
|
7
|
+
*/
|
|
8
|
+
chainId?: number;
|
|
9
|
+
/** Method to call on contract */
|
|
10
|
+
functionName: string;
|
|
5
11
|
/** Arguments to pass contract method */
|
|
6
12
|
args?: any | any[];
|
|
7
13
|
overrides?: CallOverrides;
|
|
8
14
|
};
|
|
9
15
|
export declare type WriteContractResult = providers.TransactionResponse;
|
|
10
|
-
export declare function writeContract<
|
|
16
|
+
export declare function writeContract<TContract extends Contract = Contract>({ addressOrName, args, chainId, contractInterface, functionName, overrides, signerOrProvider, }: WriteContractConfig): Promise<WriteContractResult>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { connect, disconnect, fetchBalance, fetchSigner, getAccount, getNetwork, signMessage, signTypedData, switchNetwork, watchAccount, watchNetwork, watchSigner, type ConnectArgs, type ConnectResult, type FetchBalanceArgs, type FetchBalanceResult, type FetchSignerResult, type GetAccountResult, type GetNetworkResult, type SignMessageArgs, type SignMessageResult, type SignTypedDataArgs, type SignTypedDataResult, type SwitchNetworkArgs, type SwitchNetworkResult, type WatchAccountCallback, type WatchNetworkCallback, type WatchSignerCallback, } from './accounts';
|
|
2
|
-
export { getContract, readContract, watchContractEvent, watchReadContract, writeContract, type GetContractArgs, type
|
|
2
|
+
export { getContract, readContract, readContracts, watchContractEvent, watchReadContract, watchReadContracts, writeContract, type GetContractArgs, type ReadContractConfig, type ReadContractResult, type ReadContractsConfig, type ReadContractsResult, type WatchReadContractConfig, type WatchReadContractResult, type WatchReadContractsConfig, type WatchReadContractsResult, type WriteContractConfig, type WriteContractResult, } from './contracts';
|
|
3
3
|
export { fetchEnsAddress, fetchEnsAvatar, fetchEnsName, fetchEnsResolver, type FetchEnsAddressArgs, type FetchEnsAddressResult, type FetchEnsAvatarArgs, type FetchEnsAvatarResult, type FetchEnsNameArgs, type FetchEnsNameResult, type FetchEnsResolverArgs, type FetchEnsResolverResult, } from './ens';
|
|
4
4
|
export { fetchBlockNumber, fetchFeeData, watchBlockNumber, type FetchBlockNumberArgs, type FetchBlockNumberResult, type FetchFeeDataArgs, type FetchFeeDataResult, type WatchBlockNumberArgs, type WatchBlockNumberCallback, } from './network-status';
|
|
5
5
|
export { getProvider, getWebSocketProvider, watchProvider, watchWebSocketProvider, type GetProviderArgs, type GetProviderResult, type GetWebSocketProviderArgs, type GetWebSocketProviderResult, type WatchProviderCallback, type WatchWebSocketProviderCallback, } from './providers';
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { providers } from 'ethers';
|
|
2
2
|
export declare type SendTransactionArgs = {
|
|
3
|
+
/**
|
|
4
|
+
* Chain id to use for write
|
|
5
|
+
* If signer is not active on this chain, it will attempt to programmatically switch
|
|
6
|
+
*/
|
|
7
|
+
chainId?: number;
|
|
3
8
|
/** Object to use when creating transaction */
|
|
4
9
|
request: providers.TransactionRequest;
|
|
5
10
|
};
|
|
6
11
|
export declare type SendTransactionResult = providers.TransactionResponse;
|
|
7
|
-
export declare function sendTransaction(
|
|
12
|
+
export declare function sendTransaction({ chainId, request, }: SendTransactionArgs): Promise<SendTransactionResult>;
|
|
@@ -9,14 +9,9 @@ export declare type ClientConfig<TProvider extends Provider = Provider, TWebSock
|
|
|
9
9
|
* Connectors used for linking accounts
|
|
10
10
|
* @default [new InjectedConnector()]
|
|
11
11
|
*/
|
|
12
|
-
connectors?: ((
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Interface for connecting to network
|
|
17
|
-
* @default (config) => getDefaultProvider(config.chainId)
|
|
18
|
-
*/
|
|
19
|
-
provider?: ((config: {
|
|
12
|
+
connectors?: (() => Connector[]) | Connector[];
|
|
13
|
+
/** Interface for connecting to network */
|
|
14
|
+
provider: ((config: {
|
|
20
15
|
chainId?: number;
|
|
21
16
|
}) => TProvider) | TProvider;
|
|
22
17
|
/**
|
|
@@ -54,7 +49,7 @@ export declare class Client<TProvider extends Provider = Provider, TWebSocketPro
|
|
|
54
49
|
Partial<State<TProvider, TWebSocketProvider>>
|
|
55
50
|
]
|
|
56
51
|
]>;
|
|
57
|
-
constructor({ autoConnect, connectors, provider, storage, webSocketProvider, }
|
|
52
|
+
constructor({ autoConnect, connectors, provider, storage, webSocketProvider, }: ClientConfig<TProvider, TWebSocketProvider>);
|
|
58
53
|
get chains(): import("./types").Chain[] | undefined;
|
|
59
54
|
get connectors(): Connector<any, any>[];
|
|
60
55
|
get connector(): Connector<any, any> | undefined;
|
|
@@ -62,7 +57,7 @@ export declare class Client<TProvider extends Provider = Provider, TWebSocketPro
|
|
|
62
57
|
get error(): Error | undefined;
|
|
63
58
|
get lastUsedChainId(): number | undefined;
|
|
64
59
|
get provider(): TProvider;
|
|
65
|
-
get status(): "
|
|
60
|
+
get status(): "connecting" | "connected" | "reconnecting" | "disconnected";
|
|
66
61
|
get subscribe(): {
|
|
67
62
|
(listener: (selectedState: State<TProvider, TWebSocketProvider>, previousSelectedState: State<TProvider, TWebSocketProvider>) => void): () => void;
|
|
68
63
|
<U>(selector: (state: State<TProvider, TWebSocketProvider>) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
@@ -78,5 +73,5 @@ export declare class Client<TProvider extends Provider = Provider, TWebSocketPro
|
|
|
78
73
|
setLastUsedConnector(lastUsedConnector?: string | null): void;
|
|
79
74
|
}
|
|
80
75
|
export declare let client: Client<Provider, WebSocketProvider>;
|
|
81
|
-
export declare function createClient<TProvider extends Provider = Provider, TWebSocketProvider extends WebSocketProvider = WebSocketProvider>(config
|
|
76
|
+
export declare function createClient<TProvider extends Provider = Provider, TWebSocketProvider extends WebSocketProvider = WebSocketProvider>(config: ClientConfig<TProvider, TWebSocketProvider>): Client<TProvider, TWebSocketProvider>;
|
|
82
77
|
export declare function getClient<TProvider extends Provider = Provider, TWebSocketProvider extends WebSocketProvider = WebSocketProvider>(): Client<TProvider, TWebSocketProvider>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { default as EventEmitter } from 'eventemitter3';
|
|
1
2
|
import { Signer } from 'ethers/lib/ethers';
|
|
2
|
-
import { EventEmitter } from '../utils/eventemitter';
|
|
3
3
|
import { Chain } from '../types';
|
|
4
4
|
export declare type ConnectorData<Provider = any> = {
|
|
5
5
|
account?: string;
|
|
@@ -42,9 +42,10 @@ export declare abstract class Connector<Provider = any, Options = any> extends E
|
|
|
42
42
|
abstract getChainId(): Promise<number>;
|
|
43
43
|
abstract getProvider(config?: {
|
|
44
44
|
chainId?: number;
|
|
45
|
-
create?: boolean;
|
|
46
45
|
}): Promise<Provider>;
|
|
47
|
-
abstract getSigner(
|
|
46
|
+
abstract getSigner(config?: {
|
|
47
|
+
chainId?: number;
|
|
48
|
+
}): Promise<Signer>;
|
|
48
49
|
abstract isAuthorized(): Promise<boolean>;
|
|
49
50
|
switchChain?(chainId: number): Promise<Chain>;
|
|
50
51
|
watchAsset?(asset: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Chain } from '../../types';
|
|
2
|
-
import { Connector } from '../base';
|
|
2
|
+
import { Connector, ConnectorData } from '../base';
|
|
3
3
|
import { MockProvider, MockProviderOptions } from './provider';
|
|
4
4
|
export declare class MockConnector extends Connector<MockProvider, MockProviderOptions> {
|
|
5
5
|
#private;
|
|
@@ -12,14 +12,7 @@ export declare class MockConnector extends Connector<MockProvider, MockProviderO
|
|
|
12
12
|
});
|
|
13
13
|
connect({ chainId }?: {
|
|
14
14
|
chainId?: number;
|
|
15
|
-
}): Promise<
|
|
16
|
-
account: string;
|
|
17
|
-
chain: {
|
|
18
|
-
id: number;
|
|
19
|
-
unsupported: boolean;
|
|
20
|
-
};
|
|
21
|
-
provider: MockProvider;
|
|
22
|
-
}>;
|
|
15
|
+
}): Promise<Required<ConnectorData<any>>>;
|
|
23
16
|
disconnect(): Promise<void>;
|
|
24
17
|
getAccount(): Promise<string>;
|
|
25
18
|
getChainId(): Promise<number>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { default as EventEmitter } from 'eventemitter3';
|
|
1
2
|
import { Signer, providers } from 'ethers';
|
|
2
3
|
export declare type MockProviderOptions = {
|
|
3
4
|
chainId?: number;
|
|
@@ -17,7 +18,7 @@ declare type Events = {
|
|
|
17
18
|
declare type Event = keyof Events;
|
|
18
19
|
export declare class MockProvider extends providers.BaseProvider {
|
|
19
20
|
#private;
|
|
20
|
-
events:
|
|
21
|
+
events: EventEmitter<Events, any>;
|
|
21
22
|
constructor(options: MockProviderOptions);
|
|
22
23
|
enable(): Promise<string[]>;
|
|
23
24
|
disconnect(): Promise<void>;
|
|
@@ -25,11 +25,12 @@ export declare class WalletConnectConnector extends Connector<WalletConnectProvi
|
|
|
25
25
|
disconnect(): Promise<void>;
|
|
26
26
|
getAccount(): Promise<string>;
|
|
27
27
|
getChainId(): Promise<number>;
|
|
28
|
-
getProvider({ chainId
|
|
29
|
-
chainId?: number
|
|
30
|
-
create?: boolean | undefined;
|
|
28
|
+
getProvider({ chainId }?: {
|
|
29
|
+
chainId?: number;
|
|
31
30
|
}): Promise<WalletConnectProvider>;
|
|
32
|
-
getSigner(
|
|
31
|
+
getSigner({ chainId }?: {
|
|
32
|
+
chainId?: number;
|
|
33
|
+
}): Promise<providers.JsonRpcSigner>;
|
|
33
34
|
isAuthorized(): Promise<boolean>;
|
|
34
35
|
protected onAccountsChanged: (accounts: string[]) => void;
|
|
35
36
|
protected onChainChanged: (chainId: number | string) => void;
|
|
@@ -2,6 +2,7 @@ export { erc20ABI, erc721ABI } from './abis';
|
|
|
2
2
|
export { etherscanBlockExplorers } from './blockExplorers';
|
|
3
3
|
export type { BlockExplorer, BlockExplorerName } from './blockExplorers';
|
|
4
4
|
export { chain, chainId, allChains, defaultChains, defaultL2Chains, } from './chains';
|
|
5
|
-
export {
|
|
5
|
+
export { multicallInterface } from './multicall';
|
|
6
|
+
export { alchemyRpcUrls, defaultAlchemyId, defaultInfuraId, infuraRpcUrls, publicRpcUrls, } from './rpcs';
|
|
6
7
|
export type { RpcProviderName } from './rpcs';
|
|
7
8
|
export { units } from './units';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const multicallInterface: {
|
|
2
|
+
inputs: {
|
|
3
|
+
components: {
|
|
4
|
+
internalType: string;
|
|
5
|
+
name: string;
|
|
6
|
+
type: string;
|
|
7
|
+
}[];
|
|
8
|
+
internalType: string;
|
|
9
|
+
name: string;
|
|
10
|
+
type: string;
|
|
11
|
+
}[];
|
|
12
|
+
name: string;
|
|
13
|
+
outputs: {
|
|
14
|
+
components: {
|
|
15
|
+
internalType: string;
|
|
16
|
+
name: string;
|
|
17
|
+
type: string;
|
|
18
|
+
}[];
|
|
19
|
+
internalType: string;
|
|
20
|
+
name: string;
|
|
21
|
+
type: string;
|
|
22
|
+
}[];
|
|
23
|
+
stateMutability: string;
|
|
24
|
+
type: string;
|
|
25
|
+
}[];
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { ChainName } from './chains';
|
|
2
2
|
export declare const defaultAlchemyId = "_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC";
|
|
3
3
|
export declare const defaultInfuraId = "84842078b09946638c03157f83405213";
|
|
4
|
-
export declare type RpcProviderName = 'alchemy' | 'infura';
|
|
4
|
+
export declare type RpcProviderName = 'alchemy' | 'infura' | 'public';
|
|
5
5
|
declare type AlchemyChains = Extract<ChainName, 'mainnet' | 'ropsten' | 'rinkeby' | 'goerli' | 'kovan' | 'optimism' | 'optimismKovan' | 'polygon' | 'polygonMumbai' | 'arbitrum' | 'arbitrumRinkeby'>;
|
|
6
6
|
export declare const alchemyRpcUrls: Record<AlchemyChains, string>;
|
|
7
7
|
declare type InfuraChains = Extract<ChainName, 'mainnet' | 'ropsten' | 'rinkeby' | 'goerli' | 'kovan' | 'optimism' | 'optimismKovan' | 'polygon' | 'polygonMumbai' | 'arbitrum' | 'arbitrumRinkeby'>;
|
|
8
8
|
export declare const infuraRpcUrls: Record<InfuraChains, string>;
|
|
9
|
+
declare type PublicChains = Extract<ChainName, 'mainnet' | 'ropsten' | 'rinkeby' | 'goerli' | 'kovan' | 'optimism' | 'optimismKovan' | 'polygon' | 'polygonMumbai' | 'arbitrum' | 'arbitrumRinkeby'>;
|
|
10
|
+
export declare const publicRpcUrls: Record<PublicChains, string>;
|
|
9
11
|
export {};
|