Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Ğecko
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
Ğecko
Commits
a0b04238
Commit
a0b04238
authored
2 years ago
by
poka
Browse files
Options
Downloads
Patches
Plain Diff
estimate fees are ok and diplayed to user
parent
6443e041
No related branches found
No related tags found
1 merge request
!32
Calcul tx fees
Pipeline
#17210
waiting for manual action
Stage: format
Stage: build_and_test
Stage: package
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/providers/substrate_sdk.dart
+14
-1
14 additions, 1 deletion
lib/providers/substrate_sdk.dart
lib/screens/wallet_view.dart
+33
-7
33 additions, 7 deletions
lib/screens/wallet_view.dart
pubspec.yaml
+1
-1
1 addition, 1 deletion
pubspec.yaml
with
48 additions
and
9 deletions
lib/providers/substrate_sdk.dart
+
14
−
1
View file @
a0b04238
...
...
@@ -367,6 +367,19 @@ class SubstrateSdk with ChangeNotifier {
notifyListeners
();
}
Future
<
double
>
txFees
(
String
fromAddress
,
String
destAddress
,
double
amount
)
async
{
if
(
amount
==
0
)
return
0
;
final
sender
=
await
_setSender
(
fromAddress
);
final
txInfo
=
TxInfoData
(
'balances'
,
'transferKeepAlive'
,
sender
);
final
amountUnit
=
(
amount
*
100
)
.
toInt
();
final
estimateFees
=
await
sdk
.
api
.
tx
.
estimateFees
(
txInfo
,
[
destAddress
,
amountUnit
]);
return
estimateFees
.
partialFee
/
100
;
}
/////////////////////////////////////
////// 3: SUBSTRATE CONNECTION //////
/////////////////////////////////////
...
...
@@ -714,7 +727,7 @@ class SubstrateSdk with ChangeNotifier {
txOptions
=
[
destAddress
,
false
];
tx2
=
'api.tx.balances.transferAll("
$destAddress
", false)'
;
}
else
{
int
amountUnit
;
late
int
amountUnit
;
if
(
isUdUnit
)
{
palette
=
'universalDividend'
;
call
=
'transferUd'
;
...
...
This diff is collapsed.
Click to expand it.
lib/screens/wallet_view.dart
+
33
−
7
View file @
a0b04238
...
...
@@ -452,6 +452,8 @@ void paymentPopup(BuildContext context, String toAddress) {
isScrollControlled:
true
,
context:
context
,
builder:
(
BuildContext
context
)
{
final
sub
=
Provider
.
of
<
SubstrateSdk
>(
homeContext
,
listen:
false
);
double
fees
=
0
;
return
StatefulBuilder
(
builder:
(
BuildContext
context
,
StateSetter
setState
)
{
if
(
walletViewProvider
.
payAmount
.
text
!=
''
&&
...
...
@@ -588,12 +590,26 @@ void paymentPopup(BuildContext context, String toAddress) {
],
),
const
SizedBox
(
height:
12
),
Text
(
'amount'
.
tr
(),
style:
TextStyle
(
fontSize:
19
,
fontWeight:
FontWeight
.
w500
,
color:
Colors
.
grey
[
600
]),
Row
(
children:
[
Text
(
'amount'
.
tr
(),
style:
TextStyle
(
fontSize:
19
,
fontWeight:
FontWeight
.
w500
,
color:
Colors
.
grey
[
600
]),
),
const
Spacer
(),
Text
(
'frais:
$fees
$currencyName
'
,
style:
const
TextStyle
(
color:
orangeC
,
fontSize:
17
,
fontWeight:
FontWeight
.
w500
,
),
),
const
SizedBox
(
width:
10
),
],
),
const
SizedBox
(
height:
10
),
TextField
(
...
...
@@ -606,7 +622,17 @@ void paymentPopup(BuildContext context, String toAddress) {
maxLines:
1
,
textAlign:
TextAlign
.
center
,
keyboardType:
TextInputType
.
number
,
onChanged:
(
_
)
=
>
setState
(()
{}),
onChanged:
(
_
)
async
{
fees
=
await
sub
.
txFees
(
defaultWallet
.
address
!
,
toAddress
,
double
.
parse
(
walletViewProvider
.
payAmount
.
text
==
''
?
'0'
:
walletViewProvider
.
payAmount
.
text
));
log
.
d
(
fees
);
setState
(()
{});
},
inputFormatters:
<
TextInputFormatter
>[
FilteringTextInputFormatter
.
deny
(
','
,
replacementString:
'.'
),
...
...
This diff is collapsed.
Click to expand it.
pubspec.yaml
+
1
−
1
View file @
a0b04238
...
...
@@ -5,7 +5,7 @@ description: Pay with G1.
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to
:
'
none'
# Remove this line if you wish to publish to pub.dev
version
:
0.0.11+3
1
version
:
0.0.11+3
2
environment
:
sdk
:
'
>=2.12.0
<3.0.0'
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment