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
4 changes: 2 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ export default [

'src/components/text/TitleText.tsx',
'src/components/themed/Alert.tsx',
'src/components/themed/BuyCrypto.tsx',

'src/components/themed/CreateWalletSelectCryptoRow.tsx',
'src/components/themed/DividerLine.tsx',
'src/components/themed/EdgeProviderComponent.tsx',
Expand Down Expand Up @@ -395,7 +395,7 @@ export default [
'src/components/tiles/LtvRatioTile.tsx',
'src/components/tiles/PercentageChangeArrowTile.tsx',
'src/components/tiles/TotalDebtCollateralTile.tsx',
'src/constants/WalletAndCurrencyConstants.ts',

'src/controllers/action-queue/ActionQueueStore.ts',
'src/controllers/action-queue/cleaners.ts',
'src/controllers/action-queue/push.ts',
Expand Down
10 changes: 9 additions & 1 deletion src/components/themed/BuyCrypto.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ export const BuyCrypto: React.FC<Props> = (props: Props) => {
})

const { displayName, pluginId } = wallet.currencyInfo
const { highPrecisionSyncRatioDisplay = false } =
SPECIAL_CURRENCY_INFO[pluginId]
Copy link

Choose a reason for hiding this comment

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

Bug: Robust Destructuring for Optional Data

Destructuring SPECIAL_CURRENCY_INFO[pluginId] directly will throw a runtime error if the pluginId doesn't exist in the record. The code should use getSpecialCurrencyInfo(pluginId) or add a nullish coalescing operator (?? {}) to safely handle missing entries, similar to how other parts of the codebase handle this case.

Fix in Cursor Fix in Web

const syncRatioPrecisionOpts = highPrecisionSyncRatioDisplay
? {
minPrecision: 5,
maxPrecision: 5
}
: undefined

return (
<>
Expand Down Expand Up @@ -87,7 +95,7 @@ export const BuyCrypto: React.FC<Props> = (props: Props) => {
<EdgeText style={styles.transactionsLoadingText}>
{sprintf(
lstrings.percent_complete_1s,
toPercentString(syncRatio)
toPercentString(syncRatio, syncRatioPrecisionOpts)
)}
</EdgeText>
</>
Expand Down
6 changes: 4 additions & 2 deletions src/constants/WalletAndCurrencyConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ interface SpecialCurrencyInfo {
noChangeMiningFee?: boolean
noMaxSpend?: boolean
keysOnlyMode?: boolean
highPrecisionSyncRatioDisplay?: boolean
/**
* This disables the transaction list for the wallet.
* (Default: false)
Expand Down Expand Up @@ -200,7 +201,7 @@ interface SpecialCurrencyInfo {
export const getSpecialCurrencyInfo = (
pluginId: string
): SpecialCurrencyInfo => {
if (SPECIAL_CURRENCY_INFO[pluginId]) {
if (SPECIAL_CURRENCY_INFO[pluginId] !== undefined) {
return SPECIAL_CURRENCY_INFO[pluginId]
} else {
return {
Expand Down Expand Up @@ -832,6 +833,7 @@ export const SPECIAL_CURRENCY_INFO: Record<string, SpecialCurrencyInfo> = {
noChangeMiningFee: true,
isImportKeySupported: true,
keysOnlyMode: Platform.OS === 'android' && Platform.constants.Version < 28,
highPrecisionSyncRatioDisplay: true,
importKeyOptions: [
{
optionName: 'birthdayHeight',
Expand Down Expand Up @@ -973,7 +975,7 @@ export const USD_FIAT = 'iso:USD'
/**
* Get the fiat symbol from an iso:[fiat] OR fiat currency code
*/
export const getFiatSymbol = (isoOrFiatCurrencyCode: string) => {
export const getFiatSymbol = (isoOrFiatCurrencyCode: string): string => {
if (typeof isoOrFiatCurrencyCode !== 'string') return ''
const codeWithoutIso = removeIsoPrefix(isoOrFiatCurrencyCode)
const out = FIAT_CODES_SYMBOLS[codeWithoutIso.toUpperCase()]
Expand Down
Loading