UNPKG

@knine-sdk/react

Version:

React helpers for Knine Finance projects. Part of Knine JS SDK

13 lines (10 loc) 518 B
import invariant from 'tiny-invariant'; import { useWrapperSWR } from './useWrapperSWR.js'; const useContractEstimateGasSWR = (props) => { const { shouldFetch = true, params = [], contract, method, config } = props; invariant(method != null, 'Method is required'); return useWrapperSWR(shouldFetch && contract ? [contract, method, ...params] : null, (contract, method, ...params) => { return contract.estimateGas[method](...params); }, config); }; export { useContractEstimateGasSWR };