Skip to content

Commit

Permalink
fix: invalid value on send
Browse files Browse the repository at this point in the history
  • Loading branch information
gamalielhere committed Nov 14, 2024
1 parent 76fb11b commit 6f1d4c9
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ const hasEnoughBalance = computed(() => {
return false;
}
// check if valid sendAmount.value
if (!isNumeric(sendAmount.value)) {
return false;
}
return toBN(selectedAsset.value.balance ?? '0').gte(
toBN(toBase(sendAmount.value ?? '0', selectedAsset.value.decimals!)),
);
Expand Down Expand Up @@ -345,8 +350,9 @@ const nativeBalanceAfterTransaction = computed(() => {
let endingAmount = toBN(nativeBalance.value);
if (selectedAsset.value.contract === NATIVE_TOKEN_ADDRESS) {
const locAmount = isNumeric(amount.value) ? amount.value : '0';
const rawAmount = toBN(
toBase(amount.value, selectedAsset.value.decimals!),
toBase(locAmount ?? '0', selectedAsset.value.decimals!),
);
endingAmount = endingAmount.sub(rawAmount);
}
Expand Down Expand Up @@ -531,6 +537,10 @@ const close = () => {
router.go(-1);
};
const isNumeric = (value: string) => {
return /^-?\d+(\.\d+)?$/.test(value);
};
const assetMaxValue = computed(() => {
if (!isSendToken.value) {
return '0';
Expand Down

0 comments on commit 6f1d4c9

Please sign in to comment.