@wagmi/core 0.2.0-next.14 → 0.2.0-next.15
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/connectors/mock/dist/wagmi-core-connectors-mock.cjs.dev.js +6 -5
- package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.prod.js +6 -5
- package/connectors/mock/dist/wagmi-core-connectors-mock.esm.js +6 -5
- package/dist/declarations/src/actions/accounts/index.d.ts +0 -1
- package/dist/declarations/src/actions/ens/index.d.ts +0 -4
- package/dist/declarations/src/actions/index.d.ts +4 -4
- package/dist/declarations/src/actions/network-status/index.d.ts +0 -1
- package/dist/declarations/src/actions/providers/watchProvider.d.ts +2 -2
- package/dist/declarations/src/actions/providers/watchWebSocketProvider.d.ts +2 -2
- package/dist/declarations/src/actions/tokens/index.d.ts +0 -1
- package/dist/declarations/src/actions/transactions/waitForTransaction.d.ts +3 -1
- package/dist/declarations/src/connectors/mock/connector.d.ts +1 -1
- package/dist/declarations/src/connectors/mock/provider.d.ts +1 -0
- package/dist/declarations/src/index.d.ts +2 -2
- package/dist/wagmi-core.cjs.dev.js +50 -127
- package/dist/wagmi-core.cjs.prod.js +50 -127
- package/dist/wagmi-core.esm.js +49 -121
- package/package.json +2 -2
- package/dist/declarations/src/actions/accounts/watchBalance.d.ts +0 -3
- package/dist/declarations/src/actions/ens/watchEnsAddress.d.ts +0 -3
- package/dist/declarations/src/actions/ens/watchEnsAvatar.d.ts +0 -3
- package/dist/declarations/src/actions/ens/watchEnsName.d.ts +0 -3
- package/dist/declarations/src/actions/ens/watchEnsResolver.d.ts +0 -3
- package/dist/declarations/src/actions/network-status/watchFeeData.d.ts +0 -7
- package/dist/declarations/src/actions/tokens/watchToken.d.ts +0 -3
|
@@ -69,6 +69,9 @@ class MockProvider extends ethers.providers.BaseProvider {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
async switchChain(chainId) {
|
|
72
|
+
var _classPrivateFieldGet4;
|
|
73
|
+
|
|
74
|
+
if ((_classPrivateFieldGet4 = base._classPrivateFieldGet(this, _options).flags) !== null && _classPrivateFieldGet4 !== void 0 && _classPrivateFieldGet4.failSwitchChain) throw new base.UserRejectedRequestError();
|
|
72
75
|
base._classPrivateFieldGet(this, _options).network = chainId;
|
|
73
76
|
this.network.chainId = chainId;
|
|
74
77
|
this.events.emit('chainChanged', chainId);
|
|
@@ -169,7 +172,7 @@ class MockConnector extends base.Connector {
|
|
|
169
172
|
},
|
|
170
173
|
provider
|
|
171
174
|
};
|
|
172
|
-
if (!((_this$options$flags = this.options.flags) !== null && _this$options$flags !== void 0 && _this$options$flags.
|
|
175
|
+
if (!((_this$options$flags = this.options.flags) !== null && _this$options$flags !== void 0 && _this$options$flags.noSwitchChain)) this.switchChain = classPrivateMethodGet._classPrivateMethodGet(this, _switchChain, _switchChain2);
|
|
173
176
|
return data;
|
|
174
177
|
}
|
|
175
178
|
|
|
@@ -192,8 +195,7 @@ class MockConnector extends base.Connector {
|
|
|
192
195
|
|
|
193
196
|
async getChainId() {
|
|
194
197
|
const provider = await this.getProvider();
|
|
195
|
-
|
|
196
|
-
return chainId;
|
|
198
|
+
return base.normalizeChainId(provider.network.chainId);
|
|
197
199
|
}
|
|
198
200
|
|
|
199
201
|
async getProvider() {
|
|
@@ -203,8 +205,7 @@ class MockConnector extends base.Connector {
|
|
|
203
205
|
|
|
204
206
|
async getSigner() {
|
|
205
207
|
const provider = await this.getProvider();
|
|
206
|
-
|
|
207
|
-
return signer;
|
|
208
|
+
return provider.getSigner();
|
|
208
209
|
}
|
|
209
210
|
|
|
210
211
|
async isAuthorized() {
|
|
@@ -69,6 +69,9 @@ class MockProvider extends ethers.providers.BaseProvider {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
async switchChain(chainId) {
|
|
72
|
+
var _classPrivateFieldGet4;
|
|
73
|
+
|
|
74
|
+
if ((_classPrivateFieldGet4 = base._classPrivateFieldGet(this, _options).flags) !== null && _classPrivateFieldGet4 !== void 0 && _classPrivateFieldGet4.failSwitchChain) throw new base.UserRejectedRequestError();
|
|
72
75
|
base._classPrivateFieldGet(this, _options).network = chainId;
|
|
73
76
|
this.network.chainId = chainId;
|
|
74
77
|
this.events.emit('chainChanged', chainId);
|
|
@@ -169,7 +172,7 @@ class MockConnector extends base.Connector {
|
|
|
169
172
|
},
|
|
170
173
|
provider
|
|
171
174
|
};
|
|
172
|
-
if (!((_this$options$flags = this.options.flags) !== null && _this$options$flags !== void 0 && _this$options$flags.
|
|
175
|
+
if (!((_this$options$flags = this.options.flags) !== null && _this$options$flags !== void 0 && _this$options$flags.noSwitchChain)) this.switchChain = classPrivateMethodGet._classPrivateMethodGet(this, _switchChain, _switchChain2);
|
|
173
176
|
return data;
|
|
174
177
|
}
|
|
175
178
|
|
|
@@ -192,8 +195,7 @@ class MockConnector extends base.Connector {
|
|
|
192
195
|
|
|
193
196
|
async getChainId() {
|
|
194
197
|
const provider = await this.getProvider();
|
|
195
|
-
|
|
196
|
-
return chainId;
|
|
198
|
+
return base.normalizeChainId(provider.network.chainId);
|
|
197
199
|
}
|
|
198
200
|
|
|
199
201
|
async getProvider() {
|
|
@@ -203,8 +205,7 @@ class MockConnector extends base.Connector {
|
|
|
203
205
|
|
|
204
206
|
async getSigner() {
|
|
205
207
|
const provider = await this.getProvider();
|
|
206
|
-
|
|
207
|
-
return signer;
|
|
208
|
+
return provider.getSigner();
|
|
208
209
|
}
|
|
209
210
|
|
|
210
211
|
async isAuthorized() {
|
|
@@ -61,6 +61,9 @@ class MockProvider extends providers.BaseProvider {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
async switchChain(chainId) {
|
|
64
|
+
var _classPrivateFieldGet4;
|
|
65
|
+
|
|
66
|
+
if ((_classPrivateFieldGet4 = _classPrivateFieldGet(this, _options).flags) !== null && _classPrivateFieldGet4 !== void 0 && _classPrivateFieldGet4.failSwitchChain) throw new UserRejectedRequestError();
|
|
64
67
|
_classPrivateFieldGet(this, _options).network = chainId;
|
|
65
68
|
this.network.chainId = chainId;
|
|
66
69
|
this.events.emit('chainChanged', chainId);
|
|
@@ -161,7 +164,7 @@ class MockConnector extends Connector {
|
|
|
161
164
|
},
|
|
162
165
|
provider
|
|
163
166
|
};
|
|
164
|
-
if (!((_this$options$flags = this.options.flags) !== null && _this$options$flags !== void 0 && _this$options$flags.
|
|
167
|
+
if (!((_this$options$flags = this.options.flags) !== null && _this$options$flags !== void 0 && _this$options$flags.noSwitchChain)) this.switchChain = _classPrivateMethodGet(this, _switchChain, _switchChain2);
|
|
165
168
|
return data;
|
|
166
169
|
}
|
|
167
170
|
|
|
@@ -184,8 +187,7 @@ class MockConnector extends Connector {
|
|
|
184
187
|
|
|
185
188
|
async getChainId() {
|
|
186
189
|
const provider = await this.getProvider();
|
|
187
|
-
|
|
188
|
-
return chainId;
|
|
190
|
+
return normalizeChainId(provider.network.chainId);
|
|
189
191
|
}
|
|
190
192
|
|
|
191
193
|
async getProvider() {
|
|
@@ -195,8 +197,7 @@ class MockConnector extends Connector {
|
|
|
195
197
|
|
|
196
198
|
async getSigner() {
|
|
197
199
|
const provider = await this.getProvider();
|
|
198
|
-
|
|
199
|
-
return signer;
|
|
200
|
+
return provider.getSigner();
|
|
200
201
|
}
|
|
201
202
|
|
|
202
203
|
async isAuthorized() {
|
|
@@ -8,6 +8,5 @@ export { signMessage, type SignMessageArgs, type SignMessageResult, } from './si
|
|
|
8
8
|
export { signTypedData, type SignTypedDataArgs, type SignTypedDataResult, } from './signTypedData';
|
|
9
9
|
export { switchNetwork, type SwitchNetworkArgs, type SwitchNetworkResult, } from './switchNetwork';
|
|
10
10
|
export { watchAccount, type WatchAccountCallback } from './watchAccount';
|
|
11
|
-
export { watchBalance, type WatchBalanceCallback } from './watchBalance';
|
|
12
11
|
export { watchNetwork, type WatchNetworkCallback } from './watchNetwork';
|
|
13
12
|
export { watchSigner, type WatchSignerCallback } from './watchSigner';
|
|
@@ -2,7 +2,3 @@ export { fetchEnsAddress, type FetchEnsAddressArgs, type FetchEnsAddressResult,
|
|
|
2
2
|
export { fetchEnsAvatar, type FetchEnsAvatarArgs, type FetchEnsAvatarResult, } from './fetchEnsAvatar';
|
|
3
3
|
export { fetchEnsName, type FetchEnsNameArgs, type FetchEnsNameResult, } from './fetchEnsName';
|
|
4
4
|
export { fetchEnsResolver, type FetchEnsResolverArgs, type FetchEnsResolverResult, } from './fetchEnsResolver';
|
|
5
|
-
export { watchEnsAddress, type WatchEnsAddressCallback, } from './watchEnsAddress';
|
|
6
|
-
export { type WatchEnsAvatarCallback, watchEnsAvatar } from './watchEnsAvatar';
|
|
7
|
-
export { type WatchEnsNameCallback, watchEnsName } from './watchEnsName';
|
|
8
|
-
export { watchEnsResolver, type WatchEnsResolverCallback, } from './watchEnsResolver';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { connect, disconnect, fetchBalance, fetchSigner, getAccount, getNetwork, signMessage, signTypedData, switchNetwork, watchAccount,
|
|
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
2
|
export { getContract, readContract, watchContractEvent, watchReadContract, writeContract, type GetContractArgs, type ReadContractArgs, type ReadContractConfig, type ReadContractResult, type WatchReadContractArgs, type WatchReadContractConfig, type WatchReadContractResult, type WriteContractArgs, type WriteContractConfig, type WriteContractResult, } from './contracts';
|
|
3
|
-
export { fetchEnsAddress, fetchEnsAvatar, fetchEnsName, fetchEnsResolver,
|
|
4
|
-
export { fetchBlockNumber, fetchFeeData, watchBlockNumber,
|
|
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
|
+
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';
|
|
6
|
-
export { fetchToken,
|
|
6
|
+
export { fetchToken, type FetchTokenArgs, type FetchTokenResult, } from './tokens';
|
|
7
7
|
export { sendTransaction, waitForTransaction, type SendTransactionArgs, type SendTransactionResult, type WaitForTransactionArgs, type WaitForTransactionResult, } from './transactions';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export { fetchBlockNumber, type FetchBlockNumberArgs, type FetchBlockNumberResult, } from './fetchBlockNumber';
|
|
2
2
|
export { fetchFeeData, type FetchFeeDataResult, type FetchFeeDataArgs, } from './fetchFeeData';
|
|
3
|
-
export { watchFeeData, type WatchFeeDataArgs, type WatchFeeDataCallback, } from './watchFeeData';
|
|
4
3
|
export { watchBlockNumber, type WatchBlockNumberArgs, type WatchBlockNumberCallback, } from './watchBlockNumber';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { BaseProvider } from '@ethersproject/providers';
|
|
2
|
-
import { GetProviderResult } from './getProvider';
|
|
2
|
+
import { GetProviderArgs, GetProviderResult } from './getProvider';
|
|
3
3
|
export declare type WatchProviderCallback<TProvider extends BaseProvider = BaseProvider> = (provider: GetProviderResult<TProvider>) => void;
|
|
4
|
-
export declare function watchProvider<TProvider extends BaseProvider = BaseProvider>(callback: WatchProviderCallback<TProvider>): () => void;
|
|
4
|
+
export declare function watchProvider<TProvider extends BaseProvider = BaseProvider>(args: GetProviderArgs, callback: WatchProviderCallback<TProvider>): () => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { WebSocketProvider } from '@ethersproject/providers';
|
|
2
|
-
import { GetWebSocketProviderResult } from './getWebSocketProvider';
|
|
2
|
+
import { GetWebSocketProviderArgs, GetWebSocketProviderResult } from './getWebSocketProvider';
|
|
3
3
|
export declare type WatchWebSocketProviderCallback<TWebSocketProvider extends WebSocketProvider = WebSocketProvider> = (webSocketProvider: GetWebSocketProviderResult<TWebSocketProvider>) => void;
|
|
4
|
-
export declare function watchWebSocketProvider<TWebSocketProvider extends WebSocketProvider = WebSocketProvider>(callback: WatchWebSocketProviderCallback<TWebSocketProvider>): () => void;
|
|
4
|
+
export declare function watchWebSocketProvider<TWebSocketProvider extends WebSocketProvider = WebSocketProvider>(args: GetWebSocketProviderArgs, callback: WatchWebSocketProviderCallback<TWebSocketProvider>): () => void;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { TransactionReceipt, TransactionResponse } from '@ethersproject/providers';
|
|
2
2
|
export declare type WaitForTransactionArgs = {
|
|
3
|
+
/** Chain id to use for provider */
|
|
4
|
+
chainId?: number;
|
|
3
5
|
/**
|
|
4
6
|
* Number of blocks to wait for after transaction is mined
|
|
5
7
|
* @default 1
|
|
@@ -12,4 +14,4 @@ export declare type WaitForTransactionArgs = {
|
|
|
12
14
|
wait?: TransactionResponse['wait'];
|
|
13
15
|
};
|
|
14
16
|
export declare type WaitForTransactionResult = TransactionReceipt;
|
|
15
|
-
export declare function waitForTransaction(
|
|
17
|
+
export declare function waitForTransaction({ chainId, confirmations, hash, timeout, wait: wait_, }: WaitForTransactionArgs): Promise<WaitForTransactionResult>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { connect, disconnect, fetchBalance, fetchBlockNumber, fetchEnsAddress, fetchEnsAvatar, fetchEnsName, fetchEnsResolver, fetchFeeData, fetchSigner, fetchToken, getAccount, getContract, getNetwork, getProvider, getWebSocketProvider, readContract, sendTransaction, signMessage, signTypedData, switchNetwork, waitForTransaction, watchAccount,
|
|
2
|
-
export type { ConnectArgs, ConnectResult, FetchBalanceArgs, FetchBalanceResult, FetchBlockNumberArgs, FetchBlockNumberResult, FetchEnsAddressArgs, FetchEnsAddressResult, FetchEnsAvatarArgs, FetchEnsAvatarResult, FetchEnsNameArgs, FetchEnsNameResult, FetchEnsResolverArgs, FetchEnsResolverResult, FetchFeeDataArgs, FetchFeeDataResult, FetchSignerResult, FetchTokenArgs, FetchTokenResult, GetAccountResult, GetContractArgs, GetNetworkResult, GetProviderArgs, GetProviderResult, GetWebSocketProviderArgs, GetWebSocketProviderResult, ReadContractArgs, ReadContractConfig, ReadContractResult, SendTransactionArgs, SendTransactionResult, SignMessageArgs, SignMessageResult, SignTypedDataArgs, SignTypedDataResult, SwitchNetworkArgs, SwitchNetworkResult, WaitForTransactionArgs, WaitForTransactionResult, WatchAccountCallback,
|
|
1
|
+
export { connect, disconnect, fetchBalance, fetchBlockNumber, fetchEnsAddress, fetchEnsAvatar, fetchEnsName, fetchEnsResolver, fetchFeeData, fetchSigner, fetchToken, getAccount, getContract, getNetwork, getProvider, getWebSocketProvider, readContract, sendTransaction, signMessage, signTypedData, switchNetwork, waitForTransaction, watchAccount, watchBlockNumber, watchContractEvent, watchNetwork, watchProvider, watchReadContract, watchSigner, watchWebSocketProvider, writeContract, } from './actions';
|
|
2
|
+
export type { ConnectArgs, ConnectResult, FetchBalanceArgs, FetchBalanceResult, FetchBlockNumberArgs, FetchBlockNumberResult, FetchEnsAddressArgs, FetchEnsAddressResult, FetchEnsAvatarArgs, FetchEnsAvatarResult, FetchEnsNameArgs, FetchEnsNameResult, FetchEnsResolverArgs, FetchEnsResolverResult, FetchFeeDataArgs, FetchFeeDataResult, FetchSignerResult, FetchTokenArgs, FetchTokenResult, GetAccountResult, GetContractArgs, GetNetworkResult, GetProviderArgs, GetProviderResult, GetWebSocketProviderArgs, GetWebSocketProviderResult, ReadContractArgs, ReadContractConfig, ReadContractResult, SendTransactionArgs, SendTransactionResult, SignMessageArgs, SignMessageResult, SignTypedDataArgs, SignTypedDataResult, SwitchNetworkArgs, SwitchNetworkResult, WaitForTransactionArgs, WaitForTransactionResult, WatchAccountCallback, WatchBlockNumberArgs, WatchBlockNumberCallback, WatchNetworkCallback, WatchReadContractArgs, WatchReadContractConfig, WatchReadContractResult, WatchSignerCallback, WriteContractArgs, WriteContractConfig, WriteContractResult, } from './actions';
|
|
3
3
|
export { createClient, createClient as createWagmiClient, Client, Client as WagmiClient, } from './client';
|
|
4
4
|
export type { ClientConfig, ClientConfig as WagmiClientConfig } from './client';
|
|
5
5
|
export { Connector, InjectedConnector } from './connectors';
|
|
@@ -380,7 +380,8 @@ class Client {
|
|
|
380
380
|
}),
|
|
381
381
|
chains: state === null || state === void 0 ? void 0 : state.chains
|
|
382
382
|
};
|
|
383
|
-
}
|
|
383
|
+
},
|
|
384
|
+
version: 1
|
|
384
385
|
})));
|
|
385
386
|
this.config = {
|
|
386
387
|
autoConnect,
|
|
@@ -614,6 +615,34 @@ function getWebSocketProvider() {
|
|
|
614
615
|
return client.webSocketProvider;
|
|
615
616
|
}
|
|
616
617
|
|
|
618
|
+
function watchProvider(args, callback) {
|
|
619
|
+
const client = getClient();
|
|
620
|
+
|
|
621
|
+
const handleChange = async () => callback(getProvider(args));
|
|
622
|
+
|
|
623
|
+
const unsubscribe = client.subscribe(_ref => {
|
|
624
|
+
let {
|
|
625
|
+
provider
|
|
626
|
+
} = _ref;
|
|
627
|
+
return provider;
|
|
628
|
+
}, handleChange);
|
|
629
|
+
return unsubscribe;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
function watchWebSocketProvider(args, callback) {
|
|
633
|
+
const client = getClient();
|
|
634
|
+
|
|
635
|
+
const handleChange = async () => callback(getWebSocketProvider(args));
|
|
636
|
+
|
|
637
|
+
const unsubscribe = client.subscribe(_ref => {
|
|
638
|
+
let {
|
|
639
|
+
webSocketProvider
|
|
640
|
+
} = _ref;
|
|
641
|
+
return webSocketProvider;
|
|
642
|
+
}, handleChange);
|
|
643
|
+
return unsubscribe;
|
|
644
|
+
}
|
|
645
|
+
|
|
617
646
|
async function fetchBalance(_ref) {
|
|
618
647
|
var _client$connector$cha, _client$connector, _chain$nativeCurrency, _chain$nativeCurrency2, _chain$nativeCurrency3, _chain$nativeCurrency4;
|
|
619
648
|
|
|
@@ -750,27 +779,6 @@ function watchAccount(callback) {
|
|
|
750
779
|
return unsubscribe;
|
|
751
780
|
}
|
|
752
781
|
|
|
753
|
-
function watchBalance(args, callback) {
|
|
754
|
-
const client = getClient();
|
|
755
|
-
|
|
756
|
-
const handleChange = async () => callback(await fetchBalance(args));
|
|
757
|
-
|
|
758
|
-
const unsubscribe = client.subscribe(_ref => {
|
|
759
|
-
var _data$chain;
|
|
760
|
-
|
|
761
|
-
let {
|
|
762
|
-
data
|
|
763
|
-
} = _ref;
|
|
764
|
-
return {
|
|
765
|
-
account: data === null || data === void 0 ? void 0 : data.account,
|
|
766
|
-
chainId: data === null || data === void 0 ? void 0 : (_data$chain = data.chain) === null || _data$chain === void 0 ? void 0 : _data$chain.id
|
|
767
|
-
};
|
|
768
|
-
}, handleChange, {
|
|
769
|
-
equalityFn: (selected, previous) => selected.account === previous.account && selected.chainId === previous.chainId
|
|
770
|
-
});
|
|
771
|
-
return unsubscribe;
|
|
772
|
-
}
|
|
773
|
-
|
|
774
782
|
function watchNetwork(callback) {
|
|
775
783
|
const client = getClient();
|
|
776
784
|
|
|
@@ -1043,8 +1051,7 @@ async function fetchEnsName(_ref) {
|
|
|
1043
1051
|
const provider = getProvider({
|
|
1044
1052
|
chainId
|
|
1045
1053
|
});
|
|
1046
|
-
|
|
1047
|
-
return ensName;
|
|
1054
|
+
return await provider.lookupAddress(address);
|
|
1048
1055
|
}
|
|
1049
1056
|
|
|
1050
1057
|
async function fetchEnsResolver(_ref) {
|
|
@@ -1059,62 +1066,6 @@ async function fetchEnsResolver(_ref) {
|
|
|
1059
1066
|
return resolver;
|
|
1060
1067
|
}
|
|
1061
1068
|
|
|
1062
|
-
function watchEnsAddress(args, callback) {
|
|
1063
|
-
const client = getClient();
|
|
1064
|
-
|
|
1065
|
-
const handleChange = async () => callback(await fetchEnsAddress(args));
|
|
1066
|
-
|
|
1067
|
-
const unsubscribe = client.subscribe(_ref => {
|
|
1068
|
-
let {
|
|
1069
|
-
provider
|
|
1070
|
-
} = _ref;
|
|
1071
|
-
return provider;
|
|
1072
|
-
}, handleChange);
|
|
1073
|
-
return unsubscribe;
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
|
-
function watchEnsAvatar(args, callback) {
|
|
1077
|
-
const client = getClient();
|
|
1078
|
-
|
|
1079
|
-
const handleChange = async () => callback(await fetchEnsAvatar(args));
|
|
1080
|
-
|
|
1081
|
-
const unsubscribe = client.subscribe(_ref => {
|
|
1082
|
-
let {
|
|
1083
|
-
provider
|
|
1084
|
-
} = _ref;
|
|
1085
|
-
return provider;
|
|
1086
|
-
}, handleChange);
|
|
1087
|
-
return unsubscribe;
|
|
1088
|
-
}
|
|
1089
|
-
|
|
1090
|
-
function watchEnsName(args, callback) {
|
|
1091
|
-
const client = getClient();
|
|
1092
|
-
|
|
1093
|
-
const handleChange = async () => callback(await fetchEnsName(args));
|
|
1094
|
-
|
|
1095
|
-
const unsubscribe = client.subscribe(_ref => {
|
|
1096
|
-
let {
|
|
1097
|
-
provider
|
|
1098
|
-
} = _ref;
|
|
1099
|
-
return provider;
|
|
1100
|
-
}, handleChange);
|
|
1101
|
-
return unsubscribe;
|
|
1102
|
-
}
|
|
1103
|
-
|
|
1104
|
-
function watchEnsResolver(args, callback) {
|
|
1105
|
-
const client = getClient();
|
|
1106
|
-
|
|
1107
|
-
const handleChange = async () => callback(await fetchEnsResolver(args));
|
|
1108
|
-
|
|
1109
|
-
const unsubscribe = client.subscribe(_ref => {
|
|
1110
|
-
let {
|
|
1111
|
-
provider
|
|
1112
|
-
} = _ref;
|
|
1113
|
-
return provider;
|
|
1114
|
-
}, handleChange);
|
|
1115
|
-
return unsubscribe;
|
|
1116
|
-
}
|
|
1117
|
-
|
|
1118
1069
|
async function fetchFeeData() {
|
|
1119
1070
|
let {
|
|
1120
1071
|
chainId,
|
|
@@ -1134,26 +1085,6 @@ async function fetchFeeData() {
|
|
|
1134
1085
|
};
|
|
1135
1086
|
}
|
|
1136
1087
|
|
|
1137
|
-
function watchFeeData(args, callback) {
|
|
1138
|
-
const client = getClient();
|
|
1139
|
-
|
|
1140
|
-
const handleChange = async () => callback(await fetchFeeData(args));
|
|
1141
|
-
|
|
1142
|
-
const unwatch = args.listenToBlock ? watchBlockNumber({
|
|
1143
|
-
listen: true
|
|
1144
|
-
}, handleChange) : undefined;
|
|
1145
|
-
const unsubscribe = client.subscribe(_ref => {
|
|
1146
|
-
let {
|
|
1147
|
-
provider
|
|
1148
|
-
} = _ref;
|
|
1149
|
-
return provider;
|
|
1150
|
-
}, handleChange);
|
|
1151
|
-
return () => {
|
|
1152
|
-
unsubscribe();
|
|
1153
|
-
unwatch === null || unwatch === void 0 ? void 0 : unwatch();
|
|
1154
|
-
};
|
|
1155
|
-
}
|
|
1156
|
-
|
|
1157
1088
|
async function fetchToken(_ref) {
|
|
1158
1089
|
let {
|
|
1159
1090
|
address,
|
|
@@ -1177,20 +1108,6 @@ async function fetchToken(_ref) {
|
|
|
1177
1108
|
return token;
|
|
1178
1109
|
}
|
|
1179
1110
|
|
|
1180
|
-
function watchToken(args, callback) {
|
|
1181
|
-
const client = getClient();
|
|
1182
|
-
|
|
1183
|
-
const handleChange = async () => callback(await fetchToken(args));
|
|
1184
|
-
|
|
1185
|
-
const unsubscribe = client.subscribe(_ref => {
|
|
1186
|
-
let {
|
|
1187
|
-
provider
|
|
1188
|
-
} = _ref;
|
|
1189
|
-
return provider;
|
|
1190
|
-
}, handleChange);
|
|
1191
|
-
return unsubscribe;
|
|
1192
|
-
}
|
|
1193
|
-
|
|
1194
1111
|
async function sendTransaction(args) {
|
|
1195
1112
|
try {
|
|
1196
1113
|
const signer = await fetchSigner();
|
|
@@ -1204,13 +1121,24 @@ async function sendTransaction(args) {
|
|
|
1204
1121
|
}
|
|
1205
1122
|
}
|
|
1206
1123
|
|
|
1207
|
-
async function waitForTransaction(
|
|
1208
|
-
|
|
1209
|
-
|
|
1124
|
+
async function waitForTransaction(_ref) {
|
|
1125
|
+
let {
|
|
1126
|
+
chainId,
|
|
1127
|
+
confirmations,
|
|
1128
|
+
hash,
|
|
1129
|
+
timeout,
|
|
1130
|
+
wait: wait_
|
|
1131
|
+
} = _ref;
|
|
1132
|
+
let promise;
|
|
1133
|
+
|
|
1134
|
+
if (hash) {
|
|
1135
|
+
const provider = getProvider({
|
|
1136
|
+
chainId
|
|
1137
|
+
});
|
|
1138
|
+
promise = provider.waitForTransaction(hash, confirmations, timeout);
|
|
1139
|
+
} else if (wait_) promise = wait_(confirmations);else throw new Error('hash or wait is required');
|
|
1210
1140
|
|
|
1211
|
-
|
|
1212
|
-
const receipt = await promise;
|
|
1213
|
-
return receipt;
|
|
1141
|
+
return await promise;
|
|
1214
1142
|
}
|
|
1215
1143
|
|
|
1216
1144
|
exports.AddChainError = base.AddChainError;
|
|
@@ -1264,16 +1192,11 @@ exports.switchNetwork = switchNetwork;
|
|
|
1264
1192
|
exports.units = units;
|
|
1265
1193
|
exports.waitForTransaction = waitForTransaction;
|
|
1266
1194
|
exports.watchAccount = watchAccount;
|
|
1267
|
-
exports.watchBalance = watchBalance;
|
|
1268
1195
|
exports.watchBlockNumber = watchBlockNumber;
|
|
1269
1196
|
exports.watchContractEvent = watchContractEvent;
|
|
1270
|
-
exports.watchEnsAddress = watchEnsAddress;
|
|
1271
|
-
exports.watchEnsAvatar = watchEnsAvatar;
|
|
1272
|
-
exports.watchEnsName = watchEnsName;
|
|
1273
|
-
exports.watchEnsResolver = watchEnsResolver;
|
|
1274
|
-
exports.watchFeeData = watchFeeData;
|
|
1275
1197
|
exports.watchNetwork = watchNetwork;
|
|
1198
|
+
exports.watchProvider = watchProvider;
|
|
1276
1199
|
exports.watchReadContract = watchReadContract;
|
|
1277
1200
|
exports.watchSigner = watchSigner;
|
|
1278
|
-
exports.
|
|
1201
|
+
exports.watchWebSocketProvider = watchWebSocketProvider;
|
|
1279
1202
|
exports.writeContract = writeContract;
|
|
@@ -380,7 +380,8 @@ class Client {
|
|
|
380
380
|
}),
|
|
381
381
|
chains: state === null || state === void 0 ? void 0 : state.chains
|
|
382
382
|
};
|
|
383
|
-
}
|
|
383
|
+
},
|
|
384
|
+
version: 1
|
|
384
385
|
})));
|
|
385
386
|
this.config = {
|
|
386
387
|
autoConnect,
|
|
@@ -614,6 +615,34 @@ function getWebSocketProvider() {
|
|
|
614
615
|
return client.webSocketProvider;
|
|
615
616
|
}
|
|
616
617
|
|
|
618
|
+
function watchProvider(args, callback) {
|
|
619
|
+
const client = getClient();
|
|
620
|
+
|
|
621
|
+
const handleChange = async () => callback(getProvider(args));
|
|
622
|
+
|
|
623
|
+
const unsubscribe = client.subscribe(_ref => {
|
|
624
|
+
let {
|
|
625
|
+
provider
|
|
626
|
+
} = _ref;
|
|
627
|
+
return provider;
|
|
628
|
+
}, handleChange);
|
|
629
|
+
return unsubscribe;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
function watchWebSocketProvider(args, callback) {
|
|
633
|
+
const client = getClient();
|
|
634
|
+
|
|
635
|
+
const handleChange = async () => callback(getWebSocketProvider(args));
|
|
636
|
+
|
|
637
|
+
const unsubscribe = client.subscribe(_ref => {
|
|
638
|
+
let {
|
|
639
|
+
webSocketProvider
|
|
640
|
+
} = _ref;
|
|
641
|
+
return webSocketProvider;
|
|
642
|
+
}, handleChange);
|
|
643
|
+
return unsubscribe;
|
|
644
|
+
}
|
|
645
|
+
|
|
617
646
|
async function fetchBalance(_ref) {
|
|
618
647
|
var _client$connector$cha, _client$connector, _chain$nativeCurrency, _chain$nativeCurrency2, _chain$nativeCurrency3, _chain$nativeCurrency4;
|
|
619
648
|
|
|
@@ -750,27 +779,6 @@ function watchAccount(callback) {
|
|
|
750
779
|
return unsubscribe;
|
|
751
780
|
}
|
|
752
781
|
|
|
753
|
-
function watchBalance(args, callback) {
|
|
754
|
-
const client = getClient();
|
|
755
|
-
|
|
756
|
-
const handleChange = async () => callback(await fetchBalance(args));
|
|
757
|
-
|
|
758
|
-
const unsubscribe = client.subscribe(_ref => {
|
|
759
|
-
var _data$chain;
|
|
760
|
-
|
|
761
|
-
let {
|
|
762
|
-
data
|
|
763
|
-
} = _ref;
|
|
764
|
-
return {
|
|
765
|
-
account: data === null || data === void 0 ? void 0 : data.account,
|
|
766
|
-
chainId: data === null || data === void 0 ? void 0 : (_data$chain = data.chain) === null || _data$chain === void 0 ? void 0 : _data$chain.id
|
|
767
|
-
};
|
|
768
|
-
}, handleChange, {
|
|
769
|
-
equalityFn: (selected, previous) => selected.account === previous.account && selected.chainId === previous.chainId
|
|
770
|
-
});
|
|
771
|
-
return unsubscribe;
|
|
772
|
-
}
|
|
773
|
-
|
|
774
782
|
function watchNetwork(callback) {
|
|
775
783
|
const client = getClient();
|
|
776
784
|
|
|
@@ -1043,8 +1051,7 @@ async function fetchEnsName(_ref) {
|
|
|
1043
1051
|
const provider = getProvider({
|
|
1044
1052
|
chainId
|
|
1045
1053
|
});
|
|
1046
|
-
|
|
1047
|
-
return ensName;
|
|
1054
|
+
return await provider.lookupAddress(address);
|
|
1048
1055
|
}
|
|
1049
1056
|
|
|
1050
1057
|
async function fetchEnsResolver(_ref) {
|
|
@@ -1059,62 +1066,6 @@ async function fetchEnsResolver(_ref) {
|
|
|
1059
1066
|
return resolver;
|
|
1060
1067
|
}
|
|
1061
1068
|
|
|
1062
|
-
function watchEnsAddress(args, callback) {
|
|
1063
|
-
const client = getClient();
|
|
1064
|
-
|
|
1065
|
-
const handleChange = async () => callback(await fetchEnsAddress(args));
|
|
1066
|
-
|
|
1067
|
-
const unsubscribe = client.subscribe(_ref => {
|
|
1068
|
-
let {
|
|
1069
|
-
provider
|
|
1070
|
-
} = _ref;
|
|
1071
|
-
return provider;
|
|
1072
|
-
}, handleChange);
|
|
1073
|
-
return unsubscribe;
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
|
-
function watchEnsAvatar(args, callback) {
|
|
1077
|
-
const client = getClient();
|
|
1078
|
-
|
|
1079
|
-
const handleChange = async () => callback(await fetchEnsAvatar(args));
|
|
1080
|
-
|
|
1081
|
-
const unsubscribe = client.subscribe(_ref => {
|
|
1082
|
-
let {
|
|
1083
|
-
provider
|
|
1084
|
-
} = _ref;
|
|
1085
|
-
return provider;
|
|
1086
|
-
}, handleChange);
|
|
1087
|
-
return unsubscribe;
|
|
1088
|
-
}
|
|
1089
|
-
|
|
1090
|
-
function watchEnsName(args, callback) {
|
|
1091
|
-
const client = getClient();
|
|
1092
|
-
|
|
1093
|
-
const handleChange = async () => callback(await fetchEnsName(args));
|
|
1094
|
-
|
|
1095
|
-
const unsubscribe = client.subscribe(_ref => {
|
|
1096
|
-
let {
|
|
1097
|
-
provider
|
|
1098
|
-
} = _ref;
|
|
1099
|
-
return provider;
|
|
1100
|
-
}, handleChange);
|
|
1101
|
-
return unsubscribe;
|
|
1102
|
-
}
|
|
1103
|
-
|
|
1104
|
-
function watchEnsResolver(args, callback) {
|
|
1105
|
-
const client = getClient();
|
|
1106
|
-
|
|
1107
|
-
const handleChange = async () => callback(await fetchEnsResolver(args));
|
|
1108
|
-
|
|
1109
|
-
const unsubscribe = client.subscribe(_ref => {
|
|
1110
|
-
let {
|
|
1111
|
-
provider
|
|
1112
|
-
} = _ref;
|
|
1113
|
-
return provider;
|
|
1114
|
-
}, handleChange);
|
|
1115
|
-
return unsubscribe;
|
|
1116
|
-
}
|
|
1117
|
-
|
|
1118
1069
|
async function fetchFeeData() {
|
|
1119
1070
|
let {
|
|
1120
1071
|
chainId,
|
|
@@ -1134,26 +1085,6 @@ async function fetchFeeData() {
|
|
|
1134
1085
|
};
|
|
1135
1086
|
}
|
|
1136
1087
|
|
|
1137
|
-
function watchFeeData(args, callback) {
|
|
1138
|
-
const client = getClient();
|
|
1139
|
-
|
|
1140
|
-
const handleChange = async () => callback(await fetchFeeData(args));
|
|
1141
|
-
|
|
1142
|
-
const unwatch = args.listenToBlock ? watchBlockNumber({
|
|
1143
|
-
listen: true
|
|
1144
|
-
}, handleChange) : undefined;
|
|
1145
|
-
const unsubscribe = client.subscribe(_ref => {
|
|
1146
|
-
let {
|
|
1147
|
-
provider
|
|
1148
|
-
} = _ref;
|
|
1149
|
-
return provider;
|
|
1150
|
-
}, handleChange);
|
|
1151
|
-
return () => {
|
|
1152
|
-
unsubscribe();
|
|
1153
|
-
unwatch === null || unwatch === void 0 ? void 0 : unwatch();
|
|
1154
|
-
};
|
|
1155
|
-
}
|
|
1156
|
-
|
|
1157
1088
|
async function fetchToken(_ref) {
|
|
1158
1089
|
let {
|
|
1159
1090
|
address,
|
|
@@ -1177,20 +1108,6 @@ async function fetchToken(_ref) {
|
|
|
1177
1108
|
return token;
|
|
1178
1109
|
}
|
|
1179
1110
|
|
|
1180
|
-
function watchToken(args, callback) {
|
|
1181
|
-
const client = getClient();
|
|
1182
|
-
|
|
1183
|
-
const handleChange = async () => callback(await fetchToken(args));
|
|
1184
|
-
|
|
1185
|
-
const unsubscribe = client.subscribe(_ref => {
|
|
1186
|
-
let {
|
|
1187
|
-
provider
|
|
1188
|
-
} = _ref;
|
|
1189
|
-
return provider;
|
|
1190
|
-
}, handleChange);
|
|
1191
|
-
return unsubscribe;
|
|
1192
|
-
}
|
|
1193
|
-
|
|
1194
1111
|
async function sendTransaction(args) {
|
|
1195
1112
|
try {
|
|
1196
1113
|
const signer = await fetchSigner();
|
|
@@ -1204,13 +1121,24 @@ async function sendTransaction(args) {
|
|
|
1204
1121
|
}
|
|
1205
1122
|
}
|
|
1206
1123
|
|
|
1207
|
-
async function waitForTransaction(
|
|
1208
|
-
|
|
1209
|
-
|
|
1124
|
+
async function waitForTransaction(_ref) {
|
|
1125
|
+
let {
|
|
1126
|
+
chainId,
|
|
1127
|
+
confirmations,
|
|
1128
|
+
hash,
|
|
1129
|
+
timeout,
|
|
1130
|
+
wait: wait_
|
|
1131
|
+
} = _ref;
|
|
1132
|
+
let promise;
|
|
1133
|
+
|
|
1134
|
+
if (hash) {
|
|
1135
|
+
const provider = getProvider({
|
|
1136
|
+
chainId
|
|
1137
|
+
});
|
|
1138
|
+
promise = provider.waitForTransaction(hash, confirmations, timeout);
|
|
1139
|
+
} else if (wait_) promise = wait_(confirmations);else throw new Error('hash or wait is required');
|
|
1210
1140
|
|
|
1211
|
-
|
|
1212
|
-
const receipt = await promise;
|
|
1213
|
-
return receipt;
|
|
1141
|
+
return await promise;
|
|
1214
1142
|
}
|
|
1215
1143
|
|
|
1216
1144
|
exports.AddChainError = base.AddChainError;
|
|
@@ -1264,16 +1192,11 @@ exports.switchNetwork = switchNetwork;
|
|
|
1264
1192
|
exports.units = units;
|
|
1265
1193
|
exports.waitForTransaction = waitForTransaction;
|
|
1266
1194
|
exports.watchAccount = watchAccount;
|
|
1267
|
-
exports.watchBalance = watchBalance;
|
|
1268
1195
|
exports.watchBlockNumber = watchBlockNumber;
|
|
1269
1196
|
exports.watchContractEvent = watchContractEvent;
|
|
1270
|
-
exports.watchEnsAddress = watchEnsAddress;
|
|
1271
|
-
exports.watchEnsAvatar = watchEnsAvatar;
|
|
1272
|
-
exports.watchEnsName = watchEnsName;
|
|
1273
|
-
exports.watchEnsResolver = watchEnsResolver;
|
|
1274
|
-
exports.watchFeeData = watchFeeData;
|
|
1275
1197
|
exports.watchNetwork = watchNetwork;
|
|
1198
|
+
exports.watchProvider = watchProvider;
|
|
1276
1199
|
exports.watchReadContract = watchReadContract;
|
|
1277
1200
|
exports.watchSigner = watchSigner;
|
|
1278
|
-
exports.
|
|
1201
|
+
exports.watchWebSocketProvider = watchWebSocketProvider;
|
|
1279
1202
|
exports.writeContract = writeContract;
|
package/dist/wagmi-core.esm.js
CHANGED
|
@@ -373,7 +373,8 @@ class Client {
|
|
|
373
373
|
}),
|
|
374
374
|
chains: state === null || state === void 0 ? void 0 : state.chains
|
|
375
375
|
};
|
|
376
|
-
}
|
|
376
|
+
},
|
|
377
|
+
version: 1
|
|
377
378
|
})));
|
|
378
379
|
this.config = {
|
|
379
380
|
autoConnect,
|
|
@@ -607,6 +608,34 @@ function getWebSocketProvider() {
|
|
|
607
608
|
return client.webSocketProvider;
|
|
608
609
|
}
|
|
609
610
|
|
|
611
|
+
function watchProvider(args, callback) {
|
|
612
|
+
const client = getClient();
|
|
613
|
+
|
|
614
|
+
const handleChange = async () => callback(getProvider(args));
|
|
615
|
+
|
|
616
|
+
const unsubscribe = client.subscribe(_ref => {
|
|
617
|
+
let {
|
|
618
|
+
provider
|
|
619
|
+
} = _ref;
|
|
620
|
+
return provider;
|
|
621
|
+
}, handleChange);
|
|
622
|
+
return unsubscribe;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
function watchWebSocketProvider(args, callback) {
|
|
626
|
+
const client = getClient();
|
|
627
|
+
|
|
628
|
+
const handleChange = async () => callback(getWebSocketProvider(args));
|
|
629
|
+
|
|
630
|
+
const unsubscribe = client.subscribe(_ref => {
|
|
631
|
+
let {
|
|
632
|
+
webSocketProvider
|
|
633
|
+
} = _ref;
|
|
634
|
+
return webSocketProvider;
|
|
635
|
+
}, handleChange);
|
|
636
|
+
return unsubscribe;
|
|
637
|
+
}
|
|
638
|
+
|
|
610
639
|
async function fetchBalance(_ref) {
|
|
611
640
|
var _client$connector$cha, _client$connector, _chain$nativeCurrency, _chain$nativeCurrency2, _chain$nativeCurrency3, _chain$nativeCurrency4;
|
|
612
641
|
|
|
@@ -743,27 +772,6 @@ function watchAccount(callback) {
|
|
|
743
772
|
return unsubscribe;
|
|
744
773
|
}
|
|
745
774
|
|
|
746
|
-
function watchBalance(args, callback) {
|
|
747
|
-
const client = getClient();
|
|
748
|
-
|
|
749
|
-
const handleChange = async () => callback(await fetchBalance(args));
|
|
750
|
-
|
|
751
|
-
const unsubscribe = client.subscribe(_ref => {
|
|
752
|
-
var _data$chain;
|
|
753
|
-
|
|
754
|
-
let {
|
|
755
|
-
data
|
|
756
|
-
} = _ref;
|
|
757
|
-
return {
|
|
758
|
-
account: data === null || data === void 0 ? void 0 : data.account,
|
|
759
|
-
chainId: data === null || data === void 0 ? void 0 : (_data$chain = data.chain) === null || _data$chain === void 0 ? void 0 : _data$chain.id
|
|
760
|
-
};
|
|
761
|
-
}, handleChange, {
|
|
762
|
-
equalityFn: (selected, previous) => selected.account === previous.account && selected.chainId === previous.chainId
|
|
763
|
-
});
|
|
764
|
-
return unsubscribe;
|
|
765
|
-
}
|
|
766
|
-
|
|
767
775
|
function watchNetwork(callback) {
|
|
768
776
|
const client = getClient();
|
|
769
777
|
|
|
@@ -1036,8 +1044,7 @@ async function fetchEnsName(_ref) {
|
|
|
1036
1044
|
const provider = getProvider({
|
|
1037
1045
|
chainId
|
|
1038
1046
|
});
|
|
1039
|
-
|
|
1040
|
-
return ensName;
|
|
1047
|
+
return await provider.lookupAddress(address);
|
|
1041
1048
|
}
|
|
1042
1049
|
|
|
1043
1050
|
async function fetchEnsResolver(_ref) {
|
|
@@ -1052,62 +1059,6 @@ async function fetchEnsResolver(_ref) {
|
|
|
1052
1059
|
return resolver;
|
|
1053
1060
|
}
|
|
1054
1061
|
|
|
1055
|
-
function watchEnsAddress(args, callback) {
|
|
1056
|
-
const client = getClient();
|
|
1057
|
-
|
|
1058
|
-
const handleChange = async () => callback(await fetchEnsAddress(args));
|
|
1059
|
-
|
|
1060
|
-
const unsubscribe = client.subscribe(_ref => {
|
|
1061
|
-
let {
|
|
1062
|
-
provider
|
|
1063
|
-
} = _ref;
|
|
1064
|
-
return provider;
|
|
1065
|
-
}, handleChange);
|
|
1066
|
-
return unsubscribe;
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
function watchEnsAvatar(args, callback) {
|
|
1070
|
-
const client = getClient();
|
|
1071
|
-
|
|
1072
|
-
const handleChange = async () => callback(await fetchEnsAvatar(args));
|
|
1073
|
-
|
|
1074
|
-
const unsubscribe = client.subscribe(_ref => {
|
|
1075
|
-
let {
|
|
1076
|
-
provider
|
|
1077
|
-
} = _ref;
|
|
1078
|
-
return provider;
|
|
1079
|
-
}, handleChange);
|
|
1080
|
-
return unsubscribe;
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
function watchEnsName(args, callback) {
|
|
1084
|
-
const client = getClient();
|
|
1085
|
-
|
|
1086
|
-
const handleChange = async () => callback(await fetchEnsName(args));
|
|
1087
|
-
|
|
1088
|
-
const unsubscribe = client.subscribe(_ref => {
|
|
1089
|
-
let {
|
|
1090
|
-
provider
|
|
1091
|
-
} = _ref;
|
|
1092
|
-
return provider;
|
|
1093
|
-
}, handleChange);
|
|
1094
|
-
return unsubscribe;
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
|
-
function watchEnsResolver(args, callback) {
|
|
1098
|
-
const client = getClient();
|
|
1099
|
-
|
|
1100
|
-
const handleChange = async () => callback(await fetchEnsResolver(args));
|
|
1101
|
-
|
|
1102
|
-
const unsubscribe = client.subscribe(_ref => {
|
|
1103
|
-
let {
|
|
1104
|
-
provider
|
|
1105
|
-
} = _ref;
|
|
1106
|
-
return provider;
|
|
1107
|
-
}, handleChange);
|
|
1108
|
-
return unsubscribe;
|
|
1109
|
-
}
|
|
1110
|
-
|
|
1111
1062
|
async function fetchFeeData() {
|
|
1112
1063
|
let {
|
|
1113
1064
|
chainId,
|
|
@@ -1127,26 +1078,6 @@ async function fetchFeeData() {
|
|
|
1127
1078
|
};
|
|
1128
1079
|
}
|
|
1129
1080
|
|
|
1130
|
-
function watchFeeData(args, callback) {
|
|
1131
|
-
const client = getClient();
|
|
1132
|
-
|
|
1133
|
-
const handleChange = async () => callback(await fetchFeeData(args));
|
|
1134
|
-
|
|
1135
|
-
const unwatch = args.listenToBlock ? watchBlockNumber({
|
|
1136
|
-
listen: true
|
|
1137
|
-
}, handleChange) : undefined;
|
|
1138
|
-
const unsubscribe = client.subscribe(_ref => {
|
|
1139
|
-
let {
|
|
1140
|
-
provider
|
|
1141
|
-
} = _ref;
|
|
1142
|
-
return provider;
|
|
1143
|
-
}, handleChange);
|
|
1144
|
-
return () => {
|
|
1145
|
-
unsubscribe();
|
|
1146
|
-
unwatch === null || unwatch === void 0 ? void 0 : unwatch();
|
|
1147
|
-
};
|
|
1148
|
-
}
|
|
1149
|
-
|
|
1150
1081
|
async function fetchToken(_ref) {
|
|
1151
1082
|
let {
|
|
1152
1083
|
address,
|
|
@@ -1170,20 +1101,6 @@ async function fetchToken(_ref) {
|
|
|
1170
1101
|
return token;
|
|
1171
1102
|
}
|
|
1172
1103
|
|
|
1173
|
-
function watchToken(args, callback) {
|
|
1174
|
-
const client = getClient();
|
|
1175
|
-
|
|
1176
|
-
const handleChange = async () => callback(await fetchToken(args));
|
|
1177
|
-
|
|
1178
|
-
const unsubscribe = client.subscribe(_ref => {
|
|
1179
|
-
let {
|
|
1180
|
-
provider
|
|
1181
|
-
} = _ref;
|
|
1182
|
-
return provider;
|
|
1183
|
-
}, handleChange);
|
|
1184
|
-
return unsubscribe;
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
1104
|
async function sendTransaction(args) {
|
|
1188
1105
|
try {
|
|
1189
1106
|
const signer = await fetchSigner();
|
|
@@ -1197,13 +1114,24 @@ async function sendTransaction(args) {
|
|
|
1197
1114
|
}
|
|
1198
1115
|
}
|
|
1199
1116
|
|
|
1200
|
-
async function waitForTransaction(
|
|
1201
|
-
|
|
1202
|
-
|
|
1117
|
+
async function waitForTransaction(_ref) {
|
|
1118
|
+
let {
|
|
1119
|
+
chainId,
|
|
1120
|
+
confirmations,
|
|
1121
|
+
hash,
|
|
1122
|
+
timeout,
|
|
1123
|
+
wait: wait_
|
|
1124
|
+
} = _ref;
|
|
1125
|
+
let promise;
|
|
1126
|
+
|
|
1127
|
+
if (hash) {
|
|
1128
|
+
const provider = getProvider({
|
|
1129
|
+
chainId
|
|
1130
|
+
});
|
|
1131
|
+
promise = provider.waitForTransaction(hash, confirmations, timeout);
|
|
1132
|
+
} else if (wait_) promise = wait_(confirmations);else throw new Error('hash or wait is required');
|
|
1203
1133
|
|
|
1204
|
-
|
|
1205
|
-
const receipt = await promise;
|
|
1206
|
-
return receipt;
|
|
1134
|
+
return await promise;
|
|
1207
1135
|
}
|
|
1208
1136
|
|
|
1209
|
-
export { Client, InjectedConnector, Client as WagmiClient, connect, createClient, createStorage, createClient as createWagmiClient, createStorage as createWagmiStorage, disconnect, erc20ABI, erc721ABI, fetchBalance, fetchBlockNumber, fetchEnsAddress, fetchEnsAvatar, fetchEnsName, fetchEnsResolver, fetchFeeData, fetchSigner, fetchToken, getAccount, getContract, getNetwork, getProvider, getWebSocketProvider, noopStorage, readContract, sendTransaction, signMessage, signTypedData, switchNetwork, units, waitForTransaction, watchAccount,
|
|
1137
|
+
export { Client, InjectedConnector, Client as WagmiClient, connect, createClient, createStorage, createClient as createWagmiClient, createStorage as createWagmiStorage, disconnect, erc20ABI, erc721ABI, fetchBalance, fetchBlockNumber, fetchEnsAddress, fetchEnsAvatar, fetchEnsName, fetchEnsResolver, fetchFeeData, fetchSigner, fetchToken, getAccount, getContract, getNetwork, getProvider, getWebSocketProvider, noopStorage, readContract, sendTransaction, signMessage, signTypedData, switchNetwork, units, waitForTransaction, watchAccount, watchBlockNumber, watchContractEvent, watchNetwork, watchProvider, watchReadContract, watchSigner, watchWebSocketProvider, writeContract };
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@wagmi/core",
|
|
3
3
|
"description": "Vanilla JS library for Ethereum",
|
|
4
4
|
"license": "WAGMIT",
|
|
5
|
-
"version": "0.2.0-next.
|
|
5
|
+
"version": "0.2.0-next.15",
|
|
6
6
|
"author": "awkweb.eth",
|
|
7
7
|
"ethereum": "awkweb.eth",
|
|
8
8
|
"repository": "tmm/wagmi",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"eventemitter3": "^4.0.7",
|
|
60
|
-
"zustand": "^
|
|
60
|
+
"zustand": "^4.0.0-rc.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@coinbase/wallet-sdk": "^3.0.1",
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { FetchEnsAddressArgs, FetchEnsAddressResult } from './fetchEnsAddress';
|
|
2
|
-
export declare type WatchEnsAddressCallback = (address: FetchEnsAddressResult) => void;
|
|
3
|
-
export declare function watchEnsAddress(args: FetchEnsAddressArgs, callback: WatchEnsAddressCallback): () => void;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { FetchEnsAvatarArgs, FetchEnsAvatarResult } from './fetchEnsAvatar';
|
|
2
|
-
export declare type WatchEnsAvatarCallback = (addressOrName: FetchEnsAvatarResult) => void;
|
|
3
|
-
export declare function watchEnsAvatar(args: FetchEnsAvatarArgs, callback: WatchEnsAvatarCallback): () => void;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { FetchEnsResolverArgs, FetchEnsResolverResult } from './fetchEnsResolver';
|
|
2
|
-
export declare type WatchEnsResolverCallback = (resolver: FetchEnsResolverResult) => void;
|
|
3
|
-
export declare function watchEnsResolver(args: FetchEnsResolverArgs, callback: WatchEnsResolverCallback): () => void;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { FetchFeeDataArgs, FetchFeeDataResult } from './fetchFeeData';
|
|
2
|
-
export declare type WatchFeeDataArgs = FetchFeeDataArgs & {
|
|
3
|
-
/** Watch for changes to block number */
|
|
4
|
-
listenToBlock?: boolean;
|
|
5
|
-
};
|
|
6
|
-
export declare type WatchFeeDataCallback = (feeData: FetchFeeDataResult) => void;
|
|
7
|
-
export declare function watchFeeData(args: WatchFeeDataArgs, callback: WatchFeeDataCallback): () => void;
|