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
02b59e39
Commit
02b59e39
authored
1 year ago
by
poka
Browse files
Options
Downloads
Patches
Plain Diff
feat: add query to store transactions comments to datapod
parent
5950088b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#35279
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/models/queries_datapod.dart
+11
-2
11 additions, 2 deletions
lib/models/queries_datapod.dart
lib/providers/v2s_datapod.dart
+42
-42
42 additions, 42 deletions
lib/providers/v2s_datapod.dart
with
53 additions
and
44 deletions
lib/models/queries_datapod.dart
+
11
−
2
View file @
02b59e39
const
String
updateProfileQ
=
r''
'
mutation (
$address
: String!,
$hash
: String!,
$signature
: String!,
$title
: String,
$description
: String,
$avatar
: String,
$geoloc
: GeolocInput,
$city
: String,
$socials
: [SocialInput!]) {
updateProfile(address:
$address
, hash:
$hash
, signature:
$signature
, title:
$title
, description:
$description
, avatarBase64:
$avatar
, geoloc:
$geoloc
, city:
$city
, socials:
$socials
) {
mutation (
$address
: String!,
$hash
: String!,
$signature
: String!,
$title
: String,
$description
: String,
$avatar
Base64
: String,
$geoloc
: GeolocInput,
$city
: String,
$socials
: [SocialInput!]) {
updateProfile(address:
$address
, hash:
$hash
, signature:
$signature
, title:
$title
, description:
$description
, avatarBase64:
$avatar
Base64
, geoloc:
$geoloc
, city:
$city
, socials:
$socials
) {
message
success
}
...
...
@@ -25,6 +25,15 @@ mutation ($addressOld: String!, $addressNew: String!, $hash: String!, $signature
}
'''
;
const
String
addTransactionCommentQ
=
r''
'
mutation (
$id
: String!,
$address
: String!,
$hash
: String!,
$signature
: String!,
$comment
: String!) {
addTransaction(id:
$id
, address:
$address
, hash:
$hash
, signature:
$signature
, comment:
$comment
) {
message
success
}
}
'''
;
const
String
getAvatarQ
=
r''
'
query (
$address
: String!) {
profiles_by_pk(address:
$address
) {
...
...
This diff is collapsed.
Click to expand it.
lib/providers/v2s_datapod.dart
+
42
−
42
View file @
02b59e39
...
...
@@ -13,6 +13,20 @@ import 'package:uuid/uuid.dart';
class
V2sDatapodProvider
with
ChangeNotifier
{
late
GraphQLClient
datapodClient
;
Future
<
Map
<
String
,
dynamic
>>
_setSignedVariables
(
String
address
,
Map
<
String
,
dynamic
>
messageToSign
)
async
{
final
sub
=
Provider
.
of
<
SubstrateSdk
>(
homeContext
,
listen:
false
);
final
hashDocBytes
=
utf8
.
encode
(
jsonEncode
(
messageToSign
));
final
hashDoc
=
sha256
.
convert
(
hashDocBytes
)
.
toString
()
.
toUpperCase
();
final
signature
=
await
sub
.
signDatapod
(
hashDoc
,
address
);
return
<
String
,
dynamic
>{
..
.
messageToSign
,
'hash'
:
hashDoc
,
'signature'
:
signature
};
}
Future
<
QueryResult
>
_execQuery
(
String
query
,
Map
<
String
,
dynamic
>
variables
)
async
{
final
QueryOptions
options
=
...
...
@@ -29,9 +43,7 @@ class V2sDatapodProvider with ChangeNotifier {
String
?
city
,
List
<
Map
<
String
,
String
>>
?
socials
,
Map
<
String
,
double
>
?
geoloc
})
async
{
final
sub
=
Provider
.
of
<
SubstrateSdk
>(
homeContext
,
listen:
false
);
final
messageToSign
=
jsonEncode
({
final
messageToSign
=
{
'address'
:
address
,
'description'
:
description
,
'avatarBase64'
:
avatar
,
...
...
@@ -39,22 +51,9 @@ class V2sDatapodProvider with ChangeNotifier {
'title'
:
title
,
'city'
:
city
,
'socials'
:
socials
});
final
hashDocBytes
=
utf8
.
encode
(
messageToSign
);
final
hashDoc
=
sha256
.
convert
(
hashDocBytes
)
.
toString
()
.
toUpperCase
();
final
signature
=
await
sub
.
signDatapod
(
hashDoc
,
address
);
final
variables
=
<
String
,
dynamic
>{
'address'
:
address
,
'hash'
:
hashDoc
,
'signature'
:
signature
,
'title'
:
title
,
'description'
:
description
,
'avatar'
:
avatar
,
'city'
:
city
,
'socials'
:
socials
,
'geoloc'
:
geoloc
,
};
final
variables
=
await
_setSignedVariables
(
address
,
messageToSign
);
final
result
=
await
_execQuery
(
updateProfileQ
,
variables
);
if
(
result
.
hasException
)
{
log
.
e
(
result
.
exception
.
toString
());
...
...
@@ -65,18 +64,9 @@ class V2sDatapodProvider with ChangeNotifier {
}
Future
<
bool
>
deleteProfile
({
required
String
address
})
async
{
final
sub
=
Provider
.
of
<
SubstrateSdk
>(
homeContext
,
listen:
false
);
final
messageToSign
=
{
'address'
:
address
};
final
variables
=
await
_setSignedVariables
(
address
,
messageToSign
);
final
messageToSign
=
jsonEncode
({
'address'
:
address
});
final
hashDocBytes
=
utf8
.
encode
(
messageToSign
);
final
hashDoc
=
sha256
.
convert
(
hashDocBytes
)
.
toString
()
.
toUpperCase
();
final
signature
=
await
sub
.
signDatapod
(
hashDoc
,
address
);
final
variables
=
<
String
,
dynamic
>{
'address'
:
address
,
'hash'
:
hashDoc
,
'signature'
:
signature
};
final
result
=
await
_execQuery
(
deleteProfileQ
,
variables
);
if
(
result
.
hasException
)
{
log
.
e
(
result
.
exception
.
toString
());
...
...
@@ -88,20 +78,9 @@ class V2sDatapodProvider with ChangeNotifier {
Future
<
bool
>
migrateProfile
(
{
required
String
addressOld
,
required
String
addressNew
})
async
{
final
sub
=
Provider
.
of
<
SubstrateSdk
>(
homeContext
,
listen:
false
);
final
messageToSign
=
jsonEncode
({
'addressOld'
:
addressOld
,
'addressNew'
:
addressNew
});
final
hashDocBytes
=
utf8
.
encode
(
messageToSign
);
final
hashDoc
=
sha256
.
convert
(
hashDocBytes
)
.
toString
()
.
toUpperCase
();
final
signature
=
await
sub
.
signDatapod
(
hashDoc
,
addressOld
);
final
messageToSign
=
{
'addressOld'
:
addressOld
,
'addressNew'
:
addressNew
};
final
variables
=
await
_setSignedVariables
(
addressOld
,
messageToSign
);
final
variables
=
<
String
,
dynamic
>{
'addressOld'
:
addressOld
,
'addressNew'
:
addressNew
,
'hash'
:
hashDoc
,
'signature'
:
signature
};
final
result
=
await
_execQuery
(
migrateProfileQ
,
variables
);
if
(
result
.
hasException
)
{
log
.
e
(
result
.
exception
.
toString
());
...
...
@@ -111,6 +90,27 @@ class V2sDatapodProvider with ChangeNotifier {
return
true
;
}
Future
<
bool
>
addTransactionComment
({
required
String
id
,
required
String
issuer
,
required
String
comment
,
})
async
{
final
messageToSign
=
{
'id'
:
id
,
'address'
:
issuer
,
'comment'
:
comment
,
};
final
variables
=
await
_setSignedVariables
(
issuer
,
messageToSign
);
final
result
=
await
_execQuery
(
addTransactionCommentQ
,
variables
);
if
(
result
.
hasException
)
{
log
.
e
(
result
.
exception
.
toString
());
return
false
;
}
log
.
d
(
result
.
data
!
[
'addTransaction'
][
'message'
]);
return
true
;
}
Future
<
bool
>
setAvatar
(
String
address
,
String
avatarPath
)
async
{
final
avatarBytes
=
await
File
(
avatarPath
)
.
readAsBytes
();
final
avatarString
=
base64Encode
(
avatarBytes
);
...
...
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