From 249558faca7b9a80839a8249053a402230900162 Mon Sep 17 00:00:00 2001 From: Evgeny Taktarov Date: Mon, 11 Dec 2023 16:18:57 +0700 Subject: [PATCH] fix: add config --- packages/react/src/factories/tokens.ts | 17 +++++++++-------- packages/react/src/hooks/useAllowance.ts | 3 +++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/react/src/factories/tokens.ts b/packages/react/src/factories/tokens.ts index 6bfd7a5..fc6ad35 100644 --- a/packages/react/src/factories/tokens.ts +++ b/packages/react/src/factories/tokens.ts @@ -11,6 +11,7 @@ import { useTotalSupply, useApprove, } from '../hooks'; +import { SWRConfiguration } from 'swr'; export const hooksFactory = ( getTokenAddress: (chainId: CHAINS) => string, @@ -26,25 +27,25 @@ export const hooksFactory = ( ) => UseApproveResponse; } => { return { - useTokenBalance: () => { + useTokenBalance: (config?: SWRConfiguration) => { const { chainId } = useSDK(); const tokenAddress = getTokenAddress(chainId); - return useTokenBalance(tokenAddress); + return useTokenBalance(tokenAddress, undefined, config); }, - useTotalSupply: () => { + useTotalSupply: (config?: SWRConfiguration) => { const { chainId } = useSDK(); const tokenAddress = getTokenAddress(chainId); - return useTotalSupply(tokenAddress); + return useTotalSupply(tokenAddress, config); }, - useDecimals: () => { + useDecimals: (config?: SWRConfiguration) => { const { chainId } = useSDK(); const tokenAddress = getTokenAddress(chainId); - return useDecimals(tokenAddress); + return useDecimals(tokenAddress, config); }, - useAllowance: (spender: string) => { + useAllowance: (spender: string, config?: SWRConfiguration) => { const { chainId } = useSDK(); const tokenAddress = getTokenAddress(chainId); - return useAllowance(tokenAddress, spender); + return useAllowance(tokenAddress, spender, undefined, config); }, useApprove: ( amount: BigNumber, diff --git a/packages/react/src/hooks/useAllowance.ts b/packages/react/src/hooks/useAllowance.ts index 5607b02..ff04e73 100644 --- a/packages/react/src/hooks/useAllowance.ts +++ b/packages/react/src/hooks/useAllowance.ts @@ -7,11 +7,13 @@ import { useContractSWR } from './useContractSWR'; import { SWRResponse } from './useLidoSWR'; import { useSDK } from './useSDK'; import { useDebounceCallback } from './useDebounceCallback'; +import type { SWRConfiguration } from 'swr'; export const useAllowance = ( token: string, spender: string, owner?: string, + config?: SWRConfiguration, ): SWRResponse => { const { providerRpc, providerWeb3, account } = useSDK(); const mergedOwner = owner ?? account; @@ -29,6 +31,7 @@ export const useAllowance = ( contract: contractRpc, method: 'allowance', params: [mergedOwner, spender], + config, }); const updateAllowanceDebounced = useDebounceCallback(result.update, 1000);