Skip to content

Commit

Permalink
Merge pull request #2363 from torusresearch/fix/missing-custom-token
Browse files Browse the repository at this point in the history
Fix custom tokens not showing up due to mismatched address lowercase/mixed case
  • Loading branch information
chaitanyapotti authored Oct 9, 2023
2 parents 6ea1b04 + 9963a07 commit 4100700
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/controllers/PreferencesController.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,17 @@ import {
} from '../utils/enums'
import { notifyUser } from '../utils/notifications'
import { setSentryEnabled } from '../utils/sentry'
import { formatDate, formatPastTx, formatTime, getEthTxStatus, getIFrameOrigin, getUserLanguage, isMain, waitForMs } from '../utils/utils'
import {
formatDate,
formatPastTx,
formatTime,
getEthTxStatus,
getIFrameOrigin,
getUserLanguage,
isMain,
toChecksumAddressByChainId,
waitForMs,
} from '../utils/utils'
import { ObservableStore } from './utils/ObservableStore'
import { isErrorObject, prettyPrintData } from './utils/permissionUtils'

Expand Down Expand Up @@ -217,6 +227,11 @@ class PreferencesController extends SafeEventEmitter {
customNetworks,
} = user.data || {}

// transform addresses that were saved as lowercase in our db
const chainId = this.network.getCurrentChainId()
const publicAddress = toChecksumAddressByChainId(public_address, chainId)
const defaultPublicAddress = toChecksumAddressByChainId(default_public_address) || publicAddress

this.updateStore(
{
contacts,
Expand All @@ -226,11 +241,11 @@ class PreferencesController extends SafeEventEmitter {
locale: locale || getUserLanguage(),
permissions,
accountType: account_type || ACCOUNT_TYPE.NORMAL,
defaultPublicAddress: default_public_address || public_address,
defaultPublicAddress,
customTokens,
customNfts,
},
public_address
publicAddress
)

// update network controller with all the custom network updates.
Expand Down Expand Up @@ -784,7 +799,7 @@ class PreferencesController extends SafeEventEmitter {
normalizedAddChainParams(id, addChainParams) {
/**
* addChainParams interface
*
*
* interface AddEthereumChainParameter {
chainId: string; // A 0x-prefixed hexadecimal string
chainName: string;
Expand Down

0 comments on commit 4100700

Please sign in to comment.