diff --git a/packages/web/src/hooks/token/use-token-data.tsx b/packages/web/src/hooks/token/use-token-data.tsx index bd5c27d89..6738869d6 100644 --- a/packages/web/src/hooks/token/use-token-data.tsx +++ b/packages/web/src/hooks/token/use-token-data.tsx @@ -61,7 +61,7 @@ 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; } @@ -69,8 +69,8 @@ export const useTokenData = () => { }, [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; } diff --git a/packages/web/src/providers/gnoswap-service-provider/GnoswapServiceProvider.tsx b/packages/web/src/providers/gnoswap-service-provider/GnoswapServiceProvider.tsx index 53bd09050..e91fbb17e 100644 --- a/packages/web/src/providers/gnoswap-service-provider/GnoswapServiceProvider.tsx +++ b/packages/web/src/providers/gnoswap-service-provider/GnoswapServiceProvider.tsx @@ -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 } 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"; @@ -58,8 +58,8 @@ const GnoswapServiceProvider: React.FC = ({ 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.rpcUrl); + setRPCProvider(provider); } }, [network]);