drink-next 0.8.7

Minimal sufficient architecture that allows for a fully functional ink! contract development
//! Module containing the [`Runtime`](Runtime) trait and its example implementations. You can use
//! `drink` with any runtime that implements the `Runtime` trait.

pub mod minimal;
pub mod pallet_contracts_debugging;

pub use frame_metadata::RuntimeMetadataPrefixed;
use frame_support::sp_runtime::Storage;
use frame_system::pallet_prelude::BlockNumberFor;
pub use minimal::MinimalRuntime;

/// The type of an account identifier.
pub type AccountIdFor<R> = <R as frame_system::Config>::AccountId;

/// The type of a hash.
pub type HashFor<R> = <R as frame_system::Config>::Hash;

/// A runtime to use.
pub trait Runtime: frame_system::Config {
    /// Initialize the storage at the genesis block.
    fn initialize_storage(_storage: &mut Storage) -> Result<(), String> {
        Ok(())
    }

    /// Initialize a new block at particular height.
    fn initialize_block(
        _height: BlockNumberFor<Self>,
        _parent_hash: <Self as frame_system::Config>::Hash,
    ) -> Result<(), String> {
        Ok(())
    }

    /// Finalize a block at particular height.
    fn finalize_block(
        _height: BlockNumberFor<Self>,
    ) -> Result<<Self as frame_system::Config>::Hash, String> {
        Ok(Default::default())
    }

    /// Default actor for the runtime.
    fn default_actor() -> AccountIdFor<Self>;
}

/// Convenient umbrella trait for `Runtime + pallet_contracts::Config`
pub trait RuntimeWithContracts: Runtime + pallet_contracts::Config {}
impl<T: Runtime + pallet_contracts::Config> RuntimeWithContracts for T {}