Skip to content

Commit

Permalink
refactor creation fee error
Browse files Browse the repository at this point in the history
  • Loading branch information
Ninjatosba committed Feb 26, 2024
1 parent 2bbf856 commit 017116a
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 13 deletions.
8 changes: 6 additions & 2 deletions contracts/minters/minter/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,12 @@ pub fn instantiate(
// Exact amount must be paid
if amount != creation_fee_amount {
return Err(ContractError::InvalidCreationFee {
expected: amount,
sent: amount,
expected: [Coin {
denom: creation_fee_denom,
amount: creation_fee_amount,
}]
.to_vec(),
sent: info.funds,
});
}
// Check if per address limit is 0
Expand Down
9 changes: 7 additions & 2 deletions contracts/minters/minter/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use std::convert::Infallible;

use cosmwasm_std::{CheckedFromRatioError, ConversionOverflowError, StdError, Timestamp, Uint128};
use cosmwasm_std::{
CheckedFromRatioError, Coin, ConversionOverflowError, StdError, Timestamp, Uint128,
};
use cw_utils::PaymentError;
use pauser::PauseError;
use thiserror::Error;
Expand All @@ -26,7 +28,10 @@ pub enum ContractError {
DivideByZero {},

#[error("Invalid creation fee")]
InvalidCreationFee { expected: Uint128, sent: Uint128 },
InvalidCreationFee {
expected: Vec<Coin>,
sent: Vec<Coin>,
},

#[error("Minting has not started yet")]
MintingNotStarted {
Expand Down
10 changes: 7 additions & 3 deletions contracts/minters/multi-mint-oem/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,16 @@ pub fn instantiate(
CREATION_FEE_DENOM.to_string()
};

let amount = must_pay(&info, &creation_fee_denom)?;
let amount = must_pay(&info.clone(), &creation_fee_denom)?;
// Exact amount must be paid
if amount != creation_fee_amount {
return Err(ContractError::InvalidCreationFee {
expected: amount,
sent: amount,
expected: [Coin {
denom: creation_fee_denom,
amount: creation_fee_amount,
}]
.to_vec(),
sent: info.funds.clone(),
});
}
// Check if per address limit is 0
Expand Down
7 changes: 5 additions & 2 deletions contracts/minters/multi-mint-oem/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cosmwasm_std::{StdError, Timestamp, Uint128};
use cosmwasm_std::{Coin, StdError, Timestamp, Uint128};
use cw_utils::PaymentError;
use pauser::PauseError;
use thiserror::Error;
Expand All @@ -24,7 +24,10 @@ pub enum ContractError {
DivideByZero {},

#[error("Invalid creation fee")]
InvalidCreationFee { expected: Uint128, sent: Uint128 },
InvalidCreationFee {
expected: Vec<Coin>,
sent: Vec<Coin>,
},

#[error("Minting has not started yet")]
MintingNotStarted {
Expand Down
8 changes: 6 additions & 2 deletions contracts/minters/open-edition-minter/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,12 @@ pub fn instantiate(
// Exact amount must be paid
if amount != creation_fee_amount {
return Err(ContractError::InvalidCreationFee {
expected: amount,
sent: amount,
expected: [Coin {
denom: creation_fee_denom,
amount: creation_fee_amount,
}]
.to_vec(),
sent: info.funds,
});
}
// Check if per address limit is 0
Expand Down
7 changes: 5 additions & 2 deletions contracts/minters/open-edition-minter/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cosmwasm_std::{StdError, Timestamp, Uint128};
use cosmwasm_std::{Coin, StdError, Timestamp, Uint128};
use cw_utils::PaymentError;
use pauser::PauseError;
use thiserror::Error;
Expand All @@ -24,7 +24,10 @@ pub enum ContractError {
DivideByZero {},

#[error("Invalid creation fee")]
InvalidCreationFee { expected: Uint128, sent: Uint128 },
InvalidCreationFee {
expected: Vec<Coin>,
sent: Vec<Coin>,
},

#[error("Minting has not started yet")]
MintingNotStarted {
Expand Down

0 comments on commit 017116a

Please sign in to comment.