Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Duniter v2S
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
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
nodes
rust
Duniter v2S
Commits
ab05fe8b
Commit
ab05fe8b
authored
3 years ago
by
Éloïs
Browse files
Options
Downloads
Patches
Plain Diff
feat(idty): merge call validate_identity*
parent
72162377
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pallets/identity/src/lib.rs
+12
-37
12 additions, 37 deletions
pallets/identity/src/lib.rs
runtime/common/src/handlers.rs
+1
-1
1 addition, 1 deletion
runtime/common/src/handlers.rs
with
13 additions
and
38 deletions
pallets/identity/src/lib.rs
+
12
−
37
View file @
ab05fe8b
...
...
@@ -405,6 +405,7 @@ pub mod pallet {
pub
fn
validate_identity
(
origin
:
OriginFor
<
T
>
,
idty_index
:
T
::
IdtyIndex
,
idty_rights
:
Vec
<
T
::
IdtyRight
>
,
)
->
DispatchResultWithPostInfo
{
T
::
IdtyValidationOrigin
::
ensure_origin
(
origin
.clone
())
?
;
...
...
@@ -414,51 +415,25 @@ pub mod pallet {
IdtyStatus
::
ConfirmedByOwner
=>
{
let
_post_info
=
T
::
Membership
::
claim_membership_
(
origin
,
idty_index
)
?
;
let
block_number
=
frame_system
::
pallet
::
Pallet
::
<
T
>
::
block_number
();
let
removable_on
=
block_number
+
T
::
MaxNoRightPeriod
::
get
();
idty_value
.removable_on
=
removable_on
;
idty_value
.status
=
IdtyStatus
::
Validated
;
let
name
=
idty_value
.name
.clone
();
<
Identities
<
T
>>
::
insert
(
idty_index
,
idty_value
);
<
IdentitiesRemovableOn
<
T
>>
::
append
(
removable_on
,
(
idty_index
,
IdtyStatus
::
Validated
),
);
Self
::
deposit_event
(
Event
::
IdtyValidated
(
name
));
T
::
OnIdtyChange
::
on_idty_change
(
idty_index
,
IdtyEvent
::
Validated
);
Ok
(()
.into
())
}
IdtyStatus
::
Validated
|
IdtyStatus
::
Expired
=>
{
Err
(
Error
::
<
T
>
::
IdtyAlreadyValidated
.into
())
}
}
}
else
{
Err
(
Error
::
<
T
>
::
IdtyNotFound
.into
())
}
}
#[pallet::weight(
0
)]
pub
fn
validate_identity_and_add_rights
(
origin
:
OriginFor
<
T
>
,
idty_index
:
T
::
IdtyIndex
,
rights
:
Vec
<
T
::
IdtyRight
>
,
)
->
DispatchResultWithPostInfo
{
T
::
IdtyValidationOrigin
::
ensure_origin
(
origin
)
?
;
if
let
Ok
(
mut
idty_value
)
=
<
Identities
<
T
>>
::
try_get
(
idty_index
)
{
match
idty_value
.status
{
IdtyStatus
::
Created
=>
Err
(
Error
::
<
T
>
::
IdtyNotConfirmedByOwner
.into
()),
IdtyStatus
::
ConfirmedByOwner
=>
{
idty_value
.removable_on
=
T
::
BlockNumber
::
zero
();
idty_value
.rights
=
rights
.iter
()
.map
(|
right
|
(
*
right
,
None
))
.collect
();
idty_value
.rights
=
idty_rights
.iter
()
.map
(|
right
|
(
*
right
,
None
))
.collect
();
idty_value
.status
=
IdtyStatus
::
Validated
;
let
name
=
idty_value
.name
.clone
();
let
owner_key
=
idty_value
.owner_key
.clone
();
<
Identities
<
T
>>
::
insert
(
idty_index
,
idty_value
);
if
idty_rights
.is_empty
()
{
let
block_number
=
frame_system
::
pallet
::
Pallet
::
<
T
>
::
block_number
();
let
removable_on
=
block_number
+
T
::
MaxNoRightPeriod
::
get
();
<
IdentitiesRemovableOn
<
T
>>
::
append
(
removable_on
,
(
idty_index
,
IdtyStatus
::
Validated
),
);
}
Self
::
deposit_event
(
Event
::
IdtyValidated
(
name
.clone
()));
T
::
OnIdtyChange
::
on_idty_change
(
idty_index
,
IdtyEvent
::
Validated
);
for
right
in
rights
{
for
right
in
idty_
rights
{
Self
::
deposit_event
(
Event
::
IdtyAcquireRight
(
name
.clone
(),
right
));
if
right
.allow_owner_key
()
{
T
::
OnRightKeyChange
::
on_right_key_change
(
...
...
This diff is collapsed.
Click to expand it.
runtime/common/src/handlers.rs
+
1
−
1
View file @
ab05fe8b
...
...
@@ -106,7 +106,7 @@ impl<
let
total_weight
=
0
;
if
receiver_received_count
==
MIN_STRONG_CERT_FOR_UD
{
// total_weight += Identity::WeightInfo::add_right();
let
_
=
<
pallet_identity
::
Pallet
<
Runtime
>>
::
validate_identity
_and_add_rights
(
let
_
=
<
pallet_identity
::
Pallet
<
Runtime
>>
::
validate_identity
(
frame_system
::
Origin
::
<
Runtime
>
::
Root
.into
(),
receiver
,
sp_std
::
vec!
[
IdtyRight
::
Ud
],
...
...
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