mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 12:29:51 +00:00
Deuro Savings Error Handling (#2340)
* feat(deuro): Enhance gas fee handling and error management for Deuro Savings Transactions. This change: - Introduces DeuroGasFeeException to handle insufficient ETH for gas fees. - Adds check for ETH balance before savings transactions to prevent failures due to insufficient funds. - Updates savings transaction methods to include error handling. - Adds UI feedback for transaction failures in DEuroSavingsPage. * Fix conflicts * Update cw_ethereum/lib/deuro/deuro_savings.dart Co-authored-by: Konstantin Ullrich <konstantinullrich12@gmail.com> --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> Co-authored-by: Konstantin Ullrich <konstantinullrich12@gmail.com>
This commit is contained in:
parent
b3c20a5818
commit
5aeb6b7522
4 changed files with 186 additions and 59 deletions
|
@ -22,3 +22,32 @@ class EVMChainTransactionFeesException implements Exception {
|
|||
@override
|
||||
String toString() => exceptionMessage;
|
||||
}
|
||||
|
||||
class DeuroGasFeeException implements Exception {
|
||||
final String exceptionMessage;
|
||||
final BigInt? requiredGasFee;
|
||||
final BigInt? currentBalance;
|
||||
|
||||
DeuroGasFeeException({
|
||||
this.requiredGasFee,
|
||||
this.currentBalance,
|
||||
}) : exceptionMessage = _buildMessage(requiredGasFee, currentBalance);
|
||||
|
||||
static String _buildMessage(BigInt? requiredGasFee, BigInt? currentBalance) {
|
||||
const baseMessage = 'Insufficient ETH for gas fees.';
|
||||
const addEthMessage = ' Please add ETH to your wallet to cover transaction fees.';
|
||||
|
||||
if (requiredGasFee != null) {
|
||||
final requiredEth = (requiredGasFee / BigInt.from(10).pow(18)).toStringAsFixed(8);
|
||||
final balanceInfo = currentBalance != null
|
||||
? ', Available: ${(currentBalance / BigInt.from(10).pow(18)).toStringAsFixed(8)} ETH'
|
||||
: '';
|
||||
return '$baseMessage Required: ~$requiredEth ETH$balanceInfo.$addEthMessage';
|
||||
}
|
||||
|
||||
return '$baseMessage$addEthMessage';
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() => exceptionMessage;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue