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,10 +552,22 @@ class _ConfirmTransactionViewState
String fiatAmount = "N/A";
if (externalCalls) {
final price = ref
.read(priceAnd24hChangeNotifierProvider)
.getPrice(coin)
.item1;
final price = widget.isTokenTx
? ref
.read(
priceAnd24hChangeNotifierProvider)
.getTokenPrice(
ref
.read(tokenServiceProvider)!
.tokenContract
.address,
)
.item1
: ref
.read(
priceAnd24hChangeNotifierProvider)
.getPrice(coin)
.item1;
if (price > Decimal.zero) {
fiatAmount = (amount.decimal * price)
.toAmount(fractionDigits: 2)
@ -883,58 +895,28 @@ class _ConfirmTransactionViewState
SizedBox(
height: isDesktop ? 23 : 12,
),
Padding(
padding: isDesktop
? const EdgeInsets.symmetric(
horizontal: 32,
)
: const EdgeInsets.all(0),
child: RoundedContainer(
if (!widget.isTokenTx)
Padding(
padding: isDesktop
? const EdgeInsets.symmetric(
horizontal: 16,
vertical: 18,
horizontal: 32,
)
: const EdgeInsets.all(12),
color: Theme.of(context)
.extension<StackColors>()!
.snackBarBackSuccess,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
isDesktop ? "Total amount to send" : "Total amount",
style: isDesktop
? STextStyles.desktopTextExtraExtraSmall(context)
.copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textConfirmTotalAmount,
)
: STextStyles.titleBold12(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textConfirmTotalAmount,
),
),
Builder(builder: (context) {
final coin = ref.watch(walletsChangeNotifierProvider
.select((value) => value.getManager(walletId).coin));
final fee = transactionInfo["fee"] is Amount
? transactionInfo["fee"] as Amount
: (transactionInfo["fee"] as int)
.toAmountAsRaw(fractionDigits: coin.decimals);
final locale = ref.watch(
localeServiceChangeNotifierProvider
.select((value) => value.locale),
);
final amount = transactionInfo["recipientAmt"] as Amount;
return Text(
"${(amount + fee).localizedStringAsFixed(
locale: locale,
)} ${ref.watch(
managerProvider.select((value) => value.coin),
).ticker}",
: const EdgeInsets.all(0),
child: RoundedContainer(
padding: isDesktop
? const EdgeInsets.symmetric(
horizontal: 16,
vertical: 18,
)
: const EdgeInsets.all(12),
color: Theme.of(context)
.extension<StackColors>()!
.snackBarBackSuccess,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
isDesktop ? "Total amount to send" : "Total amount",
style: isDesktop
? STextStyles.desktopTextExtraExtraSmall(context)
.copyWith(
@ -942,18 +924,51 @@ class _ConfirmTransactionViewState
.extension<StackColors>()!
.textConfirmTotalAmount,
)
: STextStyles.itemSubtitle12(context).copyWith(
: STextStyles.titleBold12(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textConfirmTotalAmount,
),
textAlign: TextAlign.right,
);
}),
],
),
Builder(builder: (context) {
final coin = ref.watch(
walletsChangeNotifierProvider.select(
(value) => value.getManager(walletId).coin));
final fee = transactionInfo["fee"] is Amount
? transactionInfo["fee"] as Amount
: (transactionInfo["fee"] as int)
.toAmountAsRaw(fractionDigits: coin.decimals);
final locale = ref.watch(
localeServiceChangeNotifierProvider
.select((value) => value.locale),
);
final amount =
transactionInfo["recipientAmt"] as Amount;
return Text(
"${(amount + fee).localizedStringAsFixed(
locale: locale,
)} ${ref.watch(
managerProvider.select((value) => value.coin),
).ticker}",
style: isDesktop
? STextStyles.desktopTextExtraExtraSmall(context)
.copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textConfirmTotalAmount,
)
: STextStyles.itemSubtitle12(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textConfirmTotalAmount,
),
textAlign: TextAlign.right,
);
}),
],
),
),
),
),
SizedBox(
height: isDesktop ? 28 : 16,
),

View file

@ -923,7 +923,7 @@ class EthereumWallet extends CoinServiceAPI with WalletCache, WalletDB {
// 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,

View file

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