Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ginkgo
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
Fred
ginkgo
Commits
70fafdad
Commit
70fafdad
authored
2 years ago
by
vjrj
Browse files
Options
Downloads
Patches
Plain Diff
Added retry to gva.history
parent
988e958c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/data/models/transaction_cubit.dart
+1
-1
1 addition, 1 deletion
lib/data/models/transaction_cubit.dart
lib/g1/api.dart
+25
-35
25 additions, 35 deletions
lib/g1/api.dart
lib/ui/widgets/fourth_screen/transaction_page.dart
+99
-96
99 additions, 96 deletions
lib/ui/widgets/fourth_screen/transaction_page.dart
with
125 additions
and
132 deletions
lib/data/models/transaction_cubit.dart
+
1
−
1
View file @
70fafdad
...
@@ -31,7 +31,7 @@ class TransactionsCubit extends HydratedCubit<TransactionsAndBalanceState> {
...
@@ -31,7 +31,7 @@ class TransactionsCubit extends HydratedCubit<TransactionsAndBalanceState> {
Future
<
void
>
fetchTransactions
(
NodeListCubit
cubit
)
async
{
Future
<
void
>
fetchTransactions
(
NodeListCubit
cubit
)
async
{
logger
(
'Loading transactions'
);
logger
(
'Loading transactions'
);
final
Map
<
String
,
dynamic
>
?
txData
=
final
Map
<
String
,
dynamic
>
?
txData
=
await
gva
()
.
h
istory
(
SharedPreferencesHelper
()
.
getPubKey
());
await
gva
H
istory
AndBalance
(
SharedPreferencesHelper
()
.
getPubKey
());
if
(
txData
==
null
)
{
if
(
txData
==
null
)
{
logger
(
'Failed to get transactions'
);
logger
(
'Failed to get transactions'
);
return
;
return
;
...
...
This diff is collapsed.
Click to expand it.
lib/g1/api.dart
+
25
−
35
View file @
70fafdad
...
@@ -411,10 +411,7 @@ Future<String> pay(
...
@@ -411,10 +411,7 @@ Future<String> pay(
final
String
node
=
output
;
final
String
node
=
output
;
try
{
try
{
final
Gva
gva
=
Gva
(
node:
node
);
final
Gva
gva
=
Gva
(
node:
node
);
logger
(
'Trying
$node
to get balance'
);
final
CesiumWallet
wallet
=
await
SharedPreferencesHelper
()
.
getWallet
();
final
CesiumWallet
wallet
=
await
SharedPreferencesHelper
()
.
getWallet
();
logger
(
'Current balance
${await gva.balance(wallet.pubkey)}
'
);
// logger('Current balance ${await gva.balance(wallet.pubkey)}');
logger
(
logger
(
'Trying
$node
to send
$amount
to
$to
with comment
${comment ?? ''}
'
);
'Trying
$node
to send
$amount
to
$to
with comment
${comment ?? ''}
'
);
...
@@ -448,40 +445,33 @@ String getGvaNode() {
...
@@ -448,40 +445,33 @@ String getGvaNode() {
}
}
}
}
Future
<
double
>
gvaBalance
()
async
{
Future
<
Map
<
String
,
dynamic
>
?
>
gvaHistoryAndBalance
(
String
pubKey
)
async
{
final
String
output
=
getGvaNode
();
final
List
<
Node
>
nodes
=
NodeManager
()
.
nodeList
(
NodeType
.
gva
);
if
(
Uri
.
tryParse
(
output
)
!=
null
)
{
if
(
nodes
.
isEmpty
)
{
final
String
node
=
output
;
nodes
.
addAll
(
defaultGvaNodes
);
try
{
final
Gva
gva
=
Gva
(
node:
node
);
logger
(
'Trying
$node
to get balance'
);
final
String
pubKey
=
SharedPreferencesHelper
()
.
getPubKey
();
final
double
balance
=
await
gva
.
balance
(
pubKey
);
logger
(
'Current balance
$balance
'
);
return
balance
;
}
catch
(
e
,
stacktrace
)
{
// move logger outside main
logger
(
e
);
logger
(
stacktrace
);
throw
Exception
(
'Oops! failed to obtain balance'
);
}
}
}
throw
Exception
(
'Sorry: I cannot find a working node to get your balance'
);
for
(
int
i
=
0
;
i
<
nodes
.
length
;
i
++
)
{
}
final
Node
node
=
nodes
[
i
];
if
(
node
.
errors
>
=
NodeManager
.
maxNodeErrors
)
{
Gva
gva
()
{
logger
(
'Too much errors skip
${node.url}
'
);
final
String
output
=
getGvaNode
();
continue
;
if
(
Uri
.
tryParse
(
output
)
!=
null
)
{
}
final
String
node
=
output
;
try
{
try
{
final
Gva
gva
=
Gva
(
node:
node
);
final
String
output
=
getGvaNode
();
return
gva
;
if
(
Uri
.
tryParse
(
output
)
!=
null
)
{
}
catch
(
e
,
stacktrace
)
{
final
String
node
=
output
;
// move logger outside main
final
Gva
gva
=
Gva
(
node:
node
);
logger
(
e
);
final
Map
<
String
,
dynamic
>
?
result
=
await
gva
.
history
(
pubKey
);
logger
(
stacktrace
);
return
result
;
throw
Exception
(
'Oops! failed to obtain balance'
);
}
}
catch
(
e
)
{
logger
(
'Error trying
${node.url}
$e
'
);
logger
(
'Increasing node errors of
${node.url}
(
${node.errors}
)'
);
NodeManager
()
.
updateNode
(
NodeType
.
gva
,
node
.
copyWith
(
errors:
node
.
errors
+
1
));
continue
;
}
}
}
}
throw
Exception
(
'Sorry: I cannot find a working node to get your balance'
);
throw
Exception
(
'Sorry: I cannot find a working node to get your transactions'
);
}
}
This diff is collapsed.
Click to expand it.
lib/ui/widgets/fourth_screen/transaction_page.dart
+
99
−
96
View file @
70fafdad
...
@@ -11,7 +11,6 @@ import '../../../data/models/transaction.dart';
...
@@ -11,7 +11,6 @@ import '../../../data/models/transaction.dart';
import
'../../../data/models/transaction_cubit.dart'
;
import
'../../../data/models/transaction_cubit.dart'
;
import
'../../../shared_prefs.dart'
;
import
'../../../shared_prefs.dart'
;
import
'../../ui_helpers.dart'
;
import
'../../ui_helpers.dart'
;
import
'../loading_box.dart'
;
import
'transaction_chart.dart'
;
import
'transaction_chart.dart'
;
import
'transaction_item.dart'
;
import
'transaction_item.dart'
;
...
@@ -52,20 +51,18 @@ class _TransactionsAndBalanceWidgetState
...
@@ -52,20 +51,18 @@ class _TransactionsAndBalanceWidgetState
if
(
/* _transScrollController.position.pixels ==
if
(
/* _transScrollController.position.pixels ==
_transScrollController.position.maxScrollExtent || */
_transScrollController.position.maxScrollExtent || */
_transScrollController
.
offset
==
0
)
{
_transScrollController
.
offset
==
0
)
{
await
_refreshTransactions
();
// await _refreshTransactions();
_refreshIndicatorKey
.
currentState
?.
show
();
}
}
}
}
Future
<
void
>
_refreshTransactions
()
async
{
Future
<
void
>
_refreshTransactions
()
async
{
setState
(()
{
return
transCubit
.
fetchTransactions
(
nodeListCubit
);
isLoading
=
true
;
});
await
transCubit
.
fetchTransactions
(
nodeListCubit
);
setState
(()
{
isLoading
=
false
;
});
}
}
final
GlobalKey
<
RefreshIndicatorState
>
_refreshIndicatorKey
=
GlobalKey
<
RefreshIndicatorState
>();
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
final
String
myPubKey
=
SharedPreferencesHelper
()
.
getPubKey
();
final
String
myPubKey
=
SharedPreferencesHelper
()
.
getPubKey
();
...
@@ -76,67 +73,70 @@ class _TransactionsAndBalanceWidgetState
...
@@ -76,67 +73,70 @@ class _TransactionsAndBalanceWidgetState
final
ContactsCubit
contactsCubit
=
context
.
read
<
ContactsCubit
>();
final
ContactsCubit
contactsCubit
=
context
.
read
<
ContactsCubit
>();
final
List
<
Transaction
>
transactions
=
transBalanceState
.
transactions
;
final
List
<
Transaction
>
transactions
=
transBalanceState
.
transactions
;
final
double
balance
=
transBalanceState
.
balance
;
final
double
balance
=
transBalanceState
.
balance
;
if
(
!
isLoading
)
{
return
BackdropScaffold
(
return
Backdrop
Scaffold
(
appBar:
Backdrop
AppBar
(
appBar:
BackdropAppBar
(
backgroundColor:
Theme
.
of
(
context
)
.
colorScheme
.
inversePrimary
,
backgroundColor:
Theme
.
of
(
context
)
.
colorScheme
.
inversePrimary
,
title:
Text
(
tr
(
'balance'
))
,
title:
Text
(
tr
(
'balance'
)),
actions:
<
Widget
>[
actions:
<
Widget
>[
IconButton
(
I
con
Button
(
i
con
:
const
Icon
(
Icons
.
refresh
),
icon:
const
Icon
(
Icons
.
refresh
),
onPressed:
()
{
onPressed:
()
{
_refreshIndicatorKey
.
currentState
?.
show
();
_refreshTransactions
();
//
_refreshTransactions();
},
},
),
),
const
BackdropToggleButton
(
const
BackdropToggleButton
(
// The default
// The default
// icon: AnimatedIcons.close_menu,
// icon: AnimatedIcons.close_menu,
)
)
],
],
),
),
backLayer:
Center
(
backLayer:
Center
(
child:
Container
(
child:
Container
(
decoration:
BoxDecoration
(
decoration:
BoxDecoration
(
color:
Theme
.
of
(
context
)
.
colorScheme
.
inversePrimary
,
color:
Theme
.
of
(
context
)
.
colorScheme
.
inversePrimary
,
border:
Border
.
all
(
border:
Border
.
all
(
color:
Theme
.
of
(
context
)
.
colorScheme
.
inversePrimary
,
color:
Theme
.
of
(
context
)
.
colorScheme
.
inversePrimary
,
width:
3
),
width:
3
),
/* borderRadius: const BorderRadius.only(
/* borderRadius: const BorderRadius.only(
topLeft: Radius.circular(8),
topLeft: Radius.circular(8),
topRight: Radius.circular(8),
topRight: Radius.circular(8),
), */
), */
),
),
child:
Scrollbar
(
child:
Scrollbar
(
child:
ListView
(
child:
ListView
(
// controller: scrollController,
// controller: scrollController,
children:
<
Widget
>[
children:
<
Widget
>[
Padding
(
Padding
(
padding:
const
EdgeInsets
.
symmetric
(
vertical:
10.0
),
padding:
const
EdgeInsets
.
symmetric
(
vertical:
10.0
),
child:
Center
(
child:
Center
(
child:
Text
(
child:
Text
(
formatKAmount
(
context
,
balance
),
formatKAmount
(
context
,
balance
),
style:
TextStyle
(
style:
TextStyle
(
fontSize:
36.0
,
fontSize:
36.0
,
color:
balance
==
0
color:
?
Colors
.
lightBlue
balance
==
0
?
Colors
.
lightBlue
:
Colors
.
lightBlue
,
:
Colors
.
lightBlue
,
fontWeight:
FontWeight
.
bold
),
fontWeight:
FontWeight
.
bold
),
)),
)),
),
),
if
(
!
kReleaseMode
)
TransactionChart
()
if
(
!
kReleaseMode
)
TransactionChart
()
/*BalanceChart(
/*BalanceChart(
transactions: .transactions),*/
transactions: .transactions),*/
],
],
)),
)),
)),
subHeader:
BackdropSubHeader
(
)),
title:
Text
(
tr
(
'transactions'
)),
subHeader:
BackdropSubHeader
(
title:
Text
(
tr
(
'transactions'
)),
divider:
Divider
(
color:
Theme
.
of
(
context
)
.
colorScheme
.
surfaceVariant
,
height:
0
,
),
),
frontLayer:
Center
(
),
child:
Column
(
frontLayer:
Center
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
child:
Column
(
children:
<
Widget
>[
crossAxisAlignment:
CrossAxisAlignment
.
start
,
/* Container(
children:
<
Widget
>[
/* Container(
/* color: Theme
/* color: Theme
.of(context)
.of(context)
.colorScheme
.colorScheme
...
@@ -146,31 +146,37 @@ class _TransactionsAndBalanceWidgetState
...
@@ -146,31 +146,37 @@ class _TransactionsAndBalanceWidgetState
child:
const
Padding
(
child:
const
Padding
(
padding:
EdgeInsets
.
symmetric
(
horizontal:
16
),
padding:
EdgeInsets
.
symmetric
(
horizontal:
16
),
child:
Header
(
text:
'transactions'
))),
*/
child:
Header
(
text:
'transactions'
))),
*/
Expanded
(
Expanded
(
child:
Padding
(
child:
Padding
(
padding:
const
EdgeInsets
.
fromLTRB
(
0
,
0
,
0
,
50
),
padding:
const
EdgeInsets
.
fromLTRB
(
0
,
0
,
0
,
50
),
child:
transactions
.
isEmpty
child:
transactions
.
isEmpty
?
Padding
(
?
Padding
(
padding:
const
EdgeInsets
.
symmetric
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
20
),
horizontal:
20
),
child:
Center
(
child:
Text
(
tr
(
'no_transactions'
))))
child:
Center
(
:
RefreshIndicator
(
child:
Text
(
tr
(
'no_transactions'
))))
key:
_refreshIndicatorKey
,
:
ListView
.
builder
(
color:
Colors
.
white
,
physics:
backgroundColor:
const
AlwaysScrollableScrollPhysics
(),
Theme
.
of
(
context
)
.
colorScheme
.
primary
,
shrinkWrap:
true
,
strokeWidth:
4.0
,
controller:
_transScrollController
,
onRefresh:
()
async
{
itemCount:
transactions
.
length
,
return
_refreshTransactions
();
// Size of elements
},
// itemExtent: 100,
// Pull from top to show refresh indicator.
itemBuilder:
child:
ListView
.
builder
(
(
BuildContext
context
,
int
index
)
{
physics:
const
AlwaysScrollableScrollPhysics
(),
return
TransactionListItem
(
shrinkWrap:
true
,
index:
index
,
controller:
_transScrollController
,
transaction:
transactions
[
index
],
itemCount:
transactions
.
length
,
avatar:
avatar
(
null
),
// Size of elements
);
// itemExtent: 100,
/*
itemBuilder:
(
BuildContext
context
,
int
index
)
{
return
TransactionListItem
(
index:
index
,
transaction:
transactions
[
index
],
avatar:
avatar
(
null
),
);
/*
Slidable(
Slidable(
// Specify a key if the Slidable is dismissible.
// Specify a key if the Slidable is dismissible.
...
@@ -238,14 +244,11 @@ class _TransactionsAndBalanceWidgetState
...
@@ -238,14 +244,11 @@ class _TransactionsAndBalanceWidgetState
: Colors.blue)),
: Colors.blue)),
));
));
*/
*/
},
},
)),
)),
)
))
]),
]),
));
));
}
else
{
return
const
LoadingScreen
();
}
});
});
}
}
...
...
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