Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

namespace: Identifier updates #565

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions pallets/namespace/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ pub mod pallet {

Self::update_activity(
&namespace_id,
IdentifierTypeOf::Auth,
IdentifierTypeOf::NameSpaceAuthorization,
CallTypeOf::Deauthorization,
)?;

Expand Down Expand Up @@ -573,7 +573,7 @@ pub mod pallet {
},
);

Self::update_activity(&identifier, IdentifierTypeOf::ChainSpace, CallTypeOf::Genesis)
Self::update_activity(&identifier, IdentifierTypeOf::NameSpace, CallTypeOf::Genesis)
.map_err(Error::<T>::from)?;

Self::deposit_event(Event::Create {
Expand Down Expand Up @@ -638,7 +638,7 @@ pub mod pallet {
NameSpaceDetailsOf::<T> { archive: true, ..namespace_details },
);

Self::update_activity(&namespace_id, IdentifierTypeOf::ChainSpace, CallTypeOf::Archive)
Self::update_activity(&namespace_id, IdentifierTypeOf::NameSpace, CallTypeOf::Archive)
.map_err(Error::<T>::from)?;

Self::deposit_event(Event::Archive { namespace: namespace_id, authority: creator });
Expand Down Expand Up @@ -698,7 +698,7 @@ pub mod pallet {
NameSpaceDetailsOf::<T> { archive: false, ..namespace_details },
);

Self::update_activity(&namespace_id, IdentifierTypeOf::ChainSpace, CallTypeOf::Restore)
Self::update_activity(&namespace_id, IdentifierTypeOf::NameSpace, CallTypeOf::Restore)
.map_err(Error::<T>::from)?;

Self::deposit_event(Event::Restore { namespace: namespace_id, authority: creator });
Expand Down Expand Up @@ -753,8 +753,12 @@ impl<T: Config> Pallet<T> {
},
);

Self::update_activity(&namespace_id, IdentifierTypeOf::Auth, CallTypeOf::Authorization)
.map_err(Error::<T>::from)?;
Self::update_activity(
&namespace_id,
IdentifierTypeOf::NameSpaceAuthorization,
CallTypeOf::Authorization,
)
.map_err(Error::<T>::from)?;

Self::deposit_event(Event::Authorization {
namespace: namespace_id,
Expand Down
8 changes: 8 additions & 0 deletions primitives/identifier/src/curi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ pub enum IdentifierType {
Entries,
RegistryAuthorization,
SchemaAccounts,
NameSpace,
NameSpaceAuthorization,
}

impl IdentifierType {
Expand All @@ -63,6 +65,8 @@ impl IdentifierType {
const IDENT_ENTRIES: u16 = 9944;
const IDENT_REGISTRYAUTH: u16 = 10001;
const IDENT_SCHEMA_ACCOUNTS: u16 = 10501;
const IDENT_NAMESPACE: u16 = 12501;
const IDENT_NAMESPACE_AUTH: u16 = 13101;

fn ident_value(&self) -> u16 {
match self {
Expand All @@ -79,6 +83,8 @@ impl IdentifierType {
IdentifierType::Entries => Self::IDENT_ENTRIES,
IdentifierType::RegistryAuthorization => Self::IDENT_REGISTRYAUTH,
IdentifierType::SchemaAccounts => Self::IDENT_SCHEMA_ACCOUNTS,
IdentifierType::NameSpace => Self::IDENT_NAMESPACE,
IdentifierType::NameSpaceAuthorization => Self::IDENT_NAMESPACE_AUTH,
}
}
fn from_u16(value: u16) -> Option<Self> {
Expand All @@ -96,6 +102,8 @@ impl IdentifierType {
9944 => Some(IdentifierType::Entries),
10001 => Some(IdentifierType::RegistryAuthorization),
10501 => Some(IdentifierType::SchemaAccounts),
12501 => Some(IdentifierType::NameSpace),
13101 => Some(IdentifierType::NameSpaceAuthorization),
_ => None,
}
}
Expand Down
2 changes: 2 additions & 0 deletions primitives/identifier/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,6 @@ pub enum IdentifierTypeOf {
Entries,
RegistryAuthorization,
SchemaAccounts,
NameSpace,
NameSpaceAuthorization,
}
Loading