Skip to content

Commit

Permalink
Merge pull request #2265 from CosmWasm/mergify/bp/release/1.5/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 2722686 + 31f136b commit bafa60b
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 57 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 @@ -16,10 +16,3 @@ default = []

[dependencies]
syn = { version = "1.0", 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 = { path = "../std" }
48 changes: 1 addition & 47 deletions packages/derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,53 +4,7 @@ extern crate syn;
use proc_macro::TokenStream;
use std::str::FromStr;

/// 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`.
// function documented in cosmwasm-std
#[proc_macro_attribute]
pub fn entry_point(_attr: TokenStream, mut item: TokenStream) -> TokenStream {
let cloned = item.clone();
Expand Down
49 changes: 47 additions & 2 deletions packages/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,51 @@ pub use crate::imports::{ExternalApi, ExternalQuerier, ExternalStorage};
#[cfg(not(target_arch = "wasm32"))]
pub mod testing;

// Re-exports

/// 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 bafa60b

Please sign in to comment.