wagmi 0.5.8 → 0.5.9

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.
@@ -21,7 +21,7 @@ export declare const queryKey: ([{ addressOrName, args, chainId, contractInterfa
21
21
  }];
22
22
  export declare function useContractRead({ addressOrName, contractInterface, functionName, args, chainId: chainId_, overrides, cacheOnBlock, cacheTime, enabled: enabled_, isDataEqual, select, staleTime, suspense, watch, onError, onSettled, onSuccess, }: UseContractReadArgs & UseContractReadConfig): Pick<import("react-query").QueryObserverResult<import("ethers/lib/utils").Result, Error>, "data" | "error" | "fetchStatus" | "isError" | "isFetched" | "isFetching" | "isLoading" | "isRefetching" | "isSuccess" | "refetch"> & {
23
23
  isIdle: boolean;
24
- status: "error" | "success" | "idle" | "loading";
24
+ status: "error" | "success" | "idle" | "loading"; /** Subscribe to changes */
25
25
  internal: Pick<import("react-query").QueryObserverResult<unknown, unknown>, "dataUpdatedAt" | "errorUpdatedAt" | "failureCount" | "isFetchedAfterMount" | "isLoadingError" | "isPaused" | "isPlaceholderData" | "isPreviousData" | "isRefetchError" | "isStale" | "remove">;
26
26
  };
27
27
  export {};
@@ -1,3 +1,2 @@
1
1
  export { deserialize } from './deserialize';
2
- export { parseContractResult } from './parseContractResult';
3
2
  export { serialize } from './serialize';
@@ -77,32 +77,6 @@ function deserialize(cachedString) {
77
77
  return deserializedCacheWithBigNumbers;
78
78
  }
79
79
 
80
- function isPlainArray(value) {
81
- return Array.isArray(value) && Object.keys(value).length === value.length;
82
- }
83
-
84
- function parseContractResult(_ref) {
85
- let {
86
- contractInterface,
87
- data,
88
- functionName
89
- } = _ref;
90
-
91
- if (data && isPlainArray(data)) {
92
- var _fragment$outputs, _fragment$outputs$, _fragment$outputs2, _fragment$outputs2$;
93
-
94
- const iface = ethers.Contract.getInterface(contractInterface);
95
- const fragment = iface.getFunction(functionName);
96
- const isArray = (fragment === null || fragment === void 0 ? void 0 : (_fragment$outputs = fragment.outputs) === null || _fragment$outputs === void 0 ? void 0 : (_fragment$outputs$ = _fragment$outputs[0]) === null || _fragment$outputs$ === void 0 ? void 0 : _fragment$outputs$.baseType) === 'array' || (fragment === null || fragment === void 0 ? void 0 : (_fragment$outputs2 = fragment.outputs) === null || _fragment$outputs2 === void 0 ? void 0 : (_fragment$outputs2$ = _fragment$outputs2[0]) === null || _fragment$outputs2$ === void 0 ? void 0 : _fragment$outputs2$.baseType) === 'tuple';
97
- const data_ = isArray ? [data] : data;
98
- const encodedResult = iface.encodeFunctionResult(functionName, data_);
99
- const decodedResult = iface.decodeFunctionResult(functionName, encodedResult);
100
- return isArray ? decodedResult[0] : decodedResult;
101
- }
102
-
103
- return data;
104
- }
105
-
106
80
  /**
107
81
  * @function getReferenceKey
108
82
  *
@@ -1490,7 +1464,7 @@ function useContractRead(_ref4) {
1490
1464
  isDataEqual,
1491
1465
  queryKeyHashFn: queryKeyHashFn$1,
1492
1466
  select: data => {
1493
- const result = parseContractResult({
1467
+ const result = core.parseContractResult({
1494
1468
  contractInterface,
1495
1469
  data,
1496
1470
  functionName
@@ -1613,7 +1587,7 @@ function useContractReads(_ref4) {
1613
1587
  const result = data.map((data, i) => {
1614
1588
  var _contracts$i, _contracts$i2;
1615
1589
 
1616
- return contracts[i] ? parseContractResult({
1590
+ return contracts[i] ? core.parseContractResult({
1617
1591
  contractInterface: (_contracts$i = contracts[i]) === null || _contracts$i === void 0 ? void 0 : _contracts$i.contractInterface,
1618
1592
  functionName: (_contracts$i2 = contracts[i]) === null || _contracts$i2 === void 0 ? void 0 : _contracts$i2.functionName,
1619
1593
  data
@@ -77,32 +77,6 @@ function deserialize(cachedString) {
77
77
  return deserializedCacheWithBigNumbers;
78
78
  }
79
79
 
80
- function isPlainArray(value) {
81
- return Array.isArray(value) && Object.keys(value).length === value.length;
82
- }
83
-
84
- function parseContractResult(_ref) {
85
- let {
86
- contractInterface,
87
- data,
88
- functionName
89
- } = _ref;
90
-
91
- if (data && isPlainArray(data)) {
92
- var _fragment$outputs, _fragment$outputs$, _fragment$outputs2, _fragment$outputs2$;
93
-
94
- const iface = ethers.Contract.getInterface(contractInterface);
95
- const fragment = iface.getFunction(functionName);
96
- const isArray = (fragment === null || fragment === void 0 ? void 0 : (_fragment$outputs = fragment.outputs) === null || _fragment$outputs === void 0 ? void 0 : (_fragment$outputs$ = _fragment$outputs[0]) === null || _fragment$outputs$ === void 0 ? void 0 : _fragment$outputs$.baseType) === 'array' || (fragment === null || fragment === void 0 ? void 0 : (_fragment$outputs2 = fragment.outputs) === null || _fragment$outputs2 === void 0 ? void 0 : (_fragment$outputs2$ = _fragment$outputs2[0]) === null || _fragment$outputs2$ === void 0 ? void 0 : _fragment$outputs2$.baseType) === 'tuple';
97
- const data_ = isArray ? [data] : data;
98
- const encodedResult = iface.encodeFunctionResult(functionName, data_);
99
- const decodedResult = iface.decodeFunctionResult(functionName, encodedResult);
100
- return isArray ? decodedResult[0] : decodedResult;
101
- }
102
-
103
- return data;
104
- }
105
-
106
80
  /**
107
81
  * @function getReferenceKey
108
82
  *
@@ -1490,7 +1464,7 @@ function useContractRead(_ref4) {
1490
1464
  isDataEqual,
1491
1465
  queryKeyHashFn: queryKeyHashFn$1,
1492
1466
  select: data => {
1493
- const result = parseContractResult({
1467
+ const result = core.parseContractResult({
1494
1468
  contractInterface,
1495
1469
  data,
1496
1470
  functionName
@@ -1613,7 +1587,7 @@ function useContractReads(_ref4) {
1613
1587
  const result = data.map((data, i) => {
1614
1588
  var _contracts$i, _contracts$i2;
1615
1589
 
1616
- return contracts[i] ? parseContractResult({
1590
+ return contracts[i] ? core.parseContractResult({
1617
1591
  contractInterface: (_contracts$i = contracts[i]) === null || _contracts$i === void 0 ? void 0 : _contracts$i.contractInterface,
1618
1592
  functionName: (_contracts$i2 = contracts[i]) === null || _contracts$i2 === void 0 ? void 0 : _contracts$i2.functionName,
1619
1593
  data
package/dist/wagmi.esm.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import * as React from 'react';
2
- import { createClient as createClient$1, getProvider, watchProvider, getWebSocketProvider, watchWebSocketProvider, fetchBlockNumber, fetchFeeData, deepEqual, getAccount, watchAccount, fetchBalance, connect, disconnect, getNetwork, watchNetwork, watchSigner, fetchSigner, signMessage, signTypedData, switchNetwork, getContract, readContracts, readContract, writeContract, fetchToken, fetchEnsAddress, fetchEnsAvatar, fetchEnsName, fetchEnsResolver, sendTransaction, waitForTransaction } from '@wagmi/core';
2
+ import { createClient as createClient$1, getProvider, watchProvider, getWebSocketProvider, watchWebSocketProvider, fetchBlockNumber, fetchFeeData, deepEqual, getAccount, watchAccount, fetchBalance, connect, disconnect, getNetwork, watchNetwork, watchSigner, fetchSigner, signMessage, signTypedData, switchNetwork, getContract, readContracts, parseContractResult, readContract, writeContract, fetchToken, fetchEnsAddress, fetchEnsAvatar, fetchEnsName, fetchEnsResolver, sendTransaction, waitForTransaction } from '@wagmi/core';
3
3
  export { AddChainError, ChainDoesNotSupportMulticallError, ChainMismatchError, ChainNotConfiguredError, Client, Connector, ConnectorAlreadyConnectedError, ConnectorNotFoundError, ContractMethodNoResultError, ProviderChainsNotFound, ProviderRpcError, ResourceUnavailableError, RpcError, SwitchChainError, SwitchChainNotSupportedError, UserRejectedRequestError, alchemyRpcUrls, allChains, chain, chainId, configureChains, createStorage, deepEqual, defaultChains, defaultL2Chains, erc20ABI, erc721ABI, etherscanBlockExplorers, infuraRpcUrls, publicRpcUrls, readContracts } from '@wagmi/core';
4
4
  import { QueryClient, QueryClientProvider, useQueryClient, useIsRestoring, useQueryErrorResetBoundary, notifyManager, InfiniteQueryObserver, QueryObserver, useMutation, hashQueryKey } from 'react-query';
5
5
  import { persistQueryClient } from 'react-query/persistQueryClient';
6
6
  import { createWebStoragePersister } from 'react-query/createWebStoragePersister';
7
- import { BigNumber, Contract } from 'ethers/lib/ethers';
7
+ import { BigNumber } from 'ethers/lib/ethers';
8
8
  import * as pkg from 'use-sync-external-store/shim/index.js';
9
9
  import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector.js';
10
10
 
@@ -53,32 +53,6 @@ function deserialize(cachedString) {
53
53
  return deserializedCacheWithBigNumbers;
54
54
  }
55
55
 
56
- function isPlainArray(value) {
57
- return Array.isArray(value) && Object.keys(value).length === value.length;
58
- }
59
-
60
- function parseContractResult(_ref) {
61
- let {
62
- contractInterface,
63
- data,
64
- functionName
65
- } = _ref;
66
-
67
- if (data && isPlainArray(data)) {
68
- var _fragment$outputs, _fragment$outputs$, _fragment$outputs2, _fragment$outputs2$;
69
-
70
- const iface = Contract.getInterface(contractInterface);
71
- const fragment = iface.getFunction(functionName);
72
- const isArray = (fragment === null || fragment === void 0 ? void 0 : (_fragment$outputs = fragment.outputs) === null || _fragment$outputs === void 0 ? void 0 : (_fragment$outputs$ = _fragment$outputs[0]) === null || _fragment$outputs$ === void 0 ? void 0 : _fragment$outputs$.baseType) === 'array' || (fragment === null || fragment === void 0 ? void 0 : (_fragment$outputs2 = fragment.outputs) === null || _fragment$outputs2 === void 0 ? void 0 : (_fragment$outputs2$ = _fragment$outputs2[0]) === null || _fragment$outputs2$ === void 0 ? void 0 : _fragment$outputs2$.baseType) === 'tuple';
73
- const data_ = isArray ? [data] : data;
74
- const encodedResult = iface.encodeFunctionResult(functionName, data_);
75
- const decodedResult = iface.decodeFunctionResult(functionName, encodedResult);
76
- return isArray ? decodedResult[0] : decodedResult;
77
- }
78
-
79
- return data;
80
- }
81
-
82
56
  /**
83
57
  * @function getReferenceKey
84
58
  *
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.5.8",
5
+ "version": "0.5.9",
6
6
  "repository": "tmm/wagmi",
7
7
  "author": "awkweb.eth",
8
8
  "homepage": "https://wagmi.sh",
@@ -96,7 +96,7 @@
96
96
  },
97
97
  "dependencies": {
98
98
  "@coinbase/wallet-sdk": "^3.3.0",
99
- "@wagmi/core": "^0.4.6",
99
+ "@wagmi/core": "^0.4.7",
100
100
  "@walletconnect/ethereum-provider": "^1.7.8",
101
101
  "react-query": "^4.0.0-beta.23",
102
102
  "use-sync-external-store": "^1.1.0"
@@ -1,7 +0,0 @@
1
- import { ContractInterface } from 'ethers/lib/ethers';
2
- import { Result } from 'ethers/lib/utils';
3
- export declare function parseContractResult({ contractInterface, data, functionName, }: {
4
- contractInterface: ContractInterface;
5
- data: Result;
6
- functionName: string;
7
- }): any;