Skip to content

Commit b830fba

Browse files
authored
Merge pull request #691 from reservoirprotocol/ted/fe-7681-add-general-warning-for-missing-token-price-detection
Add warning for missing token price detection + add stroke to all alerts
2 parents b8ec892 + 1b67ee5 commit b830fba

File tree

4 files changed

+56
-3
lines changed

4 files changed

+56
-3
lines changed

.changeset/chubby-peaches-try.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@reservoir0x/relay-kit-ui': patch
3+
---
4+
5+
Add warning for missing token price detection + add stroke to all alerts

packages/ui/panda.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export const Colors = {
3737
// Red
3838
red2: { value: '{colors.red.2}' },
3939
red3: { value: '{colors.red.3}' },
40+
red4: { value: '{colors.red.4}' },
4041
red5: { value: '{colors.red.5}' },
4142
red6: { value: '{colors.red.6}' },
4243
red9: { value: '{colors.red.9}' },

packages/ui/src/components/widgets/SwapWidget/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1558,8 +1558,9 @@ const SwapWidget: FC<SwapWidgetProps> = ({
15581558
{!isUsdInputMode &&
15591559
toToken &&
15601560
quote?.details?.currencyOut?.amountUsd &&
1561+
quote?.details?.currencyOut?.amountUsd !== '0' &&
15611562
!isFetchingQuote &&
1562-
quote.details.totalImpact?.percent ? (
1563+
quote?.details?.totalImpact?.percent ? (
15631564
<Text
15641565
style="subtitle3"
15651566
color={feeBreakdown?.totalFees.priceImpactColor}

packages/ui/src/components/widgets/WidgetErrorWell.tsx

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ export const WidgetErrorWell: FC<Props> = ({
6060
isHighPriceImpact && totalImpactUsd && Number(totalImpactUsd) <= -10
6161
const isInsufficientLiquidityError =
6262
fetchQuoteErrorMessage?.includes('No quotes found')
63+
const isMissingUsdTokenPrice =
64+
quote?.details?.currencyOut &&
65+
(quote?.details?.currencyOut?.amountUsd === undefined ||
66+
quote?.details?.currencyOut?.amountUsd === '0')
6367

6468
if (isInsufficientLiquidityError) {
6569
return null
@@ -87,6 +91,8 @@ export const WidgetErrorWell: FC<Props> = ({
8791
gap: '2',
8892
p: '3',
8993
backgroundColor: 'amber2',
94+
'--borderColor': 'colors.amber4',
95+
border: '1px solid var(--borderColor)',
9096
borderRadius: 12,
9197
mb: '3',
9298
...containerCss
@@ -113,6 +119,8 @@ export const WidgetErrorWell: FC<Props> = ({
113119
gap: '2',
114120
p: '3',
115121
backgroundColor: 'amber2',
122+
'--borderColor': 'colors.amber4',
123+
border: '1px solid var(--borderColor)',
116124
borderRadius: 12,
117125
mb: '3',
118126
...containerCss
@@ -141,6 +149,8 @@ export const WidgetErrorWell: FC<Props> = ({
141149
gap: '2',
142150
p: '3',
143151
backgroundColor: 'red2',
152+
'--borderColor': 'colors.red4',
153+
border: '1px solid var(--borderColor)',
144154
borderRadius: 12,
145155
mb: '3',
146156
...containerCss
@@ -163,6 +173,8 @@ export const WidgetErrorWell: FC<Props> = ({
163173
gap: '2',
164174
p: '3',
165175
backgroundColor: 'red2',
176+
'--borderColor': 'colors.red4',
177+
border: '1px solid var(--borderColor)',
166178
borderRadius: 12,
167179
mb: '3',
168180
...containerCss
@@ -205,6 +217,8 @@ export const WidgetErrorWell: FC<Props> = ({
205217
py: '3',
206218
px: '3',
207219
backgroundColor: 'amber2',
220+
'--borderColor': 'colors.amber4',
221+
border: '1px solid var(--borderColor)',
208222
borderRadius: 12,
209223
mb: '3',
210224
...containerCss
@@ -230,14 +244,16 @@ export const WidgetErrorWell: FC<Props> = ({
230244
gap: '2',
231245
py: '2',
232246
px: '3',
233-
backgroundColor: 'red2',
247+
backgroundColor: 'amber2',
248+
'--borderColor': 'colors.amber4',
249+
border: '1px solid var(--borderColor)',
234250
borderRadius: 12,
235251
mb: '3',
236252
...containerCss
237253
}}
238254
id={'widget-error-well-section'}
239255
>
240-
<Box css={{ color: 'red9' }}>
256+
<Box css={{ color: 'amber10' }}>
241257
<FontAwesomeIcon icon={faExclamationCircle} width={16} />
242258
</Box>
243259
<Text style="subtitle3" css={{ color: 'amber12' }}>
@@ -248,6 +264,34 @@ export const WidgetErrorWell: FC<Props> = ({
248264
)
249265
}
250266

267+
if (isMissingUsdTokenPrice) {
268+
return (
269+
<Flex
270+
align="center"
271+
css={{
272+
gap: '2',
273+
py: '2',
274+
px: '3',
275+
backgroundColor: 'amber2',
276+
'--borderColor': 'colors.amber4',
277+
border: '1px solid var(--borderColor)',
278+
borderRadius: 12,
279+
mb: '3',
280+
...containerCss
281+
}}
282+
id={'widget-error-well-section'}
283+
>
284+
<Box css={{ color: 'amber10' }}>
285+
<FontAwesomeIcon icon={faExclamationCircle} width={16} />
286+
</Box>
287+
<Text style="subtitle3" css={{ color: 'amber12' }}>
288+
Unable to detect token price. Please confirm expected output before
289+
submitting.
290+
</Text>
291+
</Flex>
292+
)
293+
}
294+
251295
if (isHighRelayerServiceFee) {
252296
return (
253297
<Flex
@@ -257,6 +301,8 @@ export const WidgetErrorWell: FC<Props> = ({
257301
py: '3',
258302
px: '3',
259303
backgroundColor: 'amber2',
304+
'--borderColor': 'colors.amber4',
305+
border: '1px solid var(--borderColor)',
260306
borderRadius: 12,
261307
mb: '3',
262308
...containerCss

0 commit comments

Comments
 (0)