@lido-sdk/react
Version:
This project is being slowly deprecated and may not receive further updates. Check out [modern Lido SDK](https://github.com/lidofinance/lido-ethereum-sdk/pulls) to access latest functionality. It is actively maintained and is built for interacting with Li
18 lines (15 loc) • 739 B
JavaScript
import invariant from 'tiny-invariant';
import { useLidoSWR } from './useLidoSWR.js';
import { useSDK } from './useSDK.js';
const useEthereumSWR = (props) => {
var _a;
const { shouldFetch = true, params = [], method, config } = props;
const providerRpcFromSdk = useSDK().providerRpc;
const providerRpc = (_a = props.providerRpc) !== null && _a !== void 0 ? _a : providerRpcFromSdk;
invariant(providerRpc != null, 'RPC Provider is not provided');
invariant(method != null, 'Method is required');
return useLidoSWR(shouldFetch ? [providerRpc, method, ...params] : null, (providerRpc, method, ...params) => {
return providerRpc[method](...params);
}, config);
};
export { useEthereumSWR };