Skip to content

Commit

Permalink
Merge pull request #2267 from CosmWasm/mergify/bp/release/2.1/pr-2245
Browse files Browse the repository at this point in the history
Document entry_point in cosmwasm-std instead of derive (backport #2245)
  • Loading branch information
aumetra authored Sep 24, 2024
2 parents 13d8bbc + 964923b commit 2afe23d
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 73 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions packages/derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.4", path = "../std" }
66 changes: 1 addition & 65 deletions packages/derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,71 +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<Response, StdError> {
/// # Ok(Default::default())
/// }
///
/// #[entry_point]
/// pub fn execute(
/// deps: DepsMut,
/// env: Env,
/// info: MessageInfo,
/// msg: ExecuteMsg,
/// ) -> Result<Response, StdError> {
/// # Ok(Default::default())
/// }
///
/// #[entry_point]
/// pub fn query(
/// deps: Deps,
/// env: Env,
/// msg: QueryMsg,
/// ) -> Result<QueryResponse, StdError> {
/// # 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,
/// # Response, StdResult,
/// # };
/// #
/// # type MigrateMsg = ();
/// #[entry_point]
/// #[migrate_version(2)]
/// pub fn migrate(deps: DepsMut, env: Env, msg: MigrateMsg) -> StdResult<Response> {
/// todo!();
/// }
/// ```
// function documented in cosmwasm-std
#[proc_macro_attribute]
pub fn entry_point(
attr: proc_macro::TokenStream,
Expand Down
48 changes: 48 additions & 0 deletions packages/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,52 @@ 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<Response, StdError> {
/// # Ok(Default::default())
/// }
///
/// #[entry_point]
/// pub fn execute(
/// deps: DepsMut,
/// env: Env,
/// info: MessageInfo,
/// msg: ExecuteMsg,
/// ) -> Result<Response, StdError> {
/// # Ok(Default::default())
/// }
///
/// #[entry_point]
/// pub fn query(
/// deps: Deps,
/// env: Env,
/// msg: QueryMsg,
/// ) -> Result<QueryResponse, StdError> {
/// # Ok(Default::default())
/// }
/// ```
///
/// where `InstantiateMsg`, `ExecuteMsg`, and `QueryMsg` are contract defined
/// types that implement `DeserializeOwned + JsonSchema`.
pub use cosmwasm_derive::entry_point;

0 comments on commit 2afe23d

Please sign in to comment.