Skip to content

Commit b309a44

Browse files
committed
Update tier calculation logic
1 parent 360bf33 commit b309a44

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

contracts/fair-burn/src/contract.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
use cosmwasm_std::{ensure, to_json_binary, Addr, BankMsg, Binary, Coin, Deps, DepsMut, Empty, Env, Event, MessageInfo, StdResult};
1+
use cosmwasm_std::{
2+
ensure, to_json_binary, Addr, BankMsg, Binary, Coin, Deps, DepsMut, Empty, Env, Event,
3+
MessageInfo, StdResult,
4+
};
25
use cw2::{get_contract_version, set_contract_version};
36
use cw_utils::{maybe_addr, NativeBalance};
47
use sg_std::{create_fund_fairburn_pool_msg, Response, NATIVE_DENOM};

contracts/vip/minter/src/contract.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::env;
44
use cosmwasm_std::entry_point;
55
use cosmwasm_std::{
66
ensure, instantiate2_address, to_json_binary, Addr, Binary, CodeInfoResponse, Deps, DepsMut,
7-
Env, Event, MessageInfo, Response, StdError, StdResult, Timestamp, Uint128, WasmMsg,
7+
Empty, Env, Event, MessageInfo, Response, StdError, StdResult, Timestamp, Uint128, WasmMsg,
88
};
99
use cw2::set_contract_version;
1010
use cw721::{AllNftInfoResponse, TokensResponse};
@@ -159,7 +159,7 @@ pub fn mint(
159159
let index = tiers
160160
.iter()
161161
.position(|&x| x >= staked_amount)
162-
.unwrap_or(tiers.len());
162+
.unwrap_or(tiers.len().saturating_sub(1));
163163
let base_uri = BASE_URI.load(deps.storage)?;
164164
let token_uri = Some(format!("{}/{}", base_uri, index));
165165

@@ -202,7 +202,8 @@ pub fn update(
202202
let index = tiers
203203
.iter()
204204
.position(|&x| x >= staked_amount)
205-
.unwrap_or(tiers.len());
205+
.unwrap_or(tiers.len().saturating_sub(1));
206+
206207
let base_uri = BASE_URI.load(deps.storage)?;
207208
let token_uri = Some(format!("{}/{}", base_uri, index));
208209

@@ -330,7 +331,7 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
330331
let index = tiers
331332
.iter()
332333
.position(|&x| x >= staked_amount)
333-
.unwrap_or(tiers.len());
334+
.unwrap_or(tiers.len().saturating_sub(1));
334335

335336
Ok(to_json_binary(&TierResponse {
336337
tier: Some(index as u64),
@@ -362,5 +363,11 @@ pub fn fetch_token_id_for_address(deps: Deps, address: String) -> StdResult<Opti
362363
Ok(token_id)
363364
}
364365

366+
#[cfg_attr(not(feature = "library"), entry_point)]
367+
pub fn migrate(deps: DepsMut, _env: Env, _msg: Empty) -> Result<sg_std::Response, ContractError> {
368+
set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;
369+
Ok(Response::new())
370+
}
371+
365372
#[cfg(test)]
366373
mod tests {}

0 commit comments

Comments
 (0)