Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make custom tokens visible in the asset list even if they have a balance of zero #3313

Closed
wants to merge 6 commits into from
Closed
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
7 changes: 6 additions & 1 deletion background/redux-slices/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
AssetDecimalAmount,
isBuiltInNetworkBaseAsset,
isSameAsset,
isUntrustedAsset,
} from "./utils/asset-utils"
import { DomainName, HexString, URI } from "../types"
import { normalizeEVMAddress, sameEVMAddress } from "../lib/utils"
Expand Down Expand Up @@ -312,7 +313,11 @@ const accountSlice = createSlice({
if (
updatedAccountBalance.assetAmount.amount === 0n &&
existingAccountData.balances[updatedAssetSymbol] === undefined &&
!isBuiltInNetworkBaseAsset(asset, network) // add base asset even if balance is 0
// add base asset even if balance is 0 or is a custom asset
!(
isUntrustedAsset(asset) ||
Copy link
Contributor

Choose a reason for hiding this comment

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

If the asset already exists it will likely be part of a token list assets and not a custom asset, in that case this won't trigger right?

isBuiltInNetworkBaseAsset(asset, network)
)
) {
return
}
Expand Down
6 changes: 5 additions & 1 deletion background/redux-slices/selectors/accountsSelectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
formatCurrencyAmount,
heuristicDesiredDecimalsForUnitPrice,
isNetworkBaseAsset,
isUntrustedAsset,
isUnverifiedAssetByUser,
} from "../utils/asset-utils"
import {
Expand Down Expand Up @@ -91,10 +92,13 @@ export function determineAssetDisplayAndVerify(
? true
: assetAmount.mainCurrencyAmount > userValueDustThreshold
const isPresent = assetAmount.decimalAmount > 0
// Tokens that are added manually should be visible in the asset list even if they have a balance of zero
const canBePresent =
isUntrustedAsset(assetAmount.asset) && isVerified ? true : isPresent
const showDust = !hideDust

const verificationStatusAllowsVisibility = showUnverifiedAssets || isVerified
const enoughBalanceToBeVisible = isPresent && (isNotDust || showDust)
const enoughBalanceToBeVisible = canBePresent && (isNotDust || showDust)

return {
displayAsset:
Expand Down