Skip to content

Commit

Permalink
Fix naming of abi types (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
ligustah authored Apr 12, 2024
1 parent 21bae1a commit f03358d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 441 deletions.
26 changes: 17 additions & 9 deletions src/premints/zora_premint_v2/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use alloy_sol_types::{SolCall, SolInterface, SolStruct};
use crate::chain::contract_call;
use crate::chain_list::CHAINS;
use crate::premints::zora_premint_v2::types::ZoraPremintV2;
use crate::rules::Evaluation::{Accept, Reject};
use crate::rules::Evaluation::{Accept, Ignore, Reject};
use crate::rules::{Evaluation, Rule, RuleContext};
use crate::typed_rule;
use crate::types::{Premint, PremintTypes};
Expand Down Expand Up @@ -102,18 +102,26 @@ mod test {
#[tokio::test]
async fn test_is_valid_signature() {
let premint: ZoraPremintV2 = serde_json::from_str(PREMINT_JSON).unwrap();
assert!(matches!(
is_valid_signature(premint, RuleContext {}).await,
Ok(Accept)
));
let result = is_valid_signature(premint, RuleContext {}).await;

match result {
Ok(Accept) => {}
Ok(Ignore) => panic!("Should not be ignored"),
Ok(Reject(reason)) => panic!("Rejected: {}", reason),
Err(err) => panic!("Error: {:?}", err),
}
}

#[tokio::test]
async fn test_is_authorized_to_create_premint() {
let premint: ZoraPremintV2 = serde_json::from_str(PREMINT_JSON).unwrap();
assert!(matches!(
is_authorized_to_create_premint(premint, RuleContext {}).await,
Ok(Accept)
));
let result = is_authorized_to_create_premint(premint, RuleContext {}).await;

match result {
Ok(Accept) => {}
Ok(Ignore) => panic!("Should not be ignored"),
Ok(Reject(reason)) => panic!("Rejected: {}", reason),
Err(err) => panic!("Error: {:?}", err),
}
}
}
17 changes: 11 additions & 6 deletions src/premints/zora_premint_v2/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,18 @@ sol! {
"src/premints/zora_premint_v2/zora1155PremintExecutor.json"
}

// aliasing the types here for readability. the original name need to stay
// because they impact signature generation
pub type PremintConfig = IZoraPremintV2::CreatorAttribution;
pub type TokenCreationConfig = IZoraPremintV2::TokenCreationConfig;
pub type ContractCreationConfig = IZoraPremintV2::ContractCreationConfig;

// modelled after the PremintRequest API type
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct ZoraPremintV2 {
pub collection: IZoraPremintV2::ContractCreationConfig,
pub premint: IZoraPremintV2::PremintConfigV2,
// pub premint: ZoraPremintConfigV2,
pub collection: ContractCreationConfig,
pub premint: PremintConfig,
pub collection_address: Address,
pub chain_id: U256,
pub signature: String,
Expand All @@ -32,13 +37,13 @@ pub struct ZoraPremintV2 {
impl Default for ZoraPremintV2 {
fn default() -> Self {
Self {
collection: IZoraPremintV2::ContractCreationConfig {
collection: ContractCreationConfig {
contractAdmin: Default::default(),
contractURI: "".to_string(),
contractName: "".to_string(),
},
premint: IZoraPremintV2::PremintConfigV2 {
tokenConfig: IZoraPremintV2::TokenCreationConfigV2 {
premint: PremintConfig {
tokenConfig: TokenCreationConfig {
tokenURI: "".to_string(),
maxSupply: Default::default(),
maxTokensPerAddress: 0,
Expand Down
Loading

0 comments on commit f03358d

Please sign in to comment.