Skip to content

Commit a50e5bc

Browse files
committed
fix: use locale-aware parsing in send view fee selection sheets
1 parent fe03d5b commit a50e5bc

3 files changed

Lines changed: 43 additions & 23 deletions

File tree

lib/pages/send_view/send_view.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,10 +1235,11 @@ class _SendViewState extends ConsumerState<SendView> {
12351235
builder: (_) => TransactionFeeSelectionSheet(
12361236
walletId: walletId,
12371237
amount:
1238-
(Decimal.tryParse(cryptoAmountController.text) ??
1239-
ref.watch(pSendAmount)?.decimal ??
1240-
Decimal.zero)
1241-
.toAmount(fractionDigits: coin.fractionDigits),
1238+
ref
1239+
.read(pAmountFormatter(coin))
1240+
.tryParse(cryptoAmountController.text) ??
1241+
ref.watch(pSendAmount) ??
1242+
Amount.zeroWith(fractionDigits: coin.fractionDigits),
12421243
updateChosen: (String fee) {
12431244
if (fee == "custom") {
12441245
if (!isCustomFee.value) {

lib/pages/send_view/sol_token_send_view.dart

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,11 @@ class _SolTokenSendViewState extends ConsumerState<SolTokenSendView> {
267267
final tokenWallet = ref.read(pCurrentSolanaTokenWallet);
268268
if (tokenWallet == null) return;
269269

270-
final cryptoAmount = Decimal.tryParse(
271-
cryptoAmountController.text,
272-
)?.toAmount(fractionDigits: tokenWallet.tokenDecimals);
270+
final cryptoAmount = ref
271+
.read(pAmountFormatter(Solana(CryptoCurrencyNetwork.main)))
272+
.tryParse(cryptoAmountController.text)
273+
?.decimal
274+
.toAmount(fractionDigits: tokenWallet.tokenDecimals);
273275
if (cryptoAmount != null) {
274276
_amountToSend = cryptoAmount;
275277
if (_cachedAmountToSend != null &&
@@ -1258,16 +1260,29 @@ class _SolTokenSendViewState extends ConsumerState<SolTokenSendView> {
12581260
walletId: walletId,
12591261
isToken: true,
12601262
amount:
1261-
(Decimal.tryParse(
1262-
cryptoAmountController
1263-
.text,
1264-
) ??
1265-
Decimal.zero)
1263+
ref
1264+
.read(
1265+
pAmountFormatter(
1266+
Solana(
1267+
CryptoCurrencyNetwork
1268+
.main,
1269+
),
1270+
),
1271+
)
1272+
.tryParse(
1273+
cryptoAmountController
1274+
.text,
1275+
)
1276+
?.decimal
12661277
.toAmount(
12671278
fractionDigits:
12681279
tokenWallet
12691280
.tokenDecimals,
1270-
),
1281+
) ??
1282+
Amount.zeroWith(
1283+
fractionDigits: tokenWallet
1284+
.tokenDecimals,
1285+
),
12711286
updateChosen: (String fee) {
12721287
setState(() {
12731288
_calculateFeesFuture = Future(

lib/pages/send_view/token_send_view.dart

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,16 +1200,20 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
12001200
walletId: walletId,
12011201
isToken: true,
12021202
amount:
1203-
(Decimal.tryParse(
1204-
cryptoAmountController
1205-
.text,
1206-
) ??
1207-
Decimal.zero)
1208-
.toAmount(
1209-
fractionDigits:
1210-
tokenContract
1211-
.decimals,
1212-
),
1203+
ref
1204+
.read(
1205+
pAmountFormatter(coin),
1206+
)
1207+
.tryParse(
1208+
cryptoAmountController
1209+
.text,
1210+
tokenContract:
1211+
tokenContract,
1212+
) ??
1213+
Amount.zeroWith(
1214+
fractionDigits:
1215+
tokenContract.decimals,
1216+
),
12131217
updateChosen: (String fee) {
12141218
if (fee == "custom") {
12151219
if (!isCustomFee.value) {

0 commit comments

Comments
 (0)