Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Ğ
Ğcli-v2s
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
Rust
Ğcli-v2s
Commits
d8ba05d3
Verified
Commit
d8ba05d3
authored
1 year ago
by
Pascal Engélibert
Browse files
Options
Downloads
Patches
Plain Diff
feat: create-identity, confirm-identity
parent
264e9b72
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/commands/expire.rs
+5
-2
5 additions, 2 deletions
src/commands/expire.rs
src/commands/identity.rs
+28
-1
28 additions, 1 deletion
src/commands/identity.rs
src/main.rs
+42
-0
42 additions, 0 deletions
src/main.rs
with
75 additions
and
3 deletions
src/commands/expire.rs
+
5
−
2
View file @
d8ba05d3
...
@@ -29,8 +29,8 @@ pub async fn monitor_expirations(
...
@@ -29,8 +29,8 @@ pub async fn monitor_expirations(
.storage
()
.storage
()
.fetch
(
&
addr_current_session
,
Some
(
parent_hash
),)
.fetch
(
&
addr_current_session
,
Some
(
parent_hash
),)
);
);
let
current_block
=
current_block
?
.unwrap
();
let
current_block
=
current_block
?
.unwrap
_or_default
();
let
current_session
=
current_session
?
.unwrap
();
let
current_session
=
current_session
?
.unwrap
_or_default
();
let
end_block
=
current_block
+
blocks
;
let
end_block
=
current_block
+
blocks
;
let
end_session
=
current_session
+
sessions
;
let
end_session
=
current_session
+
sessions
;
...
@@ -152,6 +152,9 @@ pub async fn monitor_expirations(
...
@@ -152,6 +152,9 @@ pub async fn monitor_expirations(
while
let
Some
((
k
,
v
))
=
basic_membership_iter
.next
()
.await
?
{
while
let
Some
((
k
,
v
))
=
basic_membership_iter
.next
()
.await
?
{
let
block_number
=
u32
::
from_le_bytes
(
k
.as_ref
()[
40
..
44
]
.try_into
()
.unwrap
());
let
block_number
=
u32
::
from_le_bytes
(
k
.as_ref
()[
40
..
44
]
.try_into
()
.unwrap
());
if
block_number
<
end_block
{
if
block_number
<
end_block
{
if
block_number
<
current_block
{
dbg!
((
block_number
,
current_block
));
}
basic_memberships
.insert
(
block_number
-
current_block
,
v
);
basic_memberships
.insert
(
block_number
-
current_block
,
v
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/commands/identity.rs
+
28
−
1
View file @
d8ba05d3
use
crate
::{
gdev
,
indexer
::
*
,
Args
,
Client
};
use
crate
::{
gdev
,
indexer
::
*
,
Args
,
Client
};
use
anyhow
::{
anyhow
,
Result
};
use
anyhow
::{
anyhow
,
Result
};
use
sp_core
::
crypto
::
AccountId32
;
use
sp_core
::
{
crypto
::
AccountId32
,
sr25519
::
Pair
}
;
use
std
::
str
::
FromStr
;
use
std
::
str
::
FromStr
;
use
subxt
::
tx
::{
BaseExtrinsicParamsBuilder
,
PairSigner
};
pub
async
fn
get_identity
(
pub
async
fn
get_identity
(
client
:
Client
,
client
:
Client
,
...
@@ -87,3 +88,29 @@ pub async fn get_identity(
...
@@ -87,3 +88,29 @@ pub async fn get_identity(
Ok
(())
Ok
(())
}
}
pub
async
fn
create_identity
(
pair
:
Pair
,
client
:
Client
,
target
:
AccountId32
)
->
Result
<
()
>
{
client
.tx
()
.sign_and_submit_then_watch
(
&
gdev
::
tx
()
.identity
()
.create_identity
(
target
),
&
PairSigner
::
new
(
pair
),
BaseExtrinsicParamsBuilder
::
new
(),
)
.await
?
;
Ok
(())
}
pub
async
fn
confirm_identity
(
pair
:
Pair
,
client
:
Client
,
name
:
String
)
->
Result
<
()
>
{
client
.tx
()
.sign_and_submit_then_watch
(
&
gdev
::
tx
()
.identity
()
.confirm_identity
(
name
),
&
PairSigner
::
new
(
pair
),
BaseExtrinsicParamsBuilder
::
new
(),
)
.await
?
;
Ok
(())
}
This diff is collapsed.
Click to expand it.
src/main.rs
+
42
−
0
View file @
d8ba05d3
...
@@ -82,6 +82,18 @@ pub struct Args {
...
@@ -82,6 +82,18 @@ pub struct Args {
#[derive(Debug,
clap::Subcommand)]
#[derive(Debug,
clap::Subcommand)]
pub
enum
Subcommand
{
pub
enum
Subcommand
{
/// Confirm an identity
///
/// To be called by the certified not-yet-member account, to become member.
ConfirmIdentity
{
name
:
String
,
},
/// Create and certify an identity
///
/// Caller must be member, and the target account must exist.
CreateIdentity
{
target
:
sp_core
::
crypto
::
AccountId32
,
},
CreateOneshot
{
CreateOneshot
{
balance
:
u64
,
balance
:
u64
,
dest
:
sp_core
::
crypto
::
AccountId32
,
dest
:
sp_core
::
crypto
::
AccountId32
,
...
@@ -196,6 +208,36 @@ async fn main() -> Result<()> {
...
@@ -196,6 +208,36 @@ async fn main() -> Result<()> {
}*/
}*/
match
args
.subcommand
{
match
args
.subcommand
{
Subcommand
::
ConfirmIdentity
{
name
}
=>
{
commands
::
identity
::
confirm_identity
(
get_keys
(
args
.secret_format
,
&
args
.address
,
&
args
.secret
,
NeededKeys
::
Secret
,
)
?
.1
.unwrap
(),
Client
::
from_url
(
&
args
.url
)
.await
.unwrap
(),
name
,
)
.await
?
}
Subcommand
::
CreateIdentity
{
target
}
=>
{
commands
::
identity
::
create_identity
(
get_keys
(
args
.secret_format
,
&
args
.address
,
&
args
.secret
,
NeededKeys
::
Secret
,
)
?
.1
.unwrap
(),
Client
::
from_url
(
&
args
.url
)
.await
.unwrap
(),
target
,
)
.await
?
}
Subcommand
::
CreateOneshot
{
balance
,
dest
}
=>
{
Subcommand
::
CreateOneshot
{
balance
,
dest
}
=>
{
commands
::
oneshot
::
create_oneshot_account
(
commands
::
oneshot
::
create_oneshot_account
(
get_keys
(
get_keys
(
...
...
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