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
6b5bcadd
Commit
6b5bcadd
authored
1 year ago
by
poka
Browse files
Options
Downloads
Patches
Plain Diff
fix: implement async transaction status check in initState
parent
5bc26150
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#35513
waiting for manual action
Stage: format
Stage: build_and_test
Stage: package
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/screens/transaction_in_progress.dart
+25
-8
25 additions, 8 deletions
lib/screens/transaction_in_progress.dart
with
25 additions
and
8 deletions
lib/screens/transaction_in_progress.dart
+
25
−
8
View file @
6b5bcadd
...
...
@@ -6,6 +6,7 @@ import 'package:gecko/models/widgets_keys.dart';
import
'package:gecko/providers/my_wallets.dart'
;
import
'package:gecko/providers/substrate_sdk.dart'
;
import
'package:gecko/providers/wallets_profiles.dart'
;
import
'package:gecko/widgets/commons/loading.dart'
;
import
'package:gecko/widgets/transaction_status.dart'
;
import
'package:gecko/widgets/transaction_status_icon.dart'
;
import
'package:provider/provider.dart'
;
...
...
@@ -36,7 +37,7 @@ class _TransactionInProgressState extends State<TransactionInProgress> {
late
String
toUsernameFormat
;
late
String
amount
;
late
bool
isUdUnit
;
late
TransactionContent
txContent
;
TransactionContent
?
txContent
;
@override
void
initState
()
{
...
...
@@ -59,33 +60,49 @@ class _TransactionInProgressState extends State<TransactionInProgress> {
amount
=
walletProfiles
.
payAmount
.
text
;
isUdUnit
=
configBox
.
get
(
'isUdUnit'
)
??
false
;
waitForTransactionStatus
();
super
.
initState
();
}
void
waitForTransactionStatus
()
async
{
final
sub
=
Provider
.
of
<
SubstrateSdk
>(
context
,
listen:
false
);
while
(
!
sub
.
transactionStatus
.
containsKey
(
widget
.
transactionId
))
{
await
Future
.
delayed
(
const
Duration
(
seconds:
2
));
}
setState
(()
{
txContent
=
sub
.
transactionStatus
[
widget
.
transactionId
]
!
;
});
}
@override
Widget
build
(
BuildContext
context
)
{
final
sub
=
Provider
.
of
<
SubstrateSdk
>(
context
,
listen:
true
);
if
(
txContent
==
null
)
{
return
const
Center
(
child:
Loading
());
}
if
(
sub
.
transactionStatus
.
containsKey
(
widget
.
transactionId
))
{
txContent
=
sub
.
transactionStatus
[
widget
.
transactionId
]
!
;
}
if
(
txContent
.
status
==
TransactionStatus
.
success
)
{
if
(
txContent
!
.
status
==
TransactionStatus
.
success
)
{
resultText
=
'extrinsicValidated'
.
tr
(
args:
[
actionMap
[
widget
.
transType
]
??
'strangeTransaction'
.
tr
()]);
}
else
if
(
txContent
.
status
==
TransactionStatus
.
failed
)
{
resultText
=
errorTransactionMap
[
txContent
.
error
]
??
txContent
.
error
!
;
}
else
if
(
txContent
!
.
status
==
TransactionStatus
.
failed
)
{
resultText
=
errorTransactionMap
[
txContent
!
.
error
]
??
txContent
!
.
error
!
;
}
else
{
resultText
=
statusStatusMap
[
txContent
.
status
]
??
'Unknown status:
${txContent.status}
'
;
resultText
=
statusStatusMap
[
txContent
!
.
status
]
??
'Unknown status:
${txContent
!
.status}
'
;
}
Widget
buildTransactionStatus
()
{
return
Column
(
children:
[
TransactionStatusIcon
(
txContent
.
status
),
TransactionStatusIcon
(
txContent
!
.
status
),
ScaledSizedBox
(
height:
7
),
if
(
txContent
.
status
!=
TransactionStatus
.
none
)
if
(
txContent
!
.
status
!=
TransactionStatus
.
none
)
Text
(
resultText
,
textAlign:
TextAlign
.
center
,
...
...
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