Skip to content

Commit

Permalink
fix: prevent negative balance on EVMs
Browse files Browse the repository at this point in the history
  • Loading branch information
a0ngo committed Dec 13, 2023
1 parent d8208bc commit 1a720ce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/violet-rocks-lick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@fireblocks/recovery-relay': minor
---

fix: prevent negative balance on EVMs
9 changes: 8 additions & 1 deletion apps/recovery-relay/lib/wallets/EVM/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,21 @@ export class EVM extends EVMBase implements ConnectedWallet {
const balance = formatEther(wei);
const ethBalance = Number(balance);

console.info({ ethBalance });
console.info('Eth balance info', { ethBalance });

return ethBalance;
}

public async prepare(): Promise<AccountData> {
const balance = await this.getBalance();

if (balance === 0) {
return {
balance,
insufficientBalance: true,
};
}

const nonce = await this.provider.getTransactionCount(this.address, 'latest');

// Should we use maxGasPrice? i.e. EIP1559.
Expand Down

0 comments on commit 1a720ce

Please sign in to comment.