wagmi 0.6.6 → 0.6.7
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/dist/declarations/src/hooks/network-status/useBlockNumber.d.ts +1 -0
- package/dist/declarations/src/hooks/utils/useInvalidateOnBlock.d.ts +2 -1
- package/dist/wagmi.cjs.dev.js +20 -6
- package/dist/wagmi.cjs.prod.js +20 -6
- package/dist/wagmi.esm.js +20 -6
- package/package.json +2 -2
- package/providers/coinbaseNode/dist/wagmi-providers-coinbaseNode.cjs.d.ts +11 -0
- package/providers/coinbaseNode/dist/wagmi-providers-coinbaseNode.cjs.js +16 -0
|
@@ -14,6 +14,7 @@ export declare const queryKey: ({ chainId }: {
|
|
|
14
14
|
readonly chainId: number | undefined;
|
|
15
15
|
}];
|
|
16
16
|
export declare function useBlockNumber({ cacheTime, chainId: chainId_, enabled, staleTime, suspense, watch, onBlock, onError, onSettled, onSuccess, }?: UseBlockNumberArgs & UseBlockNumberConfig): Pick<import("@tanstack/react-query").QueryObserverResult<number, Error>, "error" | "data" | "fetchStatus" | "isError" | "isFetched" | "isFetching" | "isLoading" | "isRefetching" | "isSuccess" | "refetch"> & {
|
|
17
|
+
/** Function fires when a new block is created */
|
|
17
18
|
isIdle: boolean;
|
|
18
19
|
status: "error" | "success" | "idle" | "loading";
|
|
19
20
|
internal: Pick<import("@tanstack/react-query").QueryObserverResult<unknown, unknown>, "dataUpdatedAt" | "errorUpdatedAt" | "failureCount" | "isFetchedAfterMount" | "isLoadingError" | "isPaused" | "isPlaceholderData" | "isPreviousData" | "isRefetchError" | "isStale" | "remove">;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { QueryKey } from '@tanstack/react-query';
|
|
2
|
-
export declare function useInvalidateOnBlock({ enabled, queryKey, }: {
|
|
2
|
+
export declare function useInvalidateOnBlock({ chainId, enabled, queryKey, }: {
|
|
3
|
+
chainId?: number;
|
|
3
4
|
enabled?: boolean;
|
|
4
5
|
queryKey: QueryKey;
|
|
5
6
|
}): void;
|
package/dist/wagmi.cjs.dev.js
CHANGED
|
@@ -10,6 +10,7 @@ var React = require('react');
|
|
|
10
10
|
var pkg = require('use-sync-external-store/shim/index.js');
|
|
11
11
|
var ethers = require('ethers/lib/ethers');
|
|
12
12
|
var withSelector_js = require('use-sync-external-store/shim/with-selector.js');
|
|
13
|
+
var internal = require('@wagmi/core/internal');
|
|
13
14
|
|
|
14
15
|
function _interopNamespace(e) {
|
|
15
16
|
if (e && e.__esModule) return e;
|
|
@@ -313,21 +314,28 @@ function useBlockNumber() {
|
|
|
313
314
|
const chainId = useChainId({
|
|
314
315
|
chainId: chainId_
|
|
315
316
|
});
|
|
316
|
-
const provider = useProvider(
|
|
317
|
-
|
|
317
|
+
const provider = useProvider({
|
|
318
|
+
chainId
|
|
319
|
+
});
|
|
320
|
+
const webSocketProvider = useWebSocketProvider({
|
|
321
|
+
chainId
|
|
322
|
+
});
|
|
318
323
|
const queryClient = reactQuery.useQueryClient();
|
|
319
324
|
React__namespace.useEffect(() => {
|
|
320
|
-
if (!watch && !onBlock) return;
|
|
325
|
+
if (!watch && !onBlock) return; // We need to debounce the listener as we want to opt-out
|
|
326
|
+
// of the behavior where ethers emits a "block" event for
|
|
327
|
+
// every block that was missed in between the `pollingInterval`.
|
|
328
|
+
// We are setting a wait time of 1 as emitting an event in
|
|
329
|
+
// ethers takes ~0.1ms.
|
|
321
330
|
|
|
322
|
-
const listener = blockNumber => {
|
|
331
|
+
const listener = internal.debounce(blockNumber => {
|
|
323
332
|
// Just to be safe in case the provider implementation
|
|
324
333
|
// calls the event callback after .off() has been called
|
|
325
334
|
if (watch) queryClient.setQueryData(queryKey$f({
|
|
326
335
|
chainId
|
|
327
336
|
}), blockNumber);
|
|
328
337
|
if (onBlock) onBlock(blockNumber);
|
|
329
|
-
};
|
|
330
|
-
|
|
338
|
+
}, 1);
|
|
331
339
|
const provider_ = webSocketProvider !== null && webSocketProvider !== void 0 ? webSocketProvider : provider;
|
|
332
340
|
provider_.on('block', listener);
|
|
333
341
|
return () => {
|
|
@@ -403,6 +411,7 @@ function useFeeData() {
|
|
|
403
411
|
const {
|
|
404
412
|
data: blockNumber
|
|
405
413
|
} = useBlockNumber({
|
|
414
|
+
chainId,
|
|
406
415
|
watch
|
|
407
416
|
});
|
|
408
417
|
React__namespace.useEffect(() => {
|
|
@@ -416,11 +425,13 @@ function useFeeData() {
|
|
|
416
425
|
|
|
417
426
|
function useInvalidateOnBlock(_ref) {
|
|
418
427
|
let {
|
|
428
|
+
chainId,
|
|
419
429
|
enabled,
|
|
420
430
|
queryKey
|
|
421
431
|
} = _ref;
|
|
422
432
|
const queryClient = reactQuery.useQueryClient();
|
|
423
433
|
useBlockNumber({
|
|
434
|
+
chainId,
|
|
424
435
|
onBlock: enabled ? () => queryClient.invalidateQueries(queryKey) : undefined
|
|
425
436
|
});
|
|
426
437
|
}
|
|
@@ -800,6 +811,7 @@ function useBalance() {
|
|
|
800
811
|
const {
|
|
801
812
|
data: blockNumber
|
|
802
813
|
} = useBlockNumber({
|
|
814
|
+
chainId,
|
|
803
815
|
watch
|
|
804
816
|
});
|
|
805
817
|
React__namespace.useEffect(() => {
|
|
@@ -1406,6 +1418,7 @@ function useContractRead(_ref4) {
|
|
|
1406
1418
|
const {
|
|
1407
1419
|
data: blockNumber
|
|
1408
1420
|
} = useBlockNumber({
|
|
1421
|
+
chainId,
|
|
1409
1422
|
enabled: watch || cacheOnBlock,
|
|
1410
1423
|
watch
|
|
1411
1424
|
});
|
|
@@ -1424,6 +1437,7 @@ function useContractRead(_ref4) {
|
|
|
1424
1437
|
return enabled;
|
|
1425
1438
|
}, [addressOrName, blockNumber, cacheOnBlock, enabled_, functionName]);
|
|
1426
1439
|
useInvalidateOnBlock({
|
|
1440
|
+
chainId,
|
|
1427
1441
|
enabled: watch && !cacheOnBlock,
|
|
1428
1442
|
queryKey: queryKey_
|
|
1429
1443
|
});
|
package/dist/wagmi.cjs.prod.js
CHANGED
|
@@ -10,6 +10,7 @@ var React = require('react');
|
|
|
10
10
|
var pkg = require('use-sync-external-store/shim/index.js');
|
|
11
11
|
var ethers = require('ethers/lib/ethers');
|
|
12
12
|
var withSelector_js = require('use-sync-external-store/shim/with-selector.js');
|
|
13
|
+
var internal = require('@wagmi/core/internal');
|
|
13
14
|
|
|
14
15
|
function _interopNamespace(e) {
|
|
15
16
|
if (e && e.__esModule) return e;
|
|
@@ -313,21 +314,28 @@ function useBlockNumber() {
|
|
|
313
314
|
const chainId = useChainId({
|
|
314
315
|
chainId: chainId_
|
|
315
316
|
});
|
|
316
|
-
const provider = useProvider(
|
|
317
|
-
|
|
317
|
+
const provider = useProvider({
|
|
318
|
+
chainId
|
|
319
|
+
});
|
|
320
|
+
const webSocketProvider = useWebSocketProvider({
|
|
321
|
+
chainId
|
|
322
|
+
});
|
|
318
323
|
const queryClient = reactQuery.useQueryClient();
|
|
319
324
|
React__namespace.useEffect(() => {
|
|
320
|
-
if (!watch && !onBlock) return;
|
|
325
|
+
if (!watch && !onBlock) return; // We need to debounce the listener as we want to opt-out
|
|
326
|
+
// of the behavior where ethers emits a "block" event for
|
|
327
|
+
// every block that was missed in between the `pollingInterval`.
|
|
328
|
+
// We are setting a wait time of 1 as emitting an event in
|
|
329
|
+
// ethers takes ~0.1ms.
|
|
321
330
|
|
|
322
|
-
const listener = blockNumber => {
|
|
331
|
+
const listener = internal.debounce(blockNumber => {
|
|
323
332
|
// Just to be safe in case the provider implementation
|
|
324
333
|
// calls the event callback after .off() has been called
|
|
325
334
|
if (watch) queryClient.setQueryData(queryKey$f({
|
|
326
335
|
chainId
|
|
327
336
|
}), blockNumber);
|
|
328
337
|
if (onBlock) onBlock(blockNumber);
|
|
329
|
-
};
|
|
330
|
-
|
|
338
|
+
}, 1);
|
|
331
339
|
const provider_ = webSocketProvider !== null && webSocketProvider !== void 0 ? webSocketProvider : provider;
|
|
332
340
|
provider_.on('block', listener);
|
|
333
341
|
return () => {
|
|
@@ -403,6 +411,7 @@ function useFeeData() {
|
|
|
403
411
|
const {
|
|
404
412
|
data: blockNumber
|
|
405
413
|
} = useBlockNumber({
|
|
414
|
+
chainId,
|
|
406
415
|
watch
|
|
407
416
|
});
|
|
408
417
|
React__namespace.useEffect(() => {
|
|
@@ -416,11 +425,13 @@ function useFeeData() {
|
|
|
416
425
|
|
|
417
426
|
function useInvalidateOnBlock(_ref) {
|
|
418
427
|
let {
|
|
428
|
+
chainId,
|
|
419
429
|
enabled,
|
|
420
430
|
queryKey
|
|
421
431
|
} = _ref;
|
|
422
432
|
const queryClient = reactQuery.useQueryClient();
|
|
423
433
|
useBlockNumber({
|
|
434
|
+
chainId,
|
|
424
435
|
onBlock: enabled ? () => queryClient.invalidateQueries(queryKey) : undefined
|
|
425
436
|
});
|
|
426
437
|
}
|
|
@@ -800,6 +811,7 @@ function useBalance() {
|
|
|
800
811
|
const {
|
|
801
812
|
data: blockNumber
|
|
802
813
|
} = useBlockNumber({
|
|
814
|
+
chainId,
|
|
803
815
|
watch
|
|
804
816
|
});
|
|
805
817
|
React__namespace.useEffect(() => {
|
|
@@ -1406,6 +1418,7 @@ function useContractRead(_ref4) {
|
|
|
1406
1418
|
const {
|
|
1407
1419
|
data: blockNumber
|
|
1408
1420
|
} = useBlockNumber({
|
|
1421
|
+
chainId,
|
|
1409
1422
|
enabled: watch || cacheOnBlock,
|
|
1410
1423
|
watch
|
|
1411
1424
|
});
|
|
@@ -1424,6 +1437,7 @@ function useContractRead(_ref4) {
|
|
|
1424
1437
|
return enabled;
|
|
1425
1438
|
}, [addressOrName, blockNumber, cacheOnBlock, enabled_, functionName]);
|
|
1426
1439
|
useInvalidateOnBlock({
|
|
1440
|
+
chainId,
|
|
1427
1441
|
enabled: watch && !cacheOnBlock,
|
|
1428
1442
|
queryKey: queryKey_
|
|
1429
1443
|
});
|
package/dist/wagmi.esm.js
CHANGED
|
@@ -7,6 +7,7 @@ import * as React from 'react';
|
|
|
7
7
|
import * as pkg from 'use-sync-external-store/shim/index.js';
|
|
8
8
|
import { BigNumber } from 'ethers/lib/ethers';
|
|
9
9
|
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector.js';
|
|
10
|
+
import { debounce } from '@wagmi/core/internal';
|
|
10
11
|
|
|
11
12
|
const useSyncExternalStore = pkg.useSyncExternalStore;
|
|
12
13
|
|
|
@@ -289,21 +290,28 @@ function useBlockNumber() {
|
|
|
289
290
|
const chainId = useChainId({
|
|
290
291
|
chainId: chainId_
|
|
291
292
|
});
|
|
292
|
-
const provider = useProvider(
|
|
293
|
-
|
|
293
|
+
const provider = useProvider({
|
|
294
|
+
chainId
|
|
295
|
+
});
|
|
296
|
+
const webSocketProvider = useWebSocketProvider({
|
|
297
|
+
chainId
|
|
298
|
+
});
|
|
294
299
|
const queryClient = useQueryClient();
|
|
295
300
|
React.useEffect(() => {
|
|
296
|
-
if (!watch && !onBlock) return;
|
|
301
|
+
if (!watch && !onBlock) return; // We need to debounce the listener as we want to opt-out
|
|
302
|
+
// of the behavior where ethers emits a "block" event for
|
|
303
|
+
// every block that was missed in between the `pollingInterval`.
|
|
304
|
+
// We are setting a wait time of 1 as emitting an event in
|
|
305
|
+
// ethers takes ~0.1ms.
|
|
297
306
|
|
|
298
|
-
const listener = blockNumber => {
|
|
307
|
+
const listener = debounce(blockNumber => {
|
|
299
308
|
// Just to be safe in case the provider implementation
|
|
300
309
|
// calls the event callback after .off() has been called
|
|
301
310
|
if (watch) queryClient.setQueryData(queryKey$f({
|
|
302
311
|
chainId
|
|
303
312
|
}), blockNumber);
|
|
304
313
|
if (onBlock) onBlock(blockNumber);
|
|
305
|
-
};
|
|
306
|
-
|
|
314
|
+
}, 1);
|
|
307
315
|
const provider_ = webSocketProvider !== null && webSocketProvider !== void 0 ? webSocketProvider : provider;
|
|
308
316
|
provider_.on('block', listener);
|
|
309
317
|
return () => {
|
|
@@ -379,6 +387,7 @@ function useFeeData() {
|
|
|
379
387
|
const {
|
|
380
388
|
data: blockNumber
|
|
381
389
|
} = useBlockNumber({
|
|
390
|
+
chainId,
|
|
382
391
|
watch
|
|
383
392
|
});
|
|
384
393
|
React.useEffect(() => {
|
|
@@ -392,11 +401,13 @@ function useFeeData() {
|
|
|
392
401
|
|
|
393
402
|
function useInvalidateOnBlock(_ref) {
|
|
394
403
|
let {
|
|
404
|
+
chainId,
|
|
395
405
|
enabled,
|
|
396
406
|
queryKey
|
|
397
407
|
} = _ref;
|
|
398
408
|
const queryClient = useQueryClient();
|
|
399
409
|
useBlockNumber({
|
|
410
|
+
chainId,
|
|
400
411
|
onBlock: enabled ? () => queryClient.invalidateQueries(queryKey) : undefined
|
|
401
412
|
});
|
|
402
413
|
}
|
|
@@ -776,6 +787,7 @@ function useBalance() {
|
|
|
776
787
|
const {
|
|
777
788
|
data: blockNumber
|
|
778
789
|
} = useBlockNumber({
|
|
790
|
+
chainId,
|
|
779
791
|
watch
|
|
780
792
|
});
|
|
781
793
|
React.useEffect(() => {
|
|
@@ -1382,6 +1394,7 @@ function useContractRead(_ref4) {
|
|
|
1382
1394
|
const {
|
|
1383
1395
|
data: blockNumber
|
|
1384
1396
|
} = useBlockNumber({
|
|
1397
|
+
chainId,
|
|
1385
1398
|
enabled: watch || cacheOnBlock,
|
|
1386
1399
|
watch
|
|
1387
1400
|
});
|
|
@@ -1400,6 +1413,7 @@ function useContractRead(_ref4) {
|
|
|
1400
1413
|
return enabled;
|
|
1401
1414
|
}, [addressOrName, blockNumber, cacheOnBlock, enabled_, functionName]);
|
|
1402
1415
|
useInvalidateOnBlock({
|
|
1416
|
+
chainId,
|
|
1403
1417
|
enabled: watch && !cacheOnBlock,
|
|
1404
1418
|
queryKey: queryKey_
|
|
1405
1419
|
});
|
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.6.
|
|
5
|
+
"version": "0.6.7",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/wagmi-dev/wagmi.git",
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
"@tanstack/query-sync-storage-persister": "^4.0.10",
|
|
109
109
|
"@tanstack/react-query": "^4.0.10",
|
|
110
110
|
"@tanstack/react-query-persist-client": "^4.0.10",
|
|
111
|
-
"@wagmi/core": "^0.5.
|
|
111
|
+
"@wagmi/core": "^0.5.7",
|
|
112
112
|
"@walletconnect/ethereum-provider": "^1.7.8",
|
|
113
113
|
"use-sync-external-store": "^1.2.0"
|
|
114
114
|
},
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// are you seeing an error that a default export doesn't exist but your source file has a default export?
|
|
2
|
+
// you should run `yarn` or `yarn preconstruct dev` if preconstruct dev isn't in your postinstall hook
|
|
3
|
+
|
|
4
|
+
// curious why you need to?
|
|
5
|
+
// this file exists so that you can import from the entrypoint normally
|
|
6
|
+
// except that it points to your source file and you don't need to run build constantly
|
|
7
|
+
// which means we need to re-export all of the modules from your source file
|
|
8
|
+
// and since export * doesn't include default exports, we need to read your source file
|
|
9
|
+
// to check for a default export and re-export it if it exists
|
|
10
|
+
// it's not ideal, but it works pretty well ¯\_(ツ)_/¯
|
|
11
|
+
export * from "../../../src/providers/coinbaseNode";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// this file might look strange and you might be wondering what it's for
|
|
3
|
+
// it's lets you import your source files by importing this entrypoint
|
|
4
|
+
// as you would import it if it was built with preconstruct build
|
|
5
|
+
// this file is slightly different to some others though
|
|
6
|
+
// it has a require hook which compiles your code with Babel
|
|
7
|
+
// this means that you don't have to set up @babel/register or anything like that
|
|
8
|
+
// but you can still require this module and it'll be compiled
|
|
9
|
+
|
|
10
|
+
// this bit of code imports the require hook and registers it
|
|
11
|
+
let unregister = require("../../../../../node_modules/.pnpm/@preconstruct+hook@0.4.0/node_modules/@preconstruct/hook").___internalHook(typeof __dirname === 'undefined' ? undefined : __dirname, "../../../../..", "../../..");
|
|
12
|
+
|
|
13
|
+
// this re-exports the source file
|
|
14
|
+
module.exports = require("../../../src/providers/coinbaseNode.ts");
|
|
15
|
+
|
|
16
|
+
unregister();
|