2023-05-26 21:21:16 +00:00
|
|
|
/*
|
|
|
|
* This file is part of Stack Wallet.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2023 Cypher Stack
|
|
|
|
* All Rights Reserved.
|
|
|
|
* The code is distributed under GPLv3 license, see LICENSE file for details.
|
|
|
|
* Generated by Cypher Stack on 2023-05-26
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2023-03-02 21:07:25 +00:00
|
|
|
import 'dart:convert';
|
|
|
|
|
2023-04-06 21:24:56 +00:00
|
|
|
import 'package:stackwallet/utilities/amount/amount.dart';
|
2023-03-27 14:41:59 +00:00
|
|
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
|
|
|
|
2023-03-02 21:07:25 +00:00
|
|
|
class EthTxDTO {
|
|
|
|
EthTxDTO({
|
|
|
|
required this.hash,
|
|
|
|
required this.blockHash,
|
|
|
|
required this.blockNumber,
|
|
|
|
required this.transactionIndex,
|
|
|
|
required this.timestamp,
|
|
|
|
required this.from,
|
|
|
|
required this.to,
|
|
|
|
required this.value,
|
|
|
|
required this.gas,
|
|
|
|
required this.gasPrice,
|
|
|
|
required this.maxFeePerGas,
|
|
|
|
required this.maxPriorityFeePerGas,
|
|
|
|
required this.isError,
|
|
|
|
required this.hasToken,
|
|
|
|
required this.compressedTx,
|
|
|
|
required this.gasCost,
|
|
|
|
required this.gasUsed,
|
|
|
|
});
|
|
|
|
|
|
|
|
factory EthTxDTO.fromMap(Map<String, dynamic> map) => EthTxDTO(
|
|
|
|
hash: map['hash'] as String,
|
|
|
|
blockHash: map['blockHash'] as String,
|
|
|
|
blockNumber: map['blockNumber'] as int,
|
|
|
|
transactionIndex: map['transactionIndex'] as int,
|
|
|
|
timestamp: map['timestamp'] as int,
|
|
|
|
from: map['from'] as String,
|
|
|
|
to: map['to'] as String,
|
2023-03-27 14:41:59 +00:00
|
|
|
value: _amountFromJsonNum(map['value']),
|
|
|
|
gas: _amountFromJsonNum(map['gas']),
|
|
|
|
gasPrice: _amountFromJsonNum(map['gasPrice']),
|
|
|
|
maxFeePerGas: _amountFromJsonNum(map['maxFeePerGas']),
|
|
|
|
maxPriorityFeePerGas: _amountFromJsonNum(map['maxPriorityFeePerGas']),
|
2023-03-02 21:07:25 +00:00
|
|
|
isError: map['isError'] as int,
|
|
|
|
hasToken: map['hasToken'] as int,
|
|
|
|
compressedTx: map['compressedTx'] as String,
|
2023-03-27 14:41:59 +00:00
|
|
|
gasCost: _amountFromJsonNum(map['gasCost']),
|
|
|
|
gasUsed: _amountFromJsonNum(map['gasUsed']),
|
2023-03-02 21:07:25 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
final String hash;
|
|
|
|
final String blockHash;
|
|
|
|
final int blockNumber;
|
|
|
|
final int transactionIndex;
|
|
|
|
final int timestamp;
|
|
|
|
final String from;
|
|
|
|
final String to;
|
2023-03-27 14:41:59 +00:00
|
|
|
final Amount value;
|
|
|
|
final Amount gas;
|
|
|
|
final Amount gasPrice;
|
|
|
|
final Amount maxFeePerGas;
|
|
|
|
final Amount maxPriorityFeePerGas;
|
2023-03-02 21:07:25 +00:00
|
|
|
final int isError;
|
|
|
|
final int hasToken;
|
|
|
|
final String compressedTx;
|
2023-03-27 14:41:59 +00:00
|
|
|
final Amount gasCost;
|
|
|
|
final Amount gasUsed;
|
|
|
|
|
|
|
|
static Amount _amountFromJsonNum(dynamic json) {
|
|
|
|
return Amount(
|
|
|
|
rawValue: BigInt.from(json as num),
|
|
|
|
fractionDigits: Coin.ethereum.decimals,
|
|
|
|
);
|
|
|
|
}
|
2023-03-02 21:07:25 +00:00
|
|
|
|
|
|
|
EthTxDTO copyWith({
|
|
|
|
String? hash,
|
|
|
|
String? blockHash,
|
|
|
|
int? blockNumber,
|
|
|
|
int? transactionIndex,
|
|
|
|
int? timestamp,
|
|
|
|
String? from,
|
|
|
|
String? to,
|
2023-03-27 14:41:59 +00:00
|
|
|
Amount? value,
|
|
|
|
Amount? gas,
|
|
|
|
Amount? gasPrice,
|
|
|
|
Amount? maxFeePerGas,
|
|
|
|
Amount? maxPriorityFeePerGas,
|
2023-03-02 21:07:25 +00:00
|
|
|
int? isError,
|
|
|
|
int? hasToken,
|
|
|
|
String? compressedTx,
|
2023-03-27 14:41:59 +00:00
|
|
|
Amount? gasCost,
|
|
|
|
Amount? gasUsed,
|
2023-03-02 21:07:25 +00:00
|
|
|
}) =>
|
|
|
|
EthTxDTO(
|
|
|
|
hash: hash ?? this.hash,
|
|
|
|
blockHash: blockHash ?? this.blockHash,
|
|
|
|
blockNumber: blockNumber ?? this.blockNumber,
|
|
|
|
transactionIndex: transactionIndex ?? this.transactionIndex,
|
|
|
|
timestamp: timestamp ?? this.timestamp,
|
|
|
|
from: from ?? this.from,
|
|
|
|
to: to ?? this.to,
|
|
|
|
value: value ?? this.value,
|
|
|
|
gas: gas ?? this.gas,
|
|
|
|
gasPrice: gasPrice ?? this.gasPrice,
|
|
|
|
maxFeePerGas: maxFeePerGas ?? this.maxFeePerGas,
|
|
|
|
maxPriorityFeePerGas: maxPriorityFeePerGas ?? this.maxPriorityFeePerGas,
|
|
|
|
isError: isError ?? this.isError,
|
|
|
|
hasToken: hasToken ?? this.hasToken,
|
|
|
|
compressedTx: compressedTx ?? this.compressedTx,
|
|
|
|
gasCost: gasCost ?? this.gasCost,
|
|
|
|
gasUsed: gasUsed ?? this.gasUsed,
|
|
|
|
);
|
|
|
|
|
|
|
|
Map<String, dynamic> toMap() {
|
|
|
|
final map = <String, dynamic>{};
|
|
|
|
map['hash'] = hash;
|
|
|
|
map['blockHash'] = blockHash;
|
|
|
|
map['blockNumber'] = blockNumber;
|
|
|
|
map['transactionIndex'] = transactionIndex;
|
|
|
|
map['timestamp'] = timestamp;
|
|
|
|
map['from'] = from;
|
|
|
|
map['to'] = to;
|
|
|
|
map['value'] = value;
|
|
|
|
map['gas'] = gas;
|
|
|
|
map['gasPrice'] = gasPrice;
|
|
|
|
map['maxFeePerGas'] = maxFeePerGas;
|
|
|
|
map['maxPriorityFeePerGas'] = maxPriorityFeePerGas;
|
|
|
|
map['isError'] = isError;
|
|
|
|
map['hasToken'] = hasToken;
|
|
|
|
map['compressedTx'] = compressedTx;
|
|
|
|
map['gasCost'] = gasCost;
|
|
|
|
map['gasUsed'] = gasUsed;
|
|
|
|
return map;
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() => jsonEncode(toMap());
|
|
|
|
}
|