Skip to content

Commit

Permalink
Merge pull request #91 from public-awesome/yubrew/90-reduce-u64-to-u32
Browse files Browse the repository at this point in the history
Yubrew/90-reduce-u64-to-u32
  • Loading branch information
shanev authored Mar 1, 2022
2 parents 816358d + 7c6acae commit 3239272
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions contracts/minter/schema/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"integer",
"null"
],
"format": "uint64",
"format": "uint32",
"minimum": 0.0
},
"num_tokens": {
Expand All @@ -34,7 +34,7 @@
"integer",
"null"
],
"format": "uint64",
"format": "uint32",
"minimum": 0.0
},
"sg721_code_id": {
Expand Down
4 changes: 2 additions & 2 deletions contracts/minter/schema/config_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"integer",
"null"
],
"format": "uint64",
"format": "uint32",
"minimum": 0.0
},
"num_tokens": {
Expand All @@ -35,7 +35,7 @@
"integer",
"null"
],
"format": "uint64",
"format": "uint32",
"minimum": 0.0
},
"sg721_address": {
Expand Down
6 changes: 3 additions & 3 deletions contracts/minter/schema/execute_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"properties": {
"per_address_limit": {
"type": "integer",
"format": "uint64",
"format": "uint32",
"minimum": 0.0
}
}
Expand All @@ -82,7 +82,7 @@
"properties": {
"batch_mint_limit": {
"type": "integer",
"format": "uint64",
"format": "uint32",
"minimum": 0.0
}
}
Expand Down Expand Up @@ -150,7 +150,7 @@
"properties": {
"num_mints": {
"type": "integer",
"format": "uint64",
"format": "uint32",
"minimum": 0.0
}
}
Expand Down
4 changes: 2 additions & 2 deletions contracts/minter/schema/instantiate_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"integer",
"null"
],
"format": "uint64",
"format": "uint32",
"minimum": 0.0
},
"num_tokens": {
Expand All @@ -31,7 +31,7 @@
"integer",
"null"
],
"format": "uint64",
"format": "uint32",
"minimum": 0.0
},
"sg721_code_id": {
Expand Down
22 changes: 11 additions & 11 deletions contracts/minter/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ const INSTANTIATE_SG721_REPLY_ID: u64 = 1;

// governance parameters
const MAX_TOKEN_LIMIT: u32 = 10000;
const MAX_PER_ADDRESS_LIMIT: u64 = 30;
const MAX_BATCH_MINT_LIMIT: u64 = 30;
const STARTING_BATCH_MINT_LIMIT: u64 = 5;
const STARTING_PER_ADDRESS_LIMIT: u64 = 5;
const MAX_PER_ADDRESS_LIMIT: u32 = 30;
const MAX_BATCH_MINT_LIMIT: u32 = 30;
const STARTING_BATCH_MINT_LIMIT: u32 = 5;
const STARTING_PER_ADDRESS_LIMIT: u32 = 5;
const MIN_MINT_PRICE: u128 = 50_000_000;
const MINT_FEE_PERCENT: u64 = 10;
const MINT_FEE_PERCENT: u32 = 10;

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn instantiate(
Expand Down Expand Up @@ -96,10 +96,10 @@ pub fn instantiate(
}

// Initially set batch_mint_limit if no msg
let batch_mint_limit: Option<u64> = msg.batch_mint_limit.or(Some(STARTING_BATCH_MINT_LIMIT));
let batch_mint_limit: Option<u32> = msg.batch_mint_limit.or(Some(STARTING_BATCH_MINT_LIMIT));

// Initially set per_address_limit if no msg
let per_address_limit: Option<u64> = msg.per_address_limit.or(Some(STARTING_PER_ADDRESS_LIMIT));
let per_address_limit: Option<u32> = msg.per_address_limit.or(Some(STARTING_PER_ADDRESS_LIMIT));

let whitelist_addr: Option<Addr> = match msg.whitelist {
Some(wl) => Some(deps.api.addr_validate(&wl)?),
Expand Down Expand Up @@ -341,7 +341,7 @@ pub fn execute_batch_mint(
deps: DepsMut,
env: Env,
_info: MessageInfo,
num_mints: u64,
num_mints: u32,
) -> Result<Response, ContractError> {
let config = CONFIG.load(deps.storage)?;
let mint_limit = config
Expand Down Expand Up @@ -419,7 +419,7 @@ fn _execute_mint(
let network_fee: Uint128 = if admin_no_fee {
Uint128::zero()
} else {
let fee_percent = Decimal::percent(MINT_FEE_PERCENT);
let fee_percent = Decimal::percent(MINT_FEE_PERCENT as u64);
let network_fee = mint_price.amount * fee_percent;
msgs.append(&mut burn_and_distribute_fee(
env,
Expand Down Expand Up @@ -523,7 +523,7 @@ pub fn execute_update_per_address_limit(
deps: DepsMut,
_env: Env,
info: MessageInfo,
per_address_limit: u64,
per_address_limit: u32,
) -> Result<Response, ContractError> {
let mut config = CONFIG.load(deps.storage)?;
if info.sender != config.admin {
Expand All @@ -549,7 +549,7 @@ pub fn execute_update_batch_mint_limit(
deps: DepsMut,
_env: Env,
info: MessageInfo,
batch_mint_limit: u64,
batch_mint_limit: u32,
) -> Result<Response, ContractError> {
let mut config = CONFIG.load(deps.storage)?;
if info.sender != config.admin {
Expand Down
14 changes: 7 additions & 7 deletions contracts/minter/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ pub struct InstantiateMsg {
pub sg721_code_id: u64,
pub sg721_instantiate_msg: Sg721InstantiateMsg,
pub start_time: Option<Expiration>,
pub per_address_limit: Option<u64>,
pub batch_mint_limit: Option<u64>,
pub per_address_limit: Option<u32>,
pub batch_mint_limit: Option<u32>,
pub unit_price: Coin,
pub whitelist: Option<String>,
}
Expand All @@ -24,11 +24,11 @@ pub enum ExecuteMsg {
Mint {},
SetWhitelist { whitelist: String },
UpdateStartTime(Expiration),
UpdatePerAddressLimit { per_address_limit: u64 },
UpdateBatchMintLimit { batch_mint_limit: u64 },
UpdatePerAddressLimit { per_address_limit: u32 },
UpdateBatchMintLimit { batch_mint_limit: u32 },
MintTo { recipient: Addr },
MintFor { token_id: u64, recipient: Addr },
BatchMint { num_mints: u64 },
BatchMint { num_mints: u32 },
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
Expand All @@ -44,9 +44,9 @@ pub enum QueryMsg {
pub struct ConfigResponse {
pub admin: Addr,
pub base_token_uri: String,
pub batch_mint_limit: Option<u64>,
pub batch_mint_limit: Option<u32>,
pub num_tokens: u64,
pub per_address_limit: Option<u64>,
pub per_address_limit: Option<u32>,
pub sg721_address: Addr,
pub sg721_code_id: u64,
pub start_time: Option<Expiration>,
Expand Down
4 changes: 2 additions & 2 deletions contracts/minter/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ pub struct Config {
pub unit_price: Coin,
pub whitelist: Option<Addr>,
pub start_time: Option<Expiration>,
pub per_address_limit: Option<u64>,
pub batch_mint_limit: Option<u64>,
pub per_address_limit: Option<u32>,
pub batch_mint_limit: Option<u32>,
}

pub const CONFIG: Item<Config> = Item::new("config");
Expand Down

0 comments on commit 3239272

Please sign in to comment.