Skip to content

Commit

Permalink
feat: add mint start time and mint end time checks when instantiating…
Browse files Browse the repository at this point in the history
… the contract
  • Loading branch information
manu0466 committed Jul 17, 2023
1 parent 02e2db9 commit 2f66294
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion contracts/poap/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ where
env: Env,
info: MessageInfo,
msg: InstantiateMsg,
) -> StdResult<Response<C>> {
) -> Result<Response<C>, ContractError> {
// Instantiate the base cw721 that we are extending.
let cw721_instantiate_msg = Cw721BaseInstantiateMsg {
name: msg.name,
Expand All @@ -50,6 +50,14 @@ where
self.is_transferable
.save(deps.storage, &msg.is_transferable)?;
self.is_mintable.save(deps.storage, &msg.is_mintable)?;

if msg.mint_start_time.is_some()
&& msg.mint_end_time.is_some()
&& msg.mint_start_time.unwrap() >= msg.mint_end_time.unwrap()
{
return Err(ContractError::InvalidTimestampValues {});

Check warning on line 58 in contracts/poap/src/execute.rs

View check run for this annotation

Codecov / codecov/patch

contracts/poap/src/execute.rs#L58

Added line #L58 was not covered by tests
}

self.mint_start_time
.save(deps.storage, &msg.mint_start_time)?;
self.mint_end_time.save(deps.storage, &msg.mint_end_time)?;
Expand Down
2 changes: 1 addition & 1 deletion contracts/poap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub mod entry {
env: Env,
info: MessageInfo,
msg: InstantiateMsg,
) -> StdResult<Response> {
) -> Result<Response, ContractError> {
cw2::set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;

Check warning on line 47 in contracts/poap/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

contracts/poap/src/lib.rs#L47

Added line #L47 was not covered by tests

let tract = PoapContract::<Extension, Empty, Empty, Empty>::default();
Expand Down

0 comments on commit 2f66294

Please sign in to comment.