mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-10-30 00:47:48 +00:00
b3d579c24a
* chore: Initial setup for polygon package * feat: Add polygon node urls * feat: Add Polygon(MATIC) wallet WIP * feat: Add Polygon(MATIC) wallet WIP * feat: Add Polygon MATIC wallet [skip ci] * fix: Issue with create/restore wallet for polygon * feat: Add erc20 tokens for polygon * feat: Adding Polygon MATIC Wallet * fix: Add build command for polygon to workflow file to fix failing action * fix: Switch evm to not display additional balance * chore: Sync with remote * fix: Revert change to inject app script * feat: Add polygon erc20 tokens * feat: Increase migration version * fix: Restore from QR address validator fix * fix: Adjust wallet connect connection flow to adapt to wallet type * fix: Make wallet fetch nfts based on the current wallet type * fix: Make wallet fetch nfts based on the current wallet type * fix: Try fetching transactions with moralis * fix: Requested review changes * fix: Error creating new wallet * fix: Revert script * fix: Exclude spam NFTs from nft listing API response * Update default_erc20_tokens.dart * replace matic with matic poly * Add polygon wallet scheme to app links * style: reformat default_settings_migration.dart * minor enhancement * fix using different wallet function for setting the transaction priorities * fix: Add chain to calls * Add USDC.e to initial coins * Add other default polygon node * Use Polygon scan some UI fixes * Add polygon scan api key to secrets generation code --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
85 lines
2.5 KiB
Dart
85 lines
2.5 KiB
Dart
import 'dart:math';
|
|
|
|
import 'package:cw_core/format_amount.dart';
|
|
import 'package:cw_core/transaction_direction.dart';
|
|
import 'package:cw_core/transaction_info.dart';
|
|
|
|
class EthereumTransactionInfo extends TransactionInfo {
|
|
EthereumTransactionInfo({
|
|
required this.id,
|
|
required this.height,
|
|
required this.ethAmount,
|
|
required this.ethFee,
|
|
this.tokenSymbol = "ETH",
|
|
this.exponent = 18,
|
|
required this.direction,
|
|
required this.isPending,
|
|
required this.date,
|
|
required this.confirmations,
|
|
required this.to,
|
|
}) : this.amount = ethAmount.toInt(),
|
|
this.fee = ethFee.toInt();
|
|
|
|
final String id;
|
|
final int height;
|
|
final int amount;
|
|
final BigInt ethAmount;
|
|
final int exponent;
|
|
final TransactionDirection direction;
|
|
final DateTime date;
|
|
final bool isPending;
|
|
final int fee;
|
|
final BigInt ethFee;
|
|
final int confirmations;
|
|
final String tokenSymbol;
|
|
String? _fiatAmount;
|
|
final String? to;
|
|
|
|
@override
|
|
String amountFormatted() {
|
|
final amount = formatAmount((ethAmount / BigInt.from(10).pow(exponent)).toString());
|
|
return '${amount.substring(0, min(10, amount.length))} $tokenSymbol';
|
|
}
|
|
|
|
@override
|
|
String fiatAmount() => _fiatAmount ?? '';
|
|
|
|
@override
|
|
void changeFiatAmount(String amount) => _fiatAmount = formatAmount(amount);
|
|
|
|
@override
|
|
String feeFormatted() {
|
|
final amount = (ethFee / BigInt.from(10).pow(18)).toString();
|
|
return '${amount.substring(0, min(10, amount.length))} ETH';
|
|
}
|
|
|
|
factory EthereumTransactionInfo.fromJson(Map<String, dynamic> data) {
|
|
return EthereumTransactionInfo(
|
|
id: data['id'] as String,
|
|
height: data['height'] as int,
|
|
ethAmount: BigInt.parse(data['amount']),
|
|
exponent: data['exponent'] as int,
|
|
ethFee: BigInt.parse(data['fee']),
|
|
direction: parseTransactionDirectionFromInt(data['direction'] as int),
|
|
date: DateTime.fromMillisecondsSinceEpoch(data['date'] as int),
|
|
isPending: data['isPending'] as bool,
|
|
confirmations: data['confirmations'] as int,
|
|
tokenSymbol: data['tokenSymbol'] as String,
|
|
to: data['to'],
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'id': id,
|
|
'height': height,
|
|
'amount': ethAmount.toString(),
|
|
'exponent': exponent,
|
|
'fee': ethFee.toString(),
|
|
'direction': direction.index,
|
|
'date': date.millisecondsSinceEpoch,
|
|
'isPending': isPending,
|
|
'confirmations': confirmations,
|
|
'tokenSymbol': tokenSymbol,
|
|
'to': to,
|
|
};
|
|
}
|