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

Feat/live 15542 aptos send receive fix send funds simulation failed when amount to send is slightly above max spendable amount #8766

Open
wants to merge 3 commits into
base: feat/integrate-aptos
Choose a base branch
from
Open
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,14 @@ export const getFee = async (
break;
}
default: {
throw Error(`Simulation failed with following error: ${completedTx.vm_status}`);
// HOTFIX: we need to check if there is enough balance for gas
// idealy it should be covered with EINSUFFICIENT_BALANCE from network
const expectedGas = BigNumber(gasLimit * gasPrice);
if (transaction.amount.plus(expectedGas).isGreaterThan(account.spendableBalance)) {
break;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to move this check to an early exit before line 54 const simulation = await aptosClient.simulateTransaction(publicKeyEd, tx);?
It seems like it to me, and that would result in tidier code (not a fan of test inside default cases)

} else {
throw Error(`Simulation failed with following error: ${completedTx.vm_status}`);
}
}
}
}
Expand Down
Loading