@@ -4,7 +4,7 @@ use std::env;
4
4
use cosmwasm_std:: entry_point;
5
5
use cosmwasm_std:: {
6
6
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 ,
8
8
} ;
9
9
use cw2:: set_contract_version;
10
10
use cw721:: { AllNftInfoResponse , TokensResponse } ;
@@ -159,7 +159,7 @@ pub fn mint(
159
159
let index = tiers
160
160
. iter ( )
161
161
. position ( |& x| x >= staked_amount)
162
- . unwrap_or ( tiers. len ( ) ) ;
162
+ . unwrap_or ( tiers. len ( ) . saturating_sub ( 1 ) ) ;
163
163
let base_uri = BASE_URI . load ( deps. storage ) ?;
164
164
let token_uri = Some ( format ! ( "{}/{}" , base_uri, index) ) ;
165
165
@@ -202,7 +202,8 @@ pub fn update(
202
202
let index = tiers
203
203
. iter ( )
204
204
. position ( |& x| x >= staked_amount)
205
- . unwrap_or ( tiers. len ( ) ) ;
205
+ . unwrap_or ( tiers. len ( ) . saturating_sub ( 1 ) ) ;
206
+
206
207
let base_uri = BASE_URI . load ( deps. storage ) ?;
207
208
let token_uri = Some ( format ! ( "{}/{}" , base_uri, index) ) ;
208
209
@@ -330,7 +331,7 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
330
331
let index = tiers
331
332
. iter ( )
332
333
. position ( |& x| x >= staked_amount)
333
- . unwrap_or ( tiers. len ( ) ) ;
334
+ . unwrap_or ( tiers. len ( ) . saturating_sub ( 1 ) ) ;
334
335
335
336
Ok ( to_json_binary ( & TierResponse {
336
337
tier : Some ( index as u64 ) ,
@@ -362,5 +363,11 @@ pub fn fetch_token_id_for_address(deps: Deps, address: String) -> StdResult<Opti
362
363
Ok ( token_id)
363
364
}
364
365
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
+
365
372
#[ cfg( test) ]
366
373
mod tests { }
0 commit comments