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
c34a45ed
Commit
c34a45ed
authored
1 year ago
by
vjrj
Browse files
Options
Downloads
Patches
Plain Diff
Use ContactsCache in transaction parser
parent
8676d6fe
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/g1/transaction_parser.dart
+14
-5
14 additions, 5 deletions
lib/g1/transaction_parser.dart
with
14 additions
and
5 deletions
lib/g1/transaction_parser.dart
+
14
−
5
View file @
c34a45ed
...
@@ -4,6 +4,7 @@ import '../data/models/contact.dart';
...
@@ -4,6 +4,7 @@ import '../data/models/contact.dart';
import
'../data/models/transaction.dart'
;
import
'../data/models/transaction.dart'
;
import
'../data/models/transaction_state.dart'
;
import
'../data/models/transaction_state.dart'
;
import
'../data/models/transaction_type.dart'
;
import
'../data/models/transaction_type.dart'
;
import
'../ui/contacts_cache.dart'
;
import
'g1_helper.dart'
;
import
'g1_helper.dart'
;
final
RegExp
exp
=
RegExp
(
r'\((.*?)\)'
);
final
RegExp
exp
=
RegExp
(
r'\((.*?)\)'
);
...
@@ -42,8 +43,8 @@ Future<TransactionState> transactionParser(
...
@@ -42,8 +43,8 @@ Future<TransactionState> transactionParser(
logger('Timestamp: $timestamp');
logger('Timestamp: $timestamp');
logger('Fecha: $txDate');
logger('Fecha: $txDate');
} */
} */
final
Contact
fromC
=
Contact
(
pubKey:
address2
!
);
final
Contact
fromC
=
get
Contact
Cache
(
pubKey:
address2
!
);
final
Contact
toC
=
Contact
(
pubKey:
address1
!
);
final
Contact
toC
=
get
Contact
Cache
(
pubKey:
address1
!
);
tx
.
insert
(
tx
.
insert
(
0
,
0
,
...
@@ -62,6 +63,14 @@ Future<TransactionState> transactionParser(
...
@@ -62,6 +63,14 @@ Future<TransactionState> transactionParser(
lastChecked:
DateTime
.
now
());
lastChecked:
DateTime
.
now
());
}
}
Contact
getContactCache
({
required
String
pubKey
})
{
final
Contact
contact
=
ContactsCache
()
.
getCachedContact
(
pubKey
,
false
,
true
)
??
Contact
(
pubKey:
pubKey
);
assert
(
contact
.
hasAvatar
==
false
);
return
contact
;
}
Future
<
TransactionState
>
transactionsGvaParser
(
Map
<
String
,
dynamic
>
txData
,
Future
<
TransactionState
>
transactionsGvaParser
(
Map
<
String
,
dynamic
>
txData
,
TransactionState
state
,
String
myPubKeyRaw
)
async
{
TransactionState
state
,
String
myPubKeyRaw
)
async
{
final
String
myPubKey
=
extractPublicKey
(
myPubKeyRaw
);
final
String
myPubKey
=
extractPublicKey
(
myPubKeyRaw
);
...
@@ -91,7 +100,7 @@ Future<TransactionState> transactionsGvaParser(Map<String, dynamic> txData,
...
@@ -91,7 +100,7 @@ Future<TransactionState> transactionsGvaParser(Map<String, dynamic> txData,
final
Transaction
tx
=
final
Transaction
tx
=
await
_transactionGvaParser
(
edgeRaw
as
Map
<
String
,
dynamic
>,
myPubKey
);
await
_transactionGvaParser
(
edgeRaw
as
Map
<
String
,
dynamic
>,
myPubKey
);
if
(
tx
.
from
.
pubKey
==
myPubKey
&&
if
(
tx
.
from
.
pubKey
==
myPubKey
&&
tx
.
to
.
pubKey
==
myPubKey
&&
tx
.
recipients
[
0
]
.
pubKey
==
myPubKey
&&
tx
.
recipients
.
length
==
1
)
{
tx
.
recipients
.
length
==
1
)
{
// This is a return cash back to me
// This is a return cash back to me
continue
;
continue
;
...
@@ -148,7 +157,7 @@ Future<Transaction> _txGvaParse(
...
@@ -148,7 +157,7 @@ Future<Transaction> _txGvaParse(
// Extract the recipient from each output
// Extract the recipient from each output
final
String
outputS
=
output
as
String
;
final
String
outputS
=
output
as
String
;
final
String
?
recipient
=
exp
.
firstMatch
(
outputS
)
!.
group
(
1
);
final
String
?
recipient
=
exp
.
firstMatch
(
outputS
)
!.
group
(
1
);
final
Contact
recipientContact
=
Contact
(
pubKey:
recipient
!
);
final
Contact
recipientContact
=
get
Contact
Cache
(
pubKey:
recipient
!
);
recipients
.
add
(
recipientContact
);
recipients
.
add
(
recipientContact
);
final
double
outputAmount
=
double
.
parse
(
outputS
.
split
(
':'
)[
0
]);
final
double
outputAmount
=
double
.
parse
(
outputS
.
split
(
':'
)[
0
]);
...
@@ -182,7 +191,7 @@ Future<Transaction> _txGvaParse(
...
@@ -182,7 +191,7 @@ Future<Transaction> _txGvaParse(
}
}
// Comment
// Comment
final
String
comment
=
tx
[
'comment'
]
as
String
;
final
String
comment
=
tx
[
'comment'
]
as
String
;
final
Contact
fromC
=
Contact
(
pubKey:
from
);
final
Contact
fromC
=
get
Contact
Cache
(
pubKey:
from
);
return
Transaction
(
return
Transaction
(
type:
type
,
type:
type
,
...
...
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