Skip to content

Commit

Permalink
Use cw2::set_contract_version in tfi-factory and tfi-pair
Browse files Browse the repository at this point in the history
  • Loading branch information
ueco-jb committed Dec 14, 2021
1 parent 4501321 commit ba5f250
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions contracts/tfi-factory/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ backtraces = ["cosmwasm-std/backtraces"]
[dependencies]
tfi = { path = "../../packages/tfi", default-features = false, version = "0.2.2"}
cosmwasm-std = "=1.0.0-beta"
cw2 = "=0.10"
cw-storage-plus = "=0.10"
schemars = "0.8.1"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
Expand Down
6 changes: 6 additions & 0 deletions contracts/tfi-factory/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use cosmwasm_std::{
to_binary, Binary, Decimal, Deps, DepsMut, Env, MessageInfo, Reply, Response, StdError,
StdResult, SubMsg, WasmMsg,
};
use cw2::set_contract_version;

use crate::error::ContractError;
use crate::querier::query_liquidity_token;
Expand All @@ -17,13 +18,18 @@ use tfi::factory::{
};
use tfi::pair::InstantiateMsg as PairInstantiateMsg;

// version info for migration info
const CONTRACT_NAME: &str = "crates.io:tfi-factory";
const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn instantiate(
deps: DepsMut,
_env: Env,
info: MessageInfo,
msg: InstantiateMsg,
) -> Result<Response, ContractError> {
set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;
if !(Decimal::zero()..=Decimal::one()).contains(&msg.default_commission) {
return Err(ContractError::InvalidCommission(msg.default_commission));
}
Expand Down
6 changes: 6 additions & 0 deletions contracts/tfi-pair/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use cosmwasm_std::{
Response, StdError, StdResult, SubMsg, Uint128, WasmMsg,
};

use cw2::set_contract_version;
use cw20::{Cw20ExecuteMsg, Cw20ReceiveMsg, MinterResponse};
use integer_sqrt::IntegerSquareRoot;
use tfi::asset::{Asset, AssetInfo, PairInfo};
Expand All @@ -20,13 +21,18 @@ use tfi::pair::{
use tfi::querier::query_supply;
use tfi::token::InstantiateMsg as TokenInstantiateMsg;

// version info for migration info
const CONTRACT_NAME: &str = "crates.io:tfi-pair";
const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn instantiate(
deps: DepsMut,
env: Env,
_info: MessageInfo,
msg: InstantiateMsg,
) -> Result<Response, ContractError> {
set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;
if !(Decimal::zero()..=Decimal::one()).contains(&msg.commission) {
return Err(ContractError::InvalidCommission(msg.commission));
}
Expand Down

0 comments on commit ba5f250

Please sign in to comment.