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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
rust
Duniter v2S
Commits
8b2548ac
Commit
8b2548ac
authored
2 years ago
by
Hugo Trentesaux
Browse files
Options
Downloads
Patches
Plain Diff
wip replace cert allowed check
parent
08beaa33
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
pallets/certification/src/lib.rs
+1
-6
1 addition, 6 deletions
pallets/certification/src/lib.rs
pallets/certification/src/traits.rs
+5
-3
5 additions, 3 deletions
pallets/certification/src/traits.rs
pallets/duniter-wot/src/lib.rs
+11
-12
11 additions, 12 deletions
pallets/duniter-wot/src/lib.rs
with
17 additions
and
21 deletions
pallets/certification/src/lib.rs
+
1
−
6
View file @
8b2548ac
...
...
@@ -242,8 +242,6 @@ pub mod pallet {
pub
enum
Error
<
T
,
I
=
()
>
{
/// An identity cannot certify itself
CannotCertifySelf
,
/// Certification non autorisée
CertNotAllowed
,
/// This identity has already issued the maximum number of certifications
IssuedTooManyCert
,
/// Issuer not found
...
...
@@ -325,10 +323,7 @@ pub mod pallet {
ensure!
(
issuer_owner_key
==
who
,
DispatchError
::
BadOrigin
);
// Verify compatibility with other pallets state
ensure!
(
T
::
IsCertAllowed
::
is_cert_allowed
(
issuer
,
receiver
),
Error
::
<
T
,
I
>
::
CertNotAllowed
);
T
::
IsCertAllowed
::
check_cert_allowed
(
issuer
,
receiver
)
?
;
// Verify rule MinReceivedCertToBeAbleToIssueCert
let
issuer_idty_cert_meta
=
<
StorageIdtyCertMeta
<
T
,
I
>>
::
get
(
issuer
);
...
...
This diff is collapsed.
Click to expand it.
pallets/certification/src/traits.rs
+
5
−
3
View file @
8b2548ac
...
...
@@ -14,13 +14,15 @@
// You should have received a copy of the GNU Affero General Public License
// along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>.
use
frame_support
::
pallet_prelude
::
*
;
pub
trait
IsCertAllowed
<
IdtyIndex
>
{
fn
is
_cert_allowed
(
issuer
:
IdtyIndex
,
receiver
:
IdtyIndex
)
->
bool
;
fn
check
_cert_allowed
(
issuer
:
IdtyIndex
,
receiver
:
IdtyIndex
)
->
Result
<
(),
DispatchError
>
;
}
impl
<
IdtyIndex
>
IsCertAllowed
<
IdtyIndex
>
for
()
{
fn
is
_cert_allowed
(
_issuer
:
IdtyIndex
,
_receiver
:
IdtyIndex
)
->
bool
{
true
fn
check
_cert_allowed
(
_issuer
:
IdtyIndex
,
_receiver
:
IdtyIndex
)
->
Result
<
(),
DispatchError
>
{
Ok
(())
}
}
...
...
This diff is collapsed.
Click to expand it.
pallets/duniter-wot/src/lib.rs
+
11
−
12
View file @
8b2548ac
...
...
@@ -107,6 +107,10 @@ pub mod pallet {
NotAllowedToChangeIdtyAddress
,
/// Not allowed to remove identity
NotAllowedToRemoveIdty
,
/// Issuer can not emit cert because it is not validated
IssuerCanNotEmitCert
,
/// Can not issue cert to unconfirmed identity
CertToUnconfirmedIdty
,
}
}
...
...
@@ -195,24 +199,19 @@ where
impl
<
T
:
Config
<
I
>
,
I
:
'static
>
pallet_certification
::
traits
::
IsCertAllowed
<
IdtyIndex
>
for
Pallet
<
T
,
I
>
{
fn
is
_cert_allowed
(
issuer
:
IdtyIndex
,
receiver
:
IdtyIndex
)
->
bool
{
fn
check
_cert_allowed
(
issuer
:
IdtyIndex
,
receiver
:
IdtyIndex
)
->
Result
<
(),
DispatchError
>
{
if
let
Some
(
issuer_data
)
=
pallet_identity
::
Pallet
::
<
T
>
::
identity
(
issuer
)
{
if
issuer_data
.status
!=
IdtyStatus
::
Validated
{
return
false
;
return
Err
(
Error
::
<
T
,
I
>
::
IssuerCanNotEmitCert
.into
())
;
}
if
let
Some
(
receiver_data
)
=
pallet_identity
::
Pallet
::
<
T
>
::
identity
(
receiver
)
{
match
receiver_data
.status
{
IdtyStatus
::
ConfirmedByOwner
|
IdtyStatus
::
Validated
=>
true
,
IdtyStatus
::
Created
=>
false
,
}
}
else
{
// Receiver not found
false
}
}
else
{
// Issuer not found
false
IdtyStatus
::
ConfirmedByOwner
|
IdtyStatus
::
Validated
=>
(),
IdtyStatus
::
Created
=>
return
Err
(
Error
::
<
T
,
I
>
::
CertToUnconfirmedIdty
.into
()),
}
};
};
Ok
(())
}
}
...
...
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