mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 20:39:51 +00:00
* feat: started dEuro Savings integration * fix: merge conflict regarding theming * feat: Add dEuro Savings Screen * feat: Change DEuro Savings UI * feat: Complete DEuro Savings integration with UI enhancements and transaction support * style: remove forgotten print statements * feat: localize dEuro subtitle * feat: add approval flow and priority handling to DEuro Savings integration - Introduced approval flow for DEuro Savings to enable token approvals. - Added priority handling for deposit and withdrawal operations. - Updated UI to support approval state and interactions. - Localized new strings for multiple languages. - Enhanced transaction handling with separate approval and commit actions. * feat: add support for ERC20 token approval transactions - Introduced `signApprovalTransaction` and `createApprovalTransaction` methods. - Added handling for infinite approvals. - Implemented encoding for approval transaction data. - Enhanced transaction creation flow with approval-specific functionality. * Update UI * feat: enhance DEuro Savings logic and UI with computed property and fix gradient background * feat: localize transaction confirmation content for DEuro Savings * feat: enable interest collection for DEuro Savings with localized support * fix reformatting [skip ci] --------- Co-authored-by: tuxsudo <tuxsudo@tux.pizza> Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
58 lines
1.5 KiB
Dart
58 lines
1.5 KiB
Dart
import 'dart:math';
|
|
import 'dart:typed_data';
|
|
|
|
import 'package:cw_core/pending_transaction.dart';
|
|
import 'package:web3dart/crypto.dart';
|
|
import 'package:hex/hex.dart' as Hex;
|
|
|
|
class PendingEVMChainTransaction with PendingTransaction {
|
|
final Function sendTransaction;
|
|
final Uint8List signedTransaction;
|
|
final BigInt fee;
|
|
final String amount;
|
|
final int exponent;
|
|
final bool isInfiniteApproval;
|
|
|
|
PendingEVMChainTransaction({
|
|
required this.sendTransaction,
|
|
required this.signedTransaction,
|
|
required this.fee,
|
|
required this.amount,
|
|
required this.exponent,
|
|
this.isInfiniteApproval = false,
|
|
});
|
|
|
|
@override
|
|
String get amountFormatted {
|
|
if (isInfiniteApproval) return "∞";
|
|
final _amount = (BigInt.parse(amount) / BigInt.from(pow(10, exponent))).toString();
|
|
return _amount.substring(0, min(10, _amount.length));
|
|
}
|
|
|
|
@override
|
|
Future<void> commit() async => await sendTransaction();
|
|
|
|
@override
|
|
String get feeFormatted {
|
|
final _fee = (fee / BigInt.from(pow(10, 18))).toString();
|
|
return _fee.substring(0, min(10, _fee.length));
|
|
}
|
|
|
|
@override
|
|
String get hex => bytesToHex(signedTransaction, include0x: true);
|
|
|
|
@override
|
|
String get id {
|
|
final String eip1559Hex = '0x02${hex.substring(2)}';
|
|
final Uint8List bytes = Uint8List.fromList(Hex.HEX.decode(eip1559Hex.substring(2)));
|
|
|
|
var txid = keccak256(bytes);
|
|
|
|
return '0x${Hex.HEX.encode(txid)}';
|
|
}
|
|
|
|
@override
|
|
Future<String?> commitUR() {
|
|
throw UnimplementedError();
|
|
}
|
|
}
|