@knine-sdk/react
Version:
React helpers for Knine Finance projects. Part of Knine JS SDK
14 lines (11 loc) • 530 B
JavaScript
import invariant from 'tiny-invariant';
import { useWrapperSWR } from './useWrapperSWR.js';
const useContractSWR = (props) => {
const { shouldFetch = true, params = [], contract, method, config } = props;
invariant(contract != null, 'Contract is required');
invariant(method != null, 'Method is required');
return useWrapperSWR(shouldFetch ? [contract, method, ...params] : null, (contract, method, ...params) => {
return contract[method](...params);
}, config);
};
export { useContractSWR };