Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased (develop)

- added: Added Infinite ramp plugin.
- fixed: Append chain name for L2-native assets in `RampCreateScene`

## 4.39.0 (staging)

Expand Down
20 changes: 18 additions & 2 deletions src/components/scenes/RampCreateScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import type {
import type { GuiFiatType } from '../../types/types'
import { getCurrencyCode } from '../../util/CurrencyInfoHelpers'
import { getHistoricalFiatRate } from '../../util/exchangeRates'
import { isAssetNativeToChain } from '../../util/isAbstractedAssetChain'
import { logEvent } from '../../util/tracking'
import {
convertNativeToDenomination,
Expand Down Expand Up @@ -138,6 +139,21 @@ export const RampCreateScene: React.FC<Props> = (props: Props) => {
]
: [undefined, undefined]

// Append chain name for L2-native assets like Optimism ETH
function getSelectedCryptoDisplay(): string | undefined {
if (selectedCrypto == null) return
if (selectedWallet == null) return
if (selectedCryptoCurrencyCode == null) return

const isL2Native =
selectedCrypto.tokenId == null &&
!isAssetNativeToChain(selectedWallet.currencyInfo, undefined)

return isL2Native
? `${selectedCryptoCurrencyCode} (${selectedWallet.currencyInfo.displayName})`
: selectedCryptoCurrencyCode
}

// Get the select crypto denomination for exchange rate
const denomination = React.useMemo(() => {
if (selectedCrypto == null || selectedWallet == null) return null
Expand Down Expand Up @@ -875,7 +891,7 @@ export const RampCreateScene: React.FC<Props> = (props: Props) => {
onChangeText={handleCryptoChangeText}
placeholder={sprintf(
lstrings.trade_create_amount_s,
selectedCryptoCurrencyCode
getSelectedCryptoDisplay() ?? selectedCryptoCurrencyCode
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Loading State Breaks Crypto Display

When isLoadingPersistedCryptoSelection is true, both getSelectedCryptoDisplay() and selectedCryptoCurrencyCode can be undefined, causing undefined to be passed to sprintf for the placeholder text. This happens because the input is rendered when either selectedCryptoCurrencyCode != null OR isLoadingPersistedCryptoSelection == true, but the fallback pattern doesn't handle the loading state where all crypto selection values are undefined.

Fix in Cursor Fix in Web

)}
keyboardType="decimal-pad"
numeric
Expand Down Expand Up @@ -957,7 +973,7 @@ export const RampCreateScene: React.FC<Props> = (props: Props) => {
direction === 'buy'
? lstrings.trade_buy_unavailable_body_2s
: lstrings.trade_sell_unavailable_body_2s,
selectedCryptoCurrencyCode,
getSelectedCryptoDisplay() ?? selectedCryptoCurrencyCode,
selectedFiatCurrencyCode
)}
/>
Expand Down
Loading