Skip to content

Commit

Permalink
Updated denom check on init
Browse files Browse the repository at this point in the history
  • Loading branch information
cyborgshead committed May 14, 2024
1 parent fc1a41a commit 8846b49
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{to_json_binary, Addr, Binary, Coin, Deps, DepsMut, Env, MessageInfo, Order, StdResult, Storage, Uint128, CosmosMsg, BankMsg, coins};
use cosmwasm_std::{to_json_binary, Addr, Binary, Coin, Deps, DepsMut, Env, MessageInfo, Order, StdResult, Storage, Uint128, CosmosMsg, BankMsg, coins, ensure};
use cw2::{get_contract_version, set_contract_version, ContractVersion};
use cyber_std::Response;
use cyber_std::{create_creat_thought_msg, Load, Trigger};
Expand Down Expand Up @@ -70,11 +70,12 @@ pub fn instantiate(
ROOT.save(deps.storage, &info.sender)?;
ALLOW_FAUCET.save(deps.storage, &false)?;

if info.funds.len() > 0 {
DENOM.save(deps.storage, &info.funds[0].denom)?;
} else {
DENOM.save(deps.storage, &"boot".to_string())?;
}
// denom which sent during instantiate is general denom for contract
ensure!(
info.funds.len() == 1,
ContractError::DenomSetError {}
);
DENOM.save(deps.storage, &info.funds[0].denom)?;

TOTAL_ISSUANCE.save(deps.storage, &0)?;
TOTAL_STAKE.save(deps.storage, &0)?;
Expand Down
3 changes: 3 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,7 @@ pub enum ContractError {

#[error("Thrown when metadata is invalid")]
MetadataError {},

#[error("Thrown when contract denom is not set based on instantiate message token")]
DenomSetError {},
}

0 comments on commit 8846b49

Please sign in to comment.