Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to entry_point macro #249

Merged
merged 4 commits into from
Mar 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

- save_cache:
paths:
- /usr/local/cargo/registry
Expand Down
5 changes: 5 additions & 0 deletions contracts/cw1-subkeys/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use schemars::JsonSchema;
use std::fmt;
use std::ops::{AddAssign, Sub};

#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{
attr, to_binary, BankMsg, Binary, CanonicalAddr, Coin, CosmosMsg, Deps, DepsMut, Empty, Env,
HumanAddr, MessageInfo, Order, Response, StakingMsg, StdError, StdResult,
Expand Down Expand Up @@ -30,6 +32,7 @@ use cw_storage_plus::Bound;
const CONTRACT_NAME: &str = "crates.io:cw1-subkeys";
const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn instantiate(
mut deps: DepsMut,
env: Env,
Expand All @@ -41,6 +44,7 @@ pub fn instantiate(
Ok(result)
}

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn execute(
deps: DepsMut,
env: Env,
Expand Down Expand Up @@ -283,6 +287,7 @@ where
Ok(res)
}

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::AdminList {} => to_binary(&query_admin_list(deps)?),
Expand Down
3 changes: 0 additions & 3 deletions contracts/cw1-subkeys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
6 changes: 6 additions & 0 deletions contracts/cw1-whitelist/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
use schemars::JsonSchema;
use std::fmt;

#[cfg(not(feature = "library"))]
maurolacy marked this conversation as resolved.
Show resolved Hide resolved
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;

Expand All @@ -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)]
maurolacy marked this conversation as resolved.
Show resolved Hide resolved
pub fn instantiate(
deps: DepsMut,
_env: Env,
Expand All @@ -42,6 +46,7 @@ fn map_human(api: &dyn Api, admins: &[CanonicalAddr]) -> StdResult<Vec<HumanAddr
admins.iter().map(|addr| api.human_address(addr)).collect()
}

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn execute(
deps: DepsMut,
env: Env,
Expand Down Expand Up @@ -119,6 +124,7 @@ fn can_execute(deps: Deps, sender: &HumanAddr) -> StdResult<bool> {
Ok(can)
}

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::AdminList {} => to_binary(&query_admin_list(deps)?),
Expand Down
3 changes: 0 additions & 3 deletions contracts/cw1-whitelist/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
5 changes: 5 additions & 0 deletions contracts/cw20-atomic-swap/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{
attr, from_binary, to_binary, Api, BankMsg, Binary, CosmosMsg, Deps, DepsMut, Env, HumanAddr,
MessageInfo, Response, StdResult, WasmMsg,
Expand All @@ -19,6 +21,7 @@ use cw_storage_plus::Bound;
const CONTRACT_NAME: &str = "crates.io:cw20-atomic-swap";
const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn instantiate(
deps: DepsMut,
_env: Env,
Expand All @@ -30,6 +33,7 @@ pub fn instantiate(
Ok(Response::default())
}

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn execute(
deps: DepsMut,
env: Env,
Expand Down Expand Up @@ -220,6 +224,7 @@ fn send_tokens(api: &dyn Api, to: &HumanAddr, amount: Balance) -> StdResult<Vec<
}
}

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::List { start_after, limit } => to_binary(&query_list(deps, start_after, limit)?),
Expand Down
3 changes: 0 additions & 3 deletions contracts/cw20-atomic-swap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
5 changes: 5 additions & 0 deletions contracts/cw20-base/src/contract.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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<Binary> {
match msg {
QueryMsg::Balance { address } => to_binary(&query_balance(deps, address)?),
Expand Down
3 changes: 0 additions & 3 deletions contracts/cw20-base/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
5 changes: 5 additions & 0 deletions contracts/cw20-bonding/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{
attr, coins, to_binary, BankMsg, Binary, Deps, DepsMut, Env, HumanAddr, MessageInfo, Response,
StdResult, Uint128,
Expand All @@ -23,6 +25,7 @@ use cw0::{must_pay, nonpayable};
const CONTRACT_NAME: &str = "crates.io:cw20-bonding";
const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn instantiate(
deps: DepsMut,
env: Env,
Expand Down Expand Up @@ -55,6 +58,7 @@ pub fn instantiate(
Ok(Response::default())
}

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn execute(
deps: DepsMut,
env: Env,
Expand Down Expand Up @@ -254,6 +258,7 @@ fn do_sell(
Ok(res)
}

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
// 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
Expand Down
3 changes: 0 additions & 3 deletions contracts/cw20-bonding/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
5 changes: 5 additions & 0 deletions contracts/cw20-escrow/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{
attr, from_binary, to_binary, Api, BankMsg, Binary, CosmosMsg, Deps, DepsMut, Env, HumanAddr,
MessageInfo, Response, StdResult, WasmMsg,
Expand All @@ -16,6 +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");

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn instantiate(
deps: DepsMut,
_env: Env,
Expand All @@ -27,6 +30,7 @@ pub fn instantiate(
Ok(Response::default())
}

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn execute(
deps: DepsMut,
env: Env,
Expand Down Expand Up @@ -240,6 +244,7 @@ fn send_tokens(
Ok(msgs)
}

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::List {} => to_binary(&query_list(deps)?),
Expand Down
3 changes: 0 additions & 3 deletions contracts/cw20-escrow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
6 changes: 4 additions & 2 deletions contracts/cw20-ics20/src/contract.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
5 changes: 5 additions & 0 deletions contracts/cw20-staking/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{
attr, coin, to_binary, BankMsg, Binary, Decimal, Deps, DepsMut, Env, HumanAddr, MessageInfo,
QuerierWrapper, Response, StakingMsg, StdError, StdResult, Uint128, WasmMsg,
Expand All @@ -23,6 +25,7 @@ const FALLBACK_RATIO: Decimal = Decimal::one();
const CONTRACT_NAME: &str = "crates.io:cw20-staking";
const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn instantiate(
deps: DepsMut,
env: Env,
Expand Down Expand Up @@ -71,6 +74,7 @@ pub fn instantiate(
Ok(Response::default())
}

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn execute(
deps: DepsMut,
env: Env,
Expand Down Expand Up @@ -410,6 +414,7 @@ pub fn _bond_all_tokens(
Ok(res)
}

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
// custom queries
Expand Down
3 changes: 0 additions & 3 deletions contracts/cw20-staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
5 changes: 5 additions & 0 deletions contracts/cw3-fixed-multisig/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::cmp::Ordering;

#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{
attr, to_binary, Binary, BlockInfo, CanonicalAddr, CosmosMsg, Deps, DepsMut, Empty, Env,
HumanAddr, MessageInfo, Order, Response, StdResult,
Expand All @@ -23,6 +25,7 @@ use crate::state::{
const CONTRACT_NAME: &str = "crates.io:cw3-fixed-multisig";
const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn instantiate(
deps: DepsMut,
_env: Env,
Expand Down Expand Up @@ -58,6 +61,7 @@ pub fn instantiate(
Ok(Response::default())
}

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn execute(
deps: DepsMut,
env: Env,
Expand Down Expand Up @@ -269,6 +273,7 @@ pub fn execute_close(
})
}

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::Threshold {} => to_binary(&query_threshold(deps)?),
Expand Down
3 changes: 0 additions & 3 deletions contracts/cw3-fixed-multisig/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
5 changes: 5 additions & 0 deletions contracts/cw3-flex-multisig/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::cmp::Ordering;

#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{
attr, to_binary, Binary, BlockInfo, CanonicalAddr, CosmosMsg, Deps, DepsMut, Empty, Env,
HumanAddr, MessageInfo, Order, Response, StdResult,
Expand All @@ -24,6 +26,7 @@ use crate::state::{
const CONTRACT_NAME: &str = "crates.io:cw3-flex-multisig";
const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn instantiate(
deps: DepsMut,
_env: Env,
Expand Down Expand Up @@ -53,6 +56,7 @@ pub fn instantiate(
Ok(Response::default())
}

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn execute(
deps: DepsMut,
env: Env,
Expand Down Expand Up @@ -280,6 +284,7 @@ pub fn execute_membership_hook(
Ok(Response::default())
}

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::Threshold {} => to_binary(&query_threshold(deps)?),
Expand Down
3 changes: 0 additions & 3 deletions contracts/cw3-flex-multisig/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
5 changes: 5 additions & 0 deletions contracts/cw4-group/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{
attr, to_binary, Binary, CanonicalAddr, Deps, DepsMut, Env, HumanAddr, MessageInfo, Order,
Response, StdResult,
Expand All @@ -20,6 +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
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn instantiate(
deps: DepsMut,
env: Env,
Expand Down Expand Up @@ -53,6 +56,7 @@ pub fn create(
}

// And declare a custom Error variant for the ones where you will want to make use of it
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn execute(
deps: DepsMut,
env: Env,
Expand Down Expand Up @@ -134,6 +138,7 @@ pub fn update_members(
Ok(MemberChangedHookMsg { diffs })
}

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::Member {
Expand Down
Loading