mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-02-26 13:00:19 +00:00
eth api response data changes
This commit is contained in:
parent
09f5894f21
commit
d8c5028ebc
4 changed files with 22 additions and 27 deletions
lib
dto/ethereum
services
|
@ -26,7 +26,6 @@ class EthTokenTxDto {
|
|||
required this.topics,
|
||||
required this.data,
|
||||
required this.articulatedLog,
|
||||
required this.compressedLog,
|
||||
required this.transactionHash,
|
||||
required this.transactionIndex,
|
||||
});
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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,
|
||||
);
|
||||
|
@ -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;
|
||||
|
|
|
@ -29,7 +29,6 @@ class EthTxDTO {
|
|||
required this.maxPriorityFeePerGas,
|
||||
required this.isError,
|
||||
required this.hasToken,
|
||||
required this.compressedTx,
|
||||
required this.gasCost,
|
||||
required this.gasUsed,
|
||||
});
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
);
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
);
|
||||
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue