Skip to content

Commit

Permalink
Merge pull request #114 from lidofinance/develop
Browse files Browse the repository at this point in the history
Minor release
  • Loading branch information
Jeday authored Dec 11, 2023
2 parents 77213d6 + 7746a86 commit 2fc1faa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
17 changes: 9 additions & 8 deletions packages/react/src/factories/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
useTotalSupply,
useApprove,
} from '../hooks';
import { SWRConfiguration } from 'swr';

export const hooksFactory = (
getTokenAddress: (chainId: CHAINS) => string,
Expand All @@ -26,25 +27,25 @@ export const hooksFactory = (
) => UseApproveResponse;
} => {
return {
useTokenBalance: () => {
useTokenBalance: (config?: SWRConfiguration<BigNumber>) => {
const { chainId } = useSDK();
const tokenAddress = getTokenAddress(chainId);
return useTokenBalance(tokenAddress);
return useTokenBalance(tokenAddress, undefined, config);
},
useTotalSupply: () => {
useTotalSupply: (config?: SWRConfiguration<BigNumber>) => {
const { chainId } = useSDK();
const tokenAddress = getTokenAddress(chainId);
return useTotalSupply(tokenAddress);
return useTotalSupply(tokenAddress, config);
},
useDecimals: () => {
useDecimals: (config?: SWRConfiguration<number>) => {
const { chainId } = useSDK();
const tokenAddress = getTokenAddress(chainId);
return useDecimals(tokenAddress);
return useDecimals(tokenAddress, config);
},
useAllowance: (spender: string) => {
useAllowance: (spender: string, config?: SWRConfiguration<BigNumber>) => {
const { chainId } = useSDK();
const tokenAddress = getTokenAddress(chainId);
return useAllowance(tokenAddress, spender);
return useAllowance(tokenAddress, spender, undefined, config);
},
useApprove: (
amount: BigNumber,
Expand Down
3 changes: 3 additions & 0 deletions packages/react/src/hooks/useAllowance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<BigNumber>,
): SWRResponse<BigNumber> => {
const { providerRpc, providerWeb3, account } = useSDK();
const mergedOwner = owner ?? account;
Expand All @@ -29,6 +31,7 @@ export const useAllowance = (
contract: contractRpc,
method: 'allowance',
params: [mergedOwner, spender],
config,
});

const updateAllowanceDebounced = useDebounceCallback(result.update, 1000);
Expand Down

0 comments on commit 2fc1faa

Please sign in to comment.