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
380f085c
Commit
380f085c
authored
1 year ago
by
Cédric Moreau
Browse files
Options
Downloads
Patches
Plain Diff
refac(smith-members): remove IsSubWoT
parent
d811c71b
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
pallets/duniter-wot/src/lib.rs
+24
-35
24 additions, 35 deletions
pallets/duniter-wot/src/lib.rs
pallets/duniter-wot/src/mock.rs
+0
-1
0 additions, 1 deletion
pallets/duniter-wot/src/mock.rs
runtime/common/src/pallets_config.rs
+0
-1
0 additions, 1 deletion
runtime/common/src/pallets_config.rs
with
24 additions
and
37 deletions
pallets/duniter-wot/src/lib.rs
+
24
−
35
View file @
380f085c
...
...
@@ -66,8 +66,6 @@ pub mod pallet {
#[pallet::constant]
type
FirstIssuableOn
:
Get
<
Self
::
BlockNumber
>
;
#[pallet::constant]
type
IsSubWot
:
Get
<
bool
>
;
#[pallet::constant]
type
MinCertForMembership
:
Get
<
u32
>
;
#[pallet::constant]
type
MinCertForCreateIdtyRight
:
Get
<
u32
>
;
...
...
@@ -132,30 +130,25 @@ where
{
// identity creation checks
fn
check_create_identity
(
creator
:
IdtyIndex
)
->
Result
<
(),
DispatchError
>
{
// main WoT constraints
if
!
T
::
IsSubWot
::
get
()
{
let
cert_meta
=
pallet_certification
::
Pallet
::
<
T
,
I
>
::
idty_cert_meta
(
creator
);
// perform all checks
// 1. check that identity has the right to create an identity
// identity can be member with 5 certifications and still not reach identity creation threshold which could be higher (6, 7...)
ensure!
(
cert_meta
.received_count
>=
T
::
MinCertForCreateIdtyRight
::
get
(),
Error
::
<
T
,
I
>
::
NotEnoughReceivedCertsToCreateIdty
);
// 2. check that issuer can emit one more certification
// (this is only a partial check)
ensure!
(
cert_meta
.issued_count
<
T
::
MaxByIssuer
::
get
(),
Error
::
<
T
,
I
>
::
MaxEmittedCertsReached
);
// 3. check that issuer respects certification creation period
ensure!
(
cert_meta
.next_issuable_on
<=
frame_system
::
pallet
::
Pallet
::
<
T
>
::
block_number
(),
Error
::
<
T
,
I
>
::
IdtyCreationPeriodNotRespected
);
}
// TODO (#136) make these trait implementation work on instances rather than static to avoid checking IsSubWot
// smith subwot can never prevent from creating identity
let
cert_meta
=
pallet_certification
::
Pallet
::
<
T
,
I
>
::
idty_cert_meta
(
creator
);
// perform all checks
// 1. check that identity has the right to create an identity
// identity can be member with 5 certifications and still not reach identity creation threshold which could be higher (6, 7...)
ensure!
(
cert_meta
.received_count
>=
T
::
MinCertForCreateIdtyRight
::
get
(),
Error
::
<
T
,
I
>
::
NotEnoughReceivedCertsToCreateIdty
);
// 2. check that issuer can emit one more certification
// (this is only a partial check)
ensure!
(
cert_meta
.issued_count
<
T
::
MaxByIssuer
::
get
(),
Error
::
<
T
,
I
>
::
MaxEmittedCertsReached
);
// 3. check that issuer respects certification creation period
ensure!
(
cert_meta
.next_issuable_on
<=
frame_system
::
pallet
::
Pallet
::
<
T
>
::
block_number
(),
Error
::
<
T
,
I
>
::
IdtyCreationPeriodNotRespected
);
Ok
(())
}
}
...
...
@@ -238,17 +231,13 @@ where
fn
on_event
(
membership_event
:
&
sp_membership
::
Event
<
IdtyIndex
>
)
{
match
membership_event
{
sp_membership
::
Event
::
<
IdtyIndex
>
::
MembershipAdded
(
idty_index
)
=>
{
if
!
T
::
IsSubWot
::
get
()
{
// when main membership is acquired, tell identity
// (only used on first membership acquiry)
pallet_identity
::
Pallet
::
<
T
>
::
membership_added
(
*
idty_index
);
}
// when main membership is acquired, tell identity
// (only used on first membership acquiry)
pallet_identity
::
Pallet
::
<
T
>
::
membership_added
(
*
idty_index
);
}
sp_membership
::
Event
::
<
IdtyIndex
>
::
MembershipRemoved
(
idty_index
)
=>
{
if
!
T
::
IsSubWot
::
get
()
{
// when main membership is lost, tell identity
pallet_identity
::
Pallet
::
<
T
>
::
membership_removed
(
*
idty_index
);
}
// when main membership is lost, tell identity
pallet_identity
::
Pallet
::
<
T
>
::
membership_removed
(
*
idty_index
);
}
sp_membership
::
Event
::
<
IdtyIndex
>
::
MembershipRenewed
(
_
)
=>
{}
}
...
...
This diff is collapsed.
Click to expand it.
pallets/duniter-wot/src/mock.rs
+
0
−
1
View file @
380f085c
...
...
@@ -94,7 +94,6 @@ parameter_types! {
}
impl
pallet_duniter_wot
::
Config
<
Instance1
>
for
Test
{
type
IsSubWot
=
frame_support
::
traits
::
ConstBool
<
false
>
;
type
MinCertForMembership
=
MinCertForMembership
;
type
MinCertForCreateIdtyRight
=
MinCertForCreateIdtyRight
;
type
FirstIssuableOn
=
FirstIssuableOn
;
...
...
This diff is collapsed.
Click to expand it.
runtime/common/src/pallets_config.rs
+
0
−
1
View file @
380f085c
...
...
@@ -458,7 +458,6 @@ macro_rules! pallets_config {
impl
pallet_duniter_wot
::
Config
<
Instance1
>
for
Runtime
{
type
FirstIssuableOn
=
WotFirstCertIssuableOn
;
type
IsDistanceOk
=
common_runtime
::
providers
::
MainWotIsDistanceOk
<
Runtime
>
;
type
IsSubWot
=
frame_support
::
traits
::
ConstBool
<
false
>
;
type
MinCertForMembership
=
WotMinCertForMembership
;
type
MinCertForCreateIdtyRight
=
WotMinCertForCreateIdtyRight
;
}
...
...
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