Skip to content

Commit 0043a5e

Browse files
authored
CP-12367: Use dynamic aggregator logos from API in swap pricing details (#3292)
1 parent 7dc85cd commit 0043a5e

File tree

2 files changed

+13
-21
lines changed

2 files changed

+13
-21
lines changed

packages/core-mobile/app/new/features/swap/screens/SwapPricingDetailsScreen.tsx

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
GroupList,
44
GroupListItem,
55
Icons,
6-
Logos,
6+
Image,
77
Separator,
88
Text,
99
TouchableOpacity,
@@ -16,7 +16,6 @@ import { dismissKeyboardIfNeeded } from 'common/utils/dismissKeyboardIfNeeded'
1616
import { UNKNOWN_AMOUNT } from 'consts/amount'
1717
import React, { useCallback, useEffect, useMemo } from 'react'
1818
import { FlatList } from 'react-native-gesture-handler'
19-
import { SvgProps } from 'react-native-svg'
2019
import { LocalTokenWithBalance } from 'store/balance/types'
2120
import { useSwapRate } from '../hooks/useSwapRate'
2221
import { MarkrQuote } from '../services/MarkrService'
@@ -27,19 +26,6 @@ import {
2726
NormalizedSwapQuoteResult
2827
} from '../types'
2928

30-
// Provider logo mapping
31-
const PRICE_PROVIDER_ICONS: Record<string, React.FC<SvgProps> | undefined> = {
32-
velora: Logos.PartnerLogos.Velora,
33-
odos: Logos.PartnerLogos.Odos,
34-
kyber: Logos.PartnerLogos.Kyber,
35-
yak: Logos.PartnerLogos.Yak
36-
}
37-
38-
// Function to get provider logo with fallback
39-
const getPriceProviderIcon = (id: string): React.FC<SvgProps> | null => {
40-
return PRICE_PROVIDER_ICONS[id] || null
41-
}
42-
4329
export const SwapPricingDetailsScreen = ({
4430
fromToken,
4531
toToken,
@@ -91,7 +77,7 @@ export const SwapPricingDetailsScreen = ({
9177

9278
const quote = item.quote as MarkrQuote
9379

94-
const { id, name } = quote.aggregator
80+
const { id, name, logo_url } = quote.aggregator
9581
const isLastItem = index === quotes.quotes.length - 1
9682
const isSelected =
9783
(!manuallySelected && index === 0) ||
@@ -102,9 +88,6 @@ export const SwapPricingDetailsScreen = ({
10288
? 0
10389
: formatInCurrency(toToken, BigInt(item.metadata.amountOut as string))
10490

105-
// Get the logo for this provider dynamically
106-
const Icon = getPriceProviderIcon(id)
107-
10891
return (
10992
<TouchableOpacity
11093
key={id}
@@ -133,8 +116,16 @@ export const SwapPricingDetailsScreen = ({
133116
}}>
134117
{id === 'auto' ? (
135118
<Icons.Custom.SwapProviderAuto />
136-
) : Icon ? (
137-
<Icon testID={`icon__${id}`} width={36} height={36} />
119+
) : logo_url ? (
120+
<Image
121+
source={{ uri: logo_url }}
122+
testID={`icon__${id}`}
123+
sx={{
124+
borderRadius: 18,
125+
width: 36,
126+
height: 36
127+
}}
128+
/>
138129
) : (
139130
<Text variant="body2" sx={{ color: colors.$textSecondary }}>
140131
{name.charAt(0).toUpperCase()}

packages/core-mobile/app/new/features/swap/services/MarkrService.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export type MarkrQuote = {
3434
aggregator: {
3535
id: string
3636
name: string
37+
logo_url?: string
3738
}
3839
tokenIn: string
3940
tokenInDecimals: number

0 commit comments

Comments
 (0)