Update usePools.js
This commit is contained in:
16
packages/react-app/src/hooks/usePools.js
vendored
16
packages/react-app/src/hooks/usePools.js
vendored
@@ -4,8 +4,24 @@ import { useConfig } from "@usedapp/core";
|
|||||||
|
|
||||||
import { ROUTER_ADDRESS } from "../config";
|
import { ROUTER_ADDRESS } from "../config";
|
||||||
|
|
||||||
|
export const loadPools = async (providerUrl) => { //fetch liquidity pool
|
||||||
|
const provider = new Web3.providers.HttpProvider(providerUrl);
|
||||||
|
|
||||||
|
}
|
||||||
export const usePools = () => {
|
export const usePools = () => {
|
||||||
const { readOnlyChainId, readOnlyUrls } = useConfig();
|
const { readOnlyChainId, readOnlyUrls } = useConfig();
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [pools, setPools] = useState({});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
loadPools(readOnlyUrls[readOnlyChainId])
|
||||||
|
.then((pools) => { //callback function / asynchronous
|
||||||
|
setPools(pools);
|
||||||
|
setLoading(false);
|
||||||
|
});
|
||||||
|
}, [readOnlyUrls, readOnlyChainId]); //dependency array
|
||||||
|
|
||||||
|
return [loading, pools];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user