diff --git a/contracts/name-minter/schema/name-minter.json b/contracts/name-minter/schema/name-minter.json index 886cfa02..a7b7ce15 100644 --- a/contracts/name-minter/schema/name-minter.json +++ b/contracts/name-minter/schema/name-minter.json @@ -156,16 +156,6 @@ "properties": { "address": { "type": "string" - }, - "whitelist_type": { - "anyOf": [ - { - "$ref": "#/definitions/WhitelistType" - }, - { - "type": "null" - } - ] } }, "additionalProperties": false @@ -188,16 +178,6 @@ "properties": { "address": { "type": "string" - }, - "whitelist_type": { - "anyOf": [ - { - "$ref": "#/definitions/WhitelistType" - }, - { - "type": "null" - } - ] } }, "additionalProperties": false @@ -252,13 +232,6 @@ "Uint64": { "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", "type": "string" - }, - "WhitelistType": { - "type": "string", - "enum": [ - "Updatable", - "Flatrate" - ] } } }, diff --git a/contracts/name-minter/src/contract.rs b/contracts/name-minter/src/contract.rs index de228354..2812cd80 100644 --- a/contracts/name-minter/src/contract.rs +++ b/contracts/name-minter/src/contract.rs @@ -177,8 +177,6 @@ pub fn execute_mint_and_list( .transpose()? .unwrap_or(None); - println!("discount: {:?}", discount); - let price = validate_payment(name.len(), &info, params.base_price.u128(), discount)?; if price.clone().is_some() { charge_fees( @@ -343,10 +341,14 @@ fn validate_payment( }) .into(); - if discount.is_some() && amount.ge(&Uint128::from(discount.unwrap())) { - amount = amount - .checked_sub(Uint128::from(discount.unwrap())) - .unwrap(); + if let Some(discount_value) = discount { + let discount_amount = Uint128::from(discount_value); + // TODO: should we handle the case where discount > amount (eg 1,000 discount but buying a 100 name) + if amount.ge(&discount_amount) { + amount = amount + .checked_sub(discount_amount) + .map_err(|_| StdError::generic_err("invalid discount amount"))?; + } } if amount.is_zero() { diff --git a/contracts/whitelist-updatable-flatrate/src/contract.rs b/contracts/whitelist-updatable-flatrate/src/contract.rs index 9a4751b3..e48bb21b 100644 --- a/contracts/whitelist-updatable-flatrate/src/contract.rs +++ b/contracts/whitelist-updatable-flatrate/src/contract.rs @@ -135,11 +135,7 @@ pub fn execute_add_addresses( for address in addresses.into_iter() { let addr = deps.api.addr_validate(&address.clone())?; - if WHITELIST.has(deps.storage, addr.clone()) { - return Err(ContractError::AddressAlreadyExists { - addr: addr.to_string(), - }); - } else { + if !WHITELIST.has(deps.storage, addr.clone()) { WHITELIST.save(deps.storage, addr, &0u32)?; count += 1; } diff --git a/contracts/whitelist-updatable-flatrate/src/integration_tests.rs b/contracts/whitelist-updatable-flatrate/src/integration_tests.rs index 710a5ff1..0392f1e2 100644 --- a/contracts/whitelist-updatable-flatrate/src/integration_tests.rs +++ b/contracts/whitelist-updatable-flatrate/src/integration_tests.rs @@ -244,7 +244,7 @@ mod tests { ], }; let res = app.execute_contract(Addr::unchecked(OTHER_ADMIN), wl_addr.clone(), &msg, &[]); - assert!(res.is_err()); + assert!(res.is_ok()); let res: bool = app .wrap() .query_wasm_smart( @@ -254,12 +254,12 @@ mod tests { }), ) .unwrap(); - assert!(!res); + assert!(res); let res: u64 = app .wrap() .query_wasm_smart(&wl_addr, &(QueryMsg::AddressCount {})) .unwrap(); - assert_eq!(res, 5); + assert_eq!(res, 6); let msg = ExecuteMsg::AddAddresses { addresses: vec!["addr0007".to_string(), "addr0006".to_string()], };