diff --git a/Cargo.lock b/Cargo.lock index f24230f..6c0e7d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1341,7 +1341,7 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" [[package]] name = "drink" -version = "0.12.0" +version = "0.13.0" dependencies = [ "contract-metadata", "contract-transcode", @@ -1355,6 +1355,7 @@ dependencies = [ "pallet-timestamp", "parity-scale-codec", "parity-scale-codec-derive", + "paste", "scale-info", "serde_json", "sp-externalities", @@ -1366,7 +1367,7 @@ dependencies = [ [[package]] name = "drink-cli" -version = "0.12.0" +version = "0.13.0" dependencies = [ "anyhow", "clap", @@ -1382,7 +1383,7 @@ dependencies = [ [[package]] name = "drink-test-macro" -version = "0.12.0" +version = "0.13.0" dependencies = [ "cargo_metadata", "contract-build", diff --git a/drink/src/lib.rs b/drink/src/lib.rs index 063fec9..e9507d5 100644 --- a/drink/src/lib.rs +++ b/drink/src/lib.rs @@ -21,7 +21,10 @@ use frame_system::EventRecord; #[cfg(feature = "session")] pub use session::mock::{mock_message, ContractMock, MessageMock, MockedCallResult, Selector}; /// Export pallets that are used in the minimal runtime. -pub use {frame_support, frame_system, pallet_balances, pallet_contracts, pallet_timestamp}; +pub use { + frame_support, frame_system, pallet_balances, pallet_contracts, pallet_timestamp, paste, + sp_externalities::Extension, sp_io::TestExternalities, +}; pub use crate::runtime::minimal::{self, MinimalSandbox}; diff --git a/drink/src/runtime/minimal.rs b/drink/src/runtime/minimal.rs index 2d95e65..df9ad9c 100644 --- a/drink/src/runtime/minimal.rs +++ b/drink/src/runtime/minimal.rs @@ -68,7 +68,7 @@ impl< /// Macro creating a minimal runtime with the given name. Optionally can take a chain extension /// type as a second argument. /// -/// The new macro will automatically implement `drink::SandboxConfig`. +/// The new macro will automatically implement `drink::Sandbox`. #[macro_export] macro_rules! create_minimal_sandbox { ($name:ident) => { diff --git a/drink/src/sandbox/sandbox_config.rs b/drink/src/sandbox/sandbox_config.rs deleted file mode 100644 index 52d2cca..0000000 --- a/drink/src/sandbox/sandbox_config.rs +++ /dev/null @@ -1,51 +0,0 @@ -//! Module containing the core trait use to customize the sandboxed runtime. - -use core::any::Any; - -use frame_metadata::RuntimeMetadataPrefixed; -use frame_support::sp_runtime::traits::Dispatchable; -use frame_system::pallet_prelude::BlockNumberFor; -use sp_externalities::Extension; - -/// The type of an account identifier. -pub type AccountIdFor = ::AccountId; - -/// A runtime to use. -pub trait SandboxConfig { - /// The runtime associated with the sandbox. - type Runtime: frame_system::Config; - - /// Execute the given externalities. - fn execute_with(execute: impl FnOnce() -> T) -> T; - - /// Dry run an action without modifying the storage. - fn dry_run(action: impl FnOnce() -> T) -> T; - - /// Register an extension. - fn register_extension(ext: E); - - /// Initialize a new block at particular height. - fn initialize_block( - _height: BlockNumberFor, - _parent_hash: ::Hash, - ) { - } - - /// Finalize a block at particular height. - fn finalize_block( - _height: BlockNumberFor, - ) -> ::Hash { - Default::default() - } - - /// Default actor for the sandbox. - fn default_actor() -> AccountIdFor; - - /// Metadata of the runtime. - fn get_metadata() -> RuntimeMetadataPrefixed; - - /// Convert an account to an call origin. - fn convert_account_to_origin( - account: AccountIdFor, - ) -> <::RuntimeCall as Dispatchable>::RuntimeOrigin; -} diff --git a/drink/src/session.rs b/drink/src/session.rs index 95c96bd..4c08db3 100644 --- a/drink/src/session.rs +++ b/drink/src/session.rs @@ -37,8 +37,7 @@ use error::SessionError; use self::mocking_api::MockingApi; use crate::{ - errors::MessageResult, minimal::MinimalSandboxRuntime, runtime::MinimalRuntime, - session::transcoding::TranscoderRegistry, + errors::MessageResult, minimal::MinimalSandboxRuntime, session::transcoding::TranscoderRegistry, }; type BalanceOf = diff --git a/drink/src/session/mocking_api.rs b/drink/src/session/mocking_api.rs index aa4a38c..538141a 100644 --- a/drink/src/session/mocking_api.rs +++ b/drink/src/session/mocking_api.rs @@ -1,8 +1,7 @@ //! Mocking API for the sandbox. use super::Session; use crate::{ - runtime::AccountIdFor, sandbox::prelude::*, session::mock::ContractMock, SandboxConfig, - DEFAULT_GAS_LIMIT, + runtime::AccountIdFor, sandbox::prelude::*, session::mock::ContractMock, DEFAULT_GAS_LIMIT, }; /// Interface for basic mocking operations. diff --git a/examples/chain-extension/Cargo.lock b/examples/chain-extension/Cargo.lock index a96c853..f956927 100644 --- a/examples/chain-extension/Cargo.lock +++ b/examples/chain-extension/Cargo.lock @@ -1340,7 +1340,7 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" [[package]] name = "drink" -version = "0.11.1" +version = "0.13.0" dependencies = [ "contract-metadata", "contract-transcode", @@ -1354,6 +1354,7 @@ dependencies = [ "pallet-timestamp", "parity-scale-codec", "parity-scale-codec-derive", + "paste", "scale-info", "serde_json", "sp-externalities", @@ -1365,7 +1366,7 @@ dependencies = [ [[package]] name = "drink-test-macro" -version = "0.11.1" +version = "0.13.0" dependencies = [ "cargo_metadata", "contract-build",