Skip to content

Commit

Permalink
feat: Add log
Browse files Browse the repository at this point in the history
  • Loading branch information
jinoosss committed Dec 1, 2023
1 parent a9b2dde commit d6ecfe9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ const SwapContainer: React.FC = () => {
});
}, 2000);
return () => clearTimeout(timeout);
}, [type, tokenA, tokenAAmount, tokenB, tokenBAmount]);
}, [type, tokenA, tokenAAmount, tokenB, tokenBAmount, estimateSwapRoute, checkBalance]);

useEffect(() => {
const queryValues = [];
Expand Down
5 changes: 4 additions & 1 deletion packages/web/src/hooks/swap/use-swap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const useSwap = ({
return null;
}
const pools = await poolRepository.getRPCPools();
console.log("pools", pools);
swapRouterRepository.updatePools(pools);

return swapRouterRepository.estimateSwapRoute({
Expand All @@ -59,7 +60,9 @@ export const useSwap = ({
setEstimatedRoutes(response.estimatedRoutes);
setEstimatedAmount(response.amount);
return response;
}).catch(() => {
}).catch(e => {

console.log(e);
setEstimatedRoutes([]);
setEstimatedAmount(null);
return null;
Expand Down
6 changes: 3 additions & 3 deletions packages/web/src/hooks/token/use-token-data.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,16 @@ export const useTokenData = () => {
}, [tokenPrices, tokens]);

const getTokenUSDPrice = useCallback((tokenAId: string, amount: bigint | string | number) => {
const tokenUSDPrice = tokenPrices[tokenAId].usd;
const tokenUSDPrice = tokenPrices[tokenAId]?.usd || "0";
if (!tokenUSDPrice || Number.isNaN(amount)) {
return null;
}
return BigNumber(amount.toString()).multipliedBy(tokenUSDPrice).toNumber();
}, [tokenPrices]);

const getTokenPriceRate = useCallback((tokenAId: string, tokenBId: string) => {
const tokenAUSDPrice = tokenPrices[tokenAId].usd;
const tokenBUSDPrice = tokenPrices[tokenBId].usd;
const tokenAUSDPrice = tokenPrices[tokenAId]?.usd;
const tokenBUSDPrice = tokenPrices[tokenBId]?.usd;
if (!tokenAUSDPrice || !tokenBUSDPrice) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { TokenRepositoryImpl } from "@repositories/token/token-repository-impl";
import { createContext, useEffect, useMemo, useState } from "react";
import { useAtom } from "jotai";
import { CommonState, WalletState } from "@states/index";
import { GnoProvider, GnoWSProvider } from "@gnolang/gno-js-client";
import { GnoJSONRPCProvider, GnoProvider, GnoWSProvider } from "@gnolang/gno-js-client";
import { SwapRepositoryImpl } from "@repositories/swap/swap-repository-impl";
import ChainNetworkInfos from "@resources/chains.json";
import { SwapRouterRepository } from "@repositories/swap/swap-router-repository";
Expand Down Expand Up @@ -58,8 +58,8 @@ const GnoswapServiceProvider: React.FC<React.PropsWithChildren> = ({
const defaultChainId = process.env.NEXT_PUBLIC_DEFAULT_CHAIN_ID || "";
const currentNetwork = network || ChainNetworkInfos.find(info => info.chainId === defaultChainId);
if (currentNetwork) {
const provider = new GnoWSProvider(currentNetwork.wsUrl, 5 * 1000);
provider.waitForOpenConnection().then(() => setRPCProvider(provider));
const provider = new GnoJSONRPCProvider(currentNetwork.wsUrl);
setRPCProvider(provider);
}
}, [network]);

Expand Down

0 comments on commit d6ecfe9

Please sign in to comment.