Skip to content

Commit

Permalink
fix: dont require account number when getting a quote
Browse files Browse the repository at this point in the history
  • Loading branch information
woodenfurniture committed Nov 7, 2024
1 parent 8d77d56 commit 0e299a9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 16 deletions.
3 changes: 0 additions & 3 deletions packages/swapper/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,13 @@ type CommonTradeInputBase = {

export type CommonTradeQuoteInput = CommonTradeInputBase & {
sendAddress?: string
receiveAccountNumber?: number
receiveAddress: string
accountNumber: number
quoteOrRate: 'quote'
}

type CommonTradeRateInput = CommonTradeInputBase & {
sendAddress?: undefined
receiveAccountNumber?: undefined
receiveAddress: undefined
accountNumber: undefined
quoteOrRate: 'rate'
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -41,7 +40,6 @@ export const getTradeQuoteInput = async ({
wallet,
quoteOrRate,
receiveAddress,
receiveAccountNumber,
sellAmountBeforeFeesCryptoPrecision,
allowMultiHop,
affiliateBps,
Expand Down Expand Up @@ -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
}

Expand All @@ -110,7 +105,6 @@ export const getTradeQuoteInput = async ({
...tradeQuoteInputCommonArgs,
chainId: sellAsset.chainId as CosmosSdkChainId,
sendAddress,
receiveAccountNumber,
} as GetTradeQuoteInput
}

Expand Down Expand Up @@ -170,7 +164,6 @@ export const getTradeQuoteInput = async ({
...tradeQuoteInputCommonArgs,
chainId: sellAsset.chainId as CosmosSdkChainId,
sendAddress,
receiveAccountNumber,
} as GetTradeQuoteInput
}
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -238,7 +236,6 @@ export const useGetTradeQuotes = () => {
const updatedTradeQuoteInput: GetTradeQuoteInput | undefined = await getTradeQuoteInput({
sellAsset,
sellAccountNumber,
receiveAccountNumber,
sellAccountType: sellAccountMetadata?.accountType,
buyAsset,
wallet: wallet ?? undefined,
Expand Down

0 comments on commit 0e299a9

Please sign in to comment.