|
1 | 1 | import { useColorMode, usePrevious } from '@chakra-ui/react' |
2 | 2 | import type { AssetId } from '@shapeshiftoss/caip' |
3 | | -import { fromAccountId } from '@shapeshiftoss/caip' |
4 | 3 | import type { Asset } from '@shapeshiftoss/types' |
5 | 4 | import { useQueryClient } from '@tanstack/react-query' |
6 | 5 | import { AnimatePresence } from 'framer-motion' |
@@ -28,7 +27,7 @@ import { SharedTradeInput } from '@/components/MultiHopTrade/components/SharedTr |
28 | 27 | import { SlideTransitionRoute } from '@/components/MultiHopTrade/components/SlideTransitionRoute' |
29 | 28 | import type { CollapsibleQuoteListProps } from '@/components/MultiHopTrade/components/TradeInput/components/CollapsibleQuoteList' |
30 | 29 | import { CollapsibleQuoteList } from '@/components/MultiHopTrade/components/TradeInput/components/CollapsibleQuoteList' |
31 | | -import { getReceiveAddress } from '@/components/MultiHopTrade/hooks/useReceiveAddress' |
| 30 | +import { useReceiveAddress } from '@/components/MultiHopTrade/hooks/useReceiveAddress' |
32 | 31 | import { TradeInputTab } from '@/components/MultiHopTrade/types' |
33 | 32 | import { useDebounce } from '@/hooks/useDebounce/useDebounce' |
34 | 33 | import { useModal } from '@/hooks/useModal/useModal' |
@@ -91,7 +90,7 @@ const RampRoutes = memo(({ onChangeTab, direction }: RampRoutesProps) => { |
91 | 90 | const dispatch = useAppDispatch() |
92 | 91 | const navigate = useNavigate() |
93 | 92 | const { |
94 | | - state: { isConnected, wallet }, |
| 93 | + state: { isConnected }, |
95 | 94 | } = useWallet() |
96 | 95 |
|
97 | 96 | const sellAsset = useAppSelector(selectInputSellAsset) |
@@ -131,9 +130,11 @@ const RampRoutes = memo(({ onChangeTab, direction }: RampRoutesProps) => { |
131 | 130 | selectPortfolioAccountMetadataByAccountId(state, buyAccountFilter), |
132 | 131 | ) |
133 | 132 |
|
134 | | - const walletReceiveAddress = useMemo(() => { |
135 | | - return buyAccountId ? fromAccountId(buyAccountId).account : undefined |
136 | | - }, [buyAccountId]) |
| 133 | + const { walletReceiveAddress } = useReceiveAddress({ |
| 134 | + sellAccountId: undefined, |
| 135 | + buyAccountId, |
| 136 | + buyAsset, |
| 137 | + }) |
137 | 138 |
|
138 | 139 | const RampQuotesComponent = useCallback( |
139 | 140 | (props: QuotesComponentProps) => { |
@@ -337,22 +338,12 @@ const RampRoutes = memo(({ onChangeTab, direction }: RampRoutesProps) => { |
337 | 338 | ramp: ramp.id, |
338 | 339 | } |
339 | 340 |
|
340 | | - const receiveAddress = |
341 | | - direction === FiatRampAction.Buy && buyAccountMetadata |
342 | | - ? await getReceiveAddress({ |
343 | | - asset: direction === FiatRampAction.Buy ? buyAsset : sellAsset, |
344 | | - wallet, |
345 | | - accountMetadata: buyAccountMetadata, |
346 | | - pubKey: walletReceiveAddress, |
347 | | - }) |
348 | | - : undefined |
349 | | - |
350 | 341 | getMixPanel()?.track(MixPanelEvent.FiatRamp, mpData) |
351 | 342 | const url = await ramp.onSubmit({ |
352 | 343 | action: direction, |
353 | 344 | assetId: |
354 | 345 | direction === FiatRampAction.Buy ? buyAsset?.assetId ?? '' : sellAsset?.assetId ?? '', |
355 | | - address: manualReceiveAddress ?? receiveAddress ?? '', |
| 346 | + address: manualReceiveAddress ?? walletReceiveAddress ?? '', |
356 | 347 | fiatCurrency: |
357 | 348 | direction === FiatRampAction.Buy ? sellFiatCurrency.code : buyFiatCurrency.code, |
358 | 349 | fiatAmount: direction === FiatRampAction.Buy ? buyFiatAmount : selectedQuote?.amount ?? '0', |
@@ -384,7 +375,6 @@ const RampRoutes = memo(({ onChangeTab, direction }: RampRoutesProps) => { |
384 | 375 | buyAccountMetadata, |
385 | 376 | buyAsset, |
386 | 377 | sellAsset, |
387 | | - wallet, |
388 | 378 | ], |
389 | 379 | ) |
390 | 380 |
|
|
0 commit comments