mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-18 05:51:34 +02:00
CW-829 Solana Enhancements (#1858)
* feat: Solana enhancements with rent handling for accounts * fix: Add exception classes with handled error messages to ensure proper error handling process --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
This commit is contained in:
co-authored by
Omar Hatem
parent
9a60b0146f
commit
c620d7f486
@@ -1,4 +1,3 @@
|
||||
import 'package:cake_wallet/di.dart';
|
||||
import 'package:cake_wallet/entities/contact.dart';
|
||||
import 'package:cake_wallet/entities/evm_transaction_error_fees_handler.dart';
|
||||
import 'package:cake_wallet/entities/priority_for_wallet_type.dart';
|
||||
@@ -14,7 +13,6 @@ import 'package:cake_wallet/polygon/polygon.dart';
|
||||
import 'package:cake_wallet/reactions/wallet_connect.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
import 'package:cake_wallet/solana/solana.dart';
|
||||
import 'package:cake_wallet/src/screens/ur/animated_ur_page.dart';
|
||||
import 'package:cake_wallet/store/app_store.dart';
|
||||
import 'package:cake_wallet/tron/tron.dart';
|
||||
import 'package:cake_wallet/view_model/contact_list/contact_list_view_model.dart';
|
||||
@@ -29,6 +27,7 @@ import 'package:cw_core/unspent_coin_type.dart';
|
||||
import 'package:cake_wallet/view_model/send/output.dart';
|
||||
import 'package:cake_wallet/view_model/send/send_template_view_model.dart';
|
||||
import 'package:cw_core/utils/print_verbose.dart';
|
||||
import 'package:cw_solana/solana_exceptions.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
@@ -427,7 +426,7 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
|
||||
//
|
||||
// state = FailureState(errorMsg);
|
||||
// } else {
|
||||
state = FailureState(translateErrorMessage(e, wallet.type, wallet.currency));
|
||||
state = FailureState(translateErrorMessage(e, wallet.type, wallet.currency));
|
||||
// }
|
||||
}
|
||||
return null;
|
||||
@@ -487,10 +486,11 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
|
||||
|
||||
try {
|
||||
state = TransactionCommitting();
|
||||
|
||||
|
||||
if (pendingTransaction!.shouldCommitUR()) {
|
||||
final urstr = await pendingTransaction!.commitUR();
|
||||
final result = await Navigator.of(context).pushNamed(Routes.urqrAnimatedPage, arguments: urstr);
|
||||
final result =
|
||||
await Navigator.of(context).pushNamed(Routes.urqrAnimatedPage, arguments: urstr);
|
||||
if (result == null) {
|
||||
state = FailureState("Canceled by user");
|
||||
return;
|
||||
@@ -507,12 +507,9 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
|
||||
final descriptionKey = '${pendingTransaction!.id}_${wallet.walletAddresses.primaryAddress}';
|
||||
_settingsStore.shouldSaveRecipientAddress
|
||||
? await transactionDescriptionBox.add(TransactionDescription(
|
||||
id: descriptionKey,
|
||||
recipientAddress: address,
|
||||
transactionNote: note))
|
||||
: await transactionDescriptionBox.add(TransactionDescription(
|
||||
id: descriptionKey,
|
||||
transactionNote: note));
|
||||
id: descriptionKey, recipientAddress: address, transactionNote: note))
|
||||
: await transactionDescriptionBox
|
||||
.add(TransactionDescription(id: descriptionKey, transactionNote: note));
|
||||
}
|
||||
|
||||
state = TransactionCommitted();
|
||||
@@ -674,10 +671,26 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
|
||||
lamportsNeeded != null ? ((lamportsNeeded + 5000) / lamportsPerSol) : 0.0;
|
||||
return S.current.insufficient_lamports(solValueNeeded.toString());
|
||||
} else {
|
||||
printV("No match found.");
|
||||
return S.current.insufficient_lamport_for_tx;
|
||||
}
|
||||
}
|
||||
|
||||
if (error is SolanaSignNativeTokenTransactionRentException) {
|
||||
return S.current.solana_sign_native_transaction_rent_exception;
|
||||
}
|
||||
|
||||
if (error is SolanaCreateAssociatedTokenAccountException) {
|
||||
return S.current.solana_create_associated_token_account_exception;
|
||||
}
|
||||
|
||||
if (error is SolanaSignSPLTokenTransactionRentException) {
|
||||
return S.current.solana_sign_spl_token_transaction_rent_exception;
|
||||
}
|
||||
|
||||
if (error is SolanaNoAssociatedTokenAccountException) {
|
||||
return S.current.solana_no_associated_token_account_exception;
|
||||
}
|
||||
|
||||
if (errorMessage.contains('insufficient funds for rent')) {
|
||||
return S.current.insufficientFundsForRentError;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user