Skip to content

Commit

Permalink
Merge pull request #64 from neutron-org/releases/v0.4.6
Browse files Browse the repository at this point in the history
Releases: v0.4.6
  • Loading branch information
pr0n00gler authored Oct 18, 2023
2 parents 54592b0 + 6a564a8 commit 8afcc76
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea/
target/
artifacts/
artifacts/
contracts/.DS_Store
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ compile:
@./build_release.sh

check_contracts:
@cargo install cosmwasm-check
@cargo install cosmwasm-check --locked
@cosmwasm-check --available-capabilities iterator,staking,stargate,neutron artifacts/*.wasm

build: schema clippy test fmt compile check_contracts
2 changes: 1 addition & 1 deletion contracts/vesting-investors/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "vesting-investors"
version = "1.1.0"
version = "1.1.1"
authors = ["Neutron"]
edition = "2021"
description = "Vesting contract which provides queries to get the amount of tokens that are being held by user at certain height and allows to remove vesting accounts to the contract's owner."
Expand Down
2 changes: 1 addition & 1 deletion contracts/vesting-investors/schema/vesting-investors.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"contract_name": "vesting-investors",
"contract_version": "1.1.0",
"contract_version": "1.1.1",
"idl_version": "1.0.0",
"instantiate": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
12 changes: 10 additions & 2 deletions contracts/vesting-investors/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ use cosmwasm_std::{entry_point, Binary, Deps, DepsMut, Env, MessageInfo, Respons
use cw2::set_contract_version;
use vesting_base::builder::VestingBaseBuilder;
use vesting_base::error::ContractError;
use vesting_base::handlers::{execute as base_execute, query as base_query};
use vesting_base::msg::{ExecuteMsg, QueryMsg};
use vesting_base::handlers::{
execute as base_execute, migrate as base_migrate, query as base_query,
};
use vesting_base::msg::{ExecuteMsg, MigrateMsg, QueryMsg};

/// Contract name that is used for migration.
const CONTRACT_NAME: &str = "neutron-vesting-investors";
Expand Down Expand Up @@ -45,3 +47,9 @@ pub fn execute(
pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
base_query(deps, env, msg)
}

/// Exposes migrate function.
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn migrate(deps: DepsMut, env: Env, msg: MigrateMsg) -> Result<Response, ContractError> {
base_migrate(deps, env, msg)
}
2 changes: 1 addition & 1 deletion contracts/vesting-lti/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "vesting-lti"
version = "1.1.0"
version = "1.1.1"
authors = ["andrei.z@p2p.org"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion contracts/vesting-lti/schema/vesting-lti.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"contract_name": "vesting-lti",
"contract_version": "1.1.0",
"contract_version": "1.1.1",
"idl_version": "1.0.0",
"instantiate": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
9 changes: 8 additions & 1 deletion contracts/vesting-lti/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use crate::msg::InstantiateMsg;
use cosmwasm_std::{entry_point, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult};
use cw2::set_contract_version;
use vesting_base::msg::MigrateMsg;
use vesting_base::{
builder::VestingBaseBuilder,
error::ContractError,
handlers::{execute as base_execute, query as base_query},
handlers::{execute as base_execute, migrate as base_migrate, query as base_query},
msg::{ExecuteMsg, QueryMsg},
};

Expand Down Expand Up @@ -54,3 +55,9 @@ pub fn execute(
pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
base_query(deps, env, msg)
}

// Exposes migrate function.
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn migrate(deps: DepsMut, env: Env, msg: MigrateMsg) -> Result<Response, ContractError> {
base_migrate(deps, env, msg)
}
2 changes: 1 addition & 1 deletion packages/astroport/src/mock_querier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::asset::PairInfo;
use crate::factory::QueryMsg as FactoryQueryMsg;
use cw20::{BalanceResponse, Cw20QueryMsg, TokenInfoResponse};

/// mock_dependencies is a drop-in replacement for cosmwasm_std::testing::mock_dependencies
/// mock_dependencies is a drop-in replacement for cosmwasm_std::tests::mock_dependencies
/// This uses the Astroport CustomQuerier.
pub fn mock_dependencies(
contract_balance: &[Coin],
Expand Down
3 changes: 3 additions & 0 deletions packages/vesting-base/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ pub enum ContractError {

#[error("Vesting token is not set!")]
VestingTokenIsNotSet {},

#[error("Vesting token is already set!")]
VestingTokenAlreadySet {},
}

impl From<OverflowError> for ContractError {
Expand Down
14 changes: 11 additions & 3 deletions packages/vesting-base/src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,19 @@ pub(crate) fn set_vesting_token(
if info.sender != config.owner && info.sender != config.token_info_manager {
return Err(ContractError::Unauthorized {});
}
token.check(deps.api)?;
config.vesting_token = Some(token);
if config.vesting_token.is_some() {
return Err(ContractError::VestingTokenAlreadySet {});
}

token.check(deps.api)?;
config.vesting_token = Some(token.clone());
CONFIG.save(deps.storage, &config)?;
Ok(Response::new())

let response = Response::new();
Ok(response.add_attributes(vec![
attr("action", "set_vesting_token"),
attr("vesting_token", token.to_string()),
]))
}

pub(crate) fn get_vesting_token(config: &Config) -> Result<AssetInfo, ContractError> {
Expand Down
31 changes: 30 additions & 1 deletion packages/vesting-base/src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,42 @@ fn set_vesting_token() {
execute(
deps.as_mut(),
env.clone(),
info,
info.clone(),
ExecuteMsg::SetVestingToken {
vesting_token: token_asset_info(Addr::unchecked("ntrn_token")),
},
)
.unwrap();

assert_eq!(
from_binary::<Config>(&query(deps.as_ref(), env.clone(), QueryMsg::Config {}).unwrap())
.unwrap(),
Config {
owner: Addr::unchecked("owner"),
token_info_manager: Addr::unchecked(token_info_manager),
vesting_token: Some(token_asset_info(Addr::unchecked("ntrn_token"))),
extensions: Extensions {
historical: false,
managed: false,
with_managers: false
}
}
);

// set vesting token second time by the owner -> VestingTokenAlreadySet
assert_eq!(
execute(
deps.as_mut(),
env.clone(),
info,
ExecuteMsg::SetVestingToken {
vesting_token: token_asset_info(Addr::unchecked("not_a_ntrn_token")),
},
)
.unwrap_err(),
ContractError::VestingTokenAlreadySet {},
);

assert_eq!(
from_binary::<Config>(&query(deps.as_ref(), env, QueryMsg::Config {}).unwrap()).unwrap(),
Config {
Expand Down

0 comments on commit 8afcc76

Please sign in to comment.