mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-22 02:24:30 +00:00
eth gas tracker fixes and token send tweaks
This commit is contained in:
parent
e2cc371f99
commit
b5a58064ac
4 changed files with 22 additions and 39 deletions
|
@ -342,7 +342,9 @@ class FeeDropDownChild extends ConsumerWidget {
|
|||
),
|
||||
if (feeObject != null)
|
||||
Text(
|
||||
estimatedTimeToBeIncludedInNextBlock(
|
||||
manager.coin == Coin.ethereum
|
||||
? ""
|
||||
: estimatedTimeToBeIncludedInNextBlock(
|
||||
Constants.targetBlockTimeInSeconds(manager.coin),
|
||||
feeRateType == FeeRateType.fast
|
||||
? feeObject!.numberOfBlocksFast
|
||||
|
|
|
@ -503,7 +503,7 @@ abstract class EthereumAPI {
|
|||
if (json["success"] == true) {
|
||||
return EthereumResponse(
|
||||
GasTracker.fromJson(
|
||||
Map<String, dynamic>.from(json["result"] as Map),
|
||||
Map<String, dynamic>.from(json["result"]["result"] as Map),
|
||||
),
|
||||
null,
|
||||
);
|
||||
|
|
|
@ -90,30 +90,10 @@ class EthTokenWallet extends ChangeNotifier with EthTokenCache {
|
|||
final myAddress = await currentReceivingAddress;
|
||||
final myWeb3Address = web3dart.EthereumAddress.fromHex(myAddress);
|
||||
|
||||
final est = await client.estimateGas(
|
||||
sender: myWeb3Address,
|
||||
to: web3dart.EthereumAddress.fromHex(address),
|
||||
data: _sendFunction
|
||||
.encodeCall([web3dart.EthereumAddress.fromHex(address), amount.raw]),
|
||||
gasPrice: web3dart.EtherAmount.fromUnitAndValue(
|
||||
web3dart.EtherUnit.wei,
|
||||
fee,
|
||||
),
|
||||
amountOfGas: BigInt.from(_gasLimit),
|
||||
);
|
||||
|
||||
final nonce = args?["nonce"] as int? ??
|
||||
await client.getTransactionCount(myWeb3Address,
|
||||
atBlock: const web3dart.BlockNum.pending());
|
||||
|
||||
final nResponse = await EthereumAPI.getAddressNonce(address: myAddress);
|
||||
print("==============================================================");
|
||||
print("TOKEN client.estimateGas: $est");
|
||||
print("TOKEN estimateFeeFor : $feeEstimate");
|
||||
print("TOKEN nonce custom response: $nResponse");
|
||||
print("TOKEN actual nonce : $nonce");
|
||||
print("==============================================================");
|
||||
|
||||
final tx = web3dart.Transaction.callContract(
|
||||
contract: _deployedContract,
|
||||
function: _sendFunction,
|
||||
|
@ -179,7 +159,7 @@ class EthTokenWallet extends ChangeNotifier with EthTokenCache {
|
|||
// precision may be lost here hence the following amountString
|
||||
amount: (txData["recipientAmt"] as Amount).raw.toInt(),
|
||||
amountString: (txData["recipientAmt"] as Amount).toJsonString(),
|
||||
fee: txData["fee"] as int,
|
||||
fee: (txData["fee"] as Amount).raw.toInt(),
|
||||
height: null,
|
||||
isCancelled: false,
|
||||
isLelantus: false,
|
||||
|
|
|
@ -15,7 +15,7 @@ class GasTracker {
|
|||
final int numberOfBlocksAverage;
|
||||
final int numberOfBlocksSlow;
|
||||
|
||||
final int timestamp;
|
||||
final String lastBlock;
|
||||
|
||||
const GasTracker({
|
||||
required this.average,
|
||||
|
@ -24,19 +24,20 @@ class GasTracker {
|
|||
required this.numberOfBlocksFast,
|
||||
required this.numberOfBlocksAverage,
|
||||
required this.numberOfBlocksSlow,
|
||||
required this.timestamp,
|
||||
required this.lastBlock,
|
||||
});
|
||||
|
||||
factory GasTracker.fromJson(Map<String, dynamic> json) {
|
||||
final targetTime = Constants.targetBlockTimeInSeconds(Coin.ethereum);
|
||||
return GasTracker(
|
||||
average: Decimal.parse(json["average"]["price"].toString()),
|
||||
fast: Decimal.parse(json["fast"]["price"].toString()),
|
||||
slow: Decimal.parse(json["slow"]["price"].toString()),
|
||||
numberOfBlocksAverage: (json["average"]["time"] as int) ~/ targetTime,
|
||||
numberOfBlocksFast: (json["fast"]["time"] as int) ~/ targetTime,
|
||||
numberOfBlocksSlow: (json["slow"]["time"] as int) ~/ targetTime,
|
||||
timestamp: json["timestamp"] as int,
|
||||
fast: Decimal.parse(json["FastGasPrice"].toString()),
|
||||
average: Decimal.parse(json["ProposeGasPrice"].toString()),
|
||||
slow: Decimal.parse(json["SafeGasPrice"].toString()),
|
||||
// TODO fix hardcoded
|
||||
numberOfBlocksFast: 30 ~/ targetTime,
|
||||
numberOfBlocksAverage: 180 ~/ targetTime,
|
||||
numberOfBlocksSlow: 240 ~/ targetTime,
|
||||
lastBlock: json["LastBlock"] as String,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue