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

fix: bug kly amount more than n characters #696

Merged
Merged
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
14 changes: 13 additions & 1 deletion src/components/SendFundsForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ import QrcodeCapture from '@/components/QrcodeCapture.vue'
import QrcodeScannerDialog from '@/components/QrcodeScannerDialog.vue'
import get from 'lodash/get'
import { BigNumber } from 'bignumber.js'
import * as transactions from '@klayr/transactions'
import { KLY_DECIMALS } from '@/lib/klayr/klayr-constants'

import {
INCREASE_FEE_MULTIPLIER,
Expand Down Expand Up @@ -227,6 +229,8 @@ import { isStringEqualCI } from '@/lib/textHelpers'
import { formatSendTxError } from '@/lib/txVerify'
import { AllCryptos } from '@/lib/constants/cryptos'

import { MAX_UINT64 } from '@klayr/validator'

/**
* @returns {string | boolean}
*/
Expand Down Expand Up @@ -527,7 +531,15 @@ export default {
() =>
isErc20(this.currency)
? this.ethBalance >= this.transferFee || this.$t('transfer.error_not_enough_eth_fee')
: true
: true,
(v) => {
const isKlyTransfer = this.currency === Cryptos.KLY
if (!isKlyTransfer) return true
const isKlyTransferAllowed =
this.transferFee &&
transactions.convertklyToBeddows(v.toFixed(KLY_DECIMALS)) < MAX_UINT64
return isKlyTransferAllowed || this.$t('transfer.error_incorrect_amount')
}
]
}
},
Expand Down
16 changes: 10 additions & 6 deletions src/store/modules/kly/kly-getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ export default {
...baseGetters,

fee: (state) => (amount, recipientAddress, data, isNewAccount) => {
return estimateFee({
amount,
data,
isNewAccount,
nonce: state.nonce
})
try {
return estimateFee({
amount,
data,
isNewAccount,
nonce: state.nonce
})
} catch {
return 0
}
},

height(state) {
Expand Down
Loading