Skip to content

Commit

Permalink
Document entry_point in cosmwasm-std instead of derive
Browse files Browse the repository at this point in the history
Closes #2186
  • Loading branch information
webmaster128 committed Sep 6, 2024
1 parent 3a60939 commit e230048
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 92 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.3", path = "../std" }
85 changes: 1 addition & 84 deletions packages/derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<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, MigrateInfo,
/// # Response, StdResult,
/// # };
/// #
/// # type MigrateMsg = ();
/// #[entry_point]
/// #[migrate_version(2)]
/// pub fn migrate(deps: DepsMut, env: Env, msg: MigrateMsg, migrate_info: MigrateInfo) -> StdResult<Response> {
/// 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<Response> {
/// todo!();
/// }
/// ```
// function documented in cosmwasm-std
#[proc_macro_attribute]
pub fn entry_point(
attr: proc_macro::TokenStream,
Expand Down
85 changes: 85 additions & 0 deletions packages/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<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, MigrateInfo,
/// # Response, StdResult,
/// # };
/// #
/// # type MigrateMsg = ();
/// #[entry_point]
/// #[migrate_version(2)]
/// pub fn migrate(deps: DepsMut, env: Env, msg: MigrateMsg, migrate_info: MigrateInfo) -> StdResult<Response> {
/// 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<Response> {
/// todo!();
/// }
/// ```
pub use cosmwasm_derive::entry_point;

0 comments on commit e230048

Please sign in to comment.