From d9caec654da8c1c2b0d0386a884325e301074b77 Mon Sep 17 00:00:00 2001 From: blue Date: Tue, 12 Mar 2024 22:18:09 +0900 Subject: [PATCH] fix. variable typo --- .../PoolAddLiquidityContainer.tsx | 4 +- packages/web/src/hooks/common/use-position.ts | 2 +- .../web/src/hooks/swap/use-swap-handler.tsx | 44 ++++++------ .../models/position/mapper/position-mapper.ts | 4 +- packages/web/src/pages/dashboard.tsx | 4 +- packages/web/src/react-query/pools/queries.ts | 4 +- packages/web/src/react-query/token/queries.ts | 8 +-- .../position/position-repository-impl.ts | 19 ++++-- .../position/position-repository.ts | 19 ++++-- .../position/request/claim-all-request.ts | 2 +- .../request/remove-liquidity-request.ts | 2 +- .../response/position-list-response.ts | 6 +- .../position/response/reward-response.ts | 2 +- .../swap/request/find-best-pool-request.ts | 2 +- .../repositories/swap/swap-repository-impl.ts | 67 ++++++++++--------- .../response/balance-by-address-response.ts | 25 ++++--- .../token/token-repository-impl.ts | 12 ++-- .../token/token-repository-mock.ts | 14 ++-- .../repositories/token/token-repository.ts | 17 +++-- packages/web/src/states/swap.ts | 2 +- packages/web/src/utils/common.ts | 2 +- 21 files changed, 148 insertions(+), 113 deletions(-) diff --git a/packages/web/src/containers/pool-add-liquidity-container/PoolAddLiquidityContainer.tsx b/packages/web/src/containers/pool-add-liquidity-container/PoolAddLiquidityContainer.tsx index 49255b104..975a188e7 100644 --- a/packages/web/src/containers/pool-add-liquidity-container/PoolAddLiquidityContainer.tsx +++ b/packages/web/src/containers/pool-add-liquidity-container/PoolAddLiquidityContainer.tsx @@ -22,7 +22,7 @@ import BigNumber from "bignumber.js"; import { makeSwapFeeTier, priceToNearTick, tickToPrice } from "@utils/swap-utils"; import { usePoolData } from "@hooks/pool/use-pool-data"; import { useGnotToGnot } from "@hooks/token/use-gnot-wugnot"; -import { encriptId } from "@utils/common"; +import { encryptId } from "@utils/common"; export interface AddLiquidityPriceRage { type: PriceRangeType; @@ -316,7 +316,7 @@ const EarnAddLiquidityContainer: React.FC = () => { return; } if (!initialized) { - const convertPath = encriptId(router.query["pool-path"] as string); + const convertPath = encryptId(router.query["pool-path"] as string); const splitPath: string[] = convertPath.split(":") || []; const currentTokenA = tokens.find(token => token.path === splitPath[0]) || null; const currentTokenB = tokens.find(token => token.path === splitPath[1]) || null; diff --git a/packages/web/src/hooks/common/use-position.ts b/packages/web/src/hooks/common/use-position.ts index 43f7ec4df..8e1aefc37 100644 --- a/packages/web/src/hooks/common/use-position.ts +++ b/packages/web/src/hooks/common/use-position.ts @@ -23,7 +23,7 @@ export const usePosition = (positions: PoolPositionModel[]) => { return positionRepository .claimAll({ positions: claimablePositions, - receipient: address, + recipient: address, }) .catch(() => null); }, [account?.address, positionRepository, positions]); diff --git a/packages/web/src/hooks/swap/use-swap-handler.tsx b/packages/web/src/hooks/swap/use-swap-handler.tsx index b96db1f59..1c9a4f63b 100644 --- a/packages/web/src/hooks/swap/use-swap-handler.tsx +++ b/packages/web/src/hooks/swap/use-swap-handler.tsx @@ -31,8 +31,8 @@ const findKeyByValue = ( }; export const useSwapHandler = () => { - const [memoryzeTokenSwap, setMemoryzeTokenSwap] = useAtom( - SwapState.memoryzeTokenSwap, + const [memorizeTokenSwap, setMemorizeTokenSwap] = useAtom( + SwapState.memorizeTokenSwap, ); const router = useRouter(); const [swapValue, setSwapValue] = useAtom(SwapState.swap); @@ -406,7 +406,7 @@ export const useSwapHandler = () => { const changeTokenAAmount = useCallback( (value: string, none?: boolean) => { const memoryzeTokenB = - memoryzeTokenSwap?.[`${tokenA?.symbol}:${value}:${tokenB?.symbol}`]; + memorizeTokenSwap?.[`${tokenA?.symbol}:${value}:${tokenB?.symbol}`]; if (memoryzeTokenB) { setTokenAAmount(value); setTokenBAmount(memoryzeTokenB.split(":")[1]); @@ -442,7 +442,7 @@ export const useSwapHandler = () => { })); setTokenAAmount(value); }, - [isSameToken, memoryzeTokenSwap, tokenA], + [isSameToken, memorizeTokenSwap, tokenA], ); useEffect(() => { setSwapValue(prev => ({ @@ -454,7 +454,7 @@ export const useSwapHandler = () => { const changeTokenBAmount = useCallback( (value: string, none?: boolean) => { const memoryzeTokenA = - memoryzeTokenSwap?.[`${tokenB?.symbol}:${value}:${tokenB?.symbol}`]; + memorizeTokenSwap?.[`${tokenB?.symbol}:${value}:${tokenB?.symbol}`]; if (memoryzeTokenA) { setTokenBAmount(value); setTokenAAmount(memoryzeTokenA.split(":")[1]); @@ -489,7 +489,7 @@ export const useSwapHandler = () => { })); setTokenBAmount(value); }, - [isSameToken, memoryzeTokenSwap, tokenB], + [isSameToken, memorizeTokenSwap, tokenB], ); const changeTokenA = useCallback( @@ -555,18 +555,18 @@ export const useSwapHandler = () => { const keyForValue = findKeyByValue( `${tokenA?.symbol}:${tokenAAmount}:${tokenB?.symbol}`, - memoryzeTokenSwap, + memorizeTokenSwap, ) ?? ""; - if (memoryzeTokenSwap?.[keyForValue]) { + if (memorizeTokenSwap?.[keyForValue]) { setTokenAAmount(keyForValue?.split(":")?.[1]); - setTokenBAmount(memoryzeTokenSwap?.[keyForValue]?.split(":")?.[1]); + setTokenBAmount(memorizeTokenSwap?.[keyForValue]?.split(":")?.[1]); return; } } else { const keyForValue = `${tokenB?.symbol}:${tokenBAmount}:${tokenA?.symbol}`; - if (memoryzeTokenSwap?.[keyForValue]) { + if (memorizeTokenSwap?.[keyForValue]) { setTokenAAmount(tokenBAmount); - setTokenBAmount(memoryzeTokenSwap?.[keyForValue]?.split(":")?.[1]); + setTokenBAmount(memorizeTokenSwap?.[keyForValue]?.split(":")?.[1]); return; } } @@ -591,7 +591,7 @@ export const useSwapHandler = () => { type, tokenAAmount, tokenBAmount, - memoryzeTokenSwap, + memorizeTokenSwap, ]); const copyURL = async () => { @@ -823,7 +823,7 @@ export const useSwapHandler = () => { }, []); useEffect(() => { if ( - memoryzeTokenSwap?.[ + memorizeTokenSwap?.[ `${tokenA?.symbol}:${tokenAAmount}:${tokenB?.symbol}` ] && type === "EXACT_IN" @@ -831,7 +831,7 @@ export const useSwapHandler = () => { return; } if ( - memoryzeTokenSwap?.[ + memorizeTokenSwap?.[ `${tokenB?.symbol}:${tokenBAmount}:${tokenA?.symbol}` ] && type === "EXACT_OUT" @@ -848,7 +848,7 @@ export const useSwapHandler = () => { } }, [ defaultTokenAAmount, - memoryzeTokenSwap, + memorizeTokenSwap, tokenA?.symbol, tokenAAmount, tokenBAmount, @@ -862,7 +862,7 @@ export const useSwapHandler = () => { return; } if ( - memoryzeTokenSwap?.[ + memorizeTokenSwap?.[ `${tokenA?.symbol}:${tokenAAmount}:${tokenB?.symbol}` ] && type === "EXACT_IN" @@ -871,7 +871,7 @@ export const useSwapHandler = () => { return; } if ( - memoryzeTokenSwap?.[ + memorizeTokenSwap?.[ `${tokenA?.symbol}:${tokenAAmount}:${tokenB?.symbol}` ] && type === "EXACT_OUT" @@ -917,14 +917,14 @@ export const useSwapHandler = () => { !!Number(tokenAAmount || 0) && !!Number(tokenBAmount || 0) ) { - setMemoryzeTokenSwap(prev => ({ + setMemorizeTokenSwap(prev => ({ ...prev, [`${tokenA?.symbol}:${tokenAAmount}:${tokenB?.symbol}`]: `${tokenB?.symbol}:${tokenBAmount}`, })); setIsChangeBalancesToken(false); } else { setIsChangeBalancesToken(false); - setMemoryzeTokenSwap(prev => ({ + setMemorizeTokenSwap(prev => ({ ...prev, [`${tokenA?.symbol}:${tokenAAmount}:${tokenB?.symbol}`]: `${tokenB?.symbol}:${tokenBAmount}`, })); @@ -938,7 +938,7 @@ export const useSwapHandler = () => { tokenB, tokenBAmount, isSameToken, - memoryzeTokenSwap, + memorizeTokenSwap, ]); useEffect(() => { @@ -951,12 +951,12 @@ export const useSwapHandler = () => { if (!isError) { if (isExactIn) { setTokenBAmount(expectedAmount); - setMemoryzeTokenSwap(prev => ({ + setMemorizeTokenSwap(prev => ({ ...prev, [`${tokenA?.symbol}:${tokenAAmount}:${tokenB?.symbol}`]: `${tokenB?.symbol}:${tokenBAmount}`, })); } else { - setMemoryzeTokenSwap(prev => ({ + setMemorizeTokenSwap(prev => ({ ...prev, [`${tokenB?.symbol}:${tokenBAmount}:${tokenA?.symbol}`]: `${tokenA?.symbol}:${tokenAAmount}`, })); diff --git a/packages/web/src/models/position/mapper/position-mapper.ts b/packages/web/src/models/position/mapper/position-mapper.ts index d0349ba5a..4fb76dc83 100644 --- a/packages/web/src/models/position/mapper/position-mapper.ts +++ b/packages/web/src/models/position/mapper/position-mapper.ts @@ -5,7 +5,7 @@ import { PositionListResponse, PositionResponse, } from "@repositories/position/response"; -import { RewardResposne } from "@repositories/position/response/reward-response"; +import { RewardResponse } from "@repositories/position/response/reward-response"; import { PoolPositionModel } from "../pool-position-model"; import { PositionModel } from "../position-model"; import { RewardModel } from "../reward-model"; @@ -73,7 +73,7 @@ export class PositionMapper { return positions.map(PositionMapper.from); } - public static rewardFromResponse(reward: RewardResposne): RewardModel { + public static rewardFromResponse(reward: RewardResponse): RewardModel { return { token: reward.rewardToken, accumulatedRewardOf1d: diff --git a/packages/web/src/pages/dashboard.tsx b/packages/web/src/pages/dashboard.tsx index a55605779..e2db0b59d 100644 --- a/packages/web/src/pages/dashboard.tsx +++ b/packages/web/src/pages/dashboard.tsx @@ -1,4 +1,4 @@ -import DashbordLayout from "@layouts/dashboard-layout/DashboardLayout"; +import DashboardLayout from "@layouts/dashboard-layout/DashboardLayout"; import HeaderContainer from "@containers/header-container/HeaderContainer"; import Footer from "@components/common/footer/Footer"; import TvlChartContainer from "@containers/tvl-chart-container/TvlChartContainer"; @@ -8,7 +8,7 @@ import DashboardActivitiesContainer from "@containers/dashboard-activities-conta export default function Dashboard() { return ( - } tvl={} volume={} diff --git a/packages/web/src/react-query/pools/queries.ts b/packages/web/src/react-query/pools/queries.ts index 1119fdf39..ec264dfef 100644 --- a/packages/web/src/react-query/pools/queries.ts +++ b/packages/web/src/react-query/pools/queries.ts @@ -2,7 +2,7 @@ import { UseQueryOptions, useQuery } from "@tanstack/react-query"; import { useGnoswapContext } from "@hooks/common/use-gnoswap-context"; import { PoolModel } from "@models/pool/pool-model"; import { QUERY_KEY } from "./types"; -import { encriptId } from "@utils/common"; +import { encryptId } from "@utils/common"; import { PoolDetailModel } from "@models/pool/pool-detail-model"; export const useGetPoolList = ( @@ -26,7 +26,7 @@ export const useGetPoolDetailByPath = ( options?: UseQueryOptions ) => { const { poolRepository } = useGnoswapContext(); - const convertPath = encriptId(path); + const convertPath = encryptId(path); return useQuery({ queryKey: [QUERY_KEY.poolDetail, convertPath], queryFn: async () => { diff --git a/packages/web/src/react-query/token/queries.ts b/packages/web/src/react-query/token/queries.ts index 0c6fdb02b..e1607c417 100644 --- a/packages/web/src/react-query/token/queries.ts +++ b/packages/web/src/react-query/token/queries.ts @@ -8,7 +8,7 @@ import { UseQueryOptions, useQuery } from "@tanstack/react-query"; import { QUERY_KEY } from "./types"; import { useGnoswapContext } from "@hooks/common/use-gnoswap-context"; import { TokenPriceModel } from "@models/token/token-price-model"; -import { IBalancesByAddressReponse } from "@repositories/token/response/balance-by-address-response"; +import { IBalancesByAddressResponse } from "@repositories/token/response/balance-by-address-response"; export const useGetTokensList = ( options?: UseQueryOptions, @@ -68,7 +68,7 @@ export const useGetChainList = ( export const useGetTokenByPath = ( path: string, - option?: UseQueryOptions + option?: UseQueryOptions, ) => { const { tokenRepository } = useGnoswapContext(); return useQuery({ @@ -80,10 +80,10 @@ export const useGetTokenByPath = ( export const useGetBalancesByAddress = ( address: string, - option?: UseQueryOptions + option?: UseQueryOptions, ) => { const { tokenRepository } = useGnoswapContext(); - return useQuery({ + return useQuery({ queryKey: [QUERY_KEY.tokenBalancesByAddress, address], queryFn: () => tokenRepository.getBalancesByAddress(address), ...option, diff --git a/packages/web/src/repositories/position/position-repository-impl.ts b/packages/web/src/repositories/position/position-repository-impl.ts index d43e7e49e..fc3699fb2 100644 --- a/packages/web/src/repositories/position/position-repository-impl.ts +++ b/packages/web/src/repositories/position/position-repository-impl.ts @@ -1,6 +1,9 @@ import { NetworkClient } from "@common/clients/network-client"; import { WalletClient } from "@common/clients/wallet-client"; -import { SendTransactionResponse, WalletResponse } from "@common/clients/wallet-client/protocols"; +import { + SendTransactionResponse, + WalletResponse, +} from "@common/clients/wallet-client/protocols"; import { CommonError } from "@common/errors"; import { DEFAULT_GAS_FEE, DEFAULT_GAS_WANTED } from "@common/values"; import { GnoProvider } from "@gnolang/gno-js-client"; @@ -8,7 +11,7 @@ import { PositionMapper } from "@models/position/mapper/position-mapper"; import { PositionModel } from "@models/position/position-model"; import { PositionRepository } from "./position-repository"; import { ClaimAllRequest } from "./request/claim-all-request"; -import { RemoveLiquidityReqeust } from "./request/remove-liquidity-request"; +import { RemoveLiquidityRequest } from "./request/remove-liquidity-request"; import { StakePositionsRequest } from "./request/stake-positions-request"; import { UnstakePositionsRequest } from "./request/unstake-positions-request"; import { PositionListResponse } from "./response"; @@ -45,11 +48,13 @@ export class PositionRepositoryImpl implements PositionRepository { return PositionMapper.fromList(response.data); }; - claimAll = async (request: ClaimAllRequest): Promise>> => { + claimAll = async ( + request: ClaimAllRequest, + ): Promise>> => { if (this.walletClient === null) { throw new CommonError("FAILED_INITIALIZE_WALLET"); } - const { positions, receipient } = request; + const { positions, recipient } = request; const messages = positions.flatMap(position => { const messages = []; const hasSwapFee = @@ -62,11 +67,11 @@ export class PositionRepositoryImpl implements PositionRepository { ) > -1; if (hasSwapFee) { messages.push( - makePositionCollectFeeMessage(position.lpTokenId, receipient), + makePositionCollectFeeMessage(position.lpTokenId, recipient), ); } if (hasReward) { - messages.push(makeCollectRewardMessage(position.lpTokenId, receipient)); + messages.push(makeCollectRewardMessage(position.lpTokenId, recipient)); } return messages; }); @@ -116,7 +121,7 @@ export class PositionRepositoryImpl implements PositionRepository { }; removeLiquidity = async ( - request: RemoveLiquidityReqeust, + request: RemoveLiquidityRequest, ): Promise>> => { if (this.walletClient === null) { throw new CommonError("FAILED_INITIALIZE_WALLET"); diff --git a/packages/web/src/repositories/position/position-repository.ts b/packages/web/src/repositories/position/position-repository.ts index d34e2d67d..f70eeb367 100644 --- a/packages/web/src/repositories/position/position-repository.ts +++ b/packages/web/src/repositories/position/position-repository.ts @@ -1,20 +1,29 @@ import { PositionModel } from "@models/position/position-model"; import { ClaimAllRequest } from "./request/claim-all-request"; -import { RemoveLiquidityReqeust } from "./request/remove-liquidity-request"; +import { RemoveLiquidityRequest } from "./request/remove-liquidity-request"; import { StakePositionsRequest } from "./request/stake-positions-request"; import { UnstakePositionsRequest } from "./request/unstake-positions-request"; -import { SendTransactionResponse, WalletResponse } from "@common/clients/wallet-client/protocols"; +import { + SendTransactionResponse, + WalletResponse, +} from "@common/clients/wallet-client/protocols"; export interface PositionRepository { getPositionsByAddress: (address: string) => Promise; - claimAll: (request: ClaimAllRequest) => Promise>>; + claimAll: ( + request: ClaimAllRequest, + ) => Promise>>; - stakePositions: (request: StakePositionsRequest) => Promise>> ; + stakePositions: ( + request: StakePositionsRequest, + ) => Promise>>; unstakePositions: ( request: UnstakePositionsRequest, ) => Promise>>; - removeLiquidity: (request: RemoveLiquidityReqeust) => Promise>>; + removeLiquidity: ( + request: RemoveLiquidityRequest, + ) => Promise>>; } diff --git a/packages/web/src/repositories/position/request/claim-all-request.ts b/packages/web/src/repositories/position/request/claim-all-request.ts index dd9733fa8..26ec651e2 100644 --- a/packages/web/src/repositories/position/request/claim-all-request.ts +++ b/packages/web/src/repositories/position/request/claim-all-request.ts @@ -3,5 +3,5 @@ import { PositionModel } from "@models/position/position-model"; export interface ClaimAllRequest { positions: PositionModel[]; - receipient: string; + recipient: string; } diff --git a/packages/web/src/repositories/position/request/remove-liquidity-request.ts b/packages/web/src/repositories/position/request/remove-liquidity-request.ts index c73d077a1..b51a458fe 100644 --- a/packages/web/src/repositories/position/request/remove-liquidity-request.ts +++ b/packages/web/src/repositories/position/request/remove-liquidity-request.ts @@ -1,4 +1,4 @@ -export interface RemoveLiquidityReqeust { +export interface RemoveLiquidityRequest { lpTokenIds: string[]; caller: string; diff --git a/packages/web/src/repositories/position/response/position-list-response.ts b/packages/web/src/repositories/position/response/position-list-response.ts index 023fc2b46..457f35672 100644 --- a/packages/web/src/repositories/position/response/position-list-response.ts +++ b/packages/web/src/repositories/position/response/position-list-response.ts @@ -1,5 +1,5 @@ import { PoolBinModel } from "@models/pool/pool-bin-model"; -import { RewardResposne } from "./reward-response"; +import { RewardResponse } from "./reward-response"; export type PositionListResponse = PositionResponse[]; @@ -48,8 +48,8 @@ export interface PositionResponse { stakedUsdValue?: string; - rewards?: RewardResposne[]; + rewards?: RewardResponse[]; - dailyRewards?: RewardResposne[]; + dailyRewards?: RewardResponse[]; bins: PoolBinModel[]; } diff --git a/packages/web/src/repositories/position/response/reward-response.ts b/packages/web/src/repositories/position/response/reward-response.ts index e63639d8f..c0cf70c5c 100644 --- a/packages/web/src/repositories/position/response/reward-response.ts +++ b/packages/web/src/repositories/position/response/reward-response.ts @@ -1,7 +1,7 @@ import { RewardType } from "@constants/option.constant"; import { TokenModel } from "@models/token/token-model"; -export interface RewardResposne { +export interface RewardResponse { rewardType: RewardType; rewardToken: TokenModel; diff --git a/packages/web/src/repositories/swap/request/find-best-pool-request.ts b/packages/web/src/repositories/swap/request/find-best-pool-request.ts index a14acc23f..a032dfcfa 100644 --- a/packages/web/src/repositories/swap/request/find-best-pool-request.ts +++ b/packages/web/src/repositories/swap/request/find-best-pool-request.ts @@ -1,6 +1,6 @@ import { TokenModel } from "@models/token/token-model"; -export interface FindBestPoolReqeust { +export interface FindBestPoolRequest { tokenA: TokenModel; tokenB: TokenModel; diff --git a/packages/web/src/repositories/swap/swap-repository-impl.ts b/packages/web/src/repositories/swap/swap-repository-impl.ts index 7efb2005d..e8d9fef4e 100644 --- a/packages/web/src/repositories/swap/swap-repository-impl.ts +++ b/packages/web/src/repositories/swap/swap-repository-impl.ts @@ -18,7 +18,7 @@ import { } from "@utils/rpc-utils"; import BigNumber from "bignumber.js"; import { TokenModel } from "@models/token/token-model"; -import { FindBestPoolReqeust } from "./request/find-best-pool-request"; +import { FindBestPoolRequest } from "./request/find-best-pool-request"; import { SwapPoolResponse } from "./response/swap-pool-response"; import { makeSwapFeeTier } from "@utils/swap-utils"; import { CommonError } from "@common/errors"; @@ -54,7 +54,7 @@ export class SwapRepositoryImpl implements SwapRepository { }; public findSwapPool = async ( - request: FindBestPoolReqeust, + request: FindBestPoolRequest, ): Promise => { const poolPackagePath = process.env.NEXT_PUBLIC_PACKAGE_POOL_PATH; if (!poolPackagePath || !this.rpcProvider) { @@ -66,18 +66,25 @@ export class SwapRepositoryImpl implements SwapRepository { } const tokenAPath = tokenA.symbol.toLowerCase(); const tokenBPath = tokenB.symbol.toLowerCase(); - const param = makeABCIParams("FindBestPool", [tokenAPath, tokenBPath, zeroForOne, amountSpecified]); + const param = makeABCIParams("FindBestPool", [ + tokenAPath, + tokenBPath, + zeroForOne, + amountSpecified, + ]); const result = await this.rpcProvider .evaluateExpression(poolPackagePath, param) - .then(evaluateExpressionToObject<{ - response: { - data: { - pool_path: string; - sqrt_price_x96: number; - tick_spacing: number; - } - } - }>); + .then( + evaluateExpressionToObject<{ + response: { + data: { + pool_path: string; + sqrt_price_x96: number; + tick_spacing: number; + }; + }; + }>, + ); if (result === null) { throw new SwapError("NOT_FOUND_SWAP_POOL"); @@ -85,7 +92,9 @@ export class SwapRepositoryImpl implements SwapRepository { const poolPath = result.response.data.pool_path; const poolPathSplit = poolPath.split("_"); const feeStr = poolPathSplit[poolPathSplit.length - 1]; - const sqrtPriceX96 = BigNumber(result.response.data.sqrt_price_x96).toString(); + const sqrtPriceX96 = BigNumber( + result.response.data.sqrt_price_x96, + ).toString(); const tickSpacing = result.response.data.tick_spacing; const feeTier = makeSwapFeeTier(feeStr); @@ -93,7 +102,7 @@ export class SwapRepositoryImpl implements SwapRepository { feeTier, poolPath, sqrtPriceX96, - tickSpacing + tickSpacing, }; }; @@ -108,18 +117,20 @@ export class SwapRepositoryImpl implements SwapRepository { priceImpact: 0, }; } - const { - tokenA, - tokenB, - fee, - amountSpecified, - zeroForOne, - receiver, - } = request; + const { tokenA, tokenB, fee, amountSpecified, zeroForOne, receiver } = + request; const tokenAPath = tokenA.symbol.toLowerCase(); const tokenBPath = tokenB.symbol.toLowerCase(); const priceLimit = zeroForOne ? MIN_PRICE_X96 : MAX_PRICE_X96; - const param = makeABCIParams("DrySwap", [tokenAPath, tokenBPath, fee, receiver, zeroForOne, amountSpecified, priceLimit.toString()]); + const param = makeABCIParams("DrySwap", [ + tokenAPath, + tokenBPath, + fee, + receiver, + zeroForOne, + amountSpecified, + priceLimit.toString(), + ]); const result = await this.rpcProvider .evaluateExpression(poolPackagePath, param) .then(evaluateExpressionToValues); @@ -164,14 +175,8 @@ export class SwapRepositoryImpl implements SwapRepository { throw new CommonError("FAILED_INITIALIZE_PROVIDER"); } const { address } = account.data; - const { - tokenA, - tokenB, - fee, - receiver, - zeroForOne, - amountSpecified, - } = swapRequest; + const { tokenA, tokenB, fee, receiver, zeroForOne, amountSpecified } = + swapRequest; const priceLimit = zeroForOne ? "4295128740" : "1461446703485210103287273052203988822378723970341"; diff --git a/packages/web/src/repositories/token/response/balance-by-address-response.ts b/packages/web/src/repositories/token/response/balance-by-address-response.ts index dc9affc92..e159e6420 100644 --- a/packages/web/src/repositories/token/response/balance-by-address-response.ts +++ b/packages/web/src/repositories/token/response/balance-by-address-response.ts @@ -1,13 +1,12 @@ -export interface IBalancesByAddressReponse { - address: string - balances: Balance[] - } - - export interface Balance { - type: string - path: string - address: string - balance: string - denom: string - } - \ No newline at end of file +export interface IBalancesByAddressResponse { + address: string; + balances: Balance[]; +} + +export interface Balance { + type: string; + path: string; + address: string; + balance: string; + denom: string; +} diff --git a/packages/web/src/repositories/token/token-repository-impl.ts b/packages/web/src/repositories/token/token-repository-impl.ts index 12569ba86..bb0b9a064 100644 --- a/packages/web/src/repositories/token/token-repository-impl.ts +++ b/packages/web/src/repositories/token/token-repository-impl.ts @@ -12,7 +12,7 @@ import { StorageKeyType } from "@common/values"; import { TokenSearchLogModel } from "@models/token/token-search-log-model"; import { StorageClient } from "@common/clients/storage-client"; import { NetworkClient } from "@common/clients/network-client"; -import { IBalancesByAddressReponse } from "./response/balance-by-address-response"; +import { IBalancesByAddressResponse } from "./response/balance-by-address-response"; import { customSort } from "@containers/select-token-container/SelectTokenContainer"; export class TokenRepositoryImpl implements TokenRepository { @@ -52,7 +52,9 @@ export class TokenRepositoryImpl implements TokenRepository { return response.data; }; - public getTokenDetailByPath = async (path: string): Promise => { + public getTokenDetailByPath = async ( + path: string, + ): Promise => { const response = await this.networkClient.get({ url: `/token_details/${path}`, }); @@ -66,8 +68,10 @@ export class TokenRepositoryImpl implements TokenRepository { return response.data; }; - public getBalancesByAddress = async (address: string): Promise => { - const response = await this.networkClient.get({ + public getBalancesByAddress = async ( + address: string, + ): Promise => { + const response = await this.networkClient.get({ url: `/balances/${address}`, }); return response.data; diff --git a/packages/web/src/repositories/token/token-repository-mock.ts b/packages/web/src/repositories/token/token-repository-mock.ts index 71f1cc4d7..2c7d42795 100644 --- a/packages/web/src/repositories/token/token-repository-mock.ts +++ b/packages/web/src/repositories/token/token-repository-mock.ts @@ -14,7 +14,7 @@ import { StorageClient } from "@common/clients/storage-client"; import TokenDetail from "./mock/token-detail.json"; import ChainData from "./mock/token-chain.json"; import TokenByPath from "./mock/token-by-path.json"; -import { IBalancesByAddressReponse } from "./response/balance-by-address-response"; +import { IBalancesByAddressResponse } from "./response/balance-by-address-response"; export class TokenRepositoryMock implements TokenRepository { private localStorageClient: StorageClient; @@ -29,7 +29,7 @@ export class TokenRepositoryMock implements TokenRepository { public getTokenByPath = async (path: string): Promise => { console.log(path); - + return TokenByPath as ITokenResponse; }; @@ -37,9 +37,11 @@ export class TokenRepositoryMock implements TokenRepository { return { prices: [] }; }; - public getTokenDetailByPath = async (path: string): Promise => { + public getTokenDetailByPath = async ( + path: string, + ): Promise => { console.log(path); - + return TokenDetail; }; @@ -80,7 +82,9 @@ export class TokenRepositoryMock implements TokenRepository { return true; }; - public getBalancesByAddress = async (address: string): Promise => { + public getBalancesByAddress = async ( + address: string, + ): Promise => { return { address: address, balances: [], diff --git a/packages/web/src/repositories/token/token-repository.ts b/packages/web/src/repositories/token/token-repository.ts index d23a7ae0c..5a7f31fd5 100644 --- a/packages/web/src/repositories/token/token-repository.ts +++ b/packages/web/src/repositories/token/token-repository.ts @@ -1,6 +1,13 @@ import { TokenSearchLogModel } from "@models/token/token-search-log-model"; -import { IChainResponse, ITokenDetailResponse, ITokenResponse, TokenListResponse, TokenPriceListResponse, TokenSearchLogListResponse } from "./response"; -import { IBalancesByAddressReponse } from "./response/balance-by-address-response"; +import { + IChainResponse, + ITokenDetailResponse, + ITokenResponse, + TokenListResponse, + TokenPriceListResponse, + TokenSearchLogListResponse, +} from "./response"; +import { IBalancesByAddressResponse } from "./response/balance-by-address-response"; export interface TokenRepository { getTokens: () => Promise; @@ -8,7 +15,7 @@ export interface TokenRepository { getTokenByPath: (path: string) => Promise; getTokenPrices: () => Promise; - + getTokenDetailByPath: (path: string) => Promise; createSearchLog: (searchLog: TokenSearchLogModel) => Promise; @@ -19,5 +26,7 @@ export interface TokenRepository { getChain: () => Promise; - getBalancesByAddress: (address: string) => Promise; + getBalancesByAddress: ( + address: string, + ) => Promise; } diff --git a/packages/web/src/states/swap.ts b/packages/web/src/states/swap.ts index 1f111a52a..6416eed1e 100644 --- a/packages/web/src/states/swap.ts +++ b/packages/web/src/states/swap.ts @@ -20,4 +20,4 @@ export const swap = atom({ isKeepToken: false, }); -export const memoryzeTokenSwap = atom>({}); +export const memorizeTokenSwap = atom>({}); diff --git a/packages/web/src/utils/common.ts b/packages/web/src/utils/common.ts index 6ff45f885..6741614f9 100644 --- a/packages/web/src/utils/common.ts +++ b/packages/web/src/utils/common.ts @@ -39,7 +39,7 @@ export function makeId(value: string) { return value.replace(/\//g, "_"); } -export function encriptId(value: string) { +export function encryptId(value: string) { return (value || "").replace(/_/g, "/"); }