From 0e299a9f40b8fa1b722e9d598df56375b6c6e3c3 Mon Sep 17 00:00:00 2001 From: woodenfurniture <125113430+woodenfurniture@users.noreply.github.com> Date: Fri, 8 Nov 2024 10:58:12 +1100 Subject: [PATCH] fix: dont require account number when getting a quote --- packages/swapper/src/types.ts | 3 --- .../hooks/useGetTradeQuotes/getTradeQuoteInput.ts | 13 +++---------- .../hooks/useGetTradeQuotes/useGetTradeQuotes.tsx | 3 --- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/packages/swapper/src/types.ts b/packages/swapper/src/types.ts index ca9595785ef..b41da28b946 100644 --- a/packages/swapper/src/types.ts +++ b/packages/swapper/src/types.ts @@ -138,7 +138,6 @@ type CommonTradeInputBase = { export type CommonTradeQuoteInput = CommonTradeInputBase & { sendAddress?: string - receiveAccountNumber?: number receiveAddress: string accountNumber: number quoteOrRate: 'quote' @@ -146,7 +145,6 @@ export type CommonTradeQuoteInput = CommonTradeInputBase & { type CommonTradeRateInput = CommonTradeInputBase & { sendAddress?: undefined - receiveAccountNumber?: undefined receiveAddress: undefined accountNumber: undefined quoteOrRate: 'rate' @@ -253,7 +251,6 @@ type TradeQuoteBase = { id: string rate: string // top-level rate for all steps (i.e. output amount / input amount) receiveAddress: string | undefined // if receiveAddress is undefined, this is not a trade quote but a trade rate - receiveAccountNumber?: number potentialAffiliateBps: string // even if the swapper does not support affiliateBps, we need to zero-them out or view-layer will be borked affiliateBps: string // even if the swapper does not support affiliateBps, we need to zero-them out or view-layer will be borked isStreaming?: boolean diff --git a/src/components/MultiHopTrade/hooks/useGetTradeQuotes/getTradeQuoteInput.ts b/src/components/MultiHopTrade/hooks/useGetTradeQuotes/getTradeQuoteInput.ts index 8890034a5b8..b4fd70e0791 100644 --- a/src/components/MultiHopTrade/hooks/useGetTradeQuotes/getTradeQuoteInput.ts +++ b/src/components/MultiHopTrade/hooks/useGetTradeQuotes/getTradeQuoteInput.ts @@ -27,7 +27,6 @@ export type GetTradeQuoteInputArgs = { isSnapInstalled?: boolean pubKey?: string | undefined quoteOrRate: 'quote' | 'rate' - receiveAccountNumber?: number receiveAddress: string | undefined sellAccountNumber: number | undefined wallet: HDWallet | undefined @@ -41,7 +40,6 @@ export const getTradeQuoteInput = async ({ wallet, quoteOrRate, receiveAddress, - receiveAccountNumber, sellAmountBeforeFeesCryptoPrecision, allowMultiHop, affiliateBps, @@ -80,18 +78,15 @@ export const getTradeQuoteInput = async ({ }) : undefined - if ( - quoteOrRate === 'quote' && - (receiveAccountNumber === undefined || receiveAddress === undefined) - ) - throw new Error('missing receiveAccountNumber') + if (quoteOrRate === 'quote' && receiveAddress === undefined) { + throw new Error('missing receiveAddress') + } return { ...tradeQuoteInputCommonArgs, chainId: sellAsset.chainId as EvmChainId, supportsEIP1559: Boolean(supportsEIP1559), sendAddress, - receiveAccountNumber, } as GetTradeQuoteInput } @@ -110,7 +105,6 @@ export const getTradeQuoteInput = async ({ ...tradeQuoteInputCommonArgs, chainId: sellAsset.chainId as CosmosSdkChainId, sendAddress, - receiveAccountNumber, } as GetTradeQuoteInput } @@ -170,7 +164,6 @@ export const getTradeQuoteInput = async ({ ...tradeQuoteInputCommonArgs, chainId: sellAsset.chainId as CosmosSdkChainId, sendAddress, - receiveAccountNumber, } as GetTradeQuoteInput } default: diff --git a/src/components/MultiHopTrade/hooks/useGetTradeQuotes/useGetTradeQuotes.tsx b/src/components/MultiHopTrade/hooks/useGetTradeQuotes/useGetTradeQuotes.tsx index ddb562dfe53..e1328b331a4 100644 --- a/src/components/MultiHopTrade/hooks/useGetTradeQuotes/useGetTradeQuotes.tsx +++ b/src/components/MultiHopTrade/hooks/useGetTradeQuotes/useGetTradeQuotes.tsx @@ -216,8 +216,6 @@ export const useGetTradeQuotes = () => { } ;(async () => { const sellAccountNumber = sellAccountMetadata?.bip44Params?.accountNumber - const receiveAssetBip44Params = receiveAccountMetadata?.bip44Params - const receiveAccountNumber = receiveAssetBip44Params?.accountNumber const tradeAmountUsd = bnOrZero(sellAssetUsdRate).times(sellAmountCryptoPrecision) @@ -238,7 +236,6 @@ export const useGetTradeQuotes = () => { const updatedTradeQuoteInput: GetTradeQuoteInput | undefined = await getTradeQuoteInput({ sellAsset, sellAccountNumber, - receiveAccountNumber, sellAccountType: sellAccountMetadata?.accountType, buyAsset, wallet: wallet ?? undefined,