From d2c54a33428585e9b5a081eeecf2594b64d1e3e6 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Fri, 6 Sep 2024 17:11:10 +0200 Subject: [PATCH 1/2] Document entry_point in cosmwasm-std instead of derive Closes #2186 (cherry picked from commit e230048f13e25982371ca1c3c7f97c0e87aa08c6) # Conflicts: # Cargo.lock # packages/derive/Cargo.toml # packages/derive/src/lib.rs # packages/std/src/lib.rs --- Cargo.lock | 6 +++ packages/derive/Cargo.toml | 6 +++ packages/derive/src/lib.rs | 4 ++ packages/std/src/lib.rs | 89 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 105 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index e7cff218bd..3f6b9eaf2a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -460,8 +460,14 @@ dependencies = [ name = "cosmwasm-derive" version = "1.5.8" dependencies = [ +<<<<<<< HEAD "cosmwasm-std", "syn 1.0.109", +======= + "proc-macro2", + "quote", + "syn 2.0.66", +>>>>>>> e230048f1 (Document entry_point in cosmwasm-std instead of derive) ] [[package]] diff --git a/packages/derive/Cargo.toml b/packages/derive/Cargo.toml index f0722ec99c..3f69dddc2d 100644 --- a/packages/derive/Cargo.toml +++ b/packages/derive/Cargo.toml @@ -15,6 +15,7 @@ proc-macro = true default = [] [dependencies] +<<<<<<< HEAD syn = { version = "1.0", features = ["full"] } [dev-dependencies] @@ -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) diff --git a/packages/derive/src/lib.rs b/packages/derive/src/lib.rs index 1a0f516f1f..c35dc73e61 100644 --- a/packages/derive/src/lib.rs +++ b/packages/derive/src/lib.rs @@ -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. /// @@ -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(); diff --git a/packages/std/src/lib.rs b/packages/std/src/lib.rs index dcf106b96e..664f42c40a 100644 --- a/packages/std/src/lib.rs +++ b/packages/std/src/lib.rs @@ -124,6 +124,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 { +/// # 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!(); +/// } +/// ``` +>>>>>>> e230048f1 (Document entry_point in cosmwasm-std instead of derive) pub use cosmwasm_derive::entry_point; From 31f136b09fc5b59365cd3767596852b71d55b692 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Tue, 24 Sep 2024 16:23:55 +0200 Subject: [PATCH 2/2] Fix cherrypick issues --- Cargo.lock | 7 ------ packages/derive/Cargo.toml | 13 ---------- packages/derive/src/lib.rs | 50 -------------------------------------- packages/std/src/lib.rs | 44 --------------------------------- 4 files changed, 114 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3f6b9eaf2a..6606113f7f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -460,14 +460,7 @@ dependencies = [ name = "cosmwasm-derive" version = "1.5.8" dependencies = [ -<<<<<<< HEAD - "cosmwasm-std", "syn 1.0.109", -======= - "proc-macro2", - "quote", - "syn 2.0.66", ->>>>>>> e230048f1 (Document entry_point in cosmwasm-std instead of derive) ] [[package]] diff --git a/packages/derive/Cargo.toml b/packages/derive/Cargo.toml index 3f69dddc2d..a02dd3a0f9 100644 --- a/packages/derive/Cargo.toml +++ b/packages/derive/Cargo.toml @@ -15,17 +15,4 @@ proc-macro = true default = [] [dependencies] -<<<<<<< HEAD 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" } -======= -proc-macro2 = "1.0.79" -quote = "1.0.35" -syn = { version = "2", features = ["full"] } ->>>>>>> e230048f1 (Document entry_point in cosmwasm-std instead of derive) diff --git a/packages/derive/src/lib.rs b/packages/derive/src/lib.rs index c35dc73e61..9018439bf7 100644 --- a/packages/derive/src/lib.rs +++ b/packages/derive/src/lib.rs @@ -4,57 +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. -/// -/// 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`. -======= // 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(); diff --git a/packages/std/src/lib.rs b/packages/std/src/lib.rs index 664f42c40a..9333aeec10 100644 --- a/packages/std/src/lib.rs +++ b/packages/std/src/lib.rs @@ -124,12 +124,6 @@ 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. /// @@ -177,42 +171,4 @@ pub use cosmwasm_core::{BLS12_381_G1_GENERATOR, BLS12_381_G2_GENERATOR}; /// /// 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!(); -/// } -/// ``` ->>>>>>> e230048f1 (Document entry_point in cosmwasm-std instead of derive) pub use cosmwasm_derive::entry_point;