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
3ec18ba0
Commit
3ec18ba0
authored
1 year ago
by
poka
Browse files
Options
Downloads
Patches
Plain Diff
refacto: TransactionStatus enum and status is nullable
parent
bde2b0cb
No related branches found
No related tags found
No related merge requests found
Pipeline
#34529
waiting for manual action
Stage: format
Stage: build_and_test
Stage: package
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/providers/substrate_sdk.dart
+5
-4
5 additions, 4 deletions
lib/providers/substrate_sdk.dart
lib/screens/transaction_in_progress.dart
+32
-17
32 additions, 17 deletions
lib/screens/transaction_in_progress.dart
with
37 additions
and
21 deletions
lib/providers/substrate_sdk.dart
+
5
−
4
View file @
3ec18ba0
...
...
@@ -37,7 +37,7 @@ class SubstrateSdk with ChangeNotifier {
bool
importIsLoading
=
false
;
int
blocNumber
=
0
;
bool
isLoadingEndpoint
=
false
;
String
transactionStatus
=
''
;
String
?
transactionStatus
;
final
int
initSs58
=
42
;
Map
<
String
,
int
>
currencyParameters
=
{};
TextEditingController
csSalt
=
TextEditingController
();
...
...
@@ -908,7 +908,7 @@ class SubstrateSdk with ChangeNotifier {
required
String
destAddress
,
required
double
amount
,
required
String
password
})
async
{
transactionStatus
=
''
;
transactionStatus
=
'
sending
'
;
final
sender
=
await
_setSender
(
fromAddress
);
...
...
@@ -960,7 +960,7 @@ class SubstrateSdk with ChangeNotifier {
Future
<
String
>
certify
(
String
fromAddress
,
String
destAddress
,
String
password
)
async
{
transactionStatus
=
''
;
transactionStatus
=
'
sending
'
;
final
statusList
=
await
idtyStatus
([
fromAddress
,
destAddress
]);
final
myIdtyStatus
=
statusList
[
0
];
...
...
@@ -1028,6 +1028,7 @@ class SubstrateSdk with ChangeNotifier {
Future
<
String
>
confirmIdentity
(
String
fromAddress
,
String
name
,
String
password
)
async
{
transactionStatus
=
'sending'
;
final
sender
=
await
_setSender
(
fromAddress
);
final
txInfo
=
TxInfoData
(
...
...
@@ -1047,7 +1048,7 @@ class SubstrateSdk with ChangeNotifier {
required
String
destPassword
,
required
Map
fromBalance
,
bool
withBalance
=
false
})
async
{
transactionStatus
=
''
;
transactionStatus
=
'
sending
'
;
final
sender
=
await
_setSender
(
fromAddress
);
TxInfoData
txInfo
;
...
...
This diff is collapsed.
Click to expand it.
lib/screens/transaction_in_progress.dart
+
32
−
17
View file @
3ec18ba0
...
...
@@ -27,8 +27,7 @@ class TransactionInProgress extends StatelessWidget {
Provider
.
of
<
WalletsProfilesProvider
>(
context
,
listen:
false
);
final
myWalletProvider
=
Provider
.
of
<
MyWalletsProvider
>(
context
,
listen:
false
);
bool
isValid
=
false
;
bool
isLoading
=
false
;
var
txStatus
=
TransactionStatus
.
nothing
;
final
result
=
sub
.
transactionStatus
;
final
from
=
fromAddress
??
...
...
@@ -54,7 +53,7 @@ class TransactionInProgress extends StatelessWidget {
String
resultText
=
''
;
final
Map
<
String
,
String
>
resultMap
=
{
''
:
'sending'
.
tr
(),
'
sending
'
:
'sending'
.
tr
(),
'Ready'
:
'propagating'
.
tr
(),
'Broadcast'
:
'validating'
.
tr
(),
'cert.NotRespectCertPeriod'
:
'24hbetweenCerts'
.
tr
(),
...
...
@@ -68,18 +67,21 @@ class TransactionInProgress extends StatelessWidget {
'Exception: timeout'
:
'execTimeoutOver'
.
tr
(),
};
if
(
result
.
contains
(
'blockHash: '
))
{
isValid
=
true
;
if
(
result
==
null
)
{
txStatus
=
TransactionStatus
.
nothing
;
}
else
if
(
result
.
contains
(
'blockHash: '
))
{
txStatus
=
TransactionStatus
.
success
;
resultText
=
'extrinsicValidated'
.
tr
(
args:
[
actionMap
[
transType
]
??
'strangeTransaction'
.
tr
()]);
log
.
i
(
'Bloc of last transaction:
${sub.blocNumber}
---
$result
'
);
}
else
if
(
result
.
contains
(
'Exception: '
))
{
txStatus
=
TransactionStatus
.
failed
;
resultText
=
"
${"anErrorOccurred".tr()}
:
\n
"
;
final
String
exception
=
result
.
split
(
'Exception: '
)[
1
];
resultText
=
resultMap
[
exception
]
??
"
$resultText
\n
$exception
"
;
log
.
d
(
'Error:
$exception
'
);
}
else
{
isLoading
=
true
;
txStatus
=
TransactionStatus
.
loading
;
resultText
=
resultMap
[
result
]
??
'unknown status...'
;
}
...
...
@@ -87,7 +89,7 @@ class TransactionInProgress extends StatelessWidget {
return
PopScope
(
onPopInvoked:
(
_
)
{
sub
.
transactionStatus
=
''
;
sub
.
transactionStatus
=
null
;
},
child:
Scaffold
(
backgroundColor:
backgroundColor
,
...
...
@@ -162,7 +164,7 @@ class TransactionInProgress extends StatelessWidget {
const
Spacer
(),
Column
(
children:
[
Visibility
(
visible:
isL
oading
,
visible:
txStatus
==
TransactionStatus
.
l
oading
,
child:
const
SizedBox
(
height:
18
,
width:
18
,
...
...
@@ -173,18 +175,29 @@ class TransactionInProgress extends StatelessWidget {
),
),
Visibility
(
visible:
!
isLoading
,
child:
Icon
(
isValid
?
Icons
.
done_all
:
Icons
.
close
,
visible:
txStatus
==
TransactionStatus
.
success
,
child:
const
Icon
(
Icons
.
done_all
,
size:
35
,
color:
isValid
?
Colors
.
greenAccent
:
Colors
.
redAccent
,
color:
Colors
.
greenAccent
,
),
),
Visibility
(
visible:
txStatus
==
TransactionStatus
.
failed
,
child:
const
Icon
(
Icons
.
close
,
size:
35
,
color:
Colors
.
redAccent
,
),
),
const
SizedBox
(
height:
10
),
Text
(
resultText
,
textAlign:
TextAlign
.
center
,
style:
TextStyle
(
fontSize:
19
*
ratio
),
Visibility
(
visible:
txStatus
!=
TransactionStatus
.
nothing
,
child:
Text
(
resultText
,
textAlign:
TextAlign
.
center
,
style:
TextStyle
(
fontSize:
19
*
ratio
),
),
),
]),
const
Spacer
(),
...
...
@@ -201,7 +214,7 @@ class TransactionInProgress extends StatelessWidget {
backgroundColor:
orangeC
,
// foreground
),
onPressed:
()
{
sub
.
transactionStatus
=
''
;
sub
.
transactionStatus
=
null
;
Navigator
.
pop
(
context
);
},
child:
Text
(
...
...
@@ -221,3 +234,5 @@ class TransactionInProgress extends StatelessWidget {
);
}
}
enum
TransactionStatus
{
loading
,
failed
,
success
,
nothing
}
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