Skip to content

Commit

Permalink
chore: create better consts name
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasgabrielgsp committed Oct 16, 2024
1 parent 1a1b1bb commit 339a2b5
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions source/pages/Send/SendEth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -410,24 +410,32 @@ export const SendEth = () => {
? selectedAsset.balance
: Number(activeAccount?.balances.ethereum);

if (
!selectedAsset &&
parseFloat(value) <= parseFloat(balance) &&
Number(value) > 0
) {
const isValueLowerThanBalance = selectedAsset
? parseFloat(value) <= parseFloat(selectedAsset.balance)
: parseFloat(value) <= parseFloat(balance);

const isToken = !!selectedAsset;

const isValidValue = Number(value) > 0;

const isAssetSelectedWithValidBalance =
isToken && isValidValue;

const isNFT = selectedAsset.isNft;

const isValidNFTValue =
isAssetSelectedWithValidBalance && isNFT;

const isValidTokenValue =
isAssetSelectedWithValidBalance &&
!isNFT &&
isValueLowerThanBalance;

if (!isToken && isValueLowerThanBalance && isValidValue) {
return Promise.resolve();
}

if (
(selectedAsset &&
selectedAsset.isNft &&
Number(value) > 0) ||
(selectedAsset &&
!selectedAsset.isNft &&
parseFloat(value) <=
parseFloat(selectedAsset.balance) &&
Number(value) > 0)
) {
if (isValidNFTValue || isValidTokenValue) {
return Promise.resolve();
}

Expand Down

0 comments on commit 339a2b5

Please sign in to comment.