eth api response data changes

This commit is contained in:
julian 2023-10-28 10:20:17 -06:00
parent 09f5894f21
commit d8c5028ebc
4 changed files with 22 additions and 27 deletions

View file

@ -26,7 +26,6 @@ class EthTokenTxDto {
required this.topics, required this.topics,
required this.data, required this.data,
required this.articulatedLog, required this.articulatedLog,
required this.compressedLog,
required this.transactionHash, required this.transactionHash,
required this.transactionIndex, required this.transactionIndex,
}); });
@ -44,7 +43,6 @@ class EthTokenTxDto {
map['articulatedLog'] as Map, map['articulatedLog'] as Map,
), ),
), ),
compressedLog = map['compressedLog'] as String,
transactionHash = map['transactionHash'] as String, transactionHash = map['transactionHash'] as String,
transactionIndex = map['transactionIndex'] as int; transactionIndex = map['transactionIndex'] as int;
@ -54,7 +52,6 @@ class EthTokenTxDto {
final List<String> topics; final List<String> topics;
final String data; final String data;
final ArticulatedLog? articulatedLog; final ArticulatedLog? articulatedLog;
final String compressedLog;
final String transactionHash; final String transactionHash;
final int transactionIndex; final int transactionIndex;
@ -76,7 +73,6 @@ class EthTokenTxDto {
topics: topics ?? this.topics, topics: topics ?? this.topics,
data: data ?? this.data, data: data ?? this.data,
articulatedLog: articulatedLog ?? this.articulatedLog, articulatedLog: articulatedLog ?? this.articulatedLog,
compressedLog: compressedLog ?? this.compressedLog,
transactionHash: transactionHash ?? this.transactionHash, transactionHash: transactionHash ?? this.transactionHash,
transactionIndex: transactionIndex ?? this.transactionIndex, transactionIndex: transactionIndex ?? this.transactionIndex,
); );
@ -89,7 +85,6 @@ class EthTokenTxDto {
map['topics'] = topics; map['topics'] = topics;
map['data'] = data; map['data'] = data;
map['articulatedLog'] = articulatedLog?.toMap(); map['articulatedLog'] = articulatedLog?.toMap();
map['compressedLog'] = compressedLog;
map['transactionHash'] = transactionHash; map['transactionHash'] = transactionHash;
map['transactionIndex'] = transactionIndex; map['transactionIndex'] = transactionIndex;
return map; return map;

View file

@ -29,7 +29,6 @@ class EthTxDTO {
required this.maxPriorityFeePerGas, required this.maxPriorityFeePerGas,
required this.isError, required this.isError,
required this.hasToken, required this.hasToken,
required this.compressedTx,
required this.gasCost, required this.gasCost,
required this.gasUsed, required this.gasUsed,
}); });
@ -42,16 +41,15 @@ class EthTxDTO {
timestamp: map['timestamp'] as int, timestamp: map['timestamp'] as int,
from: map['from'] as String, from: map['from'] as String,
to: map['to'] as String, to: map['to'] as String,
value: _amountFromJsonNum(map['value']), value: _amountFromJsonNum(map['value'])!,
gas: _amountFromJsonNum(map['gas']), gas: _amountFromJsonNum(map['gas'])!,
gasPrice: _amountFromJsonNum(map['gasPrice']), gasPrice: _amountFromJsonNum(map['gasPrice'])!,
maxFeePerGas: _amountFromJsonNum(map['maxFeePerGas']), maxFeePerGas: _amountFromJsonNum(map['maxFeePerGas']),
maxPriorityFeePerGas: _amountFromJsonNum(map['maxPriorityFeePerGas']), maxPriorityFeePerGas: _amountFromJsonNum(map['maxPriorityFeePerGas']),
isError: map['isError'] as int, isError: map['isError'] as bool? ?? false,
hasToken: map['hasToken'] as int, hasToken: map['hasToken'] as bool? ?? false,
compressedTx: map['compressedTx'] as String, gasCost: _amountFromJsonNum(map['gasCost'])!,
gasCost: _amountFromJsonNum(map['gasCost']), gasUsed: _amountFromJsonNum(map['gasUsed'])!,
gasUsed: _amountFromJsonNum(map['gasUsed']),
); );
final String hash; final String hash;
@ -64,17 +62,19 @@ class EthTxDTO {
final Amount value; final Amount value;
final Amount gas; final Amount gas;
final Amount gasPrice; final Amount gasPrice;
final Amount maxFeePerGas; final Amount? maxFeePerGas;
final Amount maxPriorityFeePerGas; final Amount? maxPriorityFeePerGas;
final int isError; final bool isError;
final int hasToken; final bool hasToken;
final String compressedTx;
final Amount gasCost; final Amount gasCost;
final Amount gasUsed; final Amount gasUsed;
static Amount _amountFromJsonNum(dynamic json) { static Amount? _amountFromJsonNum(dynamic json) {
if (json == null) {
return null;
}
return Amount( return Amount(
rawValue: BigInt.from(json as num), rawValue: BigInt.parse(json.toString()),
fractionDigits: Coin.ethereum.decimals, fractionDigits: Coin.ethereum.decimals,
); );
} }
@ -92,8 +92,8 @@ class EthTxDTO {
Amount? gasPrice, Amount? gasPrice,
Amount? maxFeePerGas, Amount? maxFeePerGas,
Amount? maxPriorityFeePerGas, Amount? maxPriorityFeePerGas,
int? isError, bool? isError,
int? hasToken, bool? hasToken,
String? compressedTx, String? compressedTx,
Amount? gasCost, Amount? gasCost,
Amount? gasUsed, Amount? gasUsed,
@ -113,7 +113,6 @@ class EthTxDTO {
maxPriorityFeePerGas: maxPriorityFeePerGas ?? this.maxPriorityFeePerGas, maxPriorityFeePerGas: maxPriorityFeePerGas ?? this.maxPriorityFeePerGas,
isError: isError ?? this.isError, isError: isError ?? this.isError,
hasToken: hasToken ?? this.hasToken, hasToken: hasToken ?? this.hasToken,
compressedTx: compressedTx ?? this.compressedTx,
gasCost: gasCost ?? this.gasCost, gasCost: gasCost ?? this.gasCost,
gasUsed: gasUsed ?? this.gasUsed, gasUsed: gasUsed ?? this.gasUsed,
); );
@ -134,7 +133,6 @@ class EthTxDTO {
map['maxPriorityFeePerGas'] = maxPriorityFeePerGas.toString(); map['maxPriorityFeePerGas'] = maxPriorityFeePerGas.toString();
map['isError'] = isError; map['isError'] = isError;
map['hasToken'] = hasToken; map['hasToken'] = hasToken;
map['compressedTx'] = compressedTx;
map['gasCost'] = gasCost.toString(); map['gasCost'] = gasCost.toString();
map['gasUsed'] = gasUsed.toString(); map['gasUsed'] = gasUsed.toString();
return map; return map;

View file

@ -227,7 +227,9 @@ class EthereumWallet extends CoinServiceAPI with WalletCache, WalletDB {
Future<void> updateBalance() async { Future<void> updateBalance() async {
web3.Web3Client client = getEthClient(); web3.Web3Client client = getEthClient();
web3.EtherAmount ethBalance = await client.getBalance(_credentials.address);
final address = web3.EthereumAddress.fromHex(await currentReceivingAddress);
web3.EtherAmount ethBalance = await client.getBalance(address);
_balance = Balance( _balance = Balance(
total: Amount( total: Amount(
rawValue: ethBalance.getInWei, rawValue: ethBalance.getInWei,

View file

@ -75,7 +75,7 @@ abstract class EthereumAPI {
for (final map in list!) { for (final map in list!) {
final txn = EthTxDTO.fromMap(Map<String, dynamic>.from(map as Map)); final txn = EthTxDTO.fromMap(Map<String, dynamic>.from(map as Map));
if (txn.hasToken == 0 || includeTokens) { if (!txn.hasToken || includeTokens) {
txns.add(txn); txns.add(txn);
} }
} }