Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

Commit c94bbef

Browse files
committed
feat: Added max fee to bottom sheets
1 parent 1f1abca commit c94bbef

File tree

7 files changed

+65
-36
lines changed

7 files changed

+65
-36
lines changed

lib/features/dapps/subfeatures/open_dapp/open_dapp_presenter.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@ class OpenDAppPresenter extends CompletePresenter<OpenDAppState> {
205205
}
206206

207207
String finalFee = estimatedGasFee.gasFee.toString();
208+
final maxFeeDouble = estimatedGasFee.gasFee * Config.priority;
209+
final maxFeeString = maxFeeDouble.toString();
210+
final maxFee =
211+
Validation.isExpoNumber(maxFeeString) ? '0.000' : maxFeeString;
208212

209213
if (Validation.isExpoNumber(finalFee)) {
210214
finalFee = '0.000';
@@ -219,6 +223,7 @@ class OpenDAppPresenter extends CompletePresenter<OpenDAppState> {
219223
from: bridge.from!,
220224
to: bridge.to!,
221225
estimatedFee: finalFee,
226+
maxFee: maxFee,
222227
symbol: symbol);
223228

224229
if (result != null && result) {

lib/features/dapps/subfeatures/open_dapp/widgets/transaction_dialog.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ Future<bool?> showTransactionDialog(BuildContext context,
88
required String amount,
99
required String from,
1010
required String to,
11-
String? estimatedFee,
11+
required String estimatedFee,
12+
required String maxFee,
1213
VoidCallback? onTap,
1314
required String symbol}) {
1415
return showModalBottomSheet<bool>(
@@ -45,6 +46,7 @@ Future<bool?> showTransactionDialog(BuildContext context,
4546
from: from,
4647
to: to,
4748
estimatedFee: estimatedFee,
49+
maxFee: maxFee,
4850
onTap: onTap,
4951
symbol: symbol,
5052
),

lib/features/dapps/subfeatures/open_dapp/widgets/transaction_info.dart

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@ class TransactionInfo extends ConsumerWidget {
1515
required this.amount,
1616
required this.from,
1717
required this.to,
18-
this.estimatedFee,
18+
required this.estimatedFee,
19+
required this.maxFee,
1920
this.onTap,
2021
required this.symbol})
2122
: super(key: key);
2223

2324
final String amount;
2425
final String from;
2526
final String to;
26-
final String? estimatedFee;
27+
final String estimatedFee;
28+
final String maxFee;
2729
final VoidCallback? onTap;
2830
final String symbol;
2931

@@ -44,16 +46,20 @@ class TransactionInfo extends ConsumerWidget {
4446
title: 'to',
4547
value: to,
4648
),
47-
if (estimatedFee != null)
48-
SingleLineInfoItem(
49-
title: 'estimated_fee',
50-
value: estimatedFee != null
51-
? Formatter.formatNumberForUI(
52-
estimatedFee!,
53-
)
54-
: '--',
55-
hint: symbol,
49+
SingleLineInfoItem(
50+
title: 'estimated_fee',
51+
value: Formatter.formatNumberForUI(
52+
estimatedFee,
5653
),
54+
hint: symbol,
55+
),
56+
SingleLineInfoItem(
57+
title: 'max_fee',
58+
value: Formatter.formatNumberForUI(
59+
maxFee,
60+
),
61+
hint: symbol,
62+
),
5763
],
5864
),
5965
),

lib/features/portfolio/subfeatures/token/send_token/send_crypto/send_crypto_presenter.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,17 +146,20 @@ class SendCryptoPresenter extends CompletePresenter<SendCryptoState> {
146146
return;
147147
}
148148

149-
EstimatedGasFee? estimatedGasFee;
150-
151149
double sumBalance = token.balance! - double.parse(amount);
152-
estimatedGasFee = await _estimatedFee(recipientAddress);
150+
EstimatedGasFee? estimatedGasFee = await _estimatedFee(recipientAddress);
153151
if (estimatedGasFee != null) {
154152
sumBalance -= estimatedGasFee.gasFee;
155153
final estimatedFee =
156154
Validation.isExpoNumber(estimatedGasFee.gasFee.toString())
157155
? '0.000'
158156
: estimatedGasFee.gasFee.toString();
159157

158+
final maxFeeDouble = estimatedGasFee.gasFee * Config.priority;
159+
final maxFeeString = maxFeeDouble.toString();
160+
final maxFee =
161+
Validation.isExpoNumber(maxFeeString) ? '0.000' : maxFeeString;
162+
160163
final result = await showTransactionDialog(context!,
161164
amount: amount,
162165
balance: sumBalance.toString(),
@@ -165,8 +168,9 @@ class SendCryptoPresenter extends CompletePresenter<SendCryptoState> {
165168
from: state.account!.address,
166169
to: recipient,
167170
estimatedFee: estimatedFee,
171+
maxFee: maxFee,
168172
onTap: (transactionType) =>
169-
_nextTransactionStep(transactionType, estimatedGasFee!),
173+
_nextTransactionStep(transactionType, estimatedGasFee),
170174
networkSymbol: state.network?.symbol ?? '--');
171175
}
172176
}

lib/features/portfolio/subfeatures/token/send_token/send_crypto/widgets/transaction_dialog.dart

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,20 @@ import 'transaction_info.dart';
66

77
enum TransactionProcessType { confirm, send, sending, done }
88

9-
Future<bool?> showTransactionDialog(BuildContext context,
10-
{required String amount,
11-
required String balance,
12-
required Token token,
13-
required String network,
14-
required String networkSymbol,
15-
required String from,
16-
required String to,
17-
String? estimatedFee,
18-
TransactionProcessType? processType,
19-
required Function(TransactionProcessType) onTap,}) {
9+
Future<bool?> showTransactionDialog(
10+
BuildContext context, {
11+
required String amount,
12+
required String balance,
13+
required Token token,
14+
required String network,
15+
required String networkSymbol,
16+
required String from,
17+
required String to,
18+
required String estimatedFee,
19+
required String maxFee,
20+
TransactionProcessType? processType,
21+
required Function(TransactionProcessType) onTap,
22+
}) {
2023
return showModalBottomSheet<bool>(
2124
context: context,
2225
useRootNavigator: true,
@@ -41,6 +44,7 @@ Future<bool?> showTransactionDialog(BuildContext context,
4144
from: from,
4245
to: to,
4346
estimatedFee: estimatedFee,
47+
maxFee: maxFee,
4448
processType: processType,
4549
onTap: onTap,
4650
),

lib/features/portfolio/subfeatures/token/send_token/send_crypto/widgets/transaction_info.dart

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ class TransactionInfo extends StatefulWidget {
1616
required this.networkSymbol,
1717
required this.from,
1818
required this.to,
19-
this.estimatedFee,
19+
required this.estimatedFee,
20+
required this.maxFee,
2021
this.processType = TransactionProcessType.confirm,
2122
required this.onTap,
2223
}) : super(key: key);
@@ -28,7 +29,8 @@ class TransactionInfo extends StatefulWidget {
2829
final String networkSymbol;
2930
final String from;
3031
final String to;
31-
final String? estimatedFee;
32+
final String estimatedFee;
33+
final String maxFee;
3234
final TransactionProcessType? processType;
3335
final Function(TransactionProcessType) onTap;
3436

@@ -77,16 +79,22 @@ class _TransactionInfoState extends State<TransactionInfo> {
7779
title: 'to',
7880
value: widget.to,
7981
),
80-
if (TransactionProcessType.confirm != processType)
82+
if (TransactionProcessType.confirm != processType) ...[
8183
SingleLineInfoItem(
8284
title: 'estimated_fee',
83-
value: widget.estimatedFee != null
84-
? Formatter.formatNumberForUI(
85-
widget.estimatedFee!,
86-
)
87-
: '--',
85+
value: Formatter.formatNumberForUI(
86+
widget.estimatedFee,
87+
),
8888
hint: widget.networkSymbol,
8989
),
90+
SingleLineInfoItem(
91+
title: 'max_fee',
92+
value: Formatter.formatNumberForUI(
93+
widget.maxFee,
94+
),
95+
hint: widget.networkSymbol,
96+
),
97+
]
9098
],
9199
),
92100
),

0 commit comments

Comments
 (0)