wagmi 0.2.13 ā 0.2.14
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/injected/dist/wagmi-connectors-injected.cjs.dev.js +2 -2
- package/connectors/injected/dist/wagmi-connectors-injected.cjs.prod.js +2 -2
- package/connectors/injected/dist/wagmi-connectors-injected.esm.js +1 -1
- package/connectors/walletConnect/dist/wagmi-connectors-walletConnect.cjs.dev.js +1 -1
- package/connectors/walletConnect/dist/wagmi-connectors-walletConnect.cjs.prod.js +1 -1
- package/connectors/walletConnect/dist/wagmi-connectors-walletConnect.esm.js +1 -1
- package/connectors/walletLink/dist/wagmi-connectors-walletLink.cjs.dev.js +1 -1
- package/connectors/walletLink/dist/wagmi-connectors-walletLink.cjs.prod.js +1 -1
- package/connectors/walletLink/dist/wagmi-connectors-walletLink.esm.js +1 -1
- package/dist/declarations/src/connectors/injected.d.ts +1 -1
- package/dist/declarations/src/connectors/walletConnect.d.ts +1 -1
- package/dist/declarations/src/connectors/walletLink.d.ts +1 -1
- package/dist/declarations/src/context.d.ts +1 -1
- package/dist/declarations/src/hooks/accounts/useAccount.d.ts +1 -1
- package/dist/declarations/src/hooks/accounts/useBalance.d.ts +1 -1
- package/dist/declarations/src/hooks/accounts/useConnect.d.ts +1 -1
- package/dist/declarations/src/hooks/accounts/useNetwork.d.ts +1 -1
- package/dist/declarations/src/hooks/contracts/useToken.d.ts +1 -1
- package/dist/declarations/src/hooks/network-status/useFeeData.d.ts +1 -1
- package/dist/declarations/src/index.d.ts +2 -2
- package/dist/wagmi.cjs.dev.js +31 -31
- package/dist/wagmi.cjs.prod.js +31 -31
- package/dist/wagmi.esm.js +2 -2
- package/package.json +4 -4
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var core = require('@wagmi/core');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
Object.defineProperty(exports, 'InjectedConnector', {
|
|
10
10
|
enumerable: true,
|
|
11
|
-
get: function () { return
|
|
11
|
+
get: function () { return core.InjectedConnector; }
|
|
12
12
|
});
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var core = require('@wagmi/core');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
Object.defineProperty(exports, 'InjectedConnector', {
|
|
10
10
|
enumerable: true,
|
|
11
|
-
get: function () { return
|
|
11
|
+
get: function () { return core.InjectedConnector; }
|
|
12
12
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { InjectedConnector } from 'wagmi
|
|
1
|
+
export { InjectedConnector } from '@wagmi/core';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { WalletConnectConnector } from 'wagmi
|
|
1
|
+
export { WalletConnectConnector } from '@wagmi/core/connectors/walletConnect';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { WalletLinkConnector } from 'wagmi
|
|
1
|
+
export { WalletLinkConnector } from '@wagmi/core/connectors/walletLink';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { InjectedConnector } from 'wagmi
|
|
1
|
+
export { InjectedConnector } from '@wagmi/core';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { WalletConnectConnector } from 'wagmi
|
|
1
|
+
export { WalletConnectConnector } from '@wagmi/core/connectors/walletConnect';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { WalletLinkConnector } from 'wagmi
|
|
1
|
+
export { WalletLinkConnector } from '@wagmi/core/connectors/walletLink';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { BaseProvider, Web3Provider, WebSocketProvider } from '@ethersproject/providers';
|
|
3
|
-
import { Connector, ConnectorData } from 'wagmi
|
|
3
|
+
import { Connector, ConnectorData } from '@wagmi/core';
|
|
4
4
|
declare type State = {
|
|
5
5
|
cacheBuster: number;
|
|
6
6
|
connecting?: boolean;
|
|
@@ -5,7 +5,7 @@ export declare type Config = {
|
|
|
5
5
|
export declare const useAccount: ({ fetchEns }?: Config) => readonly [{
|
|
6
6
|
readonly data: {
|
|
7
7
|
address: string;
|
|
8
|
-
connector: import("wagmi
|
|
8
|
+
connector: import("@wagmi/core").Connector<any, any> | undefined;
|
|
9
9
|
ens: {
|
|
10
10
|
avatar: string | null | undefined;
|
|
11
11
|
name: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { Provider, Provider as WagmiProvider, useContext, Context, } from './context';
|
|
2
2
|
export type { Props as ProviderProps, Props as WagmiProviderProps, } from './context';
|
|
3
3
|
export { useAccount, useBalance, useBlockNumber, useConnect, useContract, useContractEvent, useContractRead, useContractWrite, useEnsAvatar, useEnsLookup, useEnsResolveName, useEnsResolver, useFeeData, useNetwork, useProvider, useSigner, useSignMessage, useToken, useTransaction, useWaitForTransaction, useWebSocketProvider, } from './hooks';
|
|
4
|
-
export { Connector, InjectedConnector, chain, allChains, defaultChains, defaultL2Chains, developmentChains, erc1155ABI, erc20ABI, erc721ABI, normalizeChainId, AddChainError, ChainNotConfiguredError, ConnectorAlreadyConnectedError, ConnectorNotFoundError, SwitchChainError, UserRejectedRequestError, } from 'wagmi
|
|
5
|
-
export type { Chain, ConnectorData } from 'wagmi
|
|
4
|
+
export { Connector, InjectedConnector, chain, allChains, defaultChains, defaultL2Chains, developmentChains, erc1155ABI, erc20ABI, erc721ABI, normalizeChainId, AddChainError, ChainNotConfiguredError, ConnectorAlreadyConnectedError, ConnectorNotFoundError, SwitchChainError, UserRejectedRequestError, } from '@wagmi/core';
|
|
5
|
+
export type { Chain, ConnectorData } from '@wagmi/core';
|
package/dist/wagmi.cjs.dev.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var providers = require('@ethersproject/providers');
|
|
7
|
-
var
|
|
7
|
+
var core = require('@wagmi/core');
|
|
8
8
|
var ethers = require('ethers');
|
|
9
9
|
|
|
10
10
|
function _interopNamespace(e) {
|
|
@@ -771,7 +771,7 @@ var useBalance = function useBalance() {
|
|
|
771
771
|
var balance;
|
|
772
772
|
|
|
773
773
|
if (config_.token) {
|
|
774
|
-
var contract = new ethers.ethers.Contract(config_.token,
|
|
774
|
+
var contract = new ethers.ethers.Contract(config_.token, core.erc20ABI, provider);
|
|
775
775
|
var [value, decimals, symbol] = yield Promise.all([contract.balanceOf(config_.addressOrName), contract.decimals(), contract.symbol()]);
|
|
776
776
|
balance = {
|
|
777
777
|
decimals,
|
|
@@ -784,7 +784,7 @@ var useBalance = function useBalance() {
|
|
|
784
784
|
|
|
785
785
|
var _value = yield provider.getBalance(config_.addressOrName);
|
|
786
786
|
|
|
787
|
-
var chain = [...((_connector$chains = connector === null || connector === void 0 ? void 0 : connector.chains) !== null && _connector$chains !== void 0 ? _connector$chains : []), ...
|
|
787
|
+
var chain = [...((_connector$chains = connector === null || connector === void 0 ? void 0 : connector.chains) !== null && _connector$chains !== void 0 ? _connector$chains : []), ...core.defaultChains, ...core.defaultL2Chains].find(x => x.id === provider.network.chainId);
|
|
788
788
|
balance = {
|
|
789
789
|
decimals: (_chain$nativeCurrency = chain === null || chain === void 0 ? void 0 : (_chain$nativeCurrency2 = chain.nativeCurrency) === null || _chain$nativeCurrency2 === void 0 ? void 0 : _chain$nativeCurrency2.decimals) !== null && _chain$nativeCurrency !== void 0 ? _chain$nativeCurrency : 18,
|
|
790
790
|
formatted: ethers.utils.formatUnits(_value, formatUnits_),
|
|
@@ -882,7 +882,7 @@ var useConnect = () => {
|
|
|
882
882
|
|
|
883
883
|
try {
|
|
884
884
|
var activeConnector = globalState === null || globalState === void 0 ? void 0 : globalState.connector;
|
|
885
|
-
if (connector === activeConnector) throw new
|
|
885
|
+
if (connector === activeConnector) throw new core.ConnectorAlreadyConnectedError();
|
|
886
886
|
setState(x => _objectSpread2(_objectSpread2({}, x), {}, {
|
|
887
887
|
loading: true,
|
|
888
888
|
connector,
|
|
@@ -963,7 +963,7 @@ var useNetwork = () => {
|
|
|
963
963
|
var chainId = data === null || data === void 0 ? void 0 : (_data$chain = data.chain) === null || _data$chain === void 0 ? void 0 : _data$chain.id;
|
|
964
964
|
var unsupported = data === null || data === void 0 ? void 0 : (_data$chain2 = data.chain) === null || _data$chain2 === void 0 ? void 0 : _data$chain2.unsupported;
|
|
965
965
|
var activeChains = (_connector$chains = connector === null || connector === void 0 ? void 0 : connector.chains) !== null && _connector$chains !== void 0 ? _connector$chains : [];
|
|
966
|
-
var activeChain = [...activeChains, ...
|
|
966
|
+
var activeChain = [...activeChains, ...core.allChains].find(x => x.id === chainId);
|
|
967
967
|
var cancelQuery = useCancel();
|
|
968
968
|
var switchNetwork = React__namespace.useCallback( /*#__PURE__*/function () {
|
|
969
969
|
var _ref = _asyncToGenerator(function* (chainId) {
|
|
@@ -973,7 +973,7 @@ var useNetwork = () => {
|
|
|
973
973
|
});
|
|
974
974
|
if (!(connector !== null && connector !== void 0 && connector.switchChain)) return {
|
|
975
975
|
data: undefined,
|
|
976
|
-
error: new
|
|
976
|
+
error: new core.SwitchChainError()
|
|
977
977
|
};
|
|
978
978
|
|
|
979
979
|
try {
|
|
@@ -1115,7 +1115,7 @@ var useSignMessage = function useSignMessage() {
|
|
|
1115
1115
|
message
|
|
1116
1116
|
};
|
|
1117
1117
|
if (!config_.message) throw new Error('message is required');
|
|
1118
|
-
if (!connector) throw new
|
|
1118
|
+
if (!connector) throw new core.ConnectorNotFoundError();
|
|
1119
1119
|
setState(x => _objectSpread2(_objectSpread2({}, x), {}, {
|
|
1120
1120
|
error: undefined,
|
|
1121
1121
|
loading: true
|
|
@@ -1136,7 +1136,7 @@ var useSignMessage = function useSignMessage() {
|
|
|
1136
1136
|
};
|
|
1137
1137
|
} catch (error_) {
|
|
1138
1138
|
var error = error_;
|
|
1139
|
-
if (error_.code === 4001) error = new
|
|
1139
|
+
if (error_.code === 4001) error = new core.UserRejectedRequestError();
|
|
1140
1140
|
|
|
1141
1141
|
if (!didCancel) {
|
|
1142
1142
|
setState(x => _objectSpread2(_objectSpread2({}, x), {}, {
|
|
@@ -1347,7 +1347,7 @@ var useContractWrite = function useContractWrite(contractConfig, functionName) {
|
|
|
1347
1347
|
args,
|
|
1348
1348
|
overrides
|
|
1349
1349
|
};
|
|
1350
|
-
if (!connector) throw new
|
|
1350
|
+
if (!connector) throw new core.ConnectorNotFoundError();
|
|
1351
1351
|
var params = [...(Array.isArray(config_.args) ? config_.args : config_.args ? [config_.args] : []), ...(config_.overrides ? [config_.overrides] : [])];
|
|
1352
1352
|
setState(x => _objectSpread2(_objectSpread2({}, x), {}, {
|
|
1353
1353
|
error: undefined,
|
|
@@ -1371,7 +1371,7 @@ var useContractWrite = function useContractWrite(contractConfig, functionName) {
|
|
|
1371
1371
|
};
|
|
1372
1372
|
} catch (error_) {
|
|
1373
1373
|
var error = error_;
|
|
1374
|
-
if (error_.code === 4001) error = new
|
|
1374
|
+
if (error_.code === 4001) error = new core.UserRejectedRequestError();
|
|
1375
1375
|
|
|
1376
1376
|
if (!didCancel) {
|
|
1377
1377
|
setState(x => _objectSpread2(_objectSpread2({}, x), {}, {
|
|
@@ -1430,7 +1430,7 @@ var useToken = function useToken() {
|
|
|
1430
1430
|
formatUnits
|
|
1431
1431
|
};
|
|
1432
1432
|
if (!config_.address) throw new Error('address is required');
|
|
1433
|
-
var contract = new ethers.ethers.Contract(config_.address,
|
|
1433
|
+
var contract = new ethers.ethers.Contract(config_.address, core.erc20ABI, provider);
|
|
1434
1434
|
var formatUnits_ = (_config_$formatUnits = config_.formatUnits) !== null && _config_$formatUnits !== void 0 ? _config_$formatUnits : 'ether';
|
|
1435
1435
|
setState(x => _objectSpread2(_objectSpread2({}, x), {}, {
|
|
1436
1436
|
error: undefined,
|
|
@@ -1542,7 +1542,7 @@ var useTransaction = function useTransaction() {
|
|
|
1542
1542
|
request
|
|
1543
1543
|
};
|
|
1544
1544
|
if (!config_.request) throw new Error('request is required');
|
|
1545
|
-
if (!connector) throw new
|
|
1545
|
+
if (!connector) throw new core.ConnectorNotFoundError();
|
|
1546
1546
|
setState(x => _objectSpread2(_objectSpread2({}, x), {}, {
|
|
1547
1547
|
loading: true
|
|
1548
1548
|
}));
|
|
@@ -1562,7 +1562,7 @@ var useTransaction = function useTransaction() {
|
|
|
1562
1562
|
};
|
|
1563
1563
|
} catch (error_) {
|
|
1564
1564
|
var error = error_;
|
|
1565
|
-
if (error_.code === 4001) error = new
|
|
1565
|
+
if (error_.code === 4001) error = new core.UserRejectedRequestError();
|
|
1566
1566
|
|
|
1567
1567
|
if (!didCancel) {
|
|
1568
1568
|
setState(x => _objectSpread2(_objectSpread2({}, x), {}, {
|
|
@@ -1691,7 +1691,7 @@ var Provider = _ref => {
|
|
|
1691
1691
|
var {
|
|
1692
1692
|
autoConnect = false,
|
|
1693
1693
|
children,
|
|
1694
|
-
connectors: connectors_ = [new
|
|
1694
|
+
connectors: connectors_ = [new core.InjectedConnector()],
|
|
1695
1695
|
connectorStorageKey = 'wagmi.wallet',
|
|
1696
1696
|
provider: provider_ = providers.getDefaultProvider(),
|
|
1697
1697
|
webSocketProvider: webSocketProvider_
|
|
@@ -1825,71 +1825,71 @@ var useContext = () => {
|
|
|
1825
1825
|
|
|
1826
1826
|
Object.defineProperty(exports, 'AddChainError', {
|
|
1827
1827
|
enumerable: true,
|
|
1828
|
-
get: function () { return
|
|
1828
|
+
get: function () { return core.AddChainError; }
|
|
1829
1829
|
});
|
|
1830
1830
|
Object.defineProperty(exports, 'ChainNotConfiguredError', {
|
|
1831
1831
|
enumerable: true,
|
|
1832
|
-
get: function () { return
|
|
1832
|
+
get: function () { return core.ChainNotConfiguredError; }
|
|
1833
1833
|
});
|
|
1834
1834
|
Object.defineProperty(exports, 'Connector', {
|
|
1835
1835
|
enumerable: true,
|
|
1836
|
-
get: function () { return
|
|
1836
|
+
get: function () { return core.Connector; }
|
|
1837
1837
|
});
|
|
1838
1838
|
Object.defineProperty(exports, 'ConnectorAlreadyConnectedError', {
|
|
1839
1839
|
enumerable: true,
|
|
1840
|
-
get: function () { return
|
|
1840
|
+
get: function () { return core.ConnectorAlreadyConnectedError; }
|
|
1841
1841
|
});
|
|
1842
1842
|
Object.defineProperty(exports, 'ConnectorNotFoundError', {
|
|
1843
1843
|
enumerable: true,
|
|
1844
|
-
get: function () { return
|
|
1844
|
+
get: function () { return core.ConnectorNotFoundError; }
|
|
1845
1845
|
});
|
|
1846
1846
|
Object.defineProperty(exports, 'InjectedConnector', {
|
|
1847
1847
|
enumerable: true,
|
|
1848
|
-
get: function () { return
|
|
1848
|
+
get: function () { return core.InjectedConnector; }
|
|
1849
1849
|
});
|
|
1850
1850
|
Object.defineProperty(exports, 'SwitchChainError', {
|
|
1851
1851
|
enumerable: true,
|
|
1852
|
-
get: function () { return
|
|
1852
|
+
get: function () { return core.SwitchChainError; }
|
|
1853
1853
|
});
|
|
1854
1854
|
Object.defineProperty(exports, 'UserRejectedRequestError', {
|
|
1855
1855
|
enumerable: true,
|
|
1856
|
-
get: function () { return
|
|
1856
|
+
get: function () { return core.UserRejectedRequestError; }
|
|
1857
1857
|
});
|
|
1858
1858
|
Object.defineProperty(exports, 'allChains', {
|
|
1859
1859
|
enumerable: true,
|
|
1860
|
-
get: function () { return
|
|
1860
|
+
get: function () { return core.allChains; }
|
|
1861
1861
|
});
|
|
1862
1862
|
Object.defineProperty(exports, 'chain', {
|
|
1863
1863
|
enumerable: true,
|
|
1864
|
-
get: function () { return
|
|
1864
|
+
get: function () { return core.chain; }
|
|
1865
1865
|
});
|
|
1866
1866
|
Object.defineProperty(exports, 'defaultChains', {
|
|
1867
1867
|
enumerable: true,
|
|
1868
|
-
get: function () { return
|
|
1868
|
+
get: function () { return core.defaultChains; }
|
|
1869
1869
|
});
|
|
1870
1870
|
Object.defineProperty(exports, 'defaultL2Chains', {
|
|
1871
1871
|
enumerable: true,
|
|
1872
|
-
get: function () { return
|
|
1872
|
+
get: function () { return core.defaultL2Chains; }
|
|
1873
1873
|
});
|
|
1874
1874
|
Object.defineProperty(exports, 'developmentChains', {
|
|
1875
1875
|
enumerable: true,
|
|
1876
|
-
get: function () { return
|
|
1876
|
+
get: function () { return core.developmentChains; }
|
|
1877
1877
|
});
|
|
1878
1878
|
Object.defineProperty(exports, 'erc1155ABI', {
|
|
1879
1879
|
enumerable: true,
|
|
1880
|
-
get: function () { return
|
|
1880
|
+
get: function () { return core.erc1155ABI; }
|
|
1881
1881
|
});
|
|
1882
1882
|
Object.defineProperty(exports, 'erc20ABI', {
|
|
1883
1883
|
enumerable: true,
|
|
1884
|
-
get: function () { return
|
|
1884
|
+
get: function () { return core.erc20ABI; }
|
|
1885
1885
|
});
|
|
1886
1886
|
Object.defineProperty(exports, 'erc721ABI', {
|
|
1887
1887
|
enumerable: true,
|
|
1888
|
-
get: function () { return
|
|
1888
|
+
get: function () { return core.erc721ABI; }
|
|
1889
1889
|
});
|
|
1890
1890
|
Object.defineProperty(exports, 'normalizeChainId', {
|
|
1891
1891
|
enumerable: true,
|
|
1892
|
-
get: function () { return
|
|
1892
|
+
get: function () { return core.normalizeChainId; }
|
|
1893
1893
|
});
|
|
1894
1894
|
exports.Context = Context;
|
|
1895
1895
|
exports.Provider = Provider;
|
package/dist/wagmi.cjs.prod.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var providers = require('@ethersproject/providers');
|
|
7
|
-
var
|
|
7
|
+
var core = require('@wagmi/core');
|
|
8
8
|
var ethers = require('ethers');
|
|
9
9
|
|
|
10
10
|
function _interopNamespace(e) {
|
|
@@ -771,7 +771,7 @@ var useBalance = function useBalance() {
|
|
|
771
771
|
var balance;
|
|
772
772
|
|
|
773
773
|
if (config_.token) {
|
|
774
|
-
var contract = new ethers.ethers.Contract(config_.token,
|
|
774
|
+
var contract = new ethers.ethers.Contract(config_.token, core.erc20ABI, provider);
|
|
775
775
|
var [value, decimals, symbol] = yield Promise.all([contract.balanceOf(config_.addressOrName), contract.decimals(), contract.symbol()]);
|
|
776
776
|
balance = {
|
|
777
777
|
decimals,
|
|
@@ -784,7 +784,7 @@ var useBalance = function useBalance() {
|
|
|
784
784
|
|
|
785
785
|
var _value = yield provider.getBalance(config_.addressOrName);
|
|
786
786
|
|
|
787
|
-
var chain = [...((_connector$chains = connector === null || connector === void 0 ? void 0 : connector.chains) !== null && _connector$chains !== void 0 ? _connector$chains : []), ...
|
|
787
|
+
var chain = [...((_connector$chains = connector === null || connector === void 0 ? void 0 : connector.chains) !== null && _connector$chains !== void 0 ? _connector$chains : []), ...core.defaultChains, ...core.defaultL2Chains].find(x => x.id === provider.network.chainId);
|
|
788
788
|
balance = {
|
|
789
789
|
decimals: (_chain$nativeCurrency = chain === null || chain === void 0 ? void 0 : (_chain$nativeCurrency2 = chain.nativeCurrency) === null || _chain$nativeCurrency2 === void 0 ? void 0 : _chain$nativeCurrency2.decimals) !== null && _chain$nativeCurrency !== void 0 ? _chain$nativeCurrency : 18,
|
|
790
790
|
formatted: ethers.utils.formatUnits(_value, formatUnits_),
|
|
@@ -882,7 +882,7 @@ var useConnect = () => {
|
|
|
882
882
|
|
|
883
883
|
try {
|
|
884
884
|
var activeConnector = globalState === null || globalState === void 0 ? void 0 : globalState.connector;
|
|
885
|
-
if (connector === activeConnector) throw new
|
|
885
|
+
if (connector === activeConnector) throw new core.ConnectorAlreadyConnectedError();
|
|
886
886
|
setState(x => _objectSpread2(_objectSpread2({}, x), {}, {
|
|
887
887
|
loading: true,
|
|
888
888
|
connector,
|
|
@@ -963,7 +963,7 @@ var useNetwork = () => {
|
|
|
963
963
|
var chainId = data === null || data === void 0 ? void 0 : (_data$chain = data.chain) === null || _data$chain === void 0 ? void 0 : _data$chain.id;
|
|
964
964
|
var unsupported = data === null || data === void 0 ? void 0 : (_data$chain2 = data.chain) === null || _data$chain2 === void 0 ? void 0 : _data$chain2.unsupported;
|
|
965
965
|
var activeChains = (_connector$chains = connector === null || connector === void 0 ? void 0 : connector.chains) !== null && _connector$chains !== void 0 ? _connector$chains : [];
|
|
966
|
-
var activeChain = [...activeChains, ...
|
|
966
|
+
var activeChain = [...activeChains, ...core.allChains].find(x => x.id === chainId);
|
|
967
967
|
var cancelQuery = useCancel();
|
|
968
968
|
var switchNetwork = React__namespace.useCallback( /*#__PURE__*/function () {
|
|
969
969
|
var _ref = _asyncToGenerator(function* (chainId) {
|
|
@@ -973,7 +973,7 @@ var useNetwork = () => {
|
|
|
973
973
|
});
|
|
974
974
|
if (!(connector !== null && connector !== void 0 && connector.switchChain)) return {
|
|
975
975
|
data: undefined,
|
|
976
|
-
error: new
|
|
976
|
+
error: new core.SwitchChainError()
|
|
977
977
|
};
|
|
978
978
|
|
|
979
979
|
try {
|
|
@@ -1115,7 +1115,7 @@ var useSignMessage = function useSignMessage() {
|
|
|
1115
1115
|
message
|
|
1116
1116
|
};
|
|
1117
1117
|
if (!config_.message) throw new Error('message is required');
|
|
1118
|
-
if (!connector) throw new
|
|
1118
|
+
if (!connector) throw new core.ConnectorNotFoundError();
|
|
1119
1119
|
setState(x => _objectSpread2(_objectSpread2({}, x), {}, {
|
|
1120
1120
|
error: undefined,
|
|
1121
1121
|
loading: true
|
|
@@ -1136,7 +1136,7 @@ var useSignMessage = function useSignMessage() {
|
|
|
1136
1136
|
};
|
|
1137
1137
|
} catch (error_) {
|
|
1138
1138
|
var error = error_;
|
|
1139
|
-
if (error_.code === 4001) error = new
|
|
1139
|
+
if (error_.code === 4001) error = new core.UserRejectedRequestError();
|
|
1140
1140
|
|
|
1141
1141
|
if (!didCancel) {
|
|
1142
1142
|
setState(x => _objectSpread2(_objectSpread2({}, x), {}, {
|
|
@@ -1347,7 +1347,7 @@ var useContractWrite = function useContractWrite(contractConfig, functionName) {
|
|
|
1347
1347
|
args,
|
|
1348
1348
|
overrides
|
|
1349
1349
|
};
|
|
1350
|
-
if (!connector) throw new
|
|
1350
|
+
if (!connector) throw new core.ConnectorNotFoundError();
|
|
1351
1351
|
var params = [...(Array.isArray(config_.args) ? config_.args : config_.args ? [config_.args] : []), ...(config_.overrides ? [config_.overrides] : [])];
|
|
1352
1352
|
setState(x => _objectSpread2(_objectSpread2({}, x), {}, {
|
|
1353
1353
|
error: undefined,
|
|
@@ -1371,7 +1371,7 @@ var useContractWrite = function useContractWrite(contractConfig, functionName) {
|
|
|
1371
1371
|
};
|
|
1372
1372
|
} catch (error_) {
|
|
1373
1373
|
var error = error_;
|
|
1374
|
-
if (error_.code === 4001) error = new
|
|
1374
|
+
if (error_.code === 4001) error = new core.UserRejectedRequestError();
|
|
1375
1375
|
|
|
1376
1376
|
if (!didCancel) {
|
|
1377
1377
|
setState(x => _objectSpread2(_objectSpread2({}, x), {}, {
|
|
@@ -1430,7 +1430,7 @@ var useToken = function useToken() {
|
|
|
1430
1430
|
formatUnits
|
|
1431
1431
|
};
|
|
1432
1432
|
if (!config_.address) throw new Error('address is required');
|
|
1433
|
-
var contract = new ethers.ethers.Contract(config_.address,
|
|
1433
|
+
var contract = new ethers.ethers.Contract(config_.address, core.erc20ABI, provider);
|
|
1434
1434
|
var formatUnits_ = (_config_$formatUnits = config_.formatUnits) !== null && _config_$formatUnits !== void 0 ? _config_$formatUnits : 'ether';
|
|
1435
1435
|
setState(x => _objectSpread2(_objectSpread2({}, x), {}, {
|
|
1436
1436
|
error: undefined,
|
|
@@ -1542,7 +1542,7 @@ var useTransaction = function useTransaction() {
|
|
|
1542
1542
|
request
|
|
1543
1543
|
};
|
|
1544
1544
|
if (!config_.request) throw new Error('request is required');
|
|
1545
|
-
if (!connector) throw new
|
|
1545
|
+
if (!connector) throw new core.ConnectorNotFoundError();
|
|
1546
1546
|
setState(x => _objectSpread2(_objectSpread2({}, x), {}, {
|
|
1547
1547
|
loading: true
|
|
1548
1548
|
}));
|
|
@@ -1562,7 +1562,7 @@ var useTransaction = function useTransaction() {
|
|
|
1562
1562
|
};
|
|
1563
1563
|
} catch (error_) {
|
|
1564
1564
|
var error = error_;
|
|
1565
|
-
if (error_.code === 4001) error = new
|
|
1565
|
+
if (error_.code === 4001) error = new core.UserRejectedRequestError();
|
|
1566
1566
|
|
|
1567
1567
|
if (!didCancel) {
|
|
1568
1568
|
setState(x => _objectSpread2(_objectSpread2({}, x), {}, {
|
|
@@ -1691,7 +1691,7 @@ var Provider = _ref => {
|
|
|
1691
1691
|
var {
|
|
1692
1692
|
autoConnect = false,
|
|
1693
1693
|
children,
|
|
1694
|
-
connectors: connectors_ = [new
|
|
1694
|
+
connectors: connectors_ = [new core.InjectedConnector()],
|
|
1695
1695
|
connectorStorageKey = 'wagmi.wallet',
|
|
1696
1696
|
provider: provider_ = providers.getDefaultProvider(),
|
|
1697
1697
|
webSocketProvider: webSocketProvider_
|
|
@@ -1825,71 +1825,71 @@ var useContext = () => {
|
|
|
1825
1825
|
|
|
1826
1826
|
Object.defineProperty(exports, 'AddChainError', {
|
|
1827
1827
|
enumerable: true,
|
|
1828
|
-
get: function () { return
|
|
1828
|
+
get: function () { return core.AddChainError; }
|
|
1829
1829
|
});
|
|
1830
1830
|
Object.defineProperty(exports, 'ChainNotConfiguredError', {
|
|
1831
1831
|
enumerable: true,
|
|
1832
|
-
get: function () { return
|
|
1832
|
+
get: function () { return core.ChainNotConfiguredError; }
|
|
1833
1833
|
});
|
|
1834
1834
|
Object.defineProperty(exports, 'Connector', {
|
|
1835
1835
|
enumerable: true,
|
|
1836
|
-
get: function () { return
|
|
1836
|
+
get: function () { return core.Connector; }
|
|
1837
1837
|
});
|
|
1838
1838
|
Object.defineProperty(exports, 'ConnectorAlreadyConnectedError', {
|
|
1839
1839
|
enumerable: true,
|
|
1840
|
-
get: function () { return
|
|
1840
|
+
get: function () { return core.ConnectorAlreadyConnectedError; }
|
|
1841
1841
|
});
|
|
1842
1842
|
Object.defineProperty(exports, 'ConnectorNotFoundError', {
|
|
1843
1843
|
enumerable: true,
|
|
1844
|
-
get: function () { return
|
|
1844
|
+
get: function () { return core.ConnectorNotFoundError; }
|
|
1845
1845
|
});
|
|
1846
1846
|
Object.defineProperty(exports, 'InjectedConnector', {
|
|
1847
1847
|
enumerable: true,
|
|
1848
|
-
get: function () { return
|
|
1848
|
+
get: function () { return core.InjectedConnector; }
|
|
1849
1849
|
});
|
|
1850
1850
|
Object.defineProperty(exports, 'SwitchChainError', {
|
|
1851
1851
|
enumerable: true,
|
|
1852
|
-
get: function () { return
|
|
1852
|
+
get: function () { return core.SwitchChainError; }
|
|
1853
1853
|
});
|
|
1854
1854
|
Object.defineProperty(exports, 'UserRejectedRequestError', {
|
|
1855
1855
|
enumerable: true,
|
|
1856
|
-
get: function () { return
|
|
1856
|
+
get: function () { return core.UserRejectedRequestError; }
|
|
1857
1857
|
});
|
|
1858
1858
|
Object.defineProperty(exports, 'allChains', {
|
|
1859
1859
|
enumerable: true,
|
|
1860
|
-
get: function () { return
|
|
1860
|
+
get: function () { return core.allChains; }
|
|
1861
1861
|
});
|
|
1862
1862
|
Object.defineProperty(exports, 'chain', {
|
|
1863
1863
|
enumerable: true,
|
|
1864
|
-
get: function () { return
|
|
1864
|
+
get: function () { return core.chain; }
|
|
1865
1865
|
});
|
|
1866
1866
|
Object.defineProperty(exports, 'defaultChains', {
|
|
1867
1867
|
enumerable: true,
|
|
1868
|
-
get: function () { return
|
|
1868
|
+
get: function () { return core.defaultChains; }
|
|
1869
1869
|
});
|
|
1870
1870
|
Object.defineProperty(exports, 'defaultL2Chains', {
|
|
1871
1871
|
enumerable: true,
|
|
1872
|
-
get: function () { return
|
|
1872
|
+
get: function () { return core.defaultL2Chains; }
|
|
1873
1873
|
});
|
|
1874
1874
|
Object.defineProperty(exports, 'developmentChains', {
|
|
1875
1875
|
enumerable: true,
|
|
1876
|
-
get: function () { return
|
|
1876
|
+
get: function () { return core.developmentChains; }
|
|
1877
1877
|
});
|
|
1878
1878
|
Object.defineProperty(exports, 'erc1155ABI', {
|
|
1879
1879
|
enumerable: true,
|
|
1880
|
-
get: function () { return
|
|
1880
|
+
get: function () { return core.erc1155ABI; }
|
|
1881
1881
|
});
|
|
1882
1882
|
Object.defineProperty(exports, 'erc20ABI', {
|
|
1883
1883
|
enumerable: true,
|
|
1884
|
-
get: function () { return
|
|
1884
|
+
get: function () { return core.erc20ABI; }
|
|
1885
1885
|
});
|
|
1886
1886
|
Object.defineProperty(exports, 'erc721ABI', {
|
|
1887
1887
|
enumerable: true,
|
|
1888
|
-
get: function () { return
|
|
1888
|
+
get: function () { return core.erc721ABI; }
|
|
1889
1889
|
});
|
|
1890
1890
|
Object.defineProperty(exports, 'normalizeChainId', {
|
|
1891
1891
|
enumerable: true,
|
|
1892
|
-
get: function () { return
|
|
1892
|
+
get: function () { return core.normalizeChainId; }
|
|
1893
1893
|
});
|
|
1894
1894
|
exports.Context = Context;
|
|
1895
1895
|
exports.Provider = Provider;
|
package/dist/wagmi.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { getDefaultProvider } from '@ethersproject/providers';
|
|
3
|
-
import { erc20ABI, defaultChains, defaultL2Chains, ConnectorAlreadyConnectedError, allChains, SwitchChainError, ConnectorNotFoundError, UserRejectedRequestError, InjectedConnector } from 'wagmi
|
|
4
|
-
export { AddChainError, ChainNotConfiguredError, Connector, ConnectorAlreadyConnectedError, ConnectorNotFoundError, InjectedConnector, SwitchChainError, UserRejectedRequestError, allChains, chain, defaultChains, defaultL2Chains, developmentChains, erc1155ABI, erc20ABI, erc721ABI, normalizeChainId } from 'wagmi
|
|
3
|
+
import { erc20ABI, defaultChains, defaultL2Chains, ConnectorAlreadyConnectedError, allChains, SwitchChainError, ConnectorNotFoundError, UserRejectedRequestError, InjectedConnector } from '@wagmi/core';
|
|
4
|
+
export { AddChainError, ChainNotConfiguredError, Connector, ConnectorAlreadyConnectedError, ConnectorNotFoundError, InjectedConnector, SwitchChainError, UserRejectedRequestError, allChains, chain, defaultChains, defaultL2Chains, developmentChains, erc1155ABI, erc20ABI, erc721ABI, normalizeChainId } from '@wagmi/core';
|
|
5
5
|
import { utils, ethers, Contract } from 'ethers';
|
|
6
6
|
|
|
7
7
|
function _defineProperty(obj, key, value) {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "wagmi",
|
|
3
3
|
"description": "React Hooks library for Ethereum",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.2.
|
|
5
|
+
"version": "0.2.14",
|
|
6
6
|
"ethereum": "awkweb.eth",
|
|
7
7
|
"repository": "tmm/wagmi",
|
|
8
8
|
"homepage": "https://wagmi-xyz.vercel.app",
|
|
@@ -46,18 +46,18 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@ethersproject/providers": "^5.5.1",
|
|
49
|
+
"@wagmi/core": "0.1.10",
|
|
49
50
|
"@walletconnect/ethereum-provider": "1.7.1",
|
|
50
|
-
"wagmi-private": "0.1.9",
|
|
51
51
|
"walletlink": "^2.2.8"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@testing-library/react-hooks": "^7.0.2",
|
|
55
55
|
"@types/react": "^17.0.0",
|
|
56
|
+
"@wagmi/testing": "0.1.10",
|
|
56
57
|
"@walletconnect/ethereum-provider": "1.7.1",
|
|
57
58
|
"ethers": "^5.5.1",
|
|
58
59
|
"react": "^17.0.0",
|
|
59
|
-
"walletlink": "^2.2.8"
|
|
60
|
-
"wagmi-testing": "0.1.9"
|
|
60
|
+
"walletlink": "^2.2.8"
|
|
61
61
|
},
|
|
62
62
|
"readme": "<p>\n <a aria-label=\"Version\" href=\"https://www.npmjs.com/package/wagmi\">\n <img\n alt=\"\"\n src=\"https://img.shields.io/npm/v/wagmi.svg?style=for-the-badge&labelColor=161c22\"\n />\n </a>\n <a aria-label=\"License\" href=\"/LICENSE\">\n <img\n alt=\"\"\n src=\"https://img.shields.io/npm/l/wagmi.svg?style=for-the-badge&labelColor=161c22\"\n />\n </a>\n <a aria-label=\"Sponsors\" href=\"https://github.com/sponsors/tmm\">\n <img\n alt=\"\"\n src=\"https://img.shields.io/github/sponsors/tmm.svg?style=for-the-badge&labelColor=161c22\"\n />\n </a>\n <a aria-label=\"Downloads\" href=\"https://www.npmjs.com/package/wagmi\">\n <img\n alt=\"\"\n src=\"https://img.shields.io/npm/dm/wagmi.svg?style=for-the-badge&labelColor=161c22\"\n />\n </a>\n</p>\n\n# wagmi\n\n**React Hooks library for Ethereum, built on [ethers.js](https://github.com/ethers-io/ethers.js).**\n\nš 20+ hooks for working with wallets, ENS, contracts, transactions, signing, etc.\n\nš¼ Built-in wallet connectors for MetaMask, WalletConnect, and Coinbase Wallet\n\nš Auto-refresh data on wallet and network changes\n\nš¦ TypeScript ready\n\nšØ Zero-dependencies (besides ethers.js peer dependency)\n\nš³ Test suite and documentation\n\nš MIT License\n\n## Documentation\n\nVisit https://wagmi-xyz.vercel.app to view the full documentation.\n\n## Usage\n\n1. Install the dependencies.\n\n```bash\nnpm add wagmi ethers\n```\n\n2. Wrap your app with the `Provider` component.\n\n```tsx\nimport { Provider } from 'wagmi'\n\nconst App = () => (\n <Provider>\n <YourRoutes />\n </Provider>\n)\n```\n\n3. Use hooks.\n\n```tsx\nimport { useAccount } from 'wagmi'\n\nconst Page = () => {\n const [{ data, error, loading }, disconnect] = useAccount({\n fetchEns: true,\n })\n\n return ...\n}\n```\n\nEvery component inside the `Provider` is set up with the default `InjectedConnector` for connecting wallets and ethers.js [Default Provider](https://docs.ethers.io/v5/api/providers/#providers-getDefaultProvider) for fetching data.\n\nWant to learn more? Check out the [guides](https://wagmi-xyz.vercel.app/guides/connect-wallet) or browse the [API docs](https://wagmi-xyz.vercel.app/docs/provider).\n\n## Community\n\nFeel free to join the [discussions on GitHub](https://github.com/tmm/wagmi/discussions) or reach out [on Twitter](https://twitter.com/awkweb)!\n\n## Support\n\n- awkweb.eth\n- [GitHub Sponsors](https://github.com/sponsors/tmm)\n- Sign the [guestbook](https://github.com/tmm/wagmi/discussions/2)\n\n## Thanks\n\n- [ricmoo.eth](https://twitter.com/ricmoo) for creating and continued work on [ethers.js](https://github.com/ethers-io/ethers.js)\n- [Mirror](https://mirror.xyz) for creating space to do good work\n\n## License\n\nMIT.\n\n<br />\n\nwagmi\n"
|
|
63
63
|
}
|