Skip to content

Commit

Permalink
Merge pull request #696 from Adamant-im/fix/bug-kly-entering-more-tha…
Browse files Browse the repository at this point in the history
…n-n-characters-in-the-amount

fix: bug kly amount more than n characters
  • Loading branch information
bludnic authored Dec 27, 2024
2 parents fb47c2f + 0ea3c4b commit 572022d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
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

0 comments on commit 572022d

Please sign in to comment.