Skip to content

Commit

Permalink
Fix printAda
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterBenc committed Jan 14, 2021
1 parent b249428 commit 45d285b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
13 changes: 11 additions & 2 deletions app/frontend/helpers/printAda.ts
@@ -1,4 +1,13 @@
// eslint-disable-next-line no-unused-vars
import {Lovelace} from '../state'
export default (coins: Lovelace, decimals = 6): string =>
(Math.floor(coins * 0.000001 * Math.pow(10, decimals)) / Math.pow(10, decimals)).toFixed(decimals)
export default (coins: Lovelace, decimals = 6): string => {
const adaAmount = coins * 0.000001

if (decimals === 0) {
return Math.floor(adaAmount).toString()
} else if (decimals > 0 && decimals <= 6) {
return adaAmount.toFixed(7).slice(0, -7 + decimals)
} else {
return adaAmount.toFixed(decimals)
}
}
4 changes: 2 additions & 2 deletions app/frontend/wallet/account-manager.ts
@@ -1,6 +1,6 @@
import NamedError from '../helpers/NamedError'
import {Account} from './account'
import {CryptoProviderFeatures, MAX_ACCOUNT_COUNT} from './constants'
import {CryptoProviderFeatures, MAX_ACCOUNT_INDEX} from './constants'

const AccountManager = ({config, cryptoProvider, blockchainExplorer}) => {
const accounts: Array<ReturnType<typeof Account>> = []
Expand All @@ -25,7 +25,7 @@ const AccountManager = ({config, cryptoProvider, blockchainExplorer}) => {
if (
account.accountIndex !== accounts.length ||
!isLastAccountUsed ||
account.accountIndex > MAX_ACCOUNT_COUNT
account.accountIndex > MAX_ACCOUNT_INDEX
) {
throw NamedError('AccountExplorationError')
}
Expand Down
2 changes: 1 addition & 1 deletion app/frontend/wallet/constants.ts
Expand Up @@ -167,5 +167,5 @@ export const TREZOR_ERRORS = {
[CryptoProviderFeatures.POOL_OWNER]: 'TrezorPoolRegNotSupported',
}

export const MAX_ACCOUNT_COUNT = 30
export const MAX_ACCOUNT_INDEX = 30
export const MAX_BULK_EXPORT_AMOUNT = 5

0 comments on commit 45d285b

Please sign in to comment.