changed 2 years ago
Linked with GitHub

Version-Controlled Documents Pallet

pallet_version_controlled_documents

Context And Problem Statement

(See parent doc)

Description

Principally, the pallet focuses around storing "Documents" - data that groups an author, a hash representing the content, and a version number.

API

pub fn create( origin: OriginFor<T>, // Hash of the text of the document text_hash: T::Hash ) -> DispatchResult pub fn update( origin: OriginFor<T>, document_id: u32, text_hash: T::Hash ) -> DispatchResult pub fn delete(origin: OriginFor<T>, document_id: DocumentId) -> DispatchResult

Storage

/// A representation of a stored versioned document pub struct VersionedDocument<AccountId, Hash> { version: u16, author: AccountId, text_hash: Hash } #[pallet::storage] #[pallet::getter(fn get_document_id)] pub(super) type NextDocumentId<T> = StorageValue<_, u32, ValueQuery>; #[pallet::storage] #[pallet::getter(fn get_document)] pub(super) type Documents<T: Config> = StorageMap<_, Blake2_128Concat, u32, VersionedDocument<T::AccountId, T::Hash>, OptionQuery>; #[pallet::storage] #[pallet::getter(fn get_by_text_hash)] /// Storage that stores by text hash, for checking if a document has been submitted pub(super) type DocumentIdsByHash<T: Config> = StorageMap<_, Blake2_128Concat, T::Hash, u32, OptionQuery>;

Extensibility

The pallet is intended for broader use. It may take some investigation, but it's possible the pallet could be used with some of the other text content used on-chain.

Next Steps

  • Align with frontend team; the pallet should work well with the current app.
  • Understand Edgeware/Kombucha's process for getting a pallet included and deployed on-chain
Select a repo