1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
// This file is part of Anagolay Foundation.
// Copyright (C) 2019-2022 Anagolay Foundation.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// Ensure we're `no_std` when compiling for Wasm.
#![cfg_attr(not(feature = "std"), no_std)]
#![feature(type_name_of_val)]
#![feature(pattern)]
//! # Anagolay blockchain
//! This is the support pallet for the anagolay blockchain. It factors common types and behaviors
//! used in all other Anagolay pallets, which are:
//!
//! * `operations` - Exposes the extrinsics for creation, management and approval of Operations
//! * `workflows` - Exposes the extrinsics for creation, management and approval of Workflows
//!
//! ## Versions
//! Each entity on Anagolay blockchain is versioned. It means that upon creation, a check is
//! performed to prevent creation of multiple versions of the same entity and to verify that the
//! initial version that will be created is consistent
//!
//! ## Weights
//! Since creation of entities is costly, the call is required to be signed and to spend
//! a certain amount of tokens for the extrinsic call to succeed. This prevents overcharging the
//! chain. Weights of each call are generated by benchmark tests
//!
//! ## Code structure
//! Each pallet presents the following modules:
//!
//! * lib - The entry point of the pallet, defines configuration, events, errors and extrinsics
//! * benchmarking - Runner of the benchmarking
//! * functions - Private behaviour of the pallet, the lib entry points delegate to this module
//! * mock - Prepares the mocks for unit tests, only used in test configuration
//! * types - Collects the types and the data model used by the pallet
//!
//! ## Features of the support crate
//! The factored common types are:
//!
//! * Identifiers - Every entity has their own (`OperationId`, `WorkflowId`, etc.) but they are all
//! aliases of a private struct `GenericId` that deals with validation and (de)serialization
//! * Characters - Offers an interface to deal with strings in nostd
//! * AnagolayStructure - Provides a pattern struct with an id, some data nad an optional extra.
//! The id is guaranteed to be computed from the data.
//! * AnagolayVersion - Another pattern struct used by all entity to deal with their published
//! artifacts and
//! incremental versions on the blockchain
//! * AnagolayRecord - Pattern struct used to store the entities on the chain along with the caller
//! and the
//! block number
// Ensure we're `no_std` when compiling for Wasm.
#![cfg_attr(not(feature = "std"), no_std)]
mod functions;
mod types;
#[cfg(test)]
mod mock;
#[cfg(test)]
mod tests;
pub use pallet::*;
#[frame_support::pallet]
mod pallet {
pub use crate::types::*;
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
use sp_std::vec::Vec;
#[pallet::pallet]
#[pallet::generate_store(pub(super) trait Store)]
pub struct Pallet<T>(_);
#[pallet::config]
pub trait Config: frame_system::Config {}
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {}
#[pallet::call]
impl<T: Config> Pallet<T> {}
/// All published artifacts will appear here. Note that this list will be quite large, be aware of
/// querying this without proper limits!
#[pallet::storage]
#[pallet::getter(fn artifacts_by_artifact_id)]
pub type ArtifactsByArtifactId<T: Config> = StorageValue<_, Vec<ArtifactId>, ValueQuery>;
#[pallet::error]
pub enum Error<T> {}
}