diff --git a/artifacts/checksums.txt b/artifacts/checksums.txt index 2af61c4..5b167ba 100644 --- a/artifacts/checksums.txt +++ b/artifacts/checksums.txt @@ -5,4 +5,4 @@ ec6cc298bf32cad7f5f426002fdcee602b133f24f6f7d65905c5aad0e3b777c9 incentives.was d2dfc9ed4a689a8b23b020421c7e3fc0a90fd985c1291a44659073cc9021bb38 nibi_stargate.wasm bbb9c32c863ff78366ac5bae241967b206a6ad463e0154e7081309ab36904dce pricefeed.wasm 8014645275544b90c2ae33002e30c6cce6859dcd1193a48c599bedf4fb1015e3 shifter.wasm -0e4db7a116f27db4973e46db4a9cdd60abde1fb3e0dfeb7b1d5d9197c788229b token_vesting.wasm +27b401ca6e918bec98ec1e8e98dcb9f4de25191e1a53c34c4ceae6d4847b3b31 token_vesting.wasm diff --git a/artifacts/checksums_intermediate.txt b/artifacts/checksums_intermediate.txt index 326fdc4..c555ac0 100644 --- a/artifacts/checksums_intermediate.txt +++ b/artifacts/checksums_intermediate.txt @@ -5,4 +5,4 @@ f95b4a566d319f6cf39de88d168c19134bdff3864916c48c71a9a7f2d4474ee2 target/wasm32- 516fc6e8ca410041834e807cfed96478b51805d5c112bdd520bfd32e0f55eb4b target/wasm32-unknown-unknown/release/controller.wasm ae4e6405de49a97cde63c7d8abb88a77b8dcb8211759dc22ecab61b8e98f8519 target/wasm32-unknown-unknown/release/nibi_stargate.wasm 4a9bc648eaa78b691e286108dcf57111b1325c8df4c59366532b19cf80bac782 target/wasm32-unknown-unknown/release/shifter.wasm -b457a863837b7f4e93a322e9cc90887bd6b6d51f88efd0be50d9d52ee5a8c2d0 target/wasm32-unknown-unknown/release/token_vesting.wasm +f781a92390f4b89086310d79f20d9c81ce0aaa8865fb5811150244db483785f5 target/wasm32-unknown-unknown/release/token_vesting.wasm diff --git a/artifacts/token_vesting.wasm b/artifacts/token_vesting.wasm index 6ce1cc6..4d1ddc3 100644 Binary files a/artifacts/token_vesting.wasm and b/artifacts/token_vesting.wasm differ diff --git a/contracts/token-vesting/src/msg.rs b/contracts/token-vesting/src/msg.rs index c5c5c0d..8b9bc78 100644 --- a/contracts/token-vesting/src/msg.rs +++ b/contracts/token-vesting/src/msg.rs @@ -253,6 +253,15 @@ impl VestingSchedule { }); } + if vesting_amount != deposit_amount { + return Err( + VestingError::MismatchedVestingAndDepositAmount { + vesting_amount: vesting_amount.u128(), + deposit_amount: deposit_amount.u128(), + }, + ); + } + let cliff = Cliff { amount: *cliff_amount, time: *cliff_time, diff --git a/contracts/token-vesting/src/testing.rs b/contracts/token-vesting/src/testing.rs index dfcff73..8cd2a2b 100644 --- a/contracts/token-vesting/src/testing.rs +++ b/contracts/token-vesting/src/testing.rs @@ -7,6 +7,7 @@ use crate::msg::{ }; use cosmwasm_std::testing::{MockApi, MockQuerier, MockStorage}; +use cosmwasm_std::MessageInfo; use cosmwasm_std::{ from_binary, testing::{mock_dependencies, mock_env, mock_info}, @@ -64,6 +65,7 @@ fn register_cliff_vesting_account_with_native_token() -> TestResult { require_error( &mut deps, &env, + mock_info("addr0000", &[Coin::new(0u128, "uusd")]), msg, ContractError::Vesting(VestingError::ZeroVestingAmount), ); @@ -73,6 +75,7 @@ fn register_cliff_vesting_account_with_native_token() -> TestResult { require_error( &mut deps, &env, + mock_info("addr0000", &[Coin::new(1000u128, "uusd")]), msg, ContractError::Vesting(VestingError::Cliff(CliffError::ZeroAmount)), ); @@ -82,6 +85,7 @@ fn register_cliff_vesting_account_with_native_token() -> TestResult { require_error( &mut deps, &env, + mock_info("addr0000", &[Coin::new(1000u128, "uusd")]), msg, ContractError::Vesting(VestingError::Cliff(CliffError::InvalidTime { cliff_time: 99, @@ -94,6 +98,7 @@ fn register_cliff_vesting_account_with_native_token() -> TestResult { require_error( &mut deps, &env, + mock_info("addr0000", &[Coin::new(1000u128, "uusd")]), msg, ContractError::Vesting(VestingError::InvalidTimeRange { start_time: 110, @@ -106,6 +111,7 @@ fn register_cliff_vesting_account_with_native_token() -> TestResult { require_error( &mut deps, &env, + mock_info("addr0000", &[Coin::new(1000u128, "uusd")]), msg, ContractError::Vesting(VestingError::StartBeforeBlockTime { start_time: 99, @@ -119,6 +125,7 @@ fn register_cliff_vesting_account_with_native_token() -> TestResult { require_error( &mut deps, &env, + mock_info("addr0000", &[Coin::new(1000u128, "uusd")]), msg, ContractError::Vesting( CliffError::ExcessiveAmount { @@ -128,16 +135,34 @@ fn register_cliff_vesting_account_with_native_token() -> TestResult { .into(), ), ); + + // deposit amount different than vesting amount + let (vesting_amount, cliff_amount, cliff_time) = (1000, 250, 105); + let msg = create_msg(100, 110, vesting_amount, cliff_amount, cliff_time); + require_error( + &mut deps, + &env, + mock_info("addr0000", &[Coin::new(999u128, "uusd")]), + msg, + ContractError::Vesting( + VestingError::MismatchedVestingAndDepositAmount { + vesting_amount: 1000u128, + deposit_amount: 999u128, + } + .into(), + ), + ); + Ok(()) } fn require_error( deps: &mut OwnedDeps, env: &Env, + info: MessageInfo, msg: ExecuteMsg, expected_error: ContractError, ) { - let info = mock_info("addr0000", &[Coin::new(0u128, "uusd")]); let res = execute(deps.as_mut(), env.clone(), info, msg); match res { Err(err) => { @@ -173,6 +198,7 @@ fn register_vesting_account_with_native_token() -> TestResult { require_error( &mut deps, &env, + mock_info("addr0000", &[Coin::new(0u128, "uusd")]), msg, ContractError::Vesting(VestingError::ZeroVestingAmount), );