wagmi 0.3.0 → 0.3.3
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/LICENSE +1 -1
- package/README.md +2 -2
- package/connectors/metaMask/dist/wagmi-connectors-metaMask.cjs.d.ts +1 -0
- package/connectors/metaMask/dist/wagmi-connectors-metaMask.cjs.dev.js +12 -0
- package/connectors/metaMask/dist/wagmi-connectors-metaMask.cjs.js +7 -0
- package/connectors/metaMask/dist/wagmi-connectors-metaMask.cjs.prod.js +12 -0
- package/connectors/metaMask/dist/wagmi-connectors-metaMask.esm.js +1 -0
- package/connectors/metaMask/package.json +4 -0
- package/dist/declarations/src/connectors/metaMask.d.ts +1 -0
- package/dist/declarations/src/context.d.ts +8 -8
- package/dist/declarations/src/hooks/contracts/useContractRead.d.ts +2 -2
- package/dist/declarations/src/hooks/index.d.ts +1 -1
- package/dist/declarations/src/hooks/providers/useProvider.d.ts +2 -2
- package/dist/declarations/src/hooks/providers/useWebSocketProvider.d.ts +2 -2
- package/dist/declarations/src/index.d.ts +2 -1
- package/dist/declarations/src/utils/deserialize.d.ts +1 -1
- package/dist/declarations/src/utils/serialize.d.ts +16 -6
- package/dist/wagmi.cjs.dev.js +99 -116
- package/dist/wagmi.cjs.prod.js +99 -116
- package/dist/wagmi.esm.js +96 -116
- package/package.json +16 -11
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ npm install wagmi ethers
|
|
|
17
17
|
Check out the following places for more wagmi-related content:
|
|
18
18
|
|
|
19
19
|
- Join the [discussions on GitHub](https://github.com/tmm/wagmi/discussions)
|
|
20
|
-
- Follow [@awkweb](https://twitter.com/awkweb) on Twitter for project updates
|
|
20
|
+
- Follow [@awkweb](https://twitter.com/awkweb) and [@wagmi_sh](https://twitter.com/wagmi_sh) on Twitter for project updates
|
|
21
21
|
- Sign the [guestbook](https://github.com/tmm/wagmi/discussions/2)
|
|
22
22
|
- Share [your project/organization](https://github.com/tmm/wagmi/discussions/201) using wagmi
|
|
23
23
|
|
|
@@ -25,6 +25,6 @@ Check out the following places for more wagmi-related content:
|
|
|
25
25
|
|
|
26
26
|
If you find wagmi useful, please consider supporting development. Thank you 🙏
|
|
27
27
|
|
|
28
|
-
- [awkweb.eth](https://etherscan.io/enslookup-search?search=awkweb.eth)
|
|
29
28
|
- [GitHub Sponsors](https://github.com/sponsors/tmm?metadata_campaign=readme_wagmi)
|
|
30
29
|
- [Gitcoin Grant](https://gitcoin.co/grants/4493/wagmi-react-hooks-library-for-ethereum)
|
|
30
|
+
- [awkweb.eth](https://etherscan.io/enslookup-search?search=awkweb.eth)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../../dist/declarations/src/connectors/metaMask";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var metaMask = require('@wagmi/core/connectors/metaMask');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, 'MetaMaskConnector', {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return metaMask.MetaMaskConnector; }
|
|
12
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var metaMask = require('@wagmi/core/connectors/metaMask');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, 'MetaMaskConnector', {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return metaMask.MetaMaskConnector; }
|
|
12
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MetaMaskConnector } from '@wagmi/core/connectors/metaMask';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MetaMaskConnector } from '@wagmi/core/connectors/metaMask';
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { providers } from 'ethers';
|
|
3
3
|
import { WagmiClient, ClientConfig as WagmiClientConfig } from '@wagmi/core';
|
|
4
4
|
import { QueryClient } from 'react-query';
|
|
5
5
|
import { Persister } from 'react-query/persistQueryClient';
|
|
6
|
-
export declare type DecoratedWagmiClient<TProvider extends BaseProvider = BaseProvider, TWebSocketProvider extends WebSocketProvider = WebSocketProvider> = WagmiClient<TProvider, TWebSocketProvider> & {
|
|
6
|
+
export declare type DecoratedWagmiClient<TProvider extends providers.BaseProvider = providers.BaseProvider, TWebSocketProvider extends providers.WebSocketProvider = providers.WebSocketProvider> = WagmiClient<TProvider, TWebSocketProvider> & {
|
|
7
7
|
queryClient: QueryClient;
|
|
8
8
|
};
|
|
9
|
-
export declare const Context: React.Context<DecoratedWagmiClient<BaseProvider, WebSocketProvider> | undefined>;
|
|
10
|
-
export declare type ClientConfig<TProvider extends BaseProvider = BaseProvider, TWebSocketProvider extends WebSocketProvider = WebSocketProvider> = WagmiClientConfig<TProvider, TWebSocketProvider> & {
|
|
9
|
+
export declare const Context: React.Context<DecoratedWagmiClient<providers.BaseProvider, providers.WebSocketProvider> | undefined>;
|
|
10
|
+
export declare type ClientConfig<TProvider extends providers.BaseProvider = providers.BaseProvider, TWebSocketProvider extends providers.WebSocketProvider = providers.WebSocketProvider> = WagmiClientConfig<TProvider, TWebSocketProvider> & {
|
|
11
11
|
queryClient?: QueryClient;
|
|
12
12
|
persister?: Persister;
|
|
13
13
|
};
|
|
14
|
-
export declare function createClient<TProvider extends BaseProvider, TWebSocketProvider extends WebSocketProvider>({ queryClient, persister, ...config }?: ClientConfig<TProvider, TWebSocketProvider>): WagmiClient<TProvider, TWebSocketProvider> & {
|
|
14
|
+
export declare function createClient<TProvider extends providers.BaseProvider, TWebSocketProvider extends providers.WebSocketProvider>({ queryClient, persister, ...config }?: ClientConfig<TProvider, TWebSocketProvider>): WagmiClient<TProvider, TWebSocketProvider> & {
|
|
15
15
|
queryClient: QueryClient;
|
|
16
16
|
};
|
|
17
|
-
export declare type ProviderProps<TProvider extends BaseProvider = BaseProvider, TWebSocketProvider extends WebSocketProvider = WebSocketProvider> = {
|
|
17
|
+
export declare type ProviderProps<TProvider extends providers.BaseProvider = providers.BaseProvider, TWebSocketProvider extends providers.WebSocketProvider = providers.WebSocketProvider> = {
|
|
18
18
|
/** React-decorated WagmiClient instance */
|
|
19
19
|
client?: DecoratedWagmiClient<TProvider, TWebSocketProvider>;
|
|
20
20
|
};
|
|
21
|
-
export declare function Provider<TProvider extends BaseProvider, TWebSocketProvider extends WebSocketProvider>({ children, client, }: React.PropsWithChildren<ProviderProps<TProvider, TWebSocketProvider>>): JSX.Element;
|
|
22
|
-
export declare function useClient<TProvider extends BaseProvider, TWebSocketProvider extends WebSocketProvider = WebSocketProvider>(): DecoratedWagmiClient<TProvider, TWebSocketProvider>;
|
|
21
|
+
export declare function Provider<TProvider extends providers.BaseProvider, TWebSocketProvider extends providers.WebSocketProvider>({ children, client, }: React.PropsWithChildren<ProviderProps<TProvider, TWebSocketProvider>>): JSX.Element;
|
|
22
|
+
export declare function useClient<TProvider extends providers.BaseProvider, TWebSocketProvider extends providers.WebSocketProvider = providers.WebSocketProvider>(): DecoratedWagmiClient<TProvider, TWebSocketProvider>;
|
|
@@ -7,14 +7,14 @@ declare type UseContractReadArgs = Partial<ReadContractConfig> & {
|
|
|
7
7
|
watch?: boolean;
|
|
8
8
|
};
|
|
9
9
|
export declare type UseContractReadConfig = QueryConfig<ReadContractResult, Error>;
|
|
10
|
-
export declare const queryKey: ([contractConfig, functionName, { args, chainId, overrides }, { blockNumber },]: [
|
|
10
|
+
export declare const queryKey: ([contractConfig, functionName, { args, chainId, overrides }, { blockNumber },]: [ReadContractArgs, string, Partial<ReadContractConfig>, {
|
|
11
11
|
blockNumber?: number | undefined;
|
|
12
12
|
}]) => readonly [{
|
|
13
13
|
readonly entity: "readContract";
|
|
14
14
|
readonly args: any;
|
|
15
15
|
readonly blockNumber: number | undefined;
|
|
16
16
|
readonly chainId: number | undefined;
|
|
17
|
-
readonly contractConfig:
|
|
17
|
+
readonly contractConfig: ReadContractArgs;
|
|
18
18
|
readonly functionName: string;
|
|
19
19
|
readonly overrides: import("ethers").CallOverrides | undefined;
|
|
20
20
|
}];
|
|
@@ -4,4 +4,4 @@ export { useEnsAddress, useEnsAvatar, useEnsName, useEnsResolver } from './ens';
|
|
|
4
4
|
export { useBlockNumber, useFeeData } from './network-status';
|
|
5
5
|
export { useProvider, useWebSocketProvider } from './providers';
|
|
6
6
|
export { useSendTransaction, useWaitForTransaction } from './transactions';
|
|
7
|
-
export { useChainId } from './utils';
|
|
7
|
+
export { useChainId, useQuery } from './utils';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { providers } from 'ethers';
|
|
2
2
|
import { GetProviderArgs } from '@wagmi/core';
|
|
3
3
|
export declare type UseProviderArgs = Partial<GetProviderArgs>;
|
|
4
|
-
export declare function useProvider<TProvider extends BaseProvider>({ chainId, }?: UseProviderArgs): TProvider;
|
|
4
|
+
export declare function useProvider<TProvider extends providers.BaseProvider>({ chainId, }?: UseProviderArgs): TProvider;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { providers } from 'ethers';
|
|
2
2
|
import { GetWebSocketProviderArgs } from '@wagmi/core';
|
|
3
3
|
export declare type UseWebSocketProviderArgs = Partial<GetWebSocketProviderArgs>;
|
|
4
|
-
export declare function useWebSocketProvider<TWebSocketProvider extends WebSocketProvider>({ chainId }?: UseWebSocketProviderArgs): import("@wagmi/core").GetWebSocketProviderResult<TWebSocketProvider>;
|
|
4
|
+
export declare function useWebSocketProvider<TWebSocketProvider extends providers.WebSocketProvider>({ chainId }?: UseWebSocketProviderArgs): import("@wagmi/core").GetWebSocketProviderResult<TWebSocketProvider>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { createClient, createClient as createWagmiClient, Provider, Provider as WagmiProvider, useClient, useClient as useWagmiClient, } from './context';
|
|
2
2
|
export type { ClientConfig, ClientConfig as WagmiClientConfig, ProviderProps, ProviderProps as WagmiProviderProps, } from './context';
|
|
3
|
-
export { useAccount, useBalance, useBlockNumber, useConnect, useContract, useContractEvent, useContractRead, useContractWrite, useDisconnect, useEnsAddress, useEnsAvatar, useEnsName, useEnsResolver, useFeeData, useNetwork, useProvider, useSendTransaction, useSignMessage, useSignTypedData, useSigner, useToken, useWaitForTransaction, useWebSocketProvider, } from './hooks';
|
|
3
|
+
export { useAccount, useBalance, useBlockNumber, useConnect, useContract, useContractEvent, useContractRead, useContractWrite, useDisconnect, useEnsAddress, useEnsAvatar, useEnsName, useEnsResolver, useFeeData, useNetwork, useProvider, useQuery, useSendTransaction, useSignMessage, useSignTypedData, useSigner, useToken, useWaitForTransaction, useWebSocketProvider, } from './hooks';
|
|
4
|
+
export { deserialize, serialize } from './utils';
|
|
4
5
|
export { Client, Connector, WagmiClient, alchemyRpcUrls, allChains, chain, chainId, createStorage, createWagmiStorage, defaultChains, defaultL2Chains, erc20ABI, erc721ABI, etherscanBlockExplorers, infuraRpcUrls, } from '@wagmi/core';
|
|
5
6
|
export type { Chain, ConnectorData, ConnectorEvents, Storage, Unit, WagmiStorage, } from '@wagmi/core';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { PersistedClient } from 'react-query/
|
|
1
|
+
import { PersistedClient } from 'react-query/persistQueryClient';
|
|
2
2
|
export declare function deserialize(cachedString: string): PersistedClient;
|
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
declare type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
declare type StandardReplacer = (key: string, value: any) => any;
|
|
2
|
+
declare type CircularReplacer = (key: string, value: any, referenceKey: string) => any;
|
|
3
|
+
/**
|
|
4
|
+
* @function stringify
|
|
5
|
+
*
|
|
6
|
+
* @description
|
|
7
|
+
* strinigifer that handles circular values
|
|
8
|
+
* Forked from https://github.com/planttheidea/fast-stringify
|
|
9
|
+
*
|
|
10
|
+
* @param value to stringify
|
|
11
|
+
* @param [replacer] a custom replacer function for handling standard values
|
|
12
|
+
* @param [indent] the number of spaces to indent the output by
|
|
13
|
+
* @param [circularReplacer] a custom replacer function for handling circular values
|
|
14
|
+
* @returns the stringified output
|
|
15
|
+
*/
|
|
16
|
+
export declare function serialize(value: any, replacer?: StandardReplacer | null | undefined, indent?: number | null | undefined, circularReplacer?: CircularReplacer | null | undefined): string;
|
|
7
17
|
export {};
|
package/dist/wagmi.cjs.dev.js
CHANGED
|
@@ -8,7 +8,7 @@ var reactQuery = require('react-query');
|
|
|
8
8
|
var persistQueryClient = require('react-query/persistQueryClient');
|
|
9
9
|
var createWebStoragePersister = require('react-query/createWebStoragePersister');
|
|
10
10
|
var ethers = require('ethers/lib/ethers');
|
|
11
|
-
var
|
|
11
|
+
var index_js = require('use-sync-external-store/shim/index.js');
|
|
12
12
|
|
|
13
13
|
function _interopNamespace(e) {
|
|
14
14
|
if (e && e.__esModule) return e;
|
|
@@ -75,122 +75,105 @@ function deserialize(cachedString) {
|
|
|
75
75
|
return deserializedCacheWithBigNumbers;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
let res;
|
|
91
|
-
|
|
92
|
-
try {
|
|
93
|
-
if (replacerStack.length === 0) {
|
|
94
|
-
res = JSON.stringify(obj, replacer, spacer);
|
|
95
|
-
} else {
|
|
96
|
-
res = JSON.stringify(obj, replaceGetterValues(replacer), spacer);
|
|
97
|
-
}
|
|
98
|
-
} catch (_) {
|
|
99
|
-
return JSON.stringify('[unable to serialize, circular reference is too complex to analyze]');
|
|
100
|
-
} finally {
|
|
101
|
-
while (arr.length !== 0) {
|
|
102
|
-
const part = arr.pop();
|
|
103
|
-
|
|
104
|
-
if (part.length === 4) {
|
|
105
|
-
Object.defineProperty(part[0], part[1], part[3]);
|
|
106
|
-
} else {
|
|
107
|
-
part[0][part[1]] = part[2];
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return res;
|
|
78
|
+
/**
|
|
79
|
+
* @function getReferenceKey
|
|
80
|
+
*
|
|
81
|
+
* @description
|
|
82
|
+
* get the reference key for the circular value
|
|
83
|
+
*
|
|
84
|
+
* @param keys the keys to build the reference key from
|
|
85
|
+
* @param cutoff the maximum number of keys to include
|
|
86
|
+
* @returns the reference key
|
|
87
|
+
*/
|
|
88
|
+
function getReferenceKey(keys, cutoff) {
|
|
89
|
+
return keys.slice(0, cutoff).join('.') || '.';
|
|
113
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* @function getCutoff
|
|
93
|
+
*
|
|
94
|
+
* @description
|
|
95
|
+
* faster `Array.prototype.indexOf` implementation build for slicing / splicing
|
|
96
|
+
*
|
|
97
|
+
* @param array the array to match the value in
|
|
98
|
+
* @param value the value to match
|
|
99
|
+
* @returns the matching index, or -1
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
function getCutoff(array, value) {
|
|
104
|
+
const {
|
|
105
|
+
length
|
|
106
|
+
} = array;
|
|
114
107
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
if ((propertyDescriptor === null || propertyDescriptor === void 0 ? void 0 : propertyDescriptor.get) !== undefined) {
|
|
119
|
-
if (propertyDescriptor.configurable) {
|
|
120
|
-
Object.defineProperty(parent, k, {
|
|
121
|
-
value: replace
|
|
122
|
-
});
|
|
123
|
-
arr.push([parent, k, val, propertyDescriptor]);
|
|
124
|
-
} else {
|
|
125
|
-
replacerStack.push([val, k, replace]);
|
|
108
|
+
for (let index = 0; index < length; ++index) {
|
|
109
|
+
if (array[index] === value) {
|
|
110
|
+
return index + 1;
|
|
126
111
|
}
|
|
127
|
-
} else {
|
|
128
|
-
parent[k] = replace;
|
|
129
|
-
arr.push([parent, k, val]);
|
|
130
112
|
}
|
|
131
|
-
}
|
|
132
113
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
let i;
|
|
136
|
-
|
|
137
|
-
if (typeof val === 'object' && val !== null) {
|
|
138
|
-
for (i = 0; i < stack.length; i++) {
|
|
139
|
-
if (stack[i] === val) {
|
|
140
|
-
setReplace(CIRCULAR_REPLACE_NODE, val, k, parent);
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (typeof options.depthLimit !== 'undefined' && depth > options.depthLimit) {
|
|
146
|
-
setReplace(LIMIT_REPLACE_NODE, val, k, parent);
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
if (typeof options.edgesLimit !== 'undefined' && edgeIndex + 1 > options.edgesLimit) {
|
|
151
|
-
setReplace(LIMIT_REPLACE_NODE, val, k, parent);
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
stack.push(val); // Optimize for Arrays. Big arrays could kill the performance otherwise!
|
|
156
|
-
|
|
157
|
-
if (Array.isArray(val)) {
|
|
158
|
-
for (i = 0; i < val.length; i++) {
|
|
159
|
-
decirc(val[i], i, i, stack, val, depth, options);
|
|
160
|
-
}
|
|
161
|
-
} else {
|
|
162
|
-
const keys = Object.keys(val);
|
|
114
|
+
return 0;
|
|
115
|
+
}
|
|
163
116
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
117
|
+
/**
|
|
118
|
+
* @function createReplacer
|
|
119
|
+
*
|
|
120
|
+
* @description
|
|
121
|
+
* create a replacer method that handles circular values
|
|
122
|
+
*
|
|
123
|
+
* @param [replacer] a custom replacer to use for non-circular values
|
|
124
|
+
* @param [circularReplacer] a custom replacer to use for circular methods
|
|
125
|
+
* @returns the value to stringify
|
|
126
|
+
*/
|
|
127
|
+
function createReplacer(replacer, circularReplacer) {
|
|
128
|
+
const hasReplacer = typeof replacer === 'function';
|
|
129
|
+
const hasCircularReplacer = typeof circularReplacer === 'function';
|
|
130
|
+
const cache = [];
|
|
131
|
+
const keys = [];
|
|
132
|
+
return function replace(key, value) {
|
|
133
|
+
if (typeof value === 'object') {
|
|
134
|
+
if (cache.length) {
|
|
135
|
+
const thisCutoff = getCutoff(cache, this);
|
|
136
|
+
|
|
137
|
+
if (thisCutoff === 0) {
|
|
138
|
+
cache[cache.length] = this;
|
|
139
|
+
} else {
|
|
140
|
+
cache.splice(thisCutoff);
|
|
141
|
+
keys.splice(thisCutoff);
|
|
142
|
+
}
|
|
169
143
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
144
|
+
keys[keys.length] = key;
|
|
145
|
+
const valueCutoff = getCutoff(cache, value);
|
|
173
146
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
function replaceGetterValues() {
|
|
177
|
-
let replacer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : (_k, v) => v;
|
|
178
|
-
return (key, val) => {
|
|
179
|
-
if (replacerStack.length > 0) {
|
|
180
|
-
for (let i = 0; i < replacerStack.length; i++) {
|
|
181
|
-
const part = replacerStack[i];
|
|
182
|
-
|
|
183
|
-
if (part[1] === key && part[0] === val) {
|
|
184
|
-
val = part[2];
|
|
185
|
-
replacerStack.splice(i, 1);
|
|
186
|
-
break;
|
|
147
|
+
if (valueCutoff !== 0) {
|
|
148
|
+
return hasCircularReplacer ? circularReplacer.call(this, key, value, getReferenceKey(keys, valueCutoff)) : "[ref=".concat(getReferenceKey(keys, valueCutoff), "]");
|
|
187
149
|
}
|
|
150
|
+
} else {
|
|
151
|
+
cache[0] = value;
|
|
152
|
+
keys[0] = key;
|
|
188
153
|
}
|
|
189
154
|
}
|
|
190
155
|
|
|
191
|
-
return replacer.
|
|
156
|
+
return hasReplacer ? replacer.call(this, key, value) : value;
|
|
192
157
|
};
|
|
193
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* @function stringify
|
|
161
|
+
*
|
|
162
|
+
* @description
|
|
163
|
+
* strinigifer that handles circular values
|
|
164
|
+
* Forked from https://github.com/planttheidea/fast-stringify
|
|
165
|
+
*
|
|
166
|
+
* @param value to stringify
|
|
167
|
+
* @param [replacer] a custom replacer function for handling standard values
|
|
168
|
+
* @param [indent] the number of spaces to indent the output by
|
|
169
|
+
* @param [circularReplacer] a custom replacer function for handling circular values
|
|
170
|
+
* @returns the stringified output
|
|
171
|
+
*/
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
function serialize(value, replacer, indent, circularReplacer) {
|
|
175
|
+
return JSON.stringify(value, createReplacer(replacer, circularReplacer), indent !== null && indent !== void 0 ? indent : undefined);
|
|
176
|
+
}
|
|
194
177
|
|
|
195
178
|
const Context = /*#__PURE__*/React__namespace.createContext(undefined);
|
|
196
179
|
function createClient() {
|
|
@@ -198,7 +181,7 @@ function createClient() {
|
|
|
198
181
|
queryClient = new reactQuery.QueryClient({
|
|
199
182
|
defaultOptions: {
|
|
200
183
|
queries: {
|
|
201
|
-
cacheTime: 60 * 60 * 24,
|
|
184
|
+
cacheTime: 1000 * 60 * 60 * 24,
|
|
202
185
|
// 24 hours
|
|
203
186
|
networkMode: 'offlineFirst',
|
|
204
187
|
refetchOnWindowFocus: false,
|
|
@@ -379,7 +362,7 @@ function useQuery(queryKey, queryFn, options_) {
|
|
|
379
362
|
remove,
|
|
380
363
|
status: status_
|
|
381
364
|
} = observer.getOptimisticResult(defaultedOptions);
|
|
382
|
-
|
|
365
|
+
index_js.useSyncExternalStore(React__namespace.useCallback(onStoreChange => isRestoring ? () => undefined : observer.subscribe(reactQuery.notifyManager.batchCalls(onStoreChange)), [observer, isRestoring]), () => observer.getCurrentResult(), () => observer.getCurrentResult());
|
|
383
366
|
React__namespace.useEffect(() => {
|
|
384
367
|
errorResetBoundary.clearReset();
|
|
385
368
|
}, [errorResetBoundary]);
|
|
@@ -1230,11 +1213,7 @@ function useContractRead(contractConfig, functionName) {
|
|
|
1230
1213
|
}]), [args, blockNumber, cacheOnBlock, chainId, contractConfig, functionName, overrides]);
|
|
1231
1214
|
const enabled = React__namespace.useMemo(() => {
|
|
1232
1215
|
let enabled = Boolean(enabled_ && contractConfig && functionName);
|
|
1233
|
-
|
|
1234
|
-
if (cacheOnBlock) {
|
|
1235
|
-
enabled = Boolean(enabled && blockNumber);
|
|
1236
|
-
}
|
|
1237
|
-
|
|
1216
|
+
if (cacheOnBlock) enabled = Boolean(enabled && blockNumber);
|
|
1238
1217
|
return enabled;
|
|
1239
1218
|
}, [blockNumber, cacheOnBlock, contractConfig, enabled_, functionName]);
|
|
1240
1219
|
const client = reactQuery.useQueryClient();
|
|
@@ -1242,12 +1221,13 @@ function useContractRead(contractConfig, functionName) {
|
|
|
1242
1221
|
if (enabled) {
|
|
1243
1222
|
const unwatch = core.watchReadContract(contractConfig, functionName, {
|
|
1244
1223
|
args,
|
|
1224
|
+
chainId,
|
|
1245
1225
|
overrides,
|
|
1246
1226
|
listenToBlock: watch && !cacheOnBlock
|
|
1247
1227
|
}, result => client.setQueryData(queryKey_, result));
|
|
1248
1228
|
return unwatch;
|
|
1249
1229
|
}
|
|
1250
|
-
}, [args, cacheOnBlock, client, contractConfig, enabled, functionName, overrides, queryKey_, watch]);
|
|
1230
|
+
}, [args, cacheOnBlock, chainId, client, contractConfig, enabled, functionName, overrides, queryKey_, watch]);
|
|
1251
1231
|
return useQuery(queryKey_, queryFn$6, {
|
|
1252
1232
|
cacheTime,
|
|
1253
1233
|
enabled,
|
|
@@ -1371,7 +1351,7 @@ function useToken() {
|
|
|
1371
1351
|
formatUnits = 'ether',
|
|
1372
1352
|
cacheTime,
|
|
1373
1353
|
enabled = true,
|
|
1374
|
-
staleTime = 60 * 60 * 24,
|
|
1354
|
+
staleTime = 1000 * 60 * 60 * 24,
|
|
1375
1355
|
// 24 hours
|
|
1376
1356
|
suspense,
|
|
1377
1357
|
onError,
|
|
@@ -1428,7 +1408,7 @@ function useEnsAddress() {
|
|
|
1428
1408
|
chainId: chainId_,
|
|
1429
1409
|
enabled = true,
|
|
1430
1410
|
name,
|
|
1431
|
-
staleTime = 60 * 60 * 24,
|
|
1411
|
+
staleTime = 1000 * 60 * 60 * 24,
|
|
1432
1412
|
// 24 hours
|
|
1433
1413
|
suspense,
|
|
1434
1414
|
onError,
|
|
@@ -1484,7 +1464,7 @@ function useEnsAvatar() {
|
|
|
1484
1464
|
cacheTime,
|
|
1485
1465
|
chainId: chainId_,
|
|
1486
1466
|
enabled = true,
|
|
1487
|
-
staleTime = 60 * 60 * 24,
|
|
1467
|
+
staleTime = 1000 * 60 * 60 * 24,
|
|
1488
1468
|
// 24 hours
|
|
1489
1469
|
suspense,
|
|
1490
1470
|
onError,
|
|
@@ -1538,7 +1518,7 @@ function useEnsName() {
|
|
|
1538
1518
|
cacheTime,
|
|
1539
1519
|
chainId: chainId_,
|
|
1540
1520
|
enabled = true,
|
|
1541
|
-
staleTime = 60 * 60 * 24,
|
|
1521
|
+
staleTime = 1000 * 60 * 60 * 24,
|
|
1542
1522
|
// 24 hours
|
|
1543
1523
|
suspense,
|
|
1544
1524
|
onError,
|
|
@@ -1594,7 +1574,7 @@ function useEnsResolver() {
|
|
|
1594
1574
|
chainId: chainId_,
|
|
1595
1575
|
enabled = true,
|
|
1596
1576
|
name,
|
|
1597
|
-
staleTime = 60 * 60 * 24,
|
|
1577
|
+
staleTime = 1000 * 60 * 60 * 24,
|
|
1598
1578
|
// 24 hours
|
|
1599
1579
|
suspense,
|
|
1600
1580
|
onError,
|
|
@@ -1818,6 +1798,8 @@ exports.Provider = Provider;
|
|
|
1818
1798
|
exports.WagmiProvider = Provider;
|
|
1819
1799
|
exports.createClient = createClient;
|
|
1820
1800
|
exports.createWagmiClient = createClient;
|
|
1801
|
+
exports.deserialize = deserialize;
|
|
1802
|
+
exports.serialize = serialize;
|
|
1821
1803
|
exports.useAccount = useAccount;
|
|
1822
1804
|
exports.useBalance = useBalance;
|
|
1823
1805
|
exports.useBlockNumber = useBlockNumber;
|
|
@@ -1835,6 +1817,7 @@ exports.useEnsResolver = useEnsResolver;
|
|
|
1835
1817
|
exports.useFeeData = useFeeData;
|
|
1836
1818
|
exports.useNetwork = useNetwork;
|
|
1837
1819
|
exports.useProvider = useProvider;
|
|
1820
|
+
exports.useQuery = useQuery;
|
|
1838
1821
|
exports.useSendTransaction = useSendTransaction;
|
|
1839
1822
|
exports.useSignMessage = useSignMessage;
|
|
1840
1823
|
exports.useSignTypedData = useSignTypedData;
|
package/dist/wagmi.cjs.prod.js
CHANGED
|
@@ -8,7 +8,7 @@ var reactQuery = require('react-query');
|
|
|
8
8
|
var persistQueryClient = require('react-query/persistQueryClient');
|
|
9
9
|
var createWebStoragePersister = require('react-query/createWebStoragePersister');
|
|
10
10
|
var ethers = require('ethers/lib/ethers');
|
|
11
|
-
var
|
|
11
|
+
var index_js = require('use-sync-external-store/shim/index.js');
|
|
12
12
|
|
|
13
13
|
function _interopNamespace(e) {
|
|
14
14
|
if (e && e.__esModule) return e;
|
|
@@ -75,122 +75,105 @@ function deserialize(cachedString) {
|
|
|
75
75
|
return deserializedCacheWithBigNumbers;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
let res;
|
|
91
|
-
|
|
92
|
-
try {
|
|
93
|
-
if (replacerStack.length === 0) {
|
|
94
|
-
res = JSON.stringify(obj, replacer, spacer);
|
|
95
|
-
} else {
|
|
96
|
-
res = JSON.stringify(obj, replaceGetterValues(replacer), spacer);
|
|
97
|
-
}
|
|
98
|
-
} catch (_) {
|
|
99
|
-
return JSON.stringify('[unable to serialize, circular reference is too complex to analyze]');
|
|
100
|
-
} finally {
|
|
101
|
-
while (arr.length !== 0) {
|
|
102
|
-
const part = arr.pop();
|
|
103
|
-
|
|
104
|
-
if (part.length === 4) {
|
|
105
|
-
Object.defineProperty(part[0], part[1], part[3]);
|
|
106
|
-
} else {
|
|
107
|
-
part[0][part[1]] = part[2];
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return res;
|
|
78
|
+
/**
|
|
79
|
+
* @function getReferenceKey
|
|
80
|
+
*
|
|
81
|
+
* @description
|
|
82
|
+
* get the reference key for the circular value
|
|
83
|
+
*
|
|
84
|
+
* @param keys the keys to build the reference key from
|
|
85
|
+
* @param cutoff the maximum number of keys to include
|
|
86
|
+
* @returns the reference key
|
|
87
|
+
*/
|
|
88
|
+
function getReferenceKey(keys, cutoff) {
|
|
89
|
+
return keys.slice(0, cutoff).join('.') || '.';
|
|
113
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* @function getCutoff
|
|
93
|
+
*
|
|
94
|
+
* @description
|
|
95
|
+
* faster `Array.prototype.indexOf` implementation build for slicing / splicing
|
|
96
|
+
*
|
|
97
|
+
* @param array the array to match the value in
|
|
98
|
+
* @param value the value to match
|
|
99
|
+
* @returns the matching index, or -1
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
function getCutoff(array, value) {
|
|
104
|
+
const {
|
|
105
|
+
length
|
|
106
|
+
} = array;
|
|
114
107
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
if ((propertyDescriptor === null || propertyDescriptor === void 0 ? void 0 : propertyDescriptor.get) !== undefined) {
|
|
119
|
-
if (propertyDescriptor.configurable) {
|
|
120
|
-
Object.defineProperty(parent, k, {
|
|
121
|
-
value: replace
|
|
122
|
-
});
|
|
123
|
-
arr.push([parent, k, val, propertyDescriptor]);
|
|
124
|
-
} else {
|
|
125
|
-
replacerStack.push([val, k, replace]);
|
|
108
|
+
for (let index = 0; index < length; ++index) {
|
|
109
|
+
if (array[index] === value) {
|
|
110
|
+
return index + 1;
|
|
126
111
|
}
|
|
127
|
-
} else {
|
|
128
|
-
parent[k] = replace;
|
|
129
|
-
arr.push([parent, k, val]);
|
|
130
112
|
}
|
|
131
|
-
}
|
|
132
113
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
let i;
|
|
136
|
-
|
|
137
|
-
if (typeof val === 'object' && val !== null) {
|
|
138
|
-
for (i = 0; i < stack.length; i++) {
|
|
139
|
-
if (stack[i] === val) {
|
|
140
|
-
setReplace(CIRCULAR_REPLACE_NODE, val, k, parent);
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (typeof options.depthLimit !== 'undefined' && depth > options.depthLimit) {
|
|
146
|
-
setReplace(LIMIT_REPLACE_NODE, val, k, parent);
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
if (typeof options.edgesLimit !== 'undefined' && edgeIndex + 1 > options.edgesLimit) {
|
|
151
|
-
setReplace(LIMIT_REPLACE_NODE, val, k, parent);
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
stack.push(val); // Optimize for Arrays. Big arrays could kill the performance otherwise!
|
|
156
|
-
|
|
157
|
-
if (Array.isArray(val)) {
|
|
158
|
-
for (i = 0; i < val.length; i++) {
|
|
159
|
-
decirc(val[i], i, i, stack, val, depth, options);
|
|
160
|
-
}
|
|
161
|
-
} else {
|
|
162
|
-
const keys = Object.keys(val);
|
|
114
|
+
return 0;
|
|
115
|
+
}
|
|
163
116
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
117
|
+
/**
|
|
118
|
+
* @function createReplacer
|
|
119
|
+
*
|
|
120
|
+
* @description
|
|
121
|
+
* create a replacer method that handles circular values
|
|
122
|
+
*
|
|
123
|
+
* @param [replacer] a custom replacer to use for non-circular values
|
|
124
|
+
* @param [circularReplacer] a custom replacer to use for circular methods
|
|
125
|
+
* @returns the value to stringify
|
|
126
|
+
*/
|
|
127
|
+
function createReplacer(replacer, circularReplacer) {
|
|
128
|
+
const hasReplacer = typeof replacer === 'function';
|
|
129
|
+
const hasCircularReplacer = typeof circularReplacer === 'function';
|
|
130
|
+
const cache = [];
|
|
131
|
+
const keys = [];
|
|
132
|
+
return function replace(key, value) {
|
|
133
|
+
if (typeof value === 'object') {
|
|
134
|
+
if (cache.length) {
|
|
135
|
+
const thisCutoff = getCutoff(cache, this);
|
|
136
|
+
|
|
137
|
+
if (thisCutoff === 0) {
|
|
138
|
+
cache[cache.length] = this;
|
|
139
|
+
} else {
|
|
140
|
+
cache.splice(thisCutoff);
|
|
141
|
+
keys.splice(thisCutoff);
|
|
142
|
+
}
|
|
169
143
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
144
|
+
keys[keys.length] = key;
|
|
145
|
+
const valueCutoff = getCutoff(cache, value);
|
|
173
146
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
function replaceGetterValues() {
|
|
177
|
-
let replacer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : (_k, v) => v;
|
|
178
|
-
return (key, val) => {
|
|
179
|
-
if (replacerStack.length > 0) {
|
|
180
|
-
for (let i = 0; i < replacerStack.length; i++) {
|
|
181
|
-
const part = replacerStack[i];
|
|
182
|
-
|
|
183
|
-
if (part[1] === key && part[0] === val) {
|
|
184
|
-
val = part[2];
|
|
185
|
-
replacerStack.splice(i, 1);
|
|
186
|
-
break;
|
|
147
|
+
if (valueCutoff !== 0) {
|
|
148
|
+
return hasCircularReplacer ? circularReplacer.call(this, key, value, getReferenceKey(keys, valueCutoff)) : "[ref=".concat(getReferenceKey(keys, valueCutoff), "]");
|
|
187
149
|
}
|
|
150
|
+
} else {
|
|
151
|
+
cache[0] = value;
|
|
152
|
+
keys[0] = key;
|
|
188
153
|
}
|
|
189
154
|
}
|
|
190
155
|
|
|
191
|
-
return replacer.
|
|
156
|
+
return hasReplacer ? replacer.call(this, key, value) : value;
|
|
192
157
|
};
|
|
193
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* @function stringify
|
|
161
|
+
*
|
|
162
|
+
* @description
|
|
163
|
+
* strinigifer that handles circular values
|
|
164
|
+
* Forked from https://github.com/planttheidea/fast-stringify
|
|
165
|
+
*
|
|
166
|
+
* @param value to stringify
|
|
167
|
+
* @param [replacer] a custom replacer function for handling standard values
|
|
168
|
+
* @param [indent] the number of spaces to indent the output by
|
|
169
|
+
* @param [circularReplacer] a custom replacer function for handling circular values
|
|
170
|
+
* @returns the stringified output
|
|
171
|
+
*/
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
function serialize(value, replacer, indent, circularReplacer) {
|
|
175
|
+
return JSON.stringify(value, createReplacer(replacer, circularReplacer), indent !== null && indent !== void 0 ? indent : undefined);
|
|
176
|
+
}
|
|
194
177
|
|
|
195
178
|
const Context = /*#__PURE__*/React__namespace.createContext(undefined);
|
|
196
179
|
function createClient() {
|
|
@@ -198,7 +181,7 @@ function createClient() {
|
|
|
198
181
|
queryClient = new reactQuery.QueryClient({
|
|
199
182
|
defaultOptions: {
|
|
200
183
|
queries: {
|
|
201
|
-
cacheTime: 60 * 60 * 24,
|
|
184
|
+
cacheTime: 1000 * 60 * 60 * 24,
|
|
202
185
|
// 24 hours
|
|
203
186
|
networkMode: 'offlineFirst',
|
|
204
187
|
refetchOnWindowFocus: false,
|
|
@@ -379,7 +362,7 @@ function useQuery(queryKey, queryFn, options_) {
|
|
|
379
362
|
remove,
|
|
380
363
|
status: status_
|
|
381
364
|
} = observer.getOptimisticResult(defaultedOptions);
|
|
382
|
-
|
|
365
|
+
index_js.useSyncExternalStore(React__namespace.useCallback(onStoreChange => isRestoring ? () => undefined : observer.subscribe(reactQuery.notifyManager.batchCalls(onStoreChange)), [observer, isRestoring]), () => observer.getCurrentResult(), () => observer.getCurrentResult());
|
|
383
366
|
React__namespace.useEffect(() => {
|
|
384
367
|
errorResetBoundary.clearReset();
|
|
385
368
|
}, [errorResetBoundary]);
|
|
@@ -1230,11 +1213,7 @@ function useContractRead(contractConfig, functionName) {
|
|
|
1230
1213
|
}]), [args, blockNumber, cacheOnBlock, chainId, contractConfig, functionName, overrides]);
|
|
1231
1214
|
const enabled = React__namespace.useMemo(() => {
|
|
1232
1215
|
let enabled = Boolean(enabled_ && contractConfig && functionName);
|
|
1233
|
-
|
|
1234
|
-
if (cacheOnBlock) {
|
|
1235
|
-
enabled = Boolean(enabled && blockNumber);
|
|
1236
|
-
}
|
|
1237
|
-
|
|
1216
|
+
if (cacheOnBlock) enabled = Boolean(enabled && blockNumber);
|
|
1238
1217
|
return enabled;
|
|
1239
1218
|
}, [blockNumber, cacheOnBlock, contractConfig, enabled_, functionName]);
|
|
1240
1219
|
const client = reactQuery.useQueryClient();
|
|
@@ -1242,12 +1221,13 @@ function useContractRead(contractConfig, functionName) {
|
|
|
1242
1221
|
if (enabled) {
|
|
1243
1222
|
const unwatch = core.watchReadContract(contractConfig, functionName, {
|
|
1244
1223
|
args,
|
|
1224
|
+
chainId,
|
|
1245
1225
|
overrides,
|
|
1246
1226
|
listenToBlock: watch && !cacheOnBlock
|
|
1247
1227
|
}, result => client.setQueryData(queryKey_, result));
|
|
1248
1228
|
return unwatch;
|
|
1249
1229
|
}
|
|
1250
|
-
}, [args, cacheOnBlock, client, contractConfig, enabled, functionName, overrides, queryKey_, watch]);
|
|
1230
|
+
}, [args, cacheOnBlock, chainId, client, contractConfig, enabled, functionName, overrides, queryKey_, watch]);
|
|
1251
1231
|
return useQuery(queryKey_, queryFn$6, {
|
|
1252
1232
|
cacheTime,
|
|
1253
1233
|
enabled,
|
|
@@ -1371,7 +1351,7 @@ function useToken() {
|
|
|
1371
1351
|
formatUnits = 'ether',
|
|
1372
1352
|
cacheTime,
|
|
1373
1353
|
enabled = true,
|
|
1374
|
-
staleTime = 60 * 60 * 24,
|
|
1354
|
+
staleTime = 1000 * 60 * 60 * 24,
|
|
1375
1355
|
// 24 hours
|
|
1376
1356
|
suspense,
|
|
1377
1357
|
onError,
|
|
@@ -1428,7 +1408,7 @@ function useEnsAddress() {
|
|
|
1428
1408
|
chainId: chainId_,
|
|
1429
1409
|
enabled = true,
|
|
1430
1410
|
name,
|
|
1431
|
-
staleTime = 60 * 60 * 24,
|
|
1411
|
+
staleTime = 1000 * 60 * 60 * 24,
|
|
1432
1412
|
// 24 hours
|
|
1433
1413
|
suspense,
|
|
1434
1414
|
onError,
|
|
@@ -1484,7 +1464,7 @@ function useEnsAvatar() {
|
|
|
1484
1464
|
cacheTime,
|
|
1485
1465
|
chainId: chainId_,
|
|
1486
1466
|
enabled = true,
|
|
1487
|
-
staleTime = 60 * 60 * 24,
|
|
1467
|
+
staleTime = 1000 * 60 * 60 * 24,
|
|
1488
1468
|
// 24 hours
|
|
1489
1469
|
suspense,
|
|
1490
1470
|
onError,
|
|
@@ -1538,7 +1518,7 @@ function useEnsName() {
|
|
|
1538
1518
|
cacheTime,
|
|
1539
1519
|
chainId: chainId_,
|
|
1540
1520
|
enabled = true,
|
|
1541
|
-
staleTime = 60 * 60 * 24,
|
|
1521
|
+
staleTime = 1000 * 60 * 60 * 24,
|
|
1542
1522
|
// 24 hours
|
|
1543
1523
|
suspense,
|
|
1544
1524
|
onError,
|
|
@@ -1594,7 +1574,7 @@ function useEnsResolver() {
|
|
|
1594
1574
|
chainId: chainId_,
|
|
1595
1575
|
enabled = true,
|
|
1596
1576
|
name,
|
|
1597
|
-
staleTime = 60 * 60 * 24,
|
|
1577
|
+
staleTime = 1000 * 60 * 60 * 24,
|
|
1598
1578
|
// 24 hours
|
|
1599
1579
|
suspense,
|
|
1600
1580
|
onError,
|
|
@@ -1818,6 +1798,8 @@ exports.Provider = Provider;
|
|
|
1818
1798
|
exports.WagmiProvider = Provider;
|
|
1819
1799
|
exports.createClient = createClient;
|
|
1820
1800
|
exports.createWagmiClient = createClient;
|
|
1801
|
+
exports.deserialize = deserialize;
|
|
1802
|
+
exports.serialize = serialize;
|
|
1821
1803
|
exports.useAccount = useAccount;
|
|
1822
1804
|
exports.useBalance = useBalance;
|
|
1823
1805
|
exports.useBlockNumber = useBlockNumber;
|
|
@@ -1835,6 +1817,7 @@ exports.useEnsResolver = useEnsResolver;
|
|
|
1835
1817
|
exports.useFeeData = useFeeData;
|
|
1836
1818
|
exports.useNetwork = useNetwork;
|
|
1837
1819
|
exports.useProvider = useProvider;
|
|
1820
|
+
exports.useQuery = useQuery;
|
|
1838
1821
|
exports.useSendTransaction = useSendTransaction;
|
|
1839
1822
|
exports.useSignMessage = useSignMessage;
|
|
1840
1823
|
exports.useSignTypedData = useSignTypedData;
|
package/dist/wagmi.esm.js
CHANGED
|
@@ -5,7 +5,7 @@ import { QueryClient, QueryClientProvider, useQueryClient, useIsRestoring, useQu
|
|
|
5
5
|
import { persistQueryClient } from 'react-query/persistQueryClient';
|
|
6
6
|
import { createWebStoragePersister } from 'react-query/createWebStoragePersister';
|
|
7
7
|
import { BigNumber } from 'ethers/lib/ethers';
|
|
8
|
-
import { useSyncExternalStore } from 'use-sync-external-store/shim';
|
|
8
|
+
import { useSyncExternalStore } from 'use-sync-external-store/shim/index.js';
|
|
9
9
|
|
|
10
10
|
const findAndReplace = (cacheRef, _ref) => {
|
|
11
11
|
let {
|
|
@@ -52,122 +52,105 @@ function deserialize(cachedString) {
|
|
|
52
52
|
return deserializedCacheWithBigNumbers;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
let res;
|
|
68
|
-
|
|
69
|
-
try {
|
|
70
|
-
if (replacerStack.length === 0) {
|
|
71
|
-
res = JSON.stringify(obj, replacer, spacer);
|
|
72
|
-
} else {
|
|
73
|
-
res = JSON.stringify(obj, replaceGetterValues(replacer), spacer);
|
|
74
|
-
}
|
|
75
|
-
} catch (_) {
|
|
76
|
-
return JSON.stringify('[unable to serialize, circular reference is too complex to analyze]');
|
|
77
|
-
} finally {
|
|
78
|
-
while (arr.length !== 0) {
|
|
79
|
-
const part = arr.pop();
|
|
80
|
-
|
|
81
|
-
if (part.length === 4) {
|
|
82
|
-
Object.defineProperty(part[0], part[1], part[3]);
|
|
83
|
-
} else {
|
|
84
|
-
part[0][part[1]] = part[2];
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return res;
|
|
55
|
+
/**
|
|
56
|
+
* @function getReferenceKey
|
|
57
|
+
*
|
|
58
|
+
* @description
|
|
59
|
+
* get the reference key for the circular value
|
|
60
|
+
*
|
|
61
|
+
* @param keys the keys to build the reference key from
|
|
62
|
+
* @param cutoff the maximum number of keys to include
|
|
63
|
+
* @returns the reference key
|
|
64
|
+
*/
|
|
65
|
+
function getReferenceKey(keys, cutoff) {
|
|
66
|
+
return keys.slice(0, cutoff).join('.') || '.';
|
|
90
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* @function getCutoff
|
|
70
|
+
*
|
|
71
|
+
* @description
|
|
72
|
+
* faster `Array.prototype.indexOf` implementation build for slicing / splicing
|
|
73
|
+
*
|
|
74
|
+
* @param array the array to match the value in
|
|
75
|
+
* @param value the value to match
|
|
76
|
+
* @returns the matching index, or -1
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
function getCutoff(array, value) {
|
|
81
|
+
const {
|
|
82
|
+
length
|
|
83
|
+
} = array;
|
|
91
84
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if ((propertyDescriptor === null || propertyDescriptor === void 0 ? void 0 : propertyDescriptor.get) !== undefined) {
|
|
96
|
-
if (propertyDescriptor.configurable) {
|
|
97
|
-
Object.defineProperty(parent, k, {
|
|
98
|
-
value: replace
|
|
99
|
-
});
|
|
100
|
-
arr.push([parent, k, val, propertyDescriptor]);
|
|
101
|
-
} else {
|
|
102
|
-
replacerStack.push([val, k, replace]);
|
|
85
|
+
for (let index = 0; index < length; ++index) {
|
|
86
|
+
if (array[index] === value) {
|
|
87
|
+
return index + 1;
|
|
103
88
|
}
|
|
104
|
-
} else {
|
|
105
|
-
parent[k] = replace;
|
|
106
|
-
arr.push([parent, k, val]);
|
|
107
89
|
}
|
|
108
|
-
}
|
|
109
90
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
let i;
|
|
113
|
-
|
|
114
|
-
if (typeof val === 'object' && val !== null) {
|
|
115
|
-
for (i = 0; i < stack.length; i++) {
|
|
116
|
-
if (stack[i] === val) {
|
|
117
|
-
setReplace(CIRCULAR_REPLACE_NODE, val, k, parent);
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (typeof options.depthLimit !== 'undefined' && depth > options.depthLimit) {
|
|
123
|
-
setReplace(LIMIT_REPLACE_NODE, val, k, parent);
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (typeof options.edgesLimit !== 'undefined' && edgeIndex + 1 > options.edgesLimit) {
|
|
128
|
-
setReplace(LIMIT_REPLACE_NODE, val, k, parent);
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
stack.push(val); // Optimize for Arrays. Big arrays could kill the performance otherwise!
|
|
133
|
-
|
|
134
|
-
if (Array.isArray(val)) {
|
|
135
|
-
for (i = 0; i < val.length; i++) {
|
|
136
|
-
decirc(val[i], i, i, stack, val, depth, options);
|
|
137
|
-
}
|
|
138
|
-
} else {
|
|
139
|
-
const keys = Object.keys(val);
|
|
91
|
+
return 0;
|
|
92
|
+
}
|
|
140
93
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
94
|
+
/**
|
|
95
|
+
* @function createReplacer
|
|
96
|
+
*
|
|
97
|
+
* @description
|
|
98
|
+
* create a replacer method that handles circular values
|
|
99
|
+
*
|
|
100
|
+
* @param [replacer] a custom replacer to use for non-circular values
|
|
101
|
+
* @param [circularReplacer] a custom replacer to use for circular methods
|
|
102
|
+
* @returns the value to stringify
|
|
103
|
+
*/
|
|
104
|
+
function createReplacer(replacer, circularReplacer) {
|
|
105
|
+
const hasReplacer = typeof replacer === 'function';
|
|
106
|
+
const hasCircularReplacer = typeof circularReplacer === 'function';
|
|
107
|
+
const cache = [];
|
|
108
|
+
const keys = [];
|
|
109
|
+
return function replace(key, value) {
|
|
110
|
+
if (typeof value === 'object') {
|
|
111
|
+
if (cache.length) {
|
|
112
|
+
const thisCutoff = getCutoff(cache, this);
|
|
113
|
+
|
|
114
|
+
if (thisCutoff === 0) {
|
|
115
|
+
cache[cache.length] = this;
|
|
116
|
+
} else {
|
|
117
|
+
cache.splice(thisCutoff);
|
|
118
|
+
keys.splice(thisCutoff);
|
|
119
|
+
}
|
|
146
120
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
121
|
+
keys[keys.length] = key;
|
|
122
|
+
const valueCutoff = getCutoff(cache, value);
|
|
150
123
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
function replaceGetterValues() {
|
|
154
|
-
let replacer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : (_k, v) => v;
|
|
155
|
-
return (key, val) => {
|
|
156
|
-
if (replacerStack.length > 0) {
|
|
157
|
-
for (let i = 0; i < replacerStack.length; i++) {
|
|
158
|
-
const part = replacerStack[i];
|
|
159
|
-
|
|
160
|
-
if (part[1] === key && part[0] === val) {
|
|
161
|
-
val = part[2];
|
|
162
|
-
replacerStack.splice(i, 1);
|
|
163
|
-
break;
|
|
124
|
+
if (valueCutoff !== 0) {
|
|
125
|
+
return hasCircularReplacer ? circularReplacer.call(this, key, value, getReferenceKey(keys, valueCutoff)) : "[ref=".concat(getReferenceKey(keys, valueCutoff), "]");
|
|
164
126
|
}
|
|
127
|
+
} else {
|
|
128
|
+
cache[0] = value;
|
|
129
|
+
keys[0] = key;
|
|
165
130
|
}
|
|
166
131
|
}
|
|
167
132
|
|
|
168
|
-
return replacer.
|
|
133
|
+
return hasReplacer ? replacer.call(this, key, value) : value;
|
|
169
134
|
};
|
|
170
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* @function stringify
|
|
138
|
+
*
|
|
139
|
+
* @description
|
|
140
|
+
* strinigifer that handles circular values
|
|
141
|
+
* Forked from https://github.com/planttheidea/fast-stringify
|
|
142
|
+
*
|
|
143
|
+
* @param value to stringify
|
|
144
|
+
* @param [replacer] a custom replacer function for handling standard values
|
|
145
|
+
* @param [indent] the number of spaces to indent the output by
|
|
146
|
+
* @param [circularReplacer] a custom replacer function for handling circular values
|
|
147
|
+
* @returns the stringified output
|
|
148
|
+
*/
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
function serialize(value, replacer, indent, circularReplacer) {
|
|
152
|
+
return JSON.stringify(value, createReplacer(replacer, circularReplacer), indent !== null && indent !== void 0 ? indent : undefined);
|
|
153
|
+
}
|
|
171
154
|
|
|
172
155
|
const Context = /*#__PURE__*/React.createContext(undefined);
|
|
173
156
|
function createClient() {
|
|
@@ -175,7 +158,7 @@ function createClient() {
|
|
|
175
158
|
queryClient = new QueryClient({
|
|
176
159
|
defaultOptions: {
|
|
177
160
|
queries: {
|
|
178
|
-
cacheTime: 60 * 60 * 24,
|
|
161
|
+
cacheTime: 1000 * 60 * 60 * 24,
|
|
179
162
|
// 24 hours
|
|
180
163
|
networkMode: 'offlineFirst',
|
|
181
164
|
refetchOnWindowFocus: false,
|
|
@@ -1207,11 +1190,7 @@ function useContractRead(contractConfig, functionName) {
|
|
|
1207
1190
|
}]), [args, blockNumber, cacheOnBlock, chainId, contractConfig, functionName, overrides]);
|
|
1208
1191
|
const enabled = React.useMemo(() => {
|
|
1209
1192
|
let enabled = Boolean(enabled_ && contractConfig && functionName);
|
|
1210
|
-
|
|
1211
|
-
if (cacheOnBlock) {
|
|
1212
|
-
enabled = Boolean(enabled && blockNumber);
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1193
|
+
if (cacheOnBlock) enabled = Boolean(enabled && blockNumber);
|
|
1215
1194
|
return enabled;
|
|
1216
1195
|
}, [blockNumber, cacheOnBlock, contractConfig, enabled_, functionName]);
|
|
1217
1196
|
const client = useQueryClient();
|
|
@@ -1219,12 +1198,13 @@ function useContractRead(contractConfig, functionName) {
|
|
|
1219
1198
|
if (enabled) {
|
|
1220
1199
|
const unwatch = watchReadContract(contractConfig, functionName, {
|
|
1221
1200
|
args,
|
|
1201
|
+
chainId,
|
|
1222
1202
|
overrides,
|
|
1223
1203
|
listenToBlock: watch && !cacheOnBlock
|
|
1224
1204
|
}, result => client.setQueryData(queryKey_, result));
|
|
1225
1205
|
return unwatch;
|
|
1226
1206
|
}
|
|
1227
|
-
}, [args, cacheOnBlock, client, contractConfig, enabled, functionName, overrides, queryKey_, watch]);
|
|
1207
|
+
}, [args, cacheOnBlock, chainId, client, contractConfig, enabled, functionName, overrides, queryKey_, watch]);
|
|
1228
1208
|
return useQuery(queryKey_, queryFn$6, {
|
|
1229
1209
|
cacheTime,
|
|
1230
1210
|
enabled,
|
|
@@ -1348,7 +1328,7 @@ function useToken() {
|
|
|
1348
1328
|
formatUnits = 'ether',
|
|
1349
1329
|
cacheTime,
|
|
1350
1330
|
enabled = true,
|
|
1351
|
-
staleTime = 60 * 60 * 24,
|
|
1331
|
+
staleTime = 1000 * 60 * 60 * 24,
|
|
1352
1332
|
// 24 hours
|
|
1353
1333
|
suspense,
|
|
1354
1334
|
onError,
|
|
@@ -1405,7 +1385,7 @@ function useEnsAddress() {
|
|
|
1405
1385
|
chainId: chainId_,
|
|
1406
1386
|
enabled = true,
|
|
1407
1387
|
name,
|
|
1408
|
-
staleTime = 60 * 60 * 24,
|
|
1388
|
+
staleTime = 1000 * 60 * 60 * 24,
|
|
1409
1389
|
// 24 hours
|
|
1410
1390
|
suspense,
|
|
1411
1391
|
onError,
|
|
@@ -1461,7 +1441,7 @@ function useEnsAvatar() {
|
|
|
1461
1441
|
cacheTime,
|
|
1462
1442
|
chainId: chainId_,
|
|
1463
1443
|
enabled = true,
|
|
1464
|
-
staleTime = 60 * 60 * 24,
|
|
1444
|
+
staleTime = 1000 * 60 * 60 * 24,
|
|
1465
1445
|
// 24 hours
|
|
1466
1446
|
suspense,
|
|
1467
1447
|
onError,
|
|
@@ -1515,7 +1495,7 @@ function useEnsName() {
|
|
|
1515
1495
|
cacheTime,
|
|
1516
1496
|
chainId: chainId_,
|
|
1517
1497
|
enabled = true,
|
|
1518
|
-
staleTime = 60 * 60 * 24,
|
|
1498
|
+
staleTime = 1000 * 60 * 60 * 24,
|
|
1519
1499
|
// 24 hours
|
|
1520
1500
|
suspense,
|
|
1521
1501
|
onError,
|
|
@@ -1571,7 +1551,7 @@ function useEnsResolver() {
|
|
|
1571
1551
|
chainId: chainId_,
|
|
1572
1552
|
enabled = true,
|
|
1573
1553
|
name,
|
|
1574
|
-
staleTime = 60 * 60 * 24,
|
|
1554
|
+
staleTime = 1000 * 60 * 60 * 24,
|
|
1575
1555
|
// 24 hours
|
|
1576
1556
|
suspense,
|
|
1577
1557
|
onError,
|
|
@@ -1731,4 +1711,4 @@ function useWaitForTransaction() {
|
|
|
1731
1711
|
});
|
|
1732
1712
|
}
|
|
1733
1713
|
|
|
1734
|
-
export { Provider, Provider as WagmiProvider, createClient, createClient as createWagmiClient, useAccount, useBalance, useBlockNumber, useClient, useConnect, useContract, useContractEvent, useContractRead, useContractWrite, useDisconnect, useEnsAddress, useEnsAvatar, useEnsName, useEnsResolver, useFeeData, useNetwork, useProvider, useSendTransaction, useSignMessage, useSignTypedData, useSigner, useToken, useClient as useWagmiClient, useWaitForTransaction, useWebSocketProvider };
|
|
1714
|
+
export { Provider, Provider as WagmiProvider, createClient, createClient as createWagmiClient, deserialize, serialize, useAccount, useBalance, useBlockNumber, useClient, useConnect, useContract, useContractEvent, useContractRead, useContractWrite, useDisconnect, useEnsAddress, useEnsAvatar, useEnsName, useEnsResolver, useFeeData, useNetwork, useProvider, useQuery, useSendTransaction, useSignMessage, useSignTypedData, useSigner, useToken, useClient as useWagmiClient, useWaitForTransaction, useWebSocketProvider };
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "wagmi",
|
|
3
3
|
"description": "React Hooks for Ethereum",
|
|
4
4
|
"license": "WAGMIT",
|
|
5
|
-
"version": "0.3.
|
|
5
|
+
"version": "0.3.3",
|
|
6
6
|
"author": "awkweb.eth",
|
|
7
7
|
"ethereum": "awkweb.eth",
|
|
8
8
|
"repository": "tmm/wagmi",
|
|
@@ -24,6 +24,10 @@
|
|
|
24
24
|
"module": "./connectors/injected/dist/wagmi-connectors-injected.esm.js",
|
|
25
25
|
"default": "./connectors/injected/dist/wagmi-connectors-injected.cjs.js"
|
|
26
26
|
},
|
|
27
|
+
"./connectors/metaMask": {
|
|
28
|
+
"module": "./connectors/metaMask/dist/wagmi-connectors-metaMask.esm.js",
|
|
29
|
+
"default": "./connectors/metaMask/dist/wagmi-connectors-metaMask.cjs.js"
|
|
30
|
+
},
|
|
27
31
|
"./connectors/walletConnect": {
|
|
28
32
|
"module": "./connectors/walletConnect/dist/wagmi-connectors-walletConnect.esm.js",
|
|
29
33
|
"default": "./connectors/walletConnect/dist/wagmi-connectors-walletConnect.cjs.js"
|
|
@@ -38,6 +42,7 @@
|
|
|
38
42
|
"index.ts",
|
|
39
43
|
"connectors/coinbaseWallet.ts",
|
|
40
44
|
"connectors/injected.ts",
|
|
45
|
+
"connectors/metaMask.ts",
|
|
41
46
|
"connectors/walletConnect.ts"
|
|
42
47
|
]
|
|
43
48
|
},
|
|
@@ -46,22 +51,22 @@
|
|
|
46
51
|
"react": ">=17.0.0"
|
|
47
52
|
},
|
|
48
53
|
"dependencies": {
|
|
49
|
-
"@coinbase/wallet-sdk": "^3.0.
|
|
50
|
-
"@wagmi/core": "0.2.
|
|
51
|
-
"@walletconnect/ethereum-provider": "1.7.5",
|
|
52
|
-
"react-query": "^4.0.0-beta.
|
|
53
|
-
"use-sync-external-store": "^1.
|
|
54
|
+
"@coinbase/wallet-sdk": "^3.0.11",
|
|
55
|
+
"@wagmi/core": "^0.2.3",
|
|
56
|
+
"@walletconnect/ethereum-provider": "^1.7.5",
|
|
57
|
+
"react-query": "^4.0.0-beta.7",
|
|
58
|
+
"use-sync-external-store": "^1.1.0"
|
|
54
59
|
},
|
|
55
60
|
"devDependencies": {
|
|
56
61
|
"@testing-library/react": "^13.0.0",
|
|
57
62
|
"@testing-library/react-hooks": "^7.0.2",
|
|
58
|
-
"@types/react": "18.0.5",
|
|
59
|
-
"@types/react-dom": "^18.0.
|
|
63
|
+
"@types/react": "^18.0.5",
|
|
64
|
+
"@types/react-dom": "^18.0.3",
|
|
60
65
|
"@types/use-sync-external-store": "^0.0.3",
|
|
61
66
|
"ethers": "^5.6.4",
|
|
62
|
-
"react": "18.
|
|
63
|
-
"react-dom": "^18.0.0",
|
|
67
|
+
"react": "^18.1.0",
|
|
64
68
|
"react-17": "npm:react@^17.0.2",
|
|
69
|
+
"react-dom": "^18.0.0",
|
|
65
70
|
"react-dom-17": "npm:react-dom@^17.0.2"
|
|
66
71
|
},
|
|
67
72
|
"keywords": [
|
|
@@ -73,5 +78,5 @@
|
|
|
73
78
|
"wallet",
|
|
74
79
|
"web3"
|
|
75
80
|
],
|
|
76
|
-
"readme": "# wagmi\n\n## Documentation\n\nFor full documentation and examples, visit [wagmi.sh](https://wagmi.sh).\n\n## Installation\n\nInstall wagmi and its ethers peer dependency.\n\n```bash\nnpm install wagmi ethers\n```\n\n## Community\n\nCheck out the following places for more wagmi-related content:\n\n- Join the [discussions on GitHub](https://github.com/tmm/wagmi/discussions)\n- Follow [@awkweb](https://twitter.com/awkweb) on Twitter for project updates\n- Sign the [guestbook](https://github.com/tmm/wagmi/discussions/2)\n- Share [your project/organization](https://github.com/tmm/wagmi/discussions/201) using wagmi\n\n## Support\n\nIf you find wagmi useful, please consider supporting development. Thank you 🙏\n\n- [
|
|
81
|
+
"readme": "# wagmi\n\n## Documentation\n\nFor full documentation and examples, visit [wagmi.sh](https://wagmi.sh).\n\n## Installation\n\nInstall wagmi and its ethers peer dependency.\n\n```bash\nnpm install wagmi ethers\n```\n\n## Community\n\nCheck out the following places for more wagmi-related content:\n\n- Join the [discussions on GitHub](https://github.com/tmm/wagmi/discussions)\n- Follow [@awkweb](https://twitter.com/awkweb) and [@wagmi_sh](https://twitter.com/wagmi_sh) on Twitter for project updates\n- Sign the [guestbook](https://github.com/tmm/wagmi/discussions/2)\n- Share [your project/organization](https://github.com/tmm/wagmi/discussions/201) using wagmi\n\n## Support\n\nIf you find wagmi useful, please consider supporting development. Thank you 🙏\n\n- [GitHub Sponsors](https://github.com/sponsors/tmm?metadata_campaign=readme_wagmi)\n- [Gitcoin Grant](https://gitcoin.co/grants/4493/wagmi-react-hooks-library-for-ethereum)\n- [awkweb.eth](https://etherscan.io/enslookup-search?search=awkweb.eth)\n"
|
|
77
82
|
}
|