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

(cherry picked from commit e230048)

# Conflicts:
#	Cargo.lock
#	packages/derive/Cargo.toml
#	packages/derive/src/lib.rs
#	packages/std/src/lib.rs
  • Loading branch information
webmaster128 authored and mergify[bot] committed Sep 24, 2024
1 parent b5d5f70 commit 29cc7b6
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Cargo.lock

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

6 changes: 6 additions & 0 deletions packages/derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ proc-macro = true
default = []

[dependencies]
<<<<<<< HEAD
syn = { version = "1.0", features = ["full"] }

[dev-dependencies]
Expand All @@ -23,3 +24,8 @@ syn = { version = "1.0", features = ["full"] }
# "(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" }
=======
proc-macro2 = "1.0.79"
quote = "1.0.35"
syn = { version = "2", features = ["full"] }
>>>>>>> e230048f1 (Document entry_point in cosmwasm-std instead of derive)
4 changes: 4 additions & 0 deletions packages/derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ extern crate syn;
use proc_macro::TokenStream;
use std::str::FromStr;

<<<<<<< HEAD
/// This attribute macro generates the boilerplate required to call into the
/// contract-specific logic from the entry-points to the Wasm module.
///
Expand Down Expand Up @@ -51,6 +52,9 @@ use std::str::FromStr;
///
/// where `InstantiateMsg`, `ExecuteMsg`, and `QueryMsg` are contract defined
/// types that implement `DeserializeOwned + JsonSchema`.
=======
// function documented in cosmwasm-std
>>>>>>> e230048f1 (Document entry_point in cosmwasm-std instead of derive)
#[proc_macro_attribute]
pub fn entry_point(_attr: TokenStream, mut item: TokenStream) -> TokenStream {
let cloned = item.clone();
Expand Down
89 changes: 89 additions & 0 deletions packages/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,95 @@ pub use crate::imports::{ExternalApi, ExternalQuerier, ExternalStorage};
#[cfg(not(target_arch = "wasm32"))]
pub mod testing;

<<<<<<< HEAD
// Re-exports

=======
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!();
/// }
/// ```
>>>>>>> e230048f1 (Document entry_point in cosmwasm-std instead of derive)
pub use cosmwasm_derive::entry_point;

0 comments on commit 29cc7b6

Please sign in to comment.