Skip to content

Commit

Permalink
release: 2.0.1 (#4904)
Browse files Browse the repository at this point in the history
* fix: correctly show amount on send confirmation (#4895)

* chore: replace obsolete parseRawAmount with formatAmountDefault

* fix: send deep link

* fix: consider unspecified amount when formatting

* chore: fix tests

* chore: add test

* chore: add subunit check to formatTokenAmountDefault

* chore: update version

* fix: added missing check

* fix: correctly format Foundry Details
  • Loading branch information
Tuditi committed Oct 19, 2022
1 parent 0e6b789 commit 5abe868
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/desktop/package.json
@@ -1,7 +1,7 @@
{
"name": "desktop",
"productName": "Firefly Shimmer",
"version": "2.0.1-beta-1",
"version": "2.0.1",
"description": "Official wallet application of Shimmer",
"main": "public/build/main.js",
"repository": "git@github.com:iotaledger/firefly.git",
Expand Down
11 changes: 9 additions & 2 deletions packages/shared/components/molecules/FoundryDetails.svelte
Expand Up @@ -2,19 +2,26 @@
import { KeyValueBox, AmountBox, SubjectBox, ActivityInclusionStatusPill } from 'shared/components'
import { formatDate, localize } from '@core/i18n'
import { activeProfile } from '@core/profile'
import { formatTokenAmountPrecise, Subject, InclusionState, IPersistedAsset } from '@core/wallet'
import {
formatTokenAmountPrecise,
Subject,
InclusionState,
IPersistedAsset,
formatTokenAmountDefault,
} from '@core/wallet'
import { BASE_TOKEN } from '@core/network'
export let asset: IPersistedAsset
export let inclusionState: InclusionState
export let formattedFiatValue: string = null
export let amount: string = null
export let rawAmount: string = null
export let unit: string
export let storageDeposit = 0
export let giftedStorageDeposit = 0
export let subject: Subject = null
export let transactionTime: Date = null
$: amount = formatTokenAmountDefault(Number(rawAmount), asset?.metadata, unit)
$: formattedTransactionTime = formatDate(transactionTime, { dateStyle: 'long', timeStyle: 'medium' })
$: hasStorageDeposit = storageDeposit || (storageDeposit === 0 && giftedStorageDeposit === 0)
Expand Down
Expand Up @@ -87,4 +87,14 @@ describe('File: formatTokenAmountDefault.ts', () => {
const formattedAmount = formatTokenAmountDefault(amount, decimalToken, unit)
expect(formattedAmount).toEqual('12')
})
it('should return the normal string amount if unit is undefined', () => {
const amount = 12
const newToken = {
name: 'WEN',
decimals: 4,
unit: 'soon',
}
const formattedAmount = formatTokenAmountDefault(amount, newToken)
expect(formattedAmount).toEqual('0.0012')
})
})
Expand Up @@ -6,7 +6,7 @@ export function formatTokenAmountDefault(amount: number, tokenMetadata: ITokenMe
throw new Error('Amount is negative')
} else if (isDecimal(amount)) {
throw new Error('Amount is a decimal number')
} else if (unit === tokenMetadata?.subunit) {
} else if (unit && unit === tokenMetadata?.subunit) {
return formatNumber(amount, 0, 0, 0, true)
} else {
const value = tokenMetadata?.decimals ? amount / 10 ** tokenMetadata?.decimals : amount
Expand Down

0 comments on commit 5abe868

Please sign in to comment.