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

fix: toast for You do not have enough tokens to pay the transaction fee #1116

Merged
merged 12 commits into from
Jan 12, 2024
11 changes: 11 additions & 0 deletions src/v2/services/implementations/MetamaskWalletService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ export class MetamaskWalletService extends WalletService implements IWalletServi
const web3 = new Web3(this.provider as any);
const accounts = await web3.eth.getAccounts();

const balWei = await web3.eth.getBalance(accounts[0]);
console.log('balWei, accounts[0]', balWei, accounts[0]);
const useableBalance = Number(ethers.utils.formatEther(balWei));
console.log('useableBalance', useableBalance);
const message = 'Minimum balance on the network is 0.01';
if (Number(useableBalance) < Number(100000000000000000)) {
this.eventAggregator.publish(new ExtrinsicStatusMessage({ success: false, message }));
this.eventAggregator.publish(new BusyMessage(false));
throw Error(message);
}

const signedPayload = await this.provider.request({
method: 'personal_sign',
params: [accounts[0], payload],
Expand Down
8 changes: 8 additions & 0 deletions src/v2/services/implementations/PolkadotWalletService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ export class PolkadotWalletService extends WalletService implements IWalletServi
tip = tip ? ethers.utils.parseEther(tip).toString() : '1';
}

const useableBalance = await this.assetsRepository.getNativeBalance(senderAddress);
const message = 'Minimum balance on the network is 0.01';
impelcrypto marked this conversation as resolved.
Show resolved Hide resolved
if (Number(useableBalance) < Number(100000000000000000)) {
gluneau marked this conversation as resolved.
Show resolved Hide resolved
this.eventAggregator.publish(new ExtrinsicStatusMessage({ success: false, message }));
this.eventAggregator.publish(new BusyMessage(false));
throw Error(message);
}

const multisig = localStorage.getItem(LOCAL_STORAGE.MULTISIG);
if (multisig) {
try {
Expand Down
Loading