Skip to content

Commit

Permalink
Merge pull request #695 from cypherstack/ui-fixes
Browse files Browse the repository at this point in the history
Eth fixes
  • Loading branch information
rehrar authored Oct 29, 2023
2 parents 392196a + d8c5028 commit 2f3a949
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 27 deletions.
5 changes: 0 additions & 5 deletions lib/dto/ethereum/eth_token_tx_dto.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class EthTokenTxDto {
required this.topics,
required this.data,
required this.articulatedLog,
required this.compressedLog,
required this.transactionHash,
required this.transactionIndex,
});
Expand All @@ -44,7 +43,6 @@ class EthTokenTxDto {
map['articulatedLog'] as Map,
),
),
compressedLog = map['compressedLog'] as String,
transactionHash = map['transactionHash'] as String,
transactionIndex = map['transactionIndex'] as int;

Expand All @@ -54,7 +52,6 @@ class EthTokenTxDto {
final List<String> topics;
final String data;
final ArticulatedLog? articulatedLog;
final String compressedLog;
final String transactionHash;
final int transactionIndex;

Expand All @@ -76,7 +73,6 @@ class EthTokenTxDto {
topics: topics ?? this.topics,
data: data ?? this.data,
articulatedLog: articulatedLog ?? this.articulatedLog,
compressedLog: compressedLog ?? this.compressedLog,
transactionHash: transactionHash ?? this.transactionHash,
transactionIndex: transactionIndex ?? this.transactionIndex,
);
Expand All @@ -89,7 +85,6 @@ class EthTokenTxDto {
map['topics'] = topics;
map['data'] = data;
map['articulatedLog'] = articulatedLog?.toMap();
map['compressedLog'] = compressedLog;
map['transactionHash'] = transactionHash;
map['transactionIndex'] = transactionIndex;
return map;
Expand Down
38 changes: 18 additions & 20 deletions lib/dto/ethereum/eth_tx_dto.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class EthTxDTO {
required this.maxPriorityFeePerGas,
required this.isError,
required this.hasToken,
required this.compressedTx,
required this.gasCost,
required this.gasUsed,
});
Expand All @@ -42,16 +41,15 @@ class EthTxDTO {
timestamp: map['timestamp'] as int,
from: map['from'] as String,
to: map['to'] as String,
value: _amountFromJsonNum(map['value']),
gas: _amountFromJsonNum(map['gas']),
gasPrice: _amountFromJsonNum(map['gasPrice']),
value: _amountFromJsonNum(map['value'])!,
gas: _amountFromJsonNum(map['gas'])!,
gasPrice: _amountFromJsonNum(map['gasPrice'])!,
maxFeePerGas: _amountFromJsonNum(map['maxFeePerGas']),
maxPriorityFeePerGas: _amountFromJsonNum(map['maxPriorityFeePerGas']),
isError: map['isError'] as int,
hasToken: map['hasToken'] as int,
compressedTx: map['compressedTx'] as String,
gasCost: _amountFromJsonNum(map['gasCost']),
gasUsed: _amountFromJsonNum(map['gasUsed']),
isError: map['isError'] as bool? ?? false,
hasToken: map['hasToken'] as bool? ?? false,
gasCost: _amountFromJsonNum(map['gasCost'])!,
gasUsed: _amountFromJsonNum(map['gasUsed'])!,
);

final String hash;
Expand All @@ -64,17 +62,19 @@ class EthTxDTO {
final Amount value;
final Amount gas;
final Amount gasPrice;
final Amount maxFeePerGas;
final Amount maxPriorityFeePerGas;
final int isError;
final int hasToken;
final String compressedTx;
final Amount? maxFeePerGas;
final Amount? maxPriorityFeePerGas;
final bool isError;
final bool hasToken;
final Amount gasCost;
final Amount gasUsed;

static Amount _amountFromJsonNum(dynamic json) {
static Amount? _amountFromJsonNum(dynamic json) {
if (json == null) {
return null;
}
return Amount(
rawValue: BigInt.from(json as num),
rawValue: BigInt.parse(json.toString()),
fractionDigits: Coin.ethereum.decimals,
);
}
Expand All @@ -92,8 +92,8 @@ class EthTxDTO {
Amount? gasPrice,
Amount? maxFeePerGas,
Amount? maxPriorityFeePerGas,
int? isError,
int? hasToken,
bool? isError,
bool? hasToken,
String? compressedTx,
Amount? gasCost,
Amount? gasUsed,
Expand All @@ -113,7 +113,6 @@ class EthTxDTO {
maxPriorityFeePerGas: maxPriorityFeePerGas ?? this.maxPriorityFeePerGas,
isError: isError ?? this.isError,
hasToken: hasToken ?? this.hasToken,
compressedTx: compressedTx ?? this.compressedTx,
gasCost: gasCost ?? this.gasCost,
gasUsed: gasUsed ?? this.gasUsed,
);
Expand All @@ -134,7 +133,6 @@ class EthTxDTO {
map['maxPriorityFeePerGas'] = maxPriorityFeePerGas.toString();
map['isError'] = isError;
map['hasToken'] = hasToken;
map['compressedTx'] = compressedTx;
map['gasCost'] = gasCost.toString();
map['gasUsed'] = gasUsed.toString();
return map;
Expand Down
4 changes: 3 additions & 1 deletion lib/services/coins/ethereum/ethereum_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,9 @@ class EthereumWallet extends CoinServiceAPI with WalletCache, WalletDB {

Future<void> updateBalance() async {
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(
total: Amount(
rawValue: ethBalance.getInWei,
Expand Down
2 changes: 1 addition & 1 deletion lib/services/ethereum/ethereum_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ abstract class EthereumAPI {
for (final map in list!) {
final txn = EthTxDTO.fromMap(Map<String, dynamic>.from(map as Map));

if (txn.hasToken == 0 || includeTokens) {
if (!txn.hasToken || includeTokens) {
txns.add(txn);
}
}
Expand Down

0 comments on commit 2f3a949

Please sign in to comment.