wagmi-extended 1.1.7 → 2.0.0

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.
Files changed (63) hide show
  1. package/README.md +1 -1
  2. package/dist/fetch-functions/erc20/fetchAllowanceX.d.ts +4 -0
  3. package/dist/fetch-functions/erc20/fetchBalanceOfX.d.ts +4 -0
  4. package/dist/fetch-functions/erc20/fetchERC20DataX.d.ts +18 -0
  5. package/dist/fetch-functions/erc20/fetchNameX.d.ts +4 -0
  6. package/dist/fetch-functions/erc20/fetchSymbolX.d.ts +4 -0
  7. package/dist/fetch-functions/erc20/fetchTotalSupplyX.d.ts +4 -0
  8. package/dist/fetch-functions/erc4626/fetchERC4626AssetX.d.ts +4 -0
  9. package/dist/fetch-functions/erc4626/fetchERC4626ConvertToAssetsX.d.ts +4 -0
  10. package/dist/fetch-functions/erc4626/fetchERC4626ConvertToSharesX.d.ts +4 -0
  11. package/dist/fetch-functions/erc4626/fetchERC4626DataX.d.ts +24 -0
  12. package/dist/fetch-functions/erc4626/fetchERC4626MaxDepositX.d.ts +4 -0
  13. package/dist/fetch-functions/erc4626/fetchERC4626MaxMintX.d.ts +4 -0
  14. package/dist/fetch-functions/erc4626/fetchERC4626MaxRedeemX.d.ts +4 -0
  15. package/dist/fetch-functions/erc4626/fetchERC4626MaxWithdrawX.d.ts +4 -0
  16. package/dist/fetch-functions/erc4626/fetchERC4626TotalAssetsX.d.ts +4 -0
  17. package/dist/hooks/{useContractWriteX.d.ts → mutations/useContractWriteX.d.ts} +40 -35
  18. package/dist/hooks/{useHandleTransactionMutationX.d.ts → mutations/useHandleTransactionMutationX.d.ts} +8 -1
  19. package/dist/hooks/{useSendTransactionX.d.ts → mutations/useSendTransactionX.d.ts} +14 -13
  20. package/dist/hooks/queries/useERC20Data.d.ts +22 -0
  21. package/dist/hooks/queries/useFetchERC4626DataX.d.ts +28 -0
  22. package/dist/hooks/{useTokenX.d.ts → queries/useTokenX.d.ts} +18 -18
  23. package/dist/index.cjs.js +352 -118
  24. package/dist/index.cjs.js.map +1 -1
  25. package/dist/index.d.ts +17 -5
  26. package/dist/index.esm.js +342 -120
  27. package/dist/index.esm.js.map +1 -1
  28. package/dist/query-config/index.d.ts +20 -2
  29. package/dist/utils/ensureClientAndConfig.d.ts +6 -0
  30. package/package.json +1 -1
  31. package/src/fetch-functions/erc20/fetchAllowanceX.ts +31 -0
  32. package/src/fetch-functions/erc20/fetchBalanceOfX.ts +28 -0
  33. package/src/fetch-functions/erc20/fetchERC20DataX.ts +52 -0
  34. package/src/fetch-functions/erc20/fetchNameX.ts +26 -0
  35. package/src/fetch-functions/erc20/fetchSymbolX.ts +26 -0
  36. package/src/fetch-functions/erc20/fetchTotalSupplyX.ts +26 -0
  37. package/src/fetch-functions/erc4626/fetchERC4626AssetX.ts +25 -0
  38. package/src/fetch-functions/erc4626/fetchERC4626ConvertToAssetsX.ts +27 -0
  39. package/src/fetch-functions/erc4626/fetchERC4626ConvertToSharesX.ts +27 -0
  40. package/src/fetch-functions/erc4626/fetchERC4626DataX.ts +60 -0
  41. package/src/fetch-functions/erc4626/fetchERC4626MaxDepositX.ts +27 -0
  42. package/src/fetch-functions/erc4626/fetchERC4626MaxMintX.ts +27 -0
  43. package/src/fetch-functions/erc4626/fetchERC4626MaxRedeemX.ts +27 -0
  44. package/src/fetch-functions/erc4626/fetchERC4626MaxWithdrawX.ts +27 -0
  45. package/src/fetch-functions/erc4626/fetchERC4626TotalAssetsX.ts +25 -0
  46. package/src/fetch-functions/fetchTokenX.ts +16 -30
  47. package/src/hooks/{useContractWriteX.ts → mutations/useContractWriteX.ts} +32 -12
  48. package/src/hooks/{useERC20ApproveX.ts → mutations/useERC20ApproveX.ts} +10 -14
  49. package/src/hooks/{useHandleTransactionMutationX.ts → mutations/useHandleTransactionMutationX.ts} +30 -4
  50. package/src/hooks/{useSendTransactionX.ts → mutations/useSendTransactionX.ts} +36 -3
  51. package/src/hooks/queries/useERC20Data.ts +40 -0
  52. package/src/hooks/{useFetchAssetAllowanceX.ts → queries/useFetchAssetAllowanceX.ts} +6 -4
  53. package/src/hooks/queries/useFetchERC4626DataX.ts +39 -0
  54. package/src/hooks/{useTokenX.ts → queries/useTokenX.ts} +1 -1
  55. package/src/index.ts +17 -5
  56. package/src/query-config/index.ts +13 -3
  57. package/src/utils/ensureClientAndConfig.ts +18 -0
  58. package/dist/fetch-functions/fetchAllowanceX.d.ts +0 -2
  59. package/src/fetch-functions/fetchAllowanceX.ts +0 -22
  60. /package/dist/hooks/{useERC20ApproveX.d.ts → mutations/useERC20ApproveX.d.ts} +0 -0
  61. /package/dist/hooks/{useInvalidateQueries.d.ts → mutations/useInvalidateQueries.d.ts} +0 -0
  62. /package/dist/hooks/{useFetchAssetAllowanceX.d.ts → queries/useFetchAssetAllowanceX.d.ts} +0 -0
  63. /package/src/hooks/{useInvalidateQueries.ts → mutations/useInvalidateQueries.ts} +0 -0
@@ -0,0 +1,18 @@
1
+ import { QueryClient } from "@tanstack/react-query";
2
+ import { Config } from "wagmi";
3
+ import { getDefaults } from "../config/defaults.js";
4
+
5
+ export function ensureClientAndConfig(
6
+ queryClient?: QueryClient,
7
+ wagmiConfig?: Config
8
+ ): { queryClient: QueryClient; wagmiConfig: Config } {
9
+ if (!queryClient || !wagmiConfig) {
10
+ ({ queryClient, wagmiConfig } = getDefaults());
11
+ }
12
+ if (!queryClient || !wagmiConfig) {
13
+ throw new Error(
14
+ "Could not find queryClient or wagmiConfig; pass them in or setDefaults() first"
15
+ );
16
+ }
17
+ return { queryClient, wagmiConfig };
18
+ }
@@ -1,2 +0,0 @@
1
- import { Address } from "viem";
2
- export declare const fetchAllowance: (asset: Address, spender: Address, userAddress: Address, config: any) => Promise<bigint>;
@@ -1,22 +0,0 @@
1
- import { Address, erc20Abi } from "viem";
2
- import { readContract } from "viem/actions";
3
-
4
- export const fetchAllowance = async (
5
- asset: Address,
6
- spender: Address,
7
- userAddress: Address,
8
- config: any
9
- ) => {
10
- const allowance = await readContract(config, {
11
- address: asset,
12
- abi: erc20Abi,
13
- functionName: "allowance",
14
- args: [userAddress, spender],
15
- });
16
-
17
- if (allowance == null) {
18
- throw new Error("Failed to fetch token data or allowance");
19
- }
20
-
21
- return allowance;
22
- };