diff --git a/Cargo.lock b/Cargo.lock index 3b7b57731..7889b426f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -601,7 +601,6 @@ dependencies = [ name = "cosmwasm-derive" version = "2.1.3" dependencies = [ - "cosmwasm-std", "proc-macro2", "quote", "syn 2.0.66", diff --git a/packages/derive/Cargo.toml b/packages/derive/Cargo.toml index 5ae90044a..fd196c6ee 100644 --- a/packages/derive/Cargo.toml +++ b/packages/derive/Cargo.toml @@ -18,10 +18,3 @@ default = [] proc-macro2 = "1.0.79" quote = "1.0.35" syn = { version = "2", features = ["full"] } - -[dev-dependencies] -# Needed for testing docs -# "What's even more fun, Cargo packages actually can have cyclic dependencies. -# "(a package can have an indirect dev-dependency on itself)" -# https://users.rust-lang.org/t/does-cargo-support-cyclic-dependencies/35666/3 -cosmwasm-std = { version = "2.1.3", path = "../std" } diff --git a/packages/derive/src/lib.rs b/packages/derive/src/lib.rs index 253b10f94..a4de1a226 100644 --- a/packages/derive/src/lib.rs +++ b/packages/derive/src/lib.rs @@ -46,90 +46,7 @@ impl Parse for Options { } } -/// This attribute macro generates the boilerplate required to call into the -/// contract-specific logic from the entry-points to the Wasm module. -/// -/// It should be added to the contract's init, handle, migrate and query implementations -/// like this: -/// ``` -/// # use cosmwasm_std::{ -/// # Storage, Api, Querier, DepsMut, Deps, entry_point, Env, StdError, MessageInfo, -/// # Response, QueryResponse, -/// # }; -/// # -/// # type InstantiateMsg = (); -/// # type ExecuteMsg = (); -/// # type QueryMsg = (); -/// -/// #[entry_point] -/// pub fn instantiate( -/// deps: DepsMut, -/// env: Env, -/// info: MessageInfo, -/// msg: InstantiateMsg, -/// ) -> Result { -/// # Ok(Default::default()) -/// } -/// -/// #[entry_point] -/// pub fn execute( -/// deps: DepsMut, -/// env: Env, -/// info: MessageInfo, -/// msg: ExecuteMsg, -/// ) -> Result { -/// # Ok(Default::default()) -/// } -/// -/// #[entry_point] -/// pub fn query( -/// deps: Deps, -/// env: Env, -/// msg: QueryMsg, -/// ) -> Result { -/// # Ok(Default::default()) -/// } -/// ``` -/// -/// where `InstantiateMsg`, `ExecuteMsg`, and `QueryMsg` are contract defined -/// types that implement `DeserializeOwned + JsonSchema`. -/// -/// ## Set the version of the state of your contract -/// -/// The VM will use this as a hint whether it needs to run the migrate function of your contract or not. -/// -/// ``` -/// # use cosmwasm_std::{ -/// # DepsMut, entry_point, Env, MigrateInfo, -/// # Response, StdResult, -/// # }; -/// # -/// # type MigrateMsg = (); -/// #[entry_point] -/// #[migrate_version(2)] -/// pub fn migrate(deps: DepsMut, env: Env, msg: MigrateMsg, migrate_info: MigrateInfo) -> StdResult { -/// todo!(); -/// } -/// ``` -/// -/// It is also possible to assign the migrate version number to -/// a given constant name: -/// -/// ``` -/// # use cosmwasm_std::{ -/// # DepsMut, entry_point, Env, MigrateInfo, -/// # Response, StdResult, -/// # }; -/// # -/// # type MigrateMsg = (); -/// const CONTRACT_VERSION: u64 = 66; -/// -/// #[entry_point] -/// #[migrate_version(CONTRACT_VERSION)] -/// pub fn migrate(deps: DepsMut, env: Env, msg: MigrateMsg, migrate_info: MigrateInfo) -> StdResult { -/// todo!(); -/// } -/// ``` +// function documented in cosmwasm-std #[proc_macro_attribute] pub fn entry_point( attr: proc_macro::TokenStream, diff --git a/packages/std/src/lib.rs b/packages/std/src/lib.rs index f683954cf..fc628693f 100644 --- a/packages/std/src/lib.rs +++ b/packages/std/src/lib.rs @@ -148,4 +148,89 @@ pub use crate::imports::{ExternalApi, ExternalQuerier, ExternalStorage}; pub mod testing; pub use cosmwasm_core::{BLS12_381_G1_GENERATOR, BLS12_381_G2_GENERATOR}; + +/// This attribute macro generates the boilerplate required to call into the +/// contract-specific logic from the entry-points to the Wasm module. +/// +/// It should be added to the contract's init, handle, migrate and query implementations +/// like this: +/// ``` +/// # use cosmwasm_std::{ +/// # Storage, Api, Querier, DepsMut, Deps, entry_point, Env, StdError, MessageInfo, +/// # Response, QueryResponse, +/// # }; +/// # +/// # type InstantiateMsg = (); +/// # type ExecuteMsg = (); +/// # type QueryMsg = (); +/// +/// #[entry_point] +/// pub fn instantiate( +/// deps: DepsMut, +/// env: Env, +/// info: MessageInfo, +/// msg: InstantiateMsg, +/// ) -> Result { +/// # Ok(Default::default()) +/// } +/// +/// #[entry_point] +/// pub fn execute( +/// deps: DepsMut, +/// env: Env, +/// info: MessageInfo, +/// msg: ExecuteMsg, +/// ) -> Result { +/// # Ok(Default::default()) +/// } +/// +/// #[entry_point] +/// pub fn query( +/// deps: Deps, +/// env: Env, +/// msg: QueryMsg, +/// ) -> Result { +/// # Ok(Default::default()) +/// } +/// ``` +/// +/// where `InstantiateMsg`, `ExecuteMsg`, and `QueryMsg` are contract defined +/// types that implement `DeserializeOwned + JsonSchema`. +/// +/// ## Set the version of the state of your contract +/// +/// The VM will use this as a hint whether it needs to run the migrate function of your contract or not. +/// +/// ``` +/// # use cosmwasm_std::{ +/// # DepsMut, entry_point, Env, MigrateInfo, +/// # Response, StdResult, +/// # }; +/// # +/// # type MigrateMsg = (); +/// #[entry_point] +/// #[migrate_version(2)] +/// pub fn migrate(deps: DepsMut, env: Env, msg: MigrateMsg, migrate_info: MigrateInfo) -> StdResult { +/// todo!(); +/// } +/// ``` +/// +/// It is also possible to assign the migrate version number to +/// a given constant name: +/// +/// ``` +/// # use cosmwasm_std::{ +/// # DepsMut, entry_point, Env, MigrateInfo, +/// # Response, StdResult, +/// # }; +/// # +/// # type MigrateMsg = (); +/// const CONTRACT_VERSION: u64 = 66; +/// +/// #[entry_point] +/// #[migrate_version(CONTRACT_VERSION)] +/// pub fn migrate(deps: DepsMut, env: Env, msg: MigrateMsg, migrate_info: MigrateInfo) -> StdResult { +/// todo!(); +/// } +/// ``` pub use cosmwasm_derive::entry_point;