eth fixes

This commit is contained in:
julian 2023-04-11 14:25:13 -06:00
parent eae2ad1651
commit 723ec64354
3 changed files with 78 additions and 63 deletions

View file

@ -552,8 +552,20 @@ class _ConfirmTransactionViewState
String fiatAmount = "N/A"; String fiatAmount = "N/A";
if (externalCalls) { if (externalCalls) {
final price = ref final price = widget.isTokenTx
.read(priceAnd24hChangeNotifierProvider) ? ref
.read(
priceAnd24hChangeNotifierProvider)
.getTokenPrice(
ref
.read(tokenServiceProvider)!
.tokenContract
.address,
)
.item1
: ref
.read(
priceAnd24hChangeNotifierProvider)
.getPrice(coin) .getPrice(coin)
.item1; .item1;
if (price > Decimal.zero) { if (price > Decimal.zero) {
@ -883,6 +895,7 @@ class _ConfirmTransactionViewState
SizedBox( SizedBox(
height: isDesktop ? 23 : 12, height: isDesktop ? 23 : 12,
), ),
if (!widget.isTokenTx)
Padding( Padding(
padding: isDesktop padding: isDesktop
? const EdgeInsets.symmetric( ? const EdgeInsets.symmetric(
@ -918,8 +931,9 @@ class _ConfirmTransactionViewState
), ),
), ),
Builder(builder: (context) { Builder(builder: (context) {
final coin = ref.watch(walletsChangeNotifierProvider final coin = ref.watch(
.select((value) => value.getManager(walletId).coin)); walletsChangeNotifierProvider.select(
(value) => value.getManager(walletId).coin));
final fee = transactionInfo["fee"] is Amount final fee = transactionInfo["fee"] is Amount
? transactionInfo["fee"] as Amount ? transactionInfo["fee"] as Amount
: (transactionInfo["fee"] as int) : (transactionInfo["fee"] as int)
@ -928,7 +942,8 @@ class _ConfirmTransactionViewState
localeServiceChangeNotifierProvider localeServiceChangeNotifierProvider
.select((value) => value.locale), .select((value) => value.locale),
); );
final amount = transactionInfo["recipientAmt"] as Amount; final amount =
transactionInfo["recipientAmt"] as Amount;
return Text( return Text(
"${(amount + fee).localizedStringAsFixed( "${(amount + fee).localizedStringAsFixed(
locale: locale, locale: locale,

View file

@ -923,7 +923,7 @@ class EthereumWallet extends CoinServiceAPI with WalletCache, WalletDB {
// precision may be lost here hence the following amountString // precision may be lost here hence the following amountString
amount: (txData["recipientAmt"] as Amount).raw.toInt(), amount: (txData["recipientAmt"] as Amount).raw.toInt(),
amountString: (txData["recipientAmt"] as Amount).toJsonString(), amountString: (txData["recipientAmt"] as Amount).toJsonString(),
fee: txData["fee"] as int, fee: (txData["fee"] as Amount).raw.toInt(),
height: null, height: null,
isCancelled: false, isCancelled: false,
isLelantus: false, isLelantus: false,

View file

@ -449,7 +449,7 @@ abstract class EthereumAPI {
}) async { }) async {
try { try {
final uri = Uri.parse( final uri = Uri.parse(
"$stackBaseServer/state?addrs=$address&parts=nonce", "$stackBaseServer/state?addrs=$address&parts=all",
); );
final response = await get(uri); final response = await get(uri);
@ -469,7 +469,7 @@ abstract class EthereumAPI {
} }
} else { } else {
throw EthApiException( throw EthApiException(
"getWalletTokenBalance($address) failed with status code: " "getAddressNonce($address) failed with status code: "
"${response.statusCode}", "${response.statusCode}",
); );
} }
@ -480,7 +480,7 @@ abstract class EthereumAPI {
); );
} catch (e, s) { } catch (e, s) {
Logging.instance.log( Logging.instance.log(
"getWalletTokenBalance(): $e\n$s", "getAddressNonce(): $e\n$s",
level: LogLevel.Error, level: LogLevel.Error,
); );
return EthereumResponse( return EthereumResponse(