Skip to content

Commit

Permalink
Show verified checkmark when selecting asset and sort by verified
Browse files Browse the repository at this point in the history
  • Loading branch information
danield9tqh committed Jun 5, 2024
1 parent dc671e6 commit c4f3edf
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions ironfish-cli/src/utils/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,35 @@ export async function selectAsset(
balances = balances.filter((balance) => filter(assetLookup[balance.assetId]))
}

// Show verified assets at top of the list
balances = balances.sort((asset1, asset2) => {
const verified1 = assetLookup[asset1.assetId].verification.status === 'verified'
const verified2 = assetLookup[asset2.assetId].verification.status === 'verified'
if (verified1 && verified2) {
return 0
}

return verified1 ? -1 : 1
})

const choices = balances.map((balance) => {
const asset = assetLookup[balance.assetId]

const assetName = BufferUtils.toHuman(Buffer.from(assetLookup[balance.assetId].name, 'hex'))
const assetNameWithVerification = renderAssetWithVerificationStatus(assetName, asset)

const renderedAvailable = CurrencyUtils.render(
balance.available,
false,
balance.assetId,
assetLookup[balance.assetId].verification,
asset.verification,
)
const name = `${balance.assetId} (${assetName}) (${renderedAvailable})`

const name = `${balance.assetId} (${assetNameWithVerification}) (${renderedAvailable})`

const value = {
id: balance.assetId,
name: assetLookup[balance.assetId].name,
name: asset.name,
}

return { value, name }
Expand Down

0 comments on commit c4f3edf

Please sign in to comment.