@@ -8,8 +8,9 @@ import { getDecimals } from 'src/modules/networks/asset';
88import type { Chain } from 'src/modules/networks/Chain' ;
99import { createChain } from 'src/modules/networks/Chain' ;
1010import { formatTokenValue } from 'src/shared/units/formatTokenValue' ;
11- import type { QuotesData } from 'src/ui/shared/requests/useQuotes' ;
1211import { SlidingRectangle } from 'src/ui/components/SlidingRectangle' ;
12+ import type { QuotesData } from 'src/ui/shared/requests/useQuotes' ;
13+ import type { Quote } from 'src/shared/types/Quote' ;
1314import { getQuotesErrorMessage } from './getQuotesErrorMessage' ;
1415
1516function getRate ( {
@@ -66,19 +67,21 @@ export function RateLine({
6667 spendAsset,
6768 receiveAsset,
6869 quotesData,
70+ selectedQuote,
6971} : {
7072 spendAsset : Asset | null ;
7173 receiveAsset : Asset | null ;
7274 quotesData : QuotesData ;
75+ selectedQuote : Quote | null ;
7376} ) {
74- const { isLoading, quote , error } = quotesData ;
77+ const { isLoading, error } = quotesData ;
7578
7679 const rate = getRate ( {
7780 spendAsset,
7881 receiveAsset,
79- receiveAmountBase : quote ?. output_amount_estimation ,
80- spendAmountBase : quote ?. input_amount_estimation ,
81- chain : quote ? createChain ( quote . input_chain ) : undefined ,
82+ receiveAmountBase : selectedQuote ?. output_amount_estimation ,
83+ spendAmountBase : selectedQuote ?. input_amount_estimation ,
84+ chain : selectedQuote ? createChain ( selectedQuote . input_chain ) : undefined ,
8285 } ) ;
8386
8487 // If we decide to _not_ circle the images,
@@ -92,18 +95,19 @@ export function RateLine({
9295 gap = { 8 }
9396 justifyContent = "space-between"
9497 style = { {
95- visibility : ! isLoading && ! quote && ! error ? 'hidden' : undefined ,
98+ visibility :
99+ ! isLoading && ! selectedQuote && ! error ? 'hidden' : undefined ,
96100 } }
97101 >
98102 < UIText kind = "small/regular" color = "var(--neutral-700)" >
99103 Rate
100104 </ UIText >
101105 < span >
102- { isLoading && ! quote ? (
106+ { isLoading && ! selectedQuote ? (
103107 < span style = { { color : 'var(--neutral-500)' } } >
104108 Fetching offers...
105109 </ span >
106- ) : quote ? (
110+ ) : selectedQuote ? (
107111 < HStack
108112 // in design it's 4, but design has circle images
109113 gap = { gap }
@@ -113,7 +117,7 @@ export function RateLine({
113117 fontVariantNumeric : 'tabular-nums' ,
114118 } }
115119 >
116- { quote . contract_metadata ?. icon_url ? (
120+ { selectedQuote . contract_metadata ?. icon_url ? (
117121 < div
118122 style = { {
119123 position : 'relative' ,
@@ -124,10 +128,10 @@ export function RateLine({
124128 >
125129 < SlidingRectangle
126130 size = { 20 }
127- src = { quote . contract_metadata . icon_url }
131+ src = { selectedQuote . contract_metadata . icon_url }
128132 render = { ( src , index ) => (
129133 < img
130- title = { quote . contract_metadata ?. name }
134+ title = { selectedQuote . contract_metadata ?. name }
131135 style = { {
132136 position : 'absolute' ,
133137 left : 0 ,
@@ -139,7 +143,7 @@ export function RateLine({
139143 } }
140144 src = { src }
141145 // The alt here may be from a sibling image, but hopefully it doesn't matter
142- alt = { `${ quote . contract_metadata ?. name } logo` }
146+ alt = { `${ selectedQuote . contract_metadata ?. name } logo` }
143147 />
144148 ) }
145149 />
@@ -151,7 +155,7 @@ export function RateLine({
151155 rate . rightAsset . symbol
152156 ) } `
153157 ) : (
154- < span > { quote . contract_metadata ?. name ?? 'unknown' } </ span >
158+ < span > { selectedQuote . contract_metadata ?. name ?? 'unknown' } </ span >
155159 ) }
156160 </ HStack >
157161 ) : error ? (
0 commit comments