From 23c0ba57ce4c5b5394806fa811b4f6900cd69143 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Mon, 22 Mar 2021 10:20:42 +0100 Subject: [PATCH 1/4] Migrate to entry_point macro --- contracts/cw1-subkeys/src/contract.rs | 7 +++++-- contracts/cw1-subkeys/src/lib.rs | 3 --- contracts/cw1-whitelist/src/contract.rs | 6 ++++++ contracts/cw1-whitelist/src/lib.rs | 3 --- contracts/cw20-atomic-swap/src/contract.rs | 7 +++++-- contracts/cw20-atomic-swap/src/lib.rs | 3 --- contracts/cw20-bonding/src/contract.rs | 7 +++++-- contracts/cw20-bonding/src/lib.rs | 3 --- contracts/cw20-escrow/src/contract.rs | 7 +++++-- contracts/cw20-escrow/src/lib.rs | 3 --- contracts/cw20-staking/src/contract.rs | 7 +++++-- contracts/cw20-staking/src/lib.rs | 3 --- contracts/cw3-fixed-multisig/src/contract.rs | 7 +++++-- contracts/cw3-fixed-multisig/src/lib.rs | 3 --- contracts/cw3-flex-multisig/src/contract.rs | 7 +++++-- contracts/cw3-flex-multisig/src/lib.rs | 3 --- contracts/cw4-group/src/contract.rs | 7 +++++-- contracts/cw4-group/src/lib.rs | 4 ---- contracts/cw4-stake/src/contract.rs | 8 ++++++-- contracts/cw4-stake/src/lib.rs | 4 ---- contracts/cw721-base/src/contract.rs | 7 +++++-- contracts/cw721-base/src/lib.rs | 3 --- 22 files changed, 57 insertions(+), 55 deletions(-) diff --git a/contracts/cw1-subkeys/src/contract.rs b/contracts/cw1-subkeys/src/contract.rs index ac7d07682..241a5faaa 100644 --- a/contracts/cw1-subkeys/src/contract.rs +++ b/contracts/cw1-subkeys/src/contract.rs @@ -3,8 +3,8 @@ use std::fmt; use std::ops::{AddAssign, Sub}; use cosmwasm_std::{ - attr, to_binary, BankMsg, Binary, CanonicalAddr, Coin, CosmosMsg, Deps, DepsMut, Empty, Env, - HumanAddr, MessageInfo, Order, Response, StakingMsg, StdError, StdResult, + attr, entry_point, to_binary, BankMsg, Binary, CanonicalAddr, Coin, CosmosMsg, Deps, DepsMut, + Empty, Env, HumanAddr, MessageInfo, Order, Response, StakingMsg, StdError, StdResult, }; use cw0::{maybe_canonical, Expiration}; use cw1::CanExecuteResponse; @@ -30,6 +30,7 @@ use cw_storage_plus::Bound; const CONTRACT_NAME: &str = "crates.io:cw1-subkeys"; const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); +#[entry_point] pub fn instantiate( mut deps: DepsMut, env: Env, @@ -41,6 +42,7 @@ pub fn instantiate( Ok(result) } +#[entry_point] pub fn execute( deps: DepsMut, env: Env, @@ -283,6 +285,7 @@ where Ok(res) } +#[entry_point] pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { match msg { QueryMsg::AdminList {} => to_binary(&query_admin_list(deps)?), diff --git a/contracts/cw1-subkeys/src/lib.rs b/contracts/cw1-subkeys/src/lib.rs index 33ecec4df..d78159fb8 100644 --- a/contracts/cw1-subkeys/src/lib.rs +++ b/contracts/cw1-subkeys/src/lib.rs @@ -2,6 +2,3 @@ pub mod contract; mod error; pub mod msg; pub mod state; - -#[cfg(all(target_arch = "wasm32", not(feature = "library")))] -cosmwasm_std::create_entry_points!(contract); diff --git a/contracts/cw1-whitelist/src/contract.rs b/contracts/cw1-whitelist/src/contract.rs index 075a3c454..5db335e71 100644 --- a/contracts/cw1-whitelist/src/contract.rs +++ b/contracts/cw1-whitelist/src/contract.rs @@ -1,10 +1,13 @@ use schemars::JsonSchema; use std::fmt; +#[cfg(not(feature = "library"))] +use cosmwasm_std::entry_point; use cosmwasm_std::{ attr, to_binary, Api, Binary, CanonicalAddr, CosmosMsg, Deps, DepsMut, Empty, Env, HumanAddr, MessageInfo, Response, StdResult, }; + use cw1::CanExecuteResponse; use cw2::set_contract_version; @@ -16,6 +19,7 @@ use crate::state::{AdminList, ADMIN_LIST}; const CONTRACT_NAME: &str = "crates.io:cw1-whitelist"; const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); +#[cfg_attr(not(feature = "library"), entry_point)] pub fn instantiate( deps: DepsMut, _env: Env, @@ -42,6 +46,7 @@ fn map_human(api: &dyn Api, admins: &[CanonicalAddr]) -> StdResult StdResult { Ok(can) } +#[cfg_attr(not(feature = "library"), entry_point)] pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { match msg { QueryMsg::AdminList {} => to_binary(&query_admin_list(deps)?), diff --git a/contracts/cw1-whitelist/src/lib.rs b/contracts/cw1-whitelist/src/lib.rs index 804aed3c2..e5ff7237e 100644 --- a/contracts/cw1-whitelist/src/lib.rs +++ b/contracts/cw1-whitelist/src/lib.rs @@ -4,6 +4,3 @@ pub mod msg; pub mod state; pub use crate::error::ContractError; - -#[cfg(all(target_arch = "wasm32", not(feature = "library")))] -cosmwasm_std::create_entry_points!(contract); diff --git a/contracts/cw20-atomic-swap/src/contract.rs b/contracts/cw20-atomic-swap/src/contract.rs index baacaacbf..ac89d34ad 100644 --- a/contracts/cw20-atomic-swap/src/contract.rs +++ b/contracts/cw20-atomic-swap/src/contract.rs @@ -1,6 +1,6 @@ use cosmwasm_std::{ - attr, from_binary, to_binary, Api, BankMsg, Binary, CosmosMsg, Deps, DepsMut, Env, HumanAddr, - MessageInfo, Response, StdResult, WasmMsg, + attr, entry_point, from_binary, to_binary, Api, BankMsg, Binary, CosmosMsg, Deps, DepsMut, Env, + HumanAddr, MessageInfo, Response, StdResult, WasmMsg, }; use sha2::{Digest, Sha256}; @@ -19,6 +19,7 @@ use cw_storage_plus::Bound; const CONTRACT_NAME: &str = "crates.io:cw20-atomic-swap"; const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); +#[entry_point] pub fn instantiate( deps: DepsMut, _env: Env, @@ -30,6 +31,7 @@ pub fn instantiate( Ok(Response::default()) } +#[entry_point] pub fn execute( deps: DepsMut, env: Env, @@ -220,6 +222,7 @@ fn send_tokens(api: &dyn Api, to: &HumanAddr, amount: Balance) -> StdResult StdResult { match msg { QueryMsg::List { start_after, limit } => to_binary(&query_list(deps, start_after, limit)?), diff --git a/contracts/cw20-atomic-swap/src/lib.rs b/contracts/cw20-atomic-swap/src/lib.rs index 33ecec4df..d78159fb8 100644 --- a/contracts/cw20-atomic-swap/src/lib.rs +++ b/contracts/cw20-atomic-swap/src/lib.rs @@ -2,6 +2,3 @@ pub mod contract; mod error; pub mod msg; pub mod state; - -#[cfg(all(target_arch = "wasm32", not(feature = "library")))] -cosmwasm_std::create_entry_points!(contract); diff --git a/contracts/cw20-bonding/src/contract.rs b/contracts/cw20-bonding/src/contract.rs index 7de436971..7c592597e 100644 --- a/contracts/cw20-bonding/src/contract.rs +++ b/contracts/cw20-bonding/src/contract.rs @@ -1,6 +1,6 @@ use cosmwasm_std::{ - attr, coins, to_binary, BankMsg, Binary, Deps, DepsMut, Env, HumanAddr, MessageInfo, Response, - StdResult, Uint128, + attr, coins, entry_point, to_binary, BankMsg, Binary, Deps, DepsMut, Env, HumanAddr, + MessageInfo, Response, StdResult, Uint128, }; use cw2::set_contract_version; @@ -23,6 +23,7 @@ use cw0::{must_pay, nonpayable}; const CONTRACT_NAME: &str = "crates.io:cw20-bonding"; const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); +#[entry_point] pub fn instantiate( deps: DepsMut, env: Env, @@ -55,6 +56,7 @@ pub fn instantiate( Ok(Response::default()) } +#[entry_point] pub fn execute( deps: DepsMut, env: Env, @@ -254,6 +256,7 @@ fn do_sell( Ok(res) } +#[entry_point] pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { // default implementation stores curve info as enum, you can do something else in a derived // contract and just pass in your custom curve to do_execute diff --git a/contracts/cw20-bonding/src/lib.rs b/contracts/cw20-bonding/src/lib.rs index e708c995a..7a289e298 100644 --- a/contracts/cw20-bonding/src/lib.rs +++ b/contracts/cw20-bonding/src/lib.rs @@ -3,6 +3,3 @@ pub mod curves; mod error; pub mod msg; pub mod state; - -#[cfg(all(target_arch = "wasm32", not(feature = "library")))] -cosmwasm_std::create_entry_points!(contract); diff --git a/contracts/cw20-escrow/src/contract.rs b/contracts/cw20-escrow/src/contract.rs index ec784d959..8f46cf7fc 100644 --- a/contracts/cw20-escrow/src/contract.rs +++ b/contracts/cw20-escrow/src/contract.rs @@ -1,6 +1,6 @@ use cosmwasm_std::{ - attr, from_binary, to_binary, Api, BankMsg, Binary, CosmosMsg, Deps, DepsMut, Env, HumanAddr, - MessageInfo, Response, StdResult, WasmMsg, + attr, entry_point, from_binary, to_binary, Api, BankMsg, Binary, CosmosMsg, Deps, DepsMut, Env, + HumanAddr, MessageInfo, Response, StdResult, WasmMsg, }; use cw2::set_contract_version; @@ -16,6 +16,7 @@ use crate::state::{all_escrow_ids, Escrow, GenericBalance, ESCROWS}; const CONTRACT_NAME: &str = "crates.io:cw20-escrow"; const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); +#[entry_point] pub fn instantiate( deps: DepsMut, _env: Env, @@ -27,6 +28,7 @@ pub fn instantiate( Ok(Response::default()) } +#[entry_point] pub fn execute( deps: DepsMut, env: Env, @@ -240,6 +242,7 @@ fn send_tokens( Ok(msgs) } +#[entry_point] pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { match msg { QueryMsg::List {} => to_binary(&query_list(deps)?), diff --git a/contracts/cw20-escrow/src/lib.rs b/contracts/cw20-escrow/src/lib.rs index 6d596e1ca..6af0667c6 100644 --- a/contracts/cw20-escrow/src/lib.rs +++ b/contracts/cw20-escrow/src/lib.rs @@ -3,6 +3,3 @@ mod error; mod integration_test; pub mod msg; pub mod state; - -#[cfg(all(target_arch = "wasm32", not(feature = "library")))] -cosmwasm_std::create_entry_points!(contract); diff --git a/contracts/cw20-staking/src/contract.rs b/contracts/cw20-staking/src/contract.rs index 8a7359bf8..2205ca355 100644 --- a/contracts/cw20-staking/src/contract.rs +++ b/contracts/cw20-staking/src/contract.rs @@ -1,6 +1,6 @@ use cosmwasm_std::{ - attr, coin, to_binary, BankMsg, Binary, Decimal, Deps, DepsMut, Env, HumanAddr, MessageInfo, - QuerierWrapper, Response, StakingMsg, StdError, StdResult, Uint128, WasmMsg, + attr, coin, entry_point, to_binary, BankMsg, Binary, Decimal, Deps, DepsMut, Env, HumanAddr, + MessageInfo, QuerierWrapper, Response, StakingMsg, StdError, StdResult, Uint128, WasmMsg, }; use cw2::set_contract_version; @@ -23,6 +23,7 @@ const FALLBACK_RATIO: Decimal = Decimal::one(); const CONTRACT_NAME: &str = "crates.io:cw20-staking"; const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); +#[entry_point] pub fn instantiate( deps: DepsMut, env: Env, @@ -71,6 +72,7 @@ pub fn instantiate( Ok(Response::default()) } +#[entry_point] pub fn execute( deps: DepsMut, env: Env, @@ -410,6 +412,7 @@ pub fn _bond_all_tokens( Ok(res) } +#[entry_point] pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { match msg { // custom queries diff --git a/contracts/cw20-staking/src/lib.rs b/contracts/cw20-staking/src/lib.rs index 33ecec4df..d78159fb8 100644 --- a/contracts/cw20-staking/src/lib.rs +++ b/contracts/cw20-staking/src/lib.rs @@ -2,6 +2,3 @@ pub mod contract; mod error; pub mod msg; pub mod state; - -#[cfg(all(target_arch = "wasm32", not(feature = "library")))] -cosmwasm_std::create_entry_points!(contract); diff --git a/contracts/cw3-fixed-multisig/src/contract.rs b/contracts/cw3-fixed-multisig/src/contract.rs index 9ee70018a..2eeb4fa89 100644 --- a/contracts/cw3-fixed-multisig/src/contract.rs +++ b/contracts/cw3-fixed-multisig/src/contract.rs @@ -1,8 +1,8 @@ use std::cmp::Ordering; use cosmwasm_std::{ - attr, to_binary, Binary, BlockInfo, CanonicalAddr, CosmosMsg, Deps, DepsMut, Empty, Env, - HumanAddr, MessageInfo, Order, Response, StdResult, + attr, entry_point, to_binary, Binary, BlockInfo, CanonicalAddr, CosmosMsg, Deps, DepsMut, + Empty, Env, HumanAddr, MessageInfo, Order, Response, StdResult, }; use cw0::{maybe_canonical, Expiration}; @@ -23,6 +23,7 @@ use crate::state::{ const CONTRACT_NAME: &str = "crates.io:cw3-fixed-multisig"; const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); +#[entry_point] pub fn instantiate( deps: DepsMut, _env: Env, @@ -58,6 +59,7 @@ pub fn instantiate( Ok(Response::default()) } +#[entry_point] pub fn execute( deps: DepsMut, env: Env, @@ -269,6 +271,7 @@ pub fn execute_close( }) } +#[entry_point] pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { match msg { QueryMsg::Threshold {} => to_binary(&query_threshold(deps)?), diff --git a/contracts/cw3-fixed-multisig/src/lib.rs b/contracts/cw3-fixed-multisig/src/lib.rs index f7494cbb8..f379f4b39 100644 --- a/contracts/cw3-fixed-multisig/src/lib.rs +++ b/contracts/cw3-fixed-multisig/src/lib.rs @@ -3,6 +3,3 @@ mod error; mod integration_tests; pub mod msg; pub mod state; - -#[cfg(all(target_arch = "wasm32", not(feature = "library")))] -cosmwasm_std::create_entry_points!(contract); diff --git a/contracts/cw3-flex-multisig/src/contract.rs b/contracts/cw3-flex-multisig/src/contract.rs index 6706b31d3..f75f1a107 100644 --- a/contracts/cw3-flex-multisig/src/contract.rs +++ b/contracts/cw3-flex-multisig/src/contract.rs @@ -1,8 +1,8 @@ use std::cmp::Ordering; use cosmwasm_std::{ - attr, to_binary, Binary, BlockInfo, CanonicalAddr, CosmosMsg, Deps, DepsMut, Empty, Env, - HumanAddr, MessageInfo, Order, Response, StdResult, + attr, entry_point, to_binary, Binary, BlockInfo, CanonicalAddr, CosmosMsg, Deps, DepsMut, + Empty, Env, HumanAddr, MessageInfo, Order, Response, StdResult, }; use cw0::{maybe_canonical, Expiration}; @@ -24,6 +24,7 @@ use crate::state::{ const CONTRACT_NAME: &str = "crates.io:cw3-flex-multisig"; const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); +#[entry_point] pub fn instantiate( deps: DepsMut, _env: Env, @@ -53,6 +54,7 @@ pub fn instantiate( Ok(Response::default()) } +#[entry_point] pub fn execute( deps: DepsMut, env: Env, @@ -280,6 +282,7 @@ pub fn execute_membership_hook( Ok(Response::default()) } +#[entry_point] pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { match msg { QueryMsg::Threshold {} => to_binary(&query_threshold(deps)?), diff --git a/contracts/cw3-flex-multisig/src/lib.rs b/contracts/cw3-flex-multisig/src/lib.rs index 33ecec4df..d78159fb8 100644 --- a/contracts/cw3-flex-multisig/src/lib.rs +++ b/contracts/cw3-flex-multisig/src/lib.rs @@ -2,6 +2,3 @@ pub mod contract; mod error; pub mod msg; pub mod state; - -#[cfg(all(target_arch = "wasm32", not(feature = "library")))] -cosmwasm_std::create_entry_points!(contract); diff --git a/contracts/cw4-group/src/contract.rs b/contracts/cw4-group/src/contract.rs index 8ed9b4656..2ee4fc3f1 100644 --- a/contracts/cw4-group/src/contract.rs +++ b/contracts/cw4-group/src/contract.rs @@ -1,6 +1,6 @@ use cosmwasm_std::{ - attr, to_binary, Binary, CanonicalAddr, Deps, DepsMut, Env, HumanAddr, MessageInfo, Order, - Response, StdResult, + attr, entry_point, to_binary, Binary, CanonicalAddr, Deps, DepsMut, Env, HumanAddr, + MessageInfo, Order, Response, StdResult, }; use cw0::maybe_canonical; use cw2::set_contract_version; @@ -20,6 +20,7 @@ const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); // Note, you can use StdResult in some functions where you do not // make use of the custom errors +#[entry_point] pub fn instantiate( deps: DepsMut, env: Env, @@ -53,6 +54,7 @@ pub fn create( } // And declare a custom Error variant for the ones where you will want to make use of it +#[entry_point] pub fn execute( deps: DepsMut, env: Env, @@ -134,6 +136,7 @@ pub fn update_members( Ok(MemberChangedHookMsg { diffs }) } +#[entry_point] pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { match msg { QueryMsg::Member { diff --git a/contracts/cw4-group/src/lib.rs b/contracts/cw4-group/src/lib.rs index 663735331..5a89a55b4 100644 --- a/contracts/cw4-group/src/lib.rs +++ b/contracts/cw4-group/src/lib.rs @@ -3,7 +3,3 @@ pub mod error; pub mod helpers; pub mod msg; pub mod state; - -// comment this out and use the lower form if the contract supports migrations -#[cfg(all(target_arch = "wasm32", not(feature = "library")))] -cosmwasm_std::create_entry_points!(contract); diff --git a/contracts/cw4-stake/src/contract.rs b/contracts/cw4-stake/src/contract.rs index b876dba49..3fcc7d831 100644 --- a/contracts/cw4-stake/src/contract.rs +++ b/contracts/cw4-stake/src/contract.rs @@ -1,6 +1,7 @@ use cosmwasm_std::{ - attr, coin, coins, to_binary, BankMsg, Binary, CanonicalAddr, Coin, CosmosMsg, Deps, DepsMut, - Env, HumanAddr, MessageInfo, Order, Response, StdError, StdResult, Storage, Uint128, + attr, coin, coins, entry_point, to_binary, BankMsg, Binary, CanonicalAddr, Coin, CosmosMsg, + Deps, DepsMut, Env, HumanAddr, MessageInfo, Order, Response, StdError, StdResult, Storage, + Uint128, }; use cw0::{maybe_canonical, NativeBalance}; @@ -22,6 +23,7 @@ const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); // Note, you can use StdResult in some functions where you do not // make use of the custom errors +#[entry_point] pub fn instantiate( mut deps: DepsMut, _env: Env, @@ -50,6 +52,7 @@ pub fn instantiate( } // And declare a custom Error variant for the ones where you will want to make use of it +#[entry_point] pub fn execute( deps: DepsMut, env: Env, @@ -270,6 +273,7 @@ fn coins_to_string(coins: &[Coin]) -> String { strings.join(",") } +#[entry_point] pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { match msg { QueryMsg::Member { diff --git a/contracts/cw4-stake/src/lib.rs b/contracts/cw4-stake/src/lib.rs index c6449a7dd..a5abdbb0f 100644 --- a/contracts/cw4-stake/src/lib.rs +++ b/contracts/cw4-stake/src/lib.rs @@ -2,7 +2,3 @@ pub mod contract; pub mod error; pub mod msg; pub mod state; - -// comment this out and use the lower form if the contract supports migrations -#[cfg(all(target_arch = "wasm32", not(feature = "library")))] -cosmwasm_std::create_entry_points!(contract); diff --git a/contracts/cw721-base/src/contract.rs b/contracts/cw721-base/src/contract.rs index 4e27e4875..e10da234c 100644 --- a/contracts/cw721-base/src/contract.rs +++ b/contracts/cw721-base/src/contract.rs @@ -1,6 +1,6 @@ use cosmwasm_std::{ - attr, to_binary, Api, Binary, BlockInfo, Deps, DepsMut, Env, HumanAddr, MessageInfo, Order, - Response, StdError, StdResult, KV, + attr, entry_point, to_binary, Api, Binary, BlockInfo, Deps, DepsMut, Env, HumanAddr, + MessageInfo, Order, Response, StdError, StdResult, KV, }; use cw0::maybe_canonical; @@ -21,6 +21,7 @@ use cw_storage_plus::{Bound, PkOwned}; const CONTRACT_NAME: &str = "crates.io:cw721-base"; const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); +#[entry_point] pub fn instantiate( deps: DepsMut, _env: Env, @@ -39,6 +40,7 @@ pub fn instantiate( Ok(Response::default()) } +#[entry_point] pub fn execute( deps: DepsMut, env: Env, @@ -381,6 +383,7 @@ fn check_can_send( } } +#[entry_point] pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { match msg { QueryMsg::Minter {} => to_binary(&query_minter(deps)?), diff --git a/contracts/cw721-base/src/lib.rs b/contracts/cw721-base/src/lib.rs index 33ecec4df..d78159fb8 100644 --- a/contracts/cw721-base/src/lib.rs +++ b/contracts/cw721-base/src/lib.rs @@ -2,6 +2,3 @@ pub mod contract; mod error; pub mod msg; pub mod state; - -#[cfg(all(target_arch = "wasm32", not(feature = "library")))] -cosmwasm_std::create_entry_points!(contract); From 49337672850f4fc91abd7ff24cc76bf554dc9a71 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Mon, 29 Mar 2021 12:21:29 +0200 Subject: [PATCH 2/4] Migrate cw20-base to entry_point macro --- contracts/cw20-base/src/contract.rs | 5 +++++ contracts/cw20-base/src/lib.rs | 3 --- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/contracts/cw20-base/src/contract.rs b/contracts/cw20-base/src/contract.rs index 1326e549e..2582ffef1 100644 --- a/contracts/cw20-base/src/contract.rs +++ b/contracts/cw20-base/src/contract.rs @@ -1,3 +1,5 @@ +#[cfg(not(feature = "library"))] +use cosmwasm_std::entry_point; use cosmwasm_std::{ attr, to_binary, Binary, Deps, DepsMut, Env, HumanAddr, MessageInfo, Response, StdError, StdResult, Uint128, @@ -19,6 +21,7 @@ use crate::state::{MinterData, TokenInfo, BALANCES, TOKEN_INFO}; const CONTRACT_NAME: &str = "crates.io:cw20-base"; const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); +#[cfg_attr(not(feature = "library"), entry_point)] pub fn instantiate( mut deps: DepsMut, _env: Env, @@ -67,6 +70,7 @@ pub fn create_accounts(deps: &mut DepsMut, accounts: &[Cw20CoinHuman]) -> StdRes Ok(total_supply) } +#[cfg_attr(not(feature = "library"), entry_point)] pub fn execute( deps: DepsMut, env: Env, @@ -279,6 +283,7 @@ pub fn execute_send( Ok(res) } +#[cfg_attr(not(feature = "library"), entry_point)] pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { match msg { QueryMsg::Balance { address } => to_binary(&query_balance(deps, address)?), diff --git a/contracts/cw20-base/src/lib.rs b/contracts/cw20-base/src/lib.rs index 5ddbf74a2..64e8019b6 100644 --- a/contracts/cw20-base/src/lib.rs +++ b/contracts/cw20-base/src/lib.rs @@ -6,6 +6,3 @@ pub mod msg; pub mod state; pub use crate::error::ContractError; - -#[cfg(all(target_arch = "wasm32", not(feature = "library")))] -cosmwasm_std::create_entry_points!(contract); From f1247914414ffc9ca7d622ff91672a4510cf2775 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Mon, 29 Mar 2021 12:28:23 +0200 Subject: [PATCH 3/4] Add `library` feature checks for `entry_point` --- contracts/cw1-subkeys/src/contract.rs | 12 +++++++----- contracts/cw20-atomic-swap/src/contract.rs | 12 +++++++----- contracts/cw20-bonding/src/contract.rs | 12 +++++++----- contracts/cw20-escrow/src/contract.rs | 12 +++++++----- contracts/cw20-ics20/src/contract.rs | 6 ++++-- contracts/cw20-staking/src/contract.rs | 12 +++++++----- contracts/cw3-fixed-multisig/src/contract.rs | 12 +++++++----- contracts/cw3-flex-multisig/src/contract.rs | 12 +++++++----- contracts/cw4-group/src/contract.rs | 12 +++++++----- contracts/cw4-stake/src/contract.rs | 13 +++++++------ contracts/cw721-base/src/contract.rs | 12 +++++++----- 11 files changed, 74 insertions(+), 53 deletions(-) diff --git a/contracts/cw1-subkeys/src/contract.rs b/contracts/cw1-subkeys/src/contract.rs index 241a5faaa..4da1f7bf9 100644 --- a/contracts/cw1-subkeys/src/contract.rs +++ b/contracts/cw1-subkeys/src/contract.rs @@ -2,9 +2,11 @@ use schemars::JsonSchema; use std::fmt; use std::ops::{AddAssign, Sub}; +#[cfg(not(feature = "library"))] +use cosmwasm_std::entry_point; use cosmwasm_std::{ - attr, entry_point, to_binary, BankMsg, Binary, CanonicalAddr, Coin, CosmosMsg, Deps, DepsMut, - Empty, Env, HumanAddr, MessageInfo, Order, Response, StakingMsg, StdError, StdResult, + attr, to_binary, BankMsg, Binary, CanonicalAddr, Coin, CosmosMsg, Deps, DepsMut, Empty, Env, + HumanAddr, MessageInfo, Order, Response, StakingMsg, StdError, StdResult, }; use cw0::{maybe_canonical, Expiration}; use cw1::CanExecuteResponse; @@ -30,7 +32,7 @@ use cw_storage_plus::Bound; const CONTRACT_NAME: &str = "crates.io:cw1-subkeys"; const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); -#[entry_point] +#[cfg_attr(not(feature = "library"), entry_point)] pub fn instantiate( mut deps: DepsMut, env: Env, @@ -42,7 +44,7 @@ pub fn instantiate( Ok(result) } -#[entry_point] +#[cfg_attr(not(feature = "library"), entry_point)] pub fn execute( deps: DepsMut, env: Env, @@ -285,7 +287,7 @@ where Ok(res) } -#[entry_point] +#[cfg_attr(not(feature = "library"), entry_point)] pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { match msg { QueryMsg::AdminList {} => to_binary(&query_admin_list(deps)?), diff --git a/contracts/cw20-atomic-swap/src/contract.rs b/contracts/cw20-atomic-swap/src/contract.rs index ac89d34ad..f5b5caa2c 100644 --- a/contracts/cw20-atomic-swap/src/contract.rs +++ b/contracts/cw20-atomic-swap/src/contract.rs @@ -1,6 +1,8 @@ +#[cfg(not(feature = "library"))] +use cosmwasm_std::entry_point; use cosmwasm_std::{ - attr, entry_point, from_binary, to_binary, Api, BankMsg, Binary, CosmosMsg, Deps, DepsMut, Env, - HumanAddr, MessageInfo, Response, StdResult, WasmMsg, + attr, from_binary, to_binary, Api, BankMsg, Binary, CosmosMsg, Deps, DepsMut, Env, HumanAddr, + MessageInfo, Response, StdResult, WasmMsg, }; use sha2::{Digest, Sha256}; @@ -19,7 +21,7 @@ use cw_storage_plus::Bound; const CONTRACT_NAME: &str = "crates.io:cw20-atomic-swap"; const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); -#[entry_point] +#[cfg_attr(not(feature = "library"), entry_point)] pub fn instantiate( deps: DepsMut, _env: Env, @@ -31,7 +33,7 @@ pub fn instantiate( Ok(Response::default()) } -#[entry_point] +#[cfg_attr(not(feature = "library"), entry_point)] pub fn execute( deps: DepsMut, env: Env, @@ -222,7 +224,7 @@ fn send_tokens(api: &dyn Api, to: &HumanAddr, amount: Balance) -> StdResult StdResult { match msg { QueryMsg::List { start_after, limit } => to_binary(&query_list(deps, start_after, limit)?), diff --git a/contracts/cw20-bonding/src/contract.rs b/contracts/cw20-bonding/src/contract.rs index 7c592597e..d6bf9ee5c 100644 --- a/contracts/cw20-bonding/src/contract.rs +++ b/contracts/cw20-bonding/src/contract.rs @@ -1,6 +1,8 @@ +#[cfg(not(feature = "library"))] +use cosmwasm_std::entry_point; use cosmwasm_std::{ - attr, coins, entry_point, to_binary, BankMsg, Binary, Deps, DepsMut, Env, HumanAddr, - MessageInfo, Response, StdResult, Uint128, + attr, coins, to_binary, BankMsg, Binary, Deps, DepsMut, Env, HumanAddr, MessageInfo, Response, + StdResult, Uint128, }; use cw2::set_contract_version; @@ -23,7 +25,7 @@ use cw0::{must_pay, nonpayable}; const CONTRACT_NAME: &str = "crates.io:cw20-bonding"; const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); -#[entry_point] +#[cfg_attr(not(feature = "library"), entry_point)] pub fn instantiate( deps: DepsMut, env: Env, @@ -56,7 +58,7 @@ pub fn instantiate( Ok(Response::default()) } -#[entry_point] +#[cfg_attr(not(feature = "library"), entry_point)] pub fn execute( deps: DepsMut, env: Env, @@ -256,7 +258,7 @@ fn do_sell( Ok(res) } -#[entry_point] +#[cfg_attr(not(feature = "library"), entry_point)] pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { // default implementation stores curve info as enum, you can do something else in a derived // contract and just pass in your custom curve to do_execute diff --git a/contracts/cw20-escrow/src/contract.rs b/contracts/cw20-escrow/src/contract.rs index 8f46cf7fc..0ee65d695 100644 --- a/contracts/cw20-escrow/src/contract.rs +++ b/contracts/cw20-escrow/src/contract.rs @@ -1,6 +1,8 @@ +#[cfg(not(feature = "library"))] +use cosmwasm_std::entry_point; use cosmwasm_std::{ - attr, entry_point, from_binary, to_binary, Api, BankMsg, Binary, CosmosMsg, Deps, DepsMut, Env, - HumanAddr, MessageInfo, Response, StdResult, WasmMsg, + attr, from_binary, to_binary, Api, BankMsg, Binary, CosmosMsg, Deps, DepsMut, Env, HumanAddr, + MessageInfo, Response, StdResult, WasmMsg, }; use cw2::set_contract_version; @@ -16,7 +18,7 @@ use crate::state::{all_escrow_ids, Escrow, GenericBalance, ESCROWS}; const CONTRACT_NAME: &str = "crates.io:cw20-escrow"; const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); -#[entry_point] +#[cfg_attr(not(feature = "library"), entry_point)] pub fn instantiate( deps: DepsMut, _env: Env, @@ -28,7 +30,7 @@ pub fn instantiate( Ok(Response::default()) } -#[entry_point] +#[cfg_attr(not(feature = "library"), entry_point)] pub fn execute( deps: DepsMut, env: Env, @@ -242,7 +244,7 @@ fn send_tokens( Ok(msgs) } -#[entry_point] +#[cfg_attr(not(feature = "library"), entry_point)] pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { match msg { QueryMsg::List {} => to_binary(&query_list(deps)?), diff --git a/contracts/cw20-ics20/src/contract.rs b/contracts/cw20-ics20/src/contract.rs index 2be1f3b4b..09333b2da 100644 --- a/contracts/cw20-ics20/src/contract.rs +++ b/contracts/cw20-ics20/src/contract.rs @@ -1,6 +1,8 @@ +#[cfg(not(feature = "library"))] +use cosmwasm_std::entry_point; use cosmwasm_std::{ - attr, entry_point, from_binary, to_binary, Binary, Deps, DepsMut, Env, HumanAddr, IbcMsg, - IbcQuery, MessageInfo, Order, PortIdResponse, Response, StdResult, + attr, from_binary, to_binary, Binary, Deps, DepsMut, Env, HumanAddr, IbcMsg, IbcQuery, + MessageInfo, Order, PortIdResponse, Response, StdResult, }; use cw2::{get_contract_version, set_contract_version}; diff --git a/contracts/cw20-staking/src/contract.rs b/contracts/cw20-staking/src/contract.rs index 2205ca355..8a08b01d1 100644 --- a/contracts/cw20-staking/src/contract.rs +++ b/contracts/cw20-staking/src/contract.rs @@ -1,6 +1,8 @@ +#[cfg(not(feature = "library"))] +use cosmwasm_std::entry_point; use cosmwasm_std::{ - attr, coin, entry_point, to_binary, BankMsg, Binary, Decimal, Deps, DepsMut, Env, HumanAddr, - MessageInfo, QuerierWrapper, Response, StakingMsg, StdError, StdResult, Uint128, WasmMsg, + attr, coin, to_binary, BankMsg, Binary, Decimal, Deps, DepsMut, Env, HumanAddr, MessageInfo, + QuerierWrapper, Response, StakingMsg, StdError, StdResult, Uint128, WasmMsg, }; use cw2::set_contract_version; @@ -23,7 +25,7 @@ const FALLBACK_RATIO: Decimal = Decimal::one(); const CONTRACT_NAME: &str = "crates.io:cw20-staking"; const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); -#[entry_point] +#[cfg_attr(not(feature = "library"), entry_point)] pub fn instantiate( deps: DepsMut, env: Env, @@ -72,7 +74,7 @@ pub fn instantiate( Ok(Response::default()) } -#[entry_point] +#[cfg_attr(not(feature = "library"), entry_point)] pub fn execute( deps: DepsMut, env: Env, @@ -412,7 +414,7 @@ pub fn _bond_all_tokens( Ok(res) } -#[entry_point] +#[cfg_attr(not(feature = "library"), entry_point)] pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { match msg { // custom queries diff --git a/contracts/cw3-fixed-multisig/src/contract.rs b/contracts/cw3-fixed-multisig/src/contract.rs index 2eeb4fa89..95c2dcb85 100644 --- a/contracts/cw3-fixed-multisig/src/contract.rs +++ b/contracts/cw3-fixed-multisig/src/contract.rs @@ -1,8 +1,10 @@ use std::cmp::Ordering; +#[cfg(not(feature = "library"))] +use cosmwasm_std::entry_point; use cosmwasm_std::{ - attr, entry_point, to_binary, Binary, BlockInfo, CanonicalAddr, CosmosMsg, Deps, DepsMut, - Empty, Env, HumanAddr, MessageInfo, Order, Response, StdResult, + attr, to_binary, Binary, BlockInfo, CanonicalAddr, CosmosMsg, Deps, DepsMut, Empty, Env, + HumanAddr, MessageInfo, Order, Response, StdResult, }; use cw0::{maybe_canonical, Expiration}; @@ -23,7 +25,7 @@ use crate::state::{ const CONTRACT_NAME: &str = "crates.io:cw3-fixed-multisig"; const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); -#[entry_point] +#[cfg_attr(not(feature = "library"), entry_point)] pub fn instantiate( deps: DepsMut, _env: Env, @@ -59,7 +61,7 @@ pub fn instantiate( Ok(Response::default()) } -#[entry_point] +#[cfg_attr(not(feature = "library"), entry_point)] pub fn execute( deps: DepsMut, env: Env, @@ -271,7 +273,7 @@ pub fn execute_close( }) } -#[entry_point] +#[cfg_attr(not(feature = "library"), entry_point)] pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { match msg { QueryMsg::Threshold {} => to_binary(&query_threshold(deps)?), diff --git a/contracts/cw3-flex-multisig/src/contract.rs b/contracts/cw3-flex-multisig/src/contract.rs index f75f1a107..8b2fb15dc 100644 --- a/contracts/cw3-flex-multisig/src/contract.rs +++ b/contracts/cw3-flex-multisig/src/contract.rs @@ -1,8 +1,10 @@ use std::cmp::Ordering; +#[cfg(not(feature = "library"))] +use cosmwasm_std::entry_point; use cosmwasm_std::{ - attr, entry_point, to_binary, Binary, BlockInfo, CanonicalAddr, CosmosMsg, Deps, DepsMut, - Empty, Env, HumanAddr, MessageInfo, Order, Response, StdResult, + attr, to_binary, Binary, BlockInfo, CanonicalAddr, CosmosMsg, Deps, DepsMut, Empty, Env, + HumanAddr, MessageInfo, Order, Response, StdResult, }; use cw0::{maybe_canonical, Expiration}; @@ -24,7 +26,7 @@ use crate::state::{ const CONTRACT_NAME: &str = "crates.io:cw3-flex-multisig"; const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); -#[entry_point] +#[cfg_attr(not(feature = "library"), entry_point)] pub fn instantiate( deps: DepsMut, _env: Env, @@ -54,7 +56,7 @@ pub fn instantiate( Ok(Response::default()) } -#[entry_point] +#[cfg_attr(not(feature = "library"), entry_point)] pub fn execute( deps: DepsMut, env: Env, @@ -282,7 +284,7 @@ pub fn execute_membership_hook( Ok(Response::default()) } -#[entry_point] +#[cfg_attr(not(feature = "library"), entry_point)] pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { match msg { QueryMsg::Threshold {} => to_binary(&query_threshold(deps)?), diff --git a/contracts/cw4-group/src/contract.rs b/contracts/cw4-group/src/contract.rs index 2ee4fc3f1..cdf0d2df1 100644 --- a/contracts/cw4-group/src/contract.rs +++ b/contracts/cw4-group/src/contract.rs @@ -1,6 +1,8 @@ +#[cfg(not(feature = "library"))] +use cosmwasm_std::entry_point; use cosmwasm_std::{ - attr, entry_point, to_binary, Binary, CanonicalAddr, Deps, DepsMut, Env, HumanAddr, - MessageInfo, Order, Response, StdResult, + attr, to_binary, Binary, CanonicalAddr, Deps, DepsMut, Env, HumanAddr, MessageInfo, Order, + Response, StdResult, }; use cw0::maybe_canonical; use cw2::set_contract_version; @@ -20,7 +22,7 @@ const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); // Note, you can use StdResult in some functions where you do not // make use of the custom errors -#[entry_point] +#[cfg_attr(not(feature = "library"), entry_point)] pub fn instantiate( deps: DepsMut, env: Env, @@ -54,7 +56,7 @@ pub fn create( } // And declare a custom Error variant for the ones where you will want to make use of it -#[entry_point] +#[cfg_attr(not(feature = "library"), entry_point)] pub fn execute( deps: DepsMut, env: Env, @@ -136,7 +138,7 @@ pub fn update_members( Ok(MemberChangedHookMsg { diffs }) } -#[entry_point] +#[cfg_attr(not(feature = "library"), entry_point)] pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { match msg { QueryMsg::Member { diff --git a/contracts/cw4-stake/src/contract.rs b/contracts/cw4-stake/src/contract.rs index 3fcc7d831..966ea64f4 100644 --- a/contracts/cw4-stake/src/contract.rs +++ b/contracts/cw4-stake/src/contract.rs @@ -1,7 +1,8 @@ +#[cfg(not(feature = "library"))] +use cosmwasm_std::entry_point; use cosmwasm_std::{ - attr, coin, coins, entry_point, to_binary, BankMsg, Binary, CanonicalAddr, Coin, CosmosMsg, - Deps, DepsMut, Env, HumanAddr, MessageInfo, Order, Response, StdError, StdResult, Storage, - Uint128, + attr, coin, coins, to_binary, BankMsg, Binary, CanonicalAddr, Coin, CosmosMsg, Deps, DepsMut, + Env, HumanAddr, MessageInfo, Order, Response, StdError, StdResult, Storage, Uint128, }; use cw0::{maybe_canonical, NativeBalance}; @@ -23,7 +24,7 @@ const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); // Note, you can use StdResult in some functions where you do not // make use of the custom errors -#[entry_point] +#[cfg_attr(not(feature = "library"), entry_point)] pub fn instantiate( mut deps: DepsMut, _env: Env, @@ -52,7 +53,7 @@ pub fn instantiate( } // And declare a custom Error variant for the ones where you will want to make use of it -#[entry_point] +#[cfg_attr(not(feature = "library"), entry_point)] pub fn execute( deps: DepsMut, env: Env, @@ -273,7 +274,7 @@ fn coins_to_string(coins: &[Coin]) -> String { strings.join(",") } -#[entry_point] +#[cfg_attr(not(feature = "library"), entry_point)] pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { match msg { QueryMsg::Member { diff --git a/contracts/cw721-base/src/contract.rs b/contracts/cw721-base/src/contract.rs index e10da234c..dc333a60e 100644 --- a/contracts/cw721-base/src/contract.rs +++ b/contracts/cw721-base/src/contract.rs @@ -1,6 +1,8 @@ +#[cfg(not(feature = "library"))] +use cosmwasm_std::entry_point; use cosmwasm_std::{ - attr, entry_point, to_binary, Api, Binary, BlockInfo, Deps, DepsMut, Env, HumanAddr, - MessageInfo, Order, Response, StdError, StdResult, KV, + attr, to_binary, Api, Binary, BlockInfo, Deps, DepsMut, Env, HumanAddr, MessageInfo, Order, + Response, StdError, StdResult, KV, }; use cw0::maybe_canonical; @@ -21,7 +23,7 @@ use cw_storage_plus::{Bound, PkOwned}; const CONTRACT_NAME: &str = "crates.io:cw721-base"; const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); -#[entry_point] +#[cfg_attr(not(feature = "library"), entry_point)] pub fn instantiate( deps: DepsMut, _env: Env, @@ -40,7 +42,7 @@ pub fn instantiate( Ok(Response::default()) } -#[entry_point] +#[cfg_attr(not(feature = "library"), entry_point)] pub fn execute( deps: DepsMut, env: Env, @@ -383,7 +385,7 @@ fn check_can_send( } } -#[entry_point] +#[cfg_attr(not(feature = "library"), entry_point)] pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { match msg { QueryMsg::Minter {} => to_binary(&query_minter(deps)?), From d7813f83783e2e127debbca35a41cb3a1ec6d15e Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Mon, 29 Mar 2021 18:04:47 +0200 Subject: [PATCH 4/4] Switch check_contract to v0.14.0-beta1 tag (rust 1.50.0 compatible) --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 02dcbbd37..6dec279c2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -834,7 +834,7 @@ jobs: # Uses --debug for compilation speed # FIXME: Change when `check_contract` (part of `cosmwasm-0.14.0`) is published #command: cargo install --debug --features iterator --example check_contract -- cosmwasm-vm - command: cargo install --debug --features iterator --git https://github.com/CosmWasm/cosmwasm --branch=main --example check_contract -- cosmwasm-vm + command: cargo install --debug --features iterator --git https://github.com/CosmWasm/cosmwasm --tag=v0.14.0-beta1 --example check_contract -- cosmwasm-vm - save_cache: paths: - /usr/local/cargo/registry