Skip to content

Commit

Permalink
feat: add denomination to ledger tx verification popup (#7625)
Browse files Browse the repository at this point in the history
* feat: add denomination to ledger transaction verification popup

* fix: remove unnecessary prop

* feat: show token unit
  • Loading branch information
cpl121 authored Oct 24, 2023
1 parent fc24724 commit f572490
Showing 1 changed file with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { get } from 'svelte/store'

import { PopupProps } from '@auxiliary/popup'
import { formatTokenAmountDefault, newTransactionDetails, NewTransactionType } from '@core/wallet'
import {
formatTokenAmountDefault,
getUnitFromTokenMetadata,
newTransactionDetails,
NewTransactionType,
} from '@core/wallet'

export function deconstructLedgerVerificationProps(): PopupProps {
const transactionDetails = get(newTransactionDetails)
Expand All @@ -15,11 +20,16 @@ export function deconstructLedgerVerificationProps(): PopupProps {
: transactionDetails?.recipient?.address
let toAmount = '0'
if (transactionDetails?.type === NewTransactionType.TokenTransfer) {
toAmount = `${formatTokenAmountDefault(
Number(transactionDetails?.rawAmount),
transactionDetails?.asset?.metadata,
transactionDetails?.unit
)}`
const tokenMetadata = transactionDetails?.asset?.metadata
if (tokenMetadata) {
const tokenUnit = getUnitFromTokenMetadata(tokenMetadata)
const tokenAmount = formatTokenAmountDefault(
Number(transactionDetails?.rawAmount),
tokenMetadata,
tokenUnit
)
toAmount = `${tokenAmount} ${tokenUnit}`
}
}

return {
Expand Down

0 comments on commit f572490

Please sign in to comment.