mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 11:39:22 +00:00
Fix Erc20 send all feature (#1030)
* Fix Erc20 send all feature * Remove debug prints * Add user connection issues and certificate issues to ignored errors [skip ci]
This commit is contained in:
parent
07844a6ef4
commit
f4fad4d94d
3 changed files with 24 additions and 6 deletions
|
@ -181,8 +181,15 @@ abstract class EthereumWalletBase
|
|||
}
|
||||
} else {
|
||||
final output = outputs.first;
|
||||
final BigInt allAmount =
|
||||
_erc20Balance.balance - BigInt.from(calculateEstimatedFee(_credentials.priority!, null));
|
||||
// since the fees are taken from Ethereum
|
||||
// then no need to subtract the fees from the amount if send all
|
||||
final BigInt allAmount;
|
||||
if (transactionCurrency is Erc20Token) {
|
||||
allAmount = _erc20Balance.balance;
|
||||
} else {
|
||||
allAmount = _erc20Balance.balance -
|
||||
BigInt.from(calculateEstimatedFee(_credentials.priority!, null));
|
||||
}
|
||||
final totalOriginalAmount =
|
||||
EthereumFormatter.parseEthereumAmountToDouble(output.formattedCryptoAmount ?? 0);
|
||||
totalAmount = output.sendAll
|
||||
|
@ -196,7 +203,9 @@ abstract class EthereumWalletBase
|
|||
|
||||
final pendingEthereumTransaction = await _client.signTransaction(
|
||||
privateKey: _privateKey,
|
||||
toAddress: _credentials.outputs.first.address,
|
||||
toAddress: _credentials.outputs.first.isParsedAddress
|
||||
? _credentials.outputs.first.extractedAddress!
|
||||
: _credentials.outputs.first.address,
|
||||
amount: totalAmount.toString(),
|
||||
gas: _estimatedGas!,
|
||||
priority: _credentials.priority!,
|
||||
|
|
|
@ -20,13 +20,19 @@ class PendingEthereumTransaction with PendingTransaction {
|
|||
});
|
||||
|
||||
@override
|
||||
String get amountFormatted => (BigInt.parse(amount) / BigInt.from(pow(10, exponent))).toString();
|
||||
String get amountFormatted {
|
||||
final _amount = BigInt.parse(amount) / BigInt.from(pow(10, exponent));
|
||||
return _amount.toStringAsFixed(min(15, _amount.toString().length));
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> commit() async => await sendTransaction();
|
||||
|
||||
@override
|
||||
String get feeFormatted => (fee / BigInt.from(pow(10, 18))).toString();
|
||||
String get feeFormatted {
|
||||
final _fee = fee / BigInt.from(pow(10, 18));
|
||||
return _fee.toStringAsFixed(min(15, _fee.toString().length));
|
||||
}
|
||||
|
||||
@override
|
||||
String get hex => bytesToHex(signedTransaction, include0x: true);
|
||||
|
|
|
@ -144,7 +144,10 @@ class ExceptionHandler {
|
|||
"Connection closed before full header was received",
|
||||
"Connection terminated during handshake",
|
||||
"PERMISSION_NOT_GRANTED",
|
||||
"Failed host lookup: ",
|
||||
"Failed host lookup:",
|
||||
"CERTIFICATE_VERIFY_FAILED",
|
||||
"Handshake error in client",
|
||||
"Error while launching http",
|
||||
];
|
||||
|
||||
static Future<void> _addDeviceInfo(File file) async {
|
||||
|
|
Loading…
Reference in a new issue