From b606549a988cb7c90ef62c9d1547a0ccecd0f5e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bierlein?= Date: Wed, 24 Apr 2024 00:09:36 +0200 Subject: [PATCH 01/10] Rename zora_premint_v2 -> zora_premint --- src/chain.rs | 2 +- src/main.rs | 2 +- src/premints/mod.rs | 2 +- src/premints/{zora_premint_v2 => zora_premint}/mod.rs | 0 src/premints/{zora_premint_v2 => zora_premint}/rules.rs | 2 +- src/premints/{zora_premint_v2 => zora_premint}/types.rs | 4 ++-- .../zora1155PremintExecutor.json | 0 src/rules.rs | 4 ++-- src/storage.rs | 2 +- src/types.rs | 6 +++--- tests/e2e_test.rs | 4 ++-- 11 files changed, 14 insertions(+), 14 deletions(-) rename src/premints/{zora_premint_v2 => zora_premint}/mod.rs (100%) rename src/premints/{zora_premint_v2 => zora_premint}/rules.rs (99%) rename src/premints/{zora_premint_v2 => zora_premint}/types.rs (97%) rename src/premints/{zora_premint_v2 => zora_premint}/zora1155PremintExecutor.json (100%) diff --git a/src/chain.rs b/src/chain.rs index 6b05237..398a4ba 100644 --- a/src/chain.rs +++ b/src/chain.rs @@ -1,6 +1,6 @@ use crate::chain_list::{ChainListProvider, CHAINS}; use crate::controller::{ControllerCommands, ControllerInterface}; -use crate::premints::zora_premint_v2::types::PREMINT_FACTORY_ADDR; +use crate::premints::zora_premint::types::PREMINT_FACTORY_ADDR; use crate::types::{InclusionClaim, Premint, PremintTypes}; use alloy::primitives::{address, Address, Bytes, TxKind}; use alloy::providers::Provider; diff --git a/src/main.rs b/src/main.rs index 528bbb4..f87cdcf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ use clap::Parser; use mintpool::api; use mintpool::metrics::init_metrics_and_logging; -use mintpool::premints::zora_premint_v2::types::ZoraPremintV2; +use mintpool::premints::zora_premint::types::ZoraPremintV2; use mintpool::rules::RulesEngine; use mintpool::run::{start_p2p_services, start_watch_chain}; use mintpool::stdin::watch_stdin; diff --git a/src/premints/mod.rs b/src/premints/mod.rs index c81cfb0..4ee9891 100644 --- a/src/premints/mod.rs +++ b/src/premints/mod.rs @@ -1,2 +1,2 @@ pub mod metadata; -pub mod zora_premint_v2; +pub mod zora_premint; diff --git a/src/premints/zora_premint_v2/mod.rs b/src/premints/zora_premint/mod.rs similarity index 100% rename from src/premints/zora_premint_v2/mod.rs rename to src/premints/zora_premint/mod.rs diff --git a/src/premints/zora_premint_v2/rules.rs b/src/premints/zora_premint/rules.rs similarity index 99% rename from src/premints/zora_premint_v2/rules.rs rename to src/premints/zora_premint/rules.rs index 0ce62fd..78f8412 100644 --- a/src/premints/zora_premint_v2/rules.rs +++ b/src/premints/zora_premint/rules.rs @@ -1,5 +1,5 @@ use crate::chain::view_contract_call; -use crate::premints::zora_premint_v2::types::{ +use crate::premints::zora_premint::types::{ IZoraPremintV2, ZoraPremintV2, PREMINT_FACTORY_ADDR, }; use crate::rules::Evaluation::Accept; diff --git a/src/premints/zora_premint_v2/types.rs b/src/premints/zora_premint/types.rs similarity index 97% rename from src/premints/zora_premint_v2/types.rs rename to src/premints/zora_premint/types.rs index fbdc180..3c674ea 100644 --- a/src/premints/zora_premint_v2/types.rs +++ b/src/premints/zora_premint/types.rs @@ -1,6 +1,6 @@ use std::borrow::Cow; -use crate::premints::zora_premint_v2::types::IZoraPremintV2::PremintedV2; +use crate::premints::zora_premint::types::IZoraPremintV2::PremintedV2; use crate::types::{InclusionClaim, Premint, PremintMetadata, PremintName}; use alloy::primitives::{address, Address, U256}; use alloy::rpc::types::eth::{Filter, Log, TransactionReceipt}; @@ -13,7 +13,7 @@ use serde::{Deserialize, Serialize}; sol! { #[derive(Debug, Serialize, Deserialize, PartialEq)] IZoraPremintV2, - "src/premints/zora_premint_v2/zora1155PremintExecutor.json" + "src/premints/zora_premint/zora1155PremintExecutor.json" } // aliasing the types here for readability. the original name need to stay diff --git a/src/premints/zora_premint_v2/zora1155PremintExecutor.json b/src/premints/zora_premint/zora1155PremintExecutor.json similarity index 100% rename from src/premints/zora_premint_v2/zora1155PremintExecutor.json rename to src/premints/zora_premint/zora1155PremintExecutor.json diff --git a/src/rules.rs b/src/rules.rs index a9872fe..4d50bd6 100644 --- a/src/rules.rs +++ b/src/rules.rs @@ -276,7 +276,7 @@ pub fn all_rules() -> Vec>> { let mut rules: Vec>> = Vec::new(); rules.append(&mut general::all_rules()); - rules.append(&mut crate::premints::zora_premint_v2::rules::all_rules()); + rules.append(&mut crate::premints::zora_premint::rules::all_rules()); rules } @@ -455,7 +455,7 @@ mod general { #[cfg(test)] mod test { - use crate::premints::zora_premint_v2::types::ZoraPremintV2; + use crate::premints::zora_premint::types::ZoraPremintV2; use crate::rules::general::existing_token_uri; use crate::rules::Evaluation::{Accept, Reject}; use crate::storage::{PremintStorage, Writer}; diff --git a/src/storage.rs b/src/storage.rs index de27e99..a114ed1 100644 --- a/src/storage.rs +++ b/src/storage.rs @@ -326,7 +326,7 @@ mod test { use std::ops::Sub; use crate::config::Config; - use crate::premints::zora_premint_v2::types::ZoraPremintV2; + use crate::premints::zora_premint::types::ZoraPremintV2; use crate::storage; use crate::storage::{ list_all, list_all_with_options, PremintStorage, QueryOptions, Reader, Writer, diff --git a/src/types.rs b/src/types.rs index 86ea377..f3ae15b 100644 --- a/src/types.rs +++ b/src/types.rs @@ -1,4 +1,4 @@ -use crate::premints::zora_premint_v2::types::ZoraPremintV2; +use crate::premints::zora_premint::types::ZoraPremintV2; use alloy::primitives::{Address, B256, U256}; use alloy::rpc::types::eth::{Filter, Log, TransactionReceipt}; use async_trait::async_trait; @@ -178,10 +178,10 @@ pub struct PeerInclusionClaim { #[cfg(test)] mod test { use super::*; - use crate::premints::zora_premint_v2::types::IZoraPremintV2::{ + use crate::premints::zora_premint::types::IZoraPremintV2::{ ContractCreationConfig, CreatorAttribution, TokenCreationConfig, }; - use crate::premints::zora_premint_v2::types::{IZoraPremintV2, PREMINT_FACTORY_ADDR}; + use crate::premints::zora_premint::types::{IZoraPremintV2, PREMINT_FACTORY_ADDR}; use alloy::primitives::{Bytes, LogData}; use alloy::rpc::types::eth::ReceiptEnvelope; use alloy::sol_types::SolEvent; diff --git a/tests/e2e_test.rs b/tests/e2e_test.rs index 07d8713..fb2a5d4 100644 --- a/tests/e2e_test.rs +++ b/tests/e2e_test.rs @@ -16,8 +16,8 @@ use alloy::sol_types::{SolCall, SolValue}; use alloy::transports::{RpcError, TransportErrorKind}; use mintpool::config::{BootNodes, ChainInclusionMode, Config}; use mintpool::controller::{ControllerCommands, DBQuery}; -use mintpool::premints::zora_premint_v2::types::IZoraPremintV2::MintArguments; -use mintpool::premints::zora_premint_v2::types::{ +use mintpool::premints::zora_premint::types::IZoraPremintV2::MintArguments; +use mintpool::premints::zora_premint::types::{ IZoraPremintV2, ZoraPremintV2, PREMINT_FACTORY_ADDR, }; use mintpool::rules::RulesEngine; From 278f841b7c00093aadb3a54c7f57324e5c46b10c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bierlein?= Date: Wed, 24 Apr 2024 01:08:41 +0200 Subject: [PATCH 02/10] Move things around --- src/chain.rs | 1 - src/main.rs | 2 +- src/premints/zora_premint/contract.rs | 40 +++++++++++++++ src/premints/zora_premint/mod.rs | 4 +- src/premints/zora_premint/rules.rs | 14 +++--- src/premints/zora_premint/{types.rs => v2.rs} | 49 ++++++++++++------- ...r.json => zora1155PremintExecutor_v2.json} | 0 src/rules.rs | 2 +- src/storage.rs | 2 +- src/types.rs | 6 +-- tests/e2e_test.rs | 7 ++- 11 files changed, 89 insertions(+), 38 deletions(-) create mode 100644 src/premints/zora_premint/contract.rs rename src/premints/zora_premint/{types.rs => v2.rs} (79%) rename src/premints/zora_premint/{zora1155PremintExecutor.json => zora1155PremintExecutor_v2.json} (100%) diff --git a/src/chain.rs b/src/chain.rs index 398a4ba..f6728ff 100644 --- a/src/chain.rs +++ b/src/chain.rs @@ -1,6 +1,5 @@ use crate::chain_list::{ChainListProvider, CHAINS}; use crate::controller::{ControllerCommands, ControllerInterface}; -use crate::premints::zora_premint::types::PREMINT_FACTORY_ADDR; use crate::types::{InclusionClaim, Premint, PremintTypes}; use alloy::primitives::{address, Address, Bytes, TxKind}; use alloy::providers::Provider; diff --git a/src/main.rs b/src/main.rs index f87cdcf..09b5992 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ use clap::Parser; use mintpool::api; use mintpool::metrics::init_metrics_and_logging; -use mintpool::premints::zora_premint::types::ZoraPremintV2; +use mintpool::premints::zora_premint::v2::ZoraPremintV2; use mintpool::rules::RulesEngine; use mintpool::run::{start_p2p_services, start_watch_chain}; use mintpool::stdin::watch_stdin; diff --git a/src/premints/zora_premint/contract.rs b/src/premints/zora_premint/contract.rs new file mode 100644 index 0000000..78bc451 --- /dev/null +++ b/src/premints/zora_premint/contract.rs @@ -0,0 +1,40 @@ +use std::sync::Arc; + +use alloy::rpc::types::eth::{TransactionInput, TransactionRequest}; +use alloy_primitives::{address, Address, Bytes}; +use alloy_provider::Provider; +use alloy_sol_macro::sol; +use alloy_sol_types::SolCall; +use futures_util::StreamExt; +use serde::{Deserialize, Serialize}; + +use crate::chain_list::ChainListProvider; + +pub static PREMINT_FACTORY_ADDR: Address = address!("7777773606e7e46C8Ba8B98C08f5cD218e31d340"); + +sol! { + #[derive(Debug, Serialize, Deserialize, PartialEq)] + IZoraPremintERC20V1, + "src/premints/zora_premint/zora1155PremintExecutor_erc20v1.json" +} + +pub async fn contract_call(call: T, provider: &Arc) -> eyre::Result +where + T: SolCall, +{ + provider + .call( + &TransactionRequest { + to: Some(PREMINT_FACTORY_ADDR), + input: TransactionInput::new(Bytes::from(call.abi_encode())), + ..Default::default() + }, + None, + ) + .await + .map_err(|err| eyre::eyre!("Error calling contract: {:?}", err)) + .and_then(|response| { + T::abi_decode_returns(&response, false) + .map_err(|err| eyre::eyre!("Error decoding contract response: {:?}", err)) + }) +} diff --git a/src/premints/zora_premint/mod.rs b/src/premints/zora_premint/mod.rs index 5726682..d0f00e5 100644 --- a/src/premints/zora_premint/mod.rs +++ b/src/premints/zora_premint/mod.rs @@ -1,2 +1,4 @@ +pub mod contract; +pub mod erc20v1; pub mod rules; -pub mod types; +pub mod v2; diff --git a/src/premints/zora_premint/rules.rs b/src/premints/zora_premint/rules.rs index 78f8412..03405ee 100644 --- a/src/premints/zora_premint/rules.rs +++ b/src/premints/zora_premint/rules.rs @@ -1,7 +1,8 @@ +use std::str::FromStr; + use crate::chain::view_contract_call; -use crate::premints::zora_premint::types::{ - IZoraPremintV2, ZoraPremintV2, PREMINT_FACTORY_ADDR, -}; +use crate::premints::zora_premint::contract::PREMINT_FACTORY_ADDR; +use crate::premints::zora_premint::v2::ZoraPremintV2; use crate::rules::Evaluation::Accept; use crate::rules::{Evaluation, Rule, RuleContext}; use crate::storage::Reader; @@ -9,7 +10,6 @@ use crate::types::PremintTypes; use crate::{ignore, reject, typed_rule}; use alloy::primitives::Signature; use alloy::sol_types::SolStruct; -use std::str::FromStr; // create premint v2 rule implementations here @@ -22,7 +22,7 @@ pub async fn is_authorized_to_create_premint( Some(ref rpc) => rpc, }; - let call = IZoraPremintV2::isAuthorizedToCreatePremintCall { + let call = ZoraPremintV2::isAuthorizedToCreatePremintCall { contractAddress: premint.collection_address, signer: premint.collection.contractAdmin, premintContractConfigContractAdmin: premint.collection.contractAdmin, @@ -45,7 +45,7 @@ pub async fn not_minted( Some(ref rpc) => rpc, }; - let call = IZoraPremintV2::premintStatusCall { + let call = ZoraPremintV2::premintStatusCall { contractAddress: premint.collection_address, uid: premint.premint.uid, }; @@ -67,7 +67,7 @@ pub async fn premint_version_supported( Some(ref rpc) => rpc, }; - let call = IZoraPremintV2::supportedPremintSignatureVersionsCall { + let call = ZoraPremintV2::supportedPremintSignatureVersionsCall { contractAddress: premint.collection_address, }; diff --git a/src/premints/zora_premint/types.rs b/src/premints/zora_premint/v2.rs similarity index 79% rename from src/premints/zora_premint/types.rs rename to src/premints/zora_premint/v2.rs index 3c674ea..81f4c88 100644 --- a/src/premints/zora_premint/types.rs +++ b/src/premints/zora_premint/v2.rs @@ -1,33 +1,32 @@ use std::borrow::Cow; -use crate::premints::zora_premint::types::IZoraPremintV2::PremintedV2; +use crate::premints::zora_premint::v2::ZoraPremintV2::PremintedV2; use crate::types::{InclusionClaim, Premint, PremintMetadata, PremintName}; use alloy::primitives::{address, Address, U256}; use alloy::rpc::types::eth::{Filter, Log, TransactionReceipt}; use alloy::sol; +use alloy::sol_types::private::U256; use alloy::sol_types::{Eip712Domain, SolEvent}; // use alloy_sol_types::SolEvent; use async_trait::async_trait; use serde::{Deserialize, Serialize}; -sol! { - #[derive(Debug, Serialize, Deserialize, PartialEq)] - IZoraPremintV2, - "src/premints/zora_premint/zora1155PremintExecutor.json" -} +use crate::premints::zora_premint::contract::ZoraPremintV2::PremintedV2; +use crate::premints::zora_premint::contract::{ZoraPremint, ZoraPremintV2, PREMINT_FACTORY_ADDR}; +use crate::types::{InclusionClaim, Premint, PremintMetadata, PremintName}; // 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; +pub type PremintConfigV2 = ZoraPremintV2::CreatorAttribution; +pub type TokenCreationConfigV2 = ZoraPremintV2::TokenCreationConfig; +pub type ContractCreationConfigV2 = ZoraPremintV2::ContractCreationConfig; // modelled after the PremintRequest API type #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] #[serde(rename_all = "camelCase")] pub struct ZoraPremintV2 { - pub collection: ContractCreationConfig, - pub premint: PremintConfig, + pub collection: ContractCreationConfigV2, + pub premint: PremintConfigV2, pub collection_address: Address, pub chain_id: u64, pub signature: String, @@ -36,13 +35,13 @@ pub struct ZoraPremintV2 { impl Default for ZoraPremintV2 { fn default() -> Self { Self { - collection: ContractCreationConfig { + collection: ContractCreationConfigV2 { contractAdmin: Default::default(), contractURI: "".to_string(), contractName: "".to_string(), }, - premint: PremintConfig { - tokenConfig: TokenCreationConfig { + premint: PremintConfigV2 { + tokenConfig: TokenCreationConfigV2 { tokenURI: "".to_string(), maxSupply: Default::default(), maxTokensPerAddress: 0, @@ -65,8 +64,6 @@ impl Default for ZoraPremintV2 { } } -pub static PREMINT_FACTORY_ADDR: Address = address!("7777773606e7e46C8Ba8B98C08f5cD218e31d340"); - impl ZoraPremintV2 { pub fn eip712_domain(&self) -> Eip712Domain { Eip712Domain { @@ -112,12 +109,12 @@ impl Premint for ZoraPremintV2 { Some( Filter::new() .address(PREMINT_FACTORY_ADDR) - .event(IZoraPremintV2::PremintedV2::SIGNATURE), + .event(ZoraPremintV2::PremintedV2::SIGNATURE), ) } fn map_claim(chain_id: u64, log: Log) -> eyre::Result { - let event = IZoraPremintV2::PremintedV2::decode_raw_log( + let event = ZoraPremintV2::PremintedV2::decode_raw_log( log.topics(), log.data().data.as_ref(), true, @@ -142,7 +139,7 @@ impl Premint for ZoraPremintV2 { claim: InclusionClaim, ) -> bool { let event = - IZoraPremintV2::PremintedV2::decode_raw_log(log.topics(), &log.data().data, true); + ZoraPremintV2::PremintedV2::decode_raw_log(log.topics(), &log.data().data, true); match event { Ok(event) => { let conditions = vec![ @@ -167,3 +164,17 @@ impl Premint for ZoraPremintV2 { } } } + +impl ZoraPremint for ZoraPremintV2 { + fn collection_address(&self) -> Address { + self.collection_address + } + + fn chain_id(&self) -> u64 { + self.chain_id + } + + fn signature(&self) -> String { + self.signature.clone() + } +} diff --git a/src/premints/zora_premint/zora1155PremintExecutor.json b/src/premints/zora_premint/zora1155PremintExecutor_v2.json similarity index 100% rename from src/premints/zora_premint/zora1155PremintExecutor.json rename to src/premints/zora_premint/zora1155PremintExecutor_v2.json diff --git a/src/rules.rs b/src/rules.rs index 4d50bd6..2348298 100644 --- a/src/rules.rs +++ b/src/rules.rs @@ -455,7 +455,7 @@ mod general { #[cfg(test)] mod test { - use crate::premints::zora_premint::types::ZoraPremintV2; + use crate::premints::zora_premint::v2::ZoraPremintV2; use crate::rules::general::existing_token_uri; use crate::rules::Evaluation::{Accept, Reject}; use crate::storage::{PremintStorage, Writer}; diff --git a/src/storage.rs b/src/storage.rs index a114ed1..6ebb86e 100644 --- a/src/storage.rs +++ b/src/storage.rs @@ -326,7 +326,7 @@ mod test { use std::ops::Sub; use crate::config::Config; - use crate::premints::zora_premint::types::ZoraPremintV2; + use crate::premints::zora_premint::v2::ZoraPremintV2; use crate::storage; use crate::storage::{ list_all, list_all_with_options, PremintStorage, QueryOptions, Reader, Writer, diff --git a/src/types.rs b/src/types.rs index f3ae15b..141ea55 100644 --- a/src/types.rs +++ b/src/types.rs @@ -1,4 +1,4 @@ -use crate::premints::zora_premint::types::ZoraPremintV2; +use crate::premints::zora_premint::v2::ZoraPremintV2; use alloy::primitives::{Address, B256, U256}; use alloy::rpc::types::eth::{Filter, Log, TransactionReceipt}; use async_trait::async_trait; @@ -178,10 +178,10 @@ pub struct PeerInclusionClaim { #[cfg(test)] mod test { use super::*; - use crate::premints::zora_premint::types::IZoraPremintV2::{ + use crate::premints::zora_premint::contract::IZoraPremintV2::{ ContractCreationConfig, CreatorAttribution, TokenCreationConfig, }; - use crate::premints::zora_premint::types::{IZoraPremintV2, PREMINT_FACTORY_ADDR}; + use crate::premints::zora_premint::contract::{IZoraPremintV2, PREMINT_FACTORY_ADDR}; use alloy::primitives::{Bytes, LogData}; use alloy::rpc::types::eth::ReceiptEnvelope; use alloy::sol_types::SolEvent; diff --git a/tests/e2e_test.rs b/tests/e2e_test.rs index fb2a5d4..e4ffedf 100644 --- a/tests/e2e_test.rs +++ b/tests/e2e_test.rs @@ -16,10 +16,9 @@ use alloy::sol_types::{SolCall, SolValue}; use alloy::transports::{RpcError, TransportErrorKind}; use mintpool::config::{BootNodes, ChainInclusionMode, Config}; use mintpool::controller::{ControllerCommands, DBQuery}; -use mintpool::premints::zora_premint::types::IZoraPremintV2::MintArguments; -use mintpool::premints::zora_premint::types::{ - IZoraPremintV2, ZoraPremintV2, PREMINT_FACTORY_ADDR, -}; +use mintpool::premints::zora_premint::contract::IZoraPremintV2::MintArguments; +use mintpool::premints::zora_premint::contract::{IZoraPremintV2, PREMINT_FACTORY_ADDR}; +use mintpool::premints::zora_premint::v2::ZoraPremintV2; use mintpool::rules::RulesEngine; use mintpool::run; use mintpool::types::PremintTypes; From b6013ab582be4421806cb8c5c0f6446e7b3dead5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bierlein?= Date: Thu, 2 May 2024 17:58:42 +0200 Subject: [PATCH 03/10] Use macros for everything --- src/main.rs | 4 +- src/premints/zora_premint/contract.rs | 35 +- src/premints/zora_premint/mod.rs | 2 +- src/premints/zora_premint/rules.rs | 291 ++-- src/premints/zora_premint/types.rs | 171 +++ src/premints/zora_premint/v2.rs | 224 +-- .../zora1155PremintExecutor_erc20v1.json | 1364 +++++++++++++++++ src/rules.rs | 11 +- src/storage.rs | 8 +- src/types.rs | 13 +- tests/e2e_test.rs | 10 +- 11 files changed, 1751 insertions(+), 382 deletions(-) create mode 100644 src/premints/zora_premint/types.rs create mode 100644 src/premints/zora_premint/zora1155PremintExecutor_erc20v1.json diff --git a/src/main.rs b/src/main.rs index 09b5992..51fbfb0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ use clap::Parser; use mintpool::api; use mintpool::metrics::init_metrics_and_logging; -use mintpool::premints::zora_premint::v2::ZoraPremintV2; +use mintpool::premints::zora_premint::v2::V2; use mintpool::rules::RulesEngine; use mintpool::run::{start_p2p_services, start_watch_chain}; use mintpool::stdin::watch_stdin; @@ -23,7 +23,7 @@ async fn main() -> eyre::Result<()> { let router = api::router_with_defaults(&config).merge(metrics_router); api::start_api(&config, ctl.clone(), router, true).await?; - start_watch_chain::(&config, ctl.clone()).await; + start_watch_chain::(&config, ctl.clone()).await; tracing::info!(monotonic_counter.chains_watched = 1, "Watching chain"); if config.interactive { watch_stdin(ctl.clone()).await; diff --git a/src/premints/zora_premint/contract.rs b/src/premints/zora_premint/contract.rs index 78bc451..8664b28 100644 --- a/src/premints/zora_premint/contract.rs +++ b/src/premints/zora_premint/contract.rs @@ -1,10 +1,9 @@ use std::sync::Arc; -use alloy::rpc::types::eth::{TransactionInput, TransactionRequest}; -use alloy_primitives::{address, Address, Bytes}; -use alloy_provider::Provider; -use alloy_sol_macro::sol; -use alloy_sol_types::SolCall; +use alloy::primitives::{address, Address, Bytes, TxKind}; +use alloy::rpc::types::eth::{BlockId, TransactionInput, TransactionRequest}; +use alloy::sol; +use alloy::sol_types::SolCall; use futures_util::StreamExt; use serde::{Deserialize, Serialize}; @@ -12,29 +11,17 @@ use crate::chain_list::ChainListProvider; pub static PREMINT_FACTORY_ADDR: Address = address!("7777773606e7e46C8Ba8B98C08f5cD218e31d340"); +// we need to use separate namespaces for each premint version, +// because they all need to have the type names for the signatures +// to calculate correctly sol! { #[derive(Debug, Serialize, Deserialize, PartialEq)] IZoraPremintERC20V1, "src/premints/zora_premint/zora1155PremintExecutor_erc20v1.json" } -pub async fn contract_call(call: T, provider: &Arc) -> eyre::Result -where - T: SolCall, -{ - provider - .call( - &TransactionRequest { - to: Some(PREMINT_FACTORY_ADDR), - input: TransactionInput::new(Bytes::from(call.abi_encode())), - ..Default::default() - }, - None, - ) - .await - .map_err(|err| eyre::eyre!("Error calling contract: {:?}", err)) - .and_then(|response| { - T::abi_decode_returns(&response, false) - .map_err(|err| eyre::eyre!("Error decoding contract response: {:?}", err)) - }) +sol! { + #[derive(Debug, Serialize, Deserialize, PartialEq)] + IZoraPremintV2, + "src/premints/zora_premint/zora1155PremintExecutor_v2.json" } diff --git a/src/premints/zora_premint/mod.rs b/src/premints/zora_premint/mod.rs index d0f00e5..16a3c29 100644 --- a/src/premints/zora_premint/mod.rs +++ b/src/premints/zora_premint/mod.rs @@ -1,4 +1,4 @@ pub mod contract; -pub mod erc20v1; pub mod rules; +pub mod types; pub mod v2; diff --git a/src/premints/zora_premint/rules.rs b/src/premints/zora_premint/rules.rs index 03405ee..b68e197 100644 --- a/src/premints/zora_premint/rules.rs +++ b/src/premints/zora_premint/rules.rs @@ -1,170 +1,137 @@ -use std::str::FromStr; - -use crate::chain::view_contract_call; -use crate::premints::zora_premint::contract::PREMINT_FACTORY_ADDR; -use crate::premints::zora_premint::v2::ZoraPremintV2; -use crate::rules::Evaluation::Accept; -use crate::rules::{Evaluation, Rule, RuleContext}; +use crate::premints::zora_premint::v2::V2; +use crate::rules::Rule; use crate::storage::Reader; +use crate::typed_rule; use crate::types::PremintTypes; -use crate::{ignore, reject, typed_rule}; -use alloy::primitives::Signature; -use alloy::sol_types::SolStruct; - -// create premint v2 rule implementations here - -pub async fn is_authorized_to_create_premint( - premint: &ZoraPremintV2, - context: &RuleContext, -) -> eyre::Result { - let rpc = match context.rpc { - None => return ignore!("Rule requires RPC call"), - Some(ref rpc) => rpc, - }; - - let call = ZoraPremintV2::isAuthorizedToCreatePremintCall { - contractAddress: premint.collection_address, - signer: premint.collection.contractAdmin, - premintContractConfigContractAdmin: premint.collection.contractAdmin, - }; - - let result = view_contract_call(call, rpc, PREMINT_FACTORY_ADDR).await?; - - match result.isAuthorized { - true => Ok(Accept), - false => reject!("Unauthorized to create premint"), - } -} - -pub async fn not_minted( - premint: &ZoraPremintV2, - context: &RuleContext, -) -> eyre::Result { - let rpc = match context.rpc { - None => return ignore!("Rule requires RPC provider"), - Some(ref rpc) => rpc, - }; - - let call = ZoraPremintV2::premintStatusCall { - contractAddress: premint.collection_address, - uid: premint.premint.uid, - }; - - let result = view_contract_call(call, rpc, PREMINT_FACTORY_ADDR).await?; - - match result.contractCreated && !result.tokenIdForPremint.is_zero() { - false => Ok(Accept), - true => reject!("Premint already minted"), - } -} - -pub async fn premint_version_supported( - premint: &ZoraPremintV2, - context: &RuleContext, -) -> eyre::Result { - let rpc = match context.rpc { - None => return ignore!("Rule requires RPC provider"), - Some(ref rpc) => rpc, - }; - - let call = ZoraPremintV2::supportedPremintSignatureVersionsCall { - contractAddress: premint.collection_address, - }; - - let result = view_contract_call(call, rpc, PREMINT_FACTORY_ADDR).await?; - - match result.versions.contains(&"2".to_string()) { - true => Ok(Accept), - false => reject!("Premint version 2 not supported by contract"), - } -} - -// * signatureIsValid ( this can be performed entirely offline ) -// * check if the signature is valid -// * check if the signature is equal to the proposed contract admin - -pub async fn is_valid_signature( - premint: &ZoraPremintV2, - _context: &RuleContext, -) -> eyre::Result { - // * if contract exists, check if the signer is the contract admin - // * if contract does not exist, check if the signer is the proposed contract admin - let signature = Signature::from_str(premint.signature.as_str())?; - - let domain = premint.eip712_domain(); - let hash = premint.premint.eip712_signing_hash(&domain); - let signer = signature.recover_address_from_prehash(&hash)?; - - if signer != premint.collection.contractAdmin { - reject!( - "Invalid signature for contract admin {} vs recovered {}", - premint.collection.contractAdmin, - signer - ) - } else { - Ok(Accept) - } -} - -async fn is_chain_supported( - premint: &ZoraPremintV2, - _context: &RuleContext, -) -> eyre::Result { - let supported_chains: Vec = vec![7777777, 999999999, 8453]; - let chain_id = premint.chain_id; - - match supported_chains.contains(&chain_id) { - true => Ok(Accept), - false => reject!("Chain not supported"), - } -} - -pub fn all_rules() -> Vec>> { - vec![ - typed_rule!(PremintTypes::ZoraV2, is_authorized_to_create_premint), - typed_rule!(PremintTypes::ZoraV2, is_valid_signature), - typed_rule!(PremintTypes::ZoraV2, is_chain_supported), - typed_rule!(PremintTypes::ZoraV2, not_minted), - typed_rule!(PremintTypes::ZoraV2, premint_version_supported), - ] -} - -#[cfg(test)] -mod test { - use crate::rules::Evaluation::{Ignore, Reject}; - - use super::*; +#[macro_export] +macro_rules! zora_premint_rules { + ($namespace:tt, $typ:ty, $version:literal) => { + pub async fn is_authorized_to_create_premint( + premint: &$typ, + context: &$crate::rules::RuleContext, + ) -> eyre::Result<$crate::rules::Evaluation> { + let rpc = match context.rpc { + None => return $crate::ignore!("Rule requires RPC call"), + Some(ref rpc) => rpc, + }; + + let call = $namespace::isAuthorizedToCreatePremintCall { + contractAddress: premint.collection_address, + signer: premint.collection.contractAdmin, + premintContractConfigContractAdmin: premint.collection.contractAdmin, + }; + + let result = $crate::chain::view_contract_call( + call, + rpc, + $crate::premints::zora_premint::contract::PREMINT_FACTORY_ADDR, + ) + .await?; + + match result.isAuthorized { + true => Ok($crate::rules::Evaluation::Accept), + false => $crate::reject!("Unauthorized to create premint"), + } + } - const PREMINT_JSON: &str = include_str!(concat!( - env!("CARGO_MANIFEST_DIR"), - "/data/valid_zora_v2_premint.json" - )); + pub async fn not_minted( + premint: &$typ, + context: &$crate::rules::RuleContext, + ) -> eyre::Result<$crate::rules::Evaluation> { + let rpc = match context.rpc { + None => return $crate::ignore!("Rule requires RPC provider"), + Some(ref rpc) => rpc, + }; + + let call = $namespace::premintStatusCall { + contractAddress: premint.collection_address, + uid: premint.premint.uid, + }; + + let result = $crate::chain::view_contract_call( + call, + rpc, + $crate::premints::zora_premint::contract::PREMINT_FACTORY_ADDR, + ) + .await?; + + match result.contractCreated && !result.tokenIdForPremint.is_zero() { + false => Ok($crate::rules::Evaluation::Accept), + true => $crate::reject!("Premint already minted"), + } + } - #[tokio::test] - async fn test_is_valid_signature() { - let premint: ZoraPremintV2 = serde_json::from_str(PREMINT_JSON).unwrap(); - let context = RuleContext::test_default().await; - let result = is_valid_signature(&premint, &context).await; + pub async fn premint_version_supported( + premint: &$typ, + context: &$crate::rules::RuleContext, + ) -> eyre::Result<$crate::rules::Evaluation> { + let rpc = match context.rpc { + None => return $crate::ignore!("Rule requires RPC provider"), + Some(ref rpc) => rpc, + }; + + let call = $namespace::supportedPremintSignatureVersionsCall { + contractAddress: premint.collection_address, + }; + + let result = $crate::chain::view_contract_call( + call, + rpc, + $crate::premints::zora_premint::contract::PREMINT_FACTORY_ADDR, + ) + .await?; + + match result.versions.contains(&$version.to_string()) { + true => Ok($crate::rules::Evaluation::Accept), + false => $crate::reject!(concat!( + "Premint version ", + $version, + " not supported by contract" + )), + } + } - match result { - Ok(Accept) => {} - Ok(Ignore(reason)) => panic!("Should not be ignored: {}", reason), - Ok(Reject(reason)) => panic!("Rejected: {}", reason), - Err(err) => panic!("Error: {:?}", err), + // * signatureIsValid ( this can be performed entirely offline ) + // * check if the signature is valid + // * check if the signature is equal to the proposed contract admin + + pub async fn is_valid_signature( + premint: &$typ, + _context: &$crate::rules::RuleContext, + ) -> eyre::Result<$crate::rules::Evaluation> { + // * if contract exists, check if the signer is the contract admin + // * if contract does not exist, check if the signer is the proposed contract admin + + let signature: alloy::signers::Signature = + core::str::FromStr::from_str(premint.signature.as_str())?; + + let domain = premint.eip712_domain(); + let hash = alloy::sol_types::SolStruct::eip712_signing_hash(&premint.premint, &domain); + let signer: alloy::primitives::Address = + signature.recover_address_from_prehash(&hash)?; + + if signer != premint.collection.contractAdmin { + $crate::reject!( + "Invalid signature for contract admin {} vs recovered {}", + premint.collection.contractAdmin, + signer + ) + } else { + Ok($crate::rules::Evaluation::Accept) + } } - } - - #[tokio::test] - async fn test_is_authorized_to_create_premint() { - let premint: ZoraPremintV2 = serde_json::from_str(PREMINT_JSON).unwrap(); - let context = RuleContext::test_default_rpc(7777777).await; - let result = is_authorized_to_create_premint(&premint, &context).await; - - match result { - Ok(Accept) => {} - Ok(Ignore(reason)) => panic!("Should not be ignored: {}", reason), - Ok(Reject(reason)) => panic!("Rejected: {}", reason), - Err(err) => panic!("Error: {:?}", err), + + pub async fn is_chain_supported( + premint: &$typ, + _context: &$crate::rules::RuleContext, + ) -> eyre::Result<$crate::rules::Evaluation> { + let supported_chains: Vec = vec![7777777, 999999999, 8453]; + let chain_id = premint.chain_id; + + match supported_chains.contains(&chain_id) { + true => Ok($crate::rules::Evaluation::Accept), + false => $crate::reject!("Chain not supported"), + } } - } + }; } diff --git a/src/premints/zora_premint/types.rs b/src/premints/zora_premint/types.rs new file mode 100644 index 0000000..06d1cdc --- /dev/null +++ b/src/premints/zora_premint/types.rs @@ -0,0 +1,171 @@ +#[macro_export] +macro_rules! implement_zora_premint_traits { + ($namespace:tt, $typ:ident, $kind:literal, $version:tt) => { + #[derive( + std::fmt::Debug, + std::default::Default, + serde::Serialize, + serde::Deserialize, + core::clone::Clone, + core::cmp::PartialEq, + )] + #[serde(rename_all = "camelCase")] + pub struct $typ { + pub collection_address: alloy::primitives::Address, + pub chain_id: u64, + pub collection: $namespace::ContractCreationConfig, + pub premint: $namespace::CreatorAttribution, + pub signature: String, + } + + + impl core::default::Default for $namespace::ContractCreationConfig { + fn default() -> Self { + Self { + contractAdmin: Default::default(), + contractURI: String::default(), + contractName: String::default(), + } + } + } + + impl core::default::Default for $namespace::TokenCreationConfig { + fn default() -> Self { + Self { + tokenURI: Default::default(), + maxSupply: Default::default(), + maxTokensPerAddress: Default::default(), + pricePerToken: Default::default(), + mintStart: Default::default(), + mintDuration: Default::default(), + royaltyBPS: Default::default(), + payoutRecipient: Default::default(), + fixedPriceMinter: Default::default(), + createReferral: Default::default(), + } + } + } + + impl core::default::Default for $namespace::CreatorAttribution { + fn default() -> Self { + Self { + tokenConfig: Default::default(), + uid: Default::default(), + version: Default::default(), + deleted: Default::default(), + } + } + } + + impl $typ { + fn event_to_guid(chain_id: u64, event: &$namespace::PremintedV2) -> String { + format!( + "{:?}:{:?}:{:?}", + chain_id, event.contractAddress, event.uid + ) + } + + pub fn eip712_domain(&self) -> alloy::sol_types::Eip712Domain { + alloy::sol_types::Eip712Domain { + name: Some(std::borrow::Cow::from("Preminter")), + version: Some(std::borrow::Cow::from($version)), + chain_id: Some(alloy::primitives::U256::from(self.chain_id)), + verifying_contract: Some(self.collection_address), + salt: None, + } + } + + $crate::zora_premint_rules!($namespace, $typ, $version); + } + + #[async_trait::async_trait] + impl $crate::types::Premint for $typ { + + fn metadata(&self) -> $crate::types::PremintMetadata { + let id = format!( + "{:?}:{:?}:{:?}", + self.chain_id, self.collection_address, self.premint.uid + ); + + $crate::types::PremintMetadata { + id, + version: self.premint.version as u64, + kind: $crate::types::PremintName($kind.to_string()), + signer: self.collection.contractAdmin, + chain_id: self.chain_id, + collection_address: Address::default(), // TODO: source this + token_id: alloy::primitives::U256::from(self.premint.uid), + uri: self.premint.tokenConfig.tokenURI.clone(), + } + } + + fn check_filter(chain_id: u64) -> Option { + let supported_chains = [7777777, 8453]; // TODO: add the rest here and enable testnet mode + if !supported_chains.contains(&chain_id) { + return None; + } + Some( + alloy::rpc::types::eth::Filter::new() + .address($crate::premints::zora_premint::contract::PREMINT_FACTORY_ADDR) + .event(<$namespace::PremintedV2 as alloy::sol_types::SolEvent>::SIGNATURE), + ) + } + + fn map_claim( + chain_id: u64, + log: alloy::rpc::types::eth::Log, + ) -> eyre::Result<$crate::types::InclusionClaim> { + let event = <$namespace::PremintedV2 as alloy::sol_types::SolEvent>::decode_raw_log( + log.topics(), + log.data().data.as_ref(), + true, + )? + .into(); + + let id = Self::event_to_guid(chain_id, &event); + + Ok($crate::types::InclusionClaim { + premint_id: id, + chain_id, + tx_hash: log.transaction_hash.unwrap_or_default(), + log_index: log.log_index.unwrap_or_default(), + kind: $kind.to_string(), + }) + } + + async fn verify_claim( + &self, + chain_id: u64, + tx: alloy::rpc::types::eth::TransactionReceipt, + log: alloy::rpc::types::eth::Log, + claim: $crate::types::InclusionClaim, + ) -> bool { + let event = + <$namespace::PremintedV2 as alloy::sol_types::SolEvent>::decode_raw_log(log.topics(), &log.data().data, true); + + match event { + Ok(event) => { + let conditions = vec![ + log.address() == $crate::premints::zora_premint::contract::PREMINT_FACTORY_ADDR, + log.transaction_hash.unwrap_or_default() == tx.transaction_hash, + claim.tx_hash == tx.transaction_hash, + claim.log_index == log.log_index.unwrap_or_default(), + claim.premint_id == Self::event_to_guid(chain_id, &event), + claim.kind == *"zora_premint_v2", + claim.chain_id == chain_id, + self.collection_address == event.contractAddress, + self.premint.uid == event.uid, + ]; + + // confirm all conditions are true + conditions.into_iter().all(|x| x) + } + Err(e) => { + tracing::debug!("Failed to parse log: {}", e); + false + } + } + } + } + }; +} diff --git a/src/premints/zora_premint/v2.rs b/src/premints/zora_premint/v2.rs index 81f4c88..0af59f9 100644 --- a/src/premints/zora_premint/v2.rs +++ b/src/premints/zora_premint/v2.rs @@ -1,180 +1,60 @@ -use std::borrow::Cow; - -use crate::premints::zora_premint::v2::ZoraPremintV2::PremintedV2; -use crate::types::{InclusionClaim, Premint, PremintMetadata, PremintName}; -use alloy::primitives::{address, Address, U256}; -use alloy::rpc::types::eth::{Filter, Log, TransactionReceipt}; -use alloy::sol; -use alloy::sol_types::private::U256; -use alloy::sol_types::{Eip712Domain, SolEvent}; -// use alloy_sol_types::SolEvent; -use async_trait::async_trait; -use serde::{Deserialize, Serialize}; - -use crate::premints::zora_premint::contract::ZoraPremintV2::PremintedV2; -use crate::premints::zora_premint::contract::{ZoraPremint, ZoraPremintV2, PREMINT_FACTORY_ADDR}; -use crate::types::{InclusionClaim, Premint, PremintMetadata, PremintName}; - -// aliasing the types here for readability. the original name need to stay -// because they impact signature generation -pub type PremintConfigV2 = ZoraPremintV2::CreatorAttribution; -pub type TokenCreationConfigV2 = ZoraPremintV2::TokenCreationConfig; -pub type ContractCreationConfigV2 = ZoraPremintV2::ContractCreationConfig; - -// modelled after the PremintRequest API type -#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] -#[serde(rename_all = "camelCase")] -pub struct ZoraPremintV2 { - pub collection: ContractCreationConfigV2, - pub premint: PremintConfigV2, - pub collection_address: Address, - pub chain_id: u64, - pub signature: String, -} - -impl Default for ZoraPremintV2 { - fn default() -> Self { - Self { - collection: ContractCreationConfigV2 { - contractAdmin: Default::default(), - contractURI: "".to_string(), - contractName: "".to_string(), - }, - premint: PremintConfigV2 { - tokenConfig: TokenCreationConfigV2 { - tokenURI: "".to_string(), - maxSupply: Default::default(), - maxTokensPerAddress: 0, - pricePerToken: 0, - mintStart: 0, - mintDuration: 0, - royaltyBPS: 0, - payoutRecipient: Default::default(), - fixedPriceMinter: Default::default(), - createReferral: Default::default(), - }, - uid: 0, - version: 0, - deleted: false, - }, - collection_address: Address::default(), - chain_id: 0, - signature: String::default(), - } - } +use crate::{implement_zora_premint_traits, typed_rule}; +use alloy::primitives::Address; + +use crate::premints::zora_premint::contract::IZoraPremintV2; +use crate::premints::zora_premint::contract::IZoraPremintV2::PremintedV2; +use crate::rules::Rule; +use crate::storage::Reader; +use crate::types::PremintTypes; + +implement_zora_premint_traits!(IZoraPremintV2, V2, "zora_premint_v2", "2"); + +pub fn all_v2_rules() -> Vec>> { + vec![ + typed_rule!(PremintTypes::ZoraV2, V2::is_authorized_to_create_premint), + typed_rule!(PremintTypes::ZoraV2, V2::is_valid_signature), + typed_rule!(PremintTypes::ZoraV2, V2::is_chain_supported), + typed_rule!(PremintTypes::ZoraV2, V2::not_minted), + typed_rule!(PremintTypes::ZoraV2, V2::premint_version_supported), + ] } - -impl ZoraPremintV2 { - pub fn eip712_domain(&self) -> Eip712Domain { - Eip712Domain { - name: Some(Cow::from("Preminter")), - version: Some(Cow::from("2")), - chain_id: Some(U256::from(self.chain_id)), - verifying_contract: Some(self.collection_address), - salt: None, - } - } - - /// Recreate a deterministic GUID for a premint - fn event_to_guid(chain_id: u64, event: &PremintedV2) -> String { - format!("{:?}:{:?}:{:?}", chain_id, event.contractAddress, event.uid) - } -} - -#[async_trait] -impl Premint for ZoraPremintV2 { - fn metadata(&self) -> PremintMetadata { - let id = format!( - "{:?}:{:?}:{:?}", - self.chain_id, self.collection_address, self.premint.uid - ); - - PremintMetadata { - id, - version: self.premint.version as u64, - kind: PremintName("zora_premint_v2".to_string()), - signer: self.collection.contractAdmin, - chain_id: self.chain_id, - collection_address: Address::default(), // TODO: source this - token_id: U256::from(self.premint.uid), - uri: self.premint.tokenConfig.tokenURI.clone(), - } - } - - fn check_filter(chain_id: u64) -> Option { - let supported_chains = [7777777, 8453]; // TODO: add the rest here and enable testnet mode - if !supported_chains.contains(&chain_id) { - return None; +#[cfg(test)] +mod test { + use crate::rules::Evaluation::{Accept, Ignore, Reject}; + use crate::rules::RuleContext; + + use super::*; + + const PREMINT_JSON: &str = include_str!(concat!( + env!("CARGO_MANIFEST_DIR"), + "/data/valid_zora_v2_premint.json" + )); + + #[tokio::test] + async fn test_is_valid_signature() { + let premint: V2 = serde_json::from_str(PREMINT_JSON).unwrap(); + let context = RuleContext::test_default().await; + let result = V2::is_valid_signature(&premint, &context).await; + + match result { + Ok(Accept) => {} + Ok(Ignore(reason)) => panic!("Should not be ignored: {}", reason), + Ok(Reject(reason)) => panic!("Rejected: {}", reason), + Err(err) => panic!("Error: {:?}", err), } - Some( - Filter::new() - .address(PREMINT_FACTORY_ADDR) - .event(ZoraPremintV2::PremintedV2::SIGNATURE), - ) - } - - fn map_claim(chain_id: u64, log: Log) -> eyre::Result { - let event = ZoraPremintV2::PremintedV2::decode_raw_log( - log.topics(), - log.data().data.as_ref(), - true, - )?; - - let id = Self::event_to_guid(chain_id, &event); - - Ok(InclusionClaim { - premint_id: id, - chain_id, - tx_hash: log.transaction_hash.unwrap_or_default(), - log_index: log.log_index.unwrap_or_default(), - kind: "zora_premint_v2".to_string(), - }) } - async fn verify_claim( - &self, - chain_id: u64, - tx: TransactionReceipt, - log: Log, - claim: InclusionClaim, - ) -> bool { - let event = - ZoraPremintV2::PremintedV2::decode_raw_log(log.topics(), &log.data().data, true); - match event { - Ok(event) => { - let conditions = vec![ - log.address() == PREMINT_FACTORY_ADDR, - log.transaction_hash.unwrap_or_default() == tx.transaction_hash, - claim.tx_hash == tx.transaction_hash, - claim.log_index == log.log_index.unwrap_or_default(), - claim.premint_id == Self::event_to_guid(chain_id, &event), - claim.kind == *"zora_premint_v2", - claim.chain_id == chain_id, - self.collection_address == event.contractAddress, - self.premint.uid == event.uid, - ]; + #[tokio::test] + async fn test_is_authorized_to_create_premint() { + let premint: V2 = serde_json::from_str(PREMINT_JSON).unwrap(); + let context = RuleContext::test_default_rpc(7777777).await; + let result = V2::is_authorized_to_create_premint(&premint, &context).await; - // confirm all conditions are true - conditions.into_iter().all(|x| x) - } - Err(e) => { - tracing::debug!("Failed to parse log: {}", e); - false - } + match result { + Ok(Accept) => {} + Ok(Ignore(reason)) => panic!("Should not be ignored: {}", reason), + Ok(Reject(reason)) => panic!("Rejected: {}", reason), + Err(err) => panic!("Error: {:?}", err), } } } - -impl ZoraPremint for ZoraPremintV2 { - fn collection_address(&self) -> Address { - self.collection_address - } - - fn chain_id(&self) -> u64 { - self.chain_id - } - - fn signature(&self) -> String { - self.signature.clone() - } -} diff --git a/src/premints/zora_premint/zora1155PremintExecutor_erc20v1.json b/src/premints/zora_premint/zora1155PremintExecutor_erc20v1.json new file mode 100644 index 0000000..01f8b1a --- /dev/null +++ b/src/premints/zora_premint/zora1155PremintExecutor_erc20v1.json @@ -0,0 +1,1364 @@ +[ + { + "inputs": [ + { + "internalType": "contract IZoraCreator1155Factory", + "name": "_factory", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "ADDRESS_DELEGATECALL_TO_NON_CONTRACT", + "type": "error" + }, + { + "inputs": [], + "name": "ADDRESS_LOW_LEVEL_CALL_FAILED", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "Burn_NotOwnerOrApproved", + "type": "error" + }, + { + "inputs": [], + "name": "CREATOR_FUNDS_RECIPIENT_NOT_SET", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "reason", + "type": "bytes" + } + ], + "name": "CallFailed", + "type": "error" + }, + { + "inputs": [], + "name": "Call_TokenIdMismatch", + "type": "error" + }, + { + "inputs": [], + "name": "CallerNotZoraCreator1155", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "quantity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalMinted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxSupply", + "type": "uint256" + } + ], + "name": "CannotMintMoreTokens", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "proposedAddress", + "type": "address" + } + ], + "name": "Config_TransferHookNotSupported", + "type": "error" + }, + { + "inputs": [], + "name": "ERC1155_MINT_TO_ZERO_ADDRESS", + "type": "error" + }, + { + "inputs": [], + "name": "ERC1967_NEW_IMPL_NOT_CONTRACT", + "type": "error" + }, + { + "inputs": [], + "name": "ERC1967_NEW_IMPL_NOT_UUPS", + "type": "error" + }, + { + "inputs": [], + "name": "ERC1967_UNSUPPORTED_PROXIABLEUUID", + "type": "error" + }, + { + "inputs": [], + "name": "ERC20TransferSlippage", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "ETHWithdrawFailed", + "type": "error" + }, + { + "inputs": [], + "name": "FUNCTION_MUST_BE_CALLED_THROUGH_ACTIVE_PROXY", + "type": "error" + }, + { + "inputs": [], + "name": "FUNCTION_MUST_BE_CALLED_THROUGH_DELEGATECALL", + "type": "error" + }, + { + "inputs": [], + "name": "FirstMinterAddressZero", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "contractValue", + "type": "uint256" + } + ], + "name": "FundsWithdrawInsolvent", + "type": "error" + }, + { + "inputs": [], + "name": "INITIALIZABLE_CONTRACT_ALREADY_INITIALIZED", + "type": "error" + }, + { + "inputs": [], + "name": "INITIALIZABLE_CONTRACT_IS_INITIALIZING", + "type": "error" + }, + { + "inputs": [], + "name": "INITIALIZABLE_CONTRACT_IS_NOT_INITIALIZING", + "type": "error" + }, + { + "inputs": [], + "name": "INVALID_ADDRESS_ZERO", + "type": "error" + }, + { + "inputs": [], + "name": "INVALID_ETH_AMOUNT", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "mintTo", + "type": "address" + }, + { + "internalType": "bytes32[]", + "name": "merkleProof", + "type": "bytes32[]" + }, + { + "internalType": "bytes32", + "name": "merkleRoot", + "type": "bytes32" + } + ], + "name": "InvalidMerkleProof", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidMintSchedule", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidPremintVersion", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidSignature", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidSignatureVersion", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "magicValue", + "type": "bytes4" + } + ], + "name": "InvalidSigner", + "type": "error" + }, + { + "inputs": [], + "name": "MintNotYetStarted", + "type": "error" + }, + { + "inputs": [], + "name": "Mint_InsolventSaleTransfer", + "type": "error" + }, + { + "inputs": [], + "name": "Mint_InvalidMintArrayLength", + "type": "error" + }, + { + "inputs": [], + "name": "Mint_TokenIDMintNotAllowed", + "type": "error" + }, + { + "inputs": [], + "name": "Mint_UnknownCommand", + "type": "error" + }, + { + "inputs": [], + "name": "Mint_ValueTransferFail", + "type": "error" + }, + { + "inputs": [], + "name": "MinterContractAlreadyExists", + "type": "error" + }, + { + "inputs": [], + "name": "MinterContractDoesNotExist", + "type": "error" + }, + { + "inputs": [], + "name": "NewOwnerNeedsToBeAdmin", + "type": "error" + }, + { + "inputs": [], + "name": "NonEthRedemption", + "type": "error" + }, + { + "inputs": [], + "name": "ONLY_CREATE_REFERRAL", + "type": "error" + }, + { + "inputs": [], + "name": "ONLY_OWNER", + "type": "error" + }, + { + "inputs": [], + "name": "ONLY_PENDING_OWNER", + "type": "error" + }, + { + "inputs": [], + "name": "OWNER_CANNOT_BE_ZERO_ADDRESS", + "type": "error" + }, + { + "inputs": [], + "name": "OnlyTransfersFromZoraMints", + "type": "error" + }, + { + "inputs": [], + "name": "PremintDeleted", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "caller", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "ProtocolRewardsWithdrawFailed", + "type": "error" + }, + { + "inputs": [], + "name": "Renderer_NotValidRendererContract", + "type": "error" + }, + { + "inputs": [], + "name": "SaleEnded", + "type": "error" + }, + { + "inputs": [], + "name": "SaleHasNotStarted", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "targetContract", + "type": "address" + } + ], + "name": "Sale_CannotCallNonSalesContract", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "expected", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "actual", + "type": "uint256" + } + ], + "name": "TokenIdMismatch", + "type": "error" + }, + { + "inputs": [], + "name": "UUPS_UPGRADEABLE_MUST_NOT_BE_CALLED_THROUGH_DELEGATECALL", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "expected", + "type": "string" + }, + { + "internalType": "string", + "name": "actual", + "type": "string" + } + ], + "name": "UpgradeToMismatchedContractName", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "uint256", + "name": "limit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "requestedAmount", + "type": "uint256" + } + ], + "name": "UserExceedsMintLimit", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "role", + "type": "uint256" + } + ], + "name": "UserMissingRoleForToken", + "type": "error" + }, + { + "inputs": [], + "name": "WrongValueSent", + "type": "error" + }, + { + "inputs": [], + "name": "premintSignerContractFailedToRecoverSigner", + "type": "error" + }, + { + "inputs": [], + "name": "premintSignerContractNotAContract", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "canceledOwner", + "type": "address" + } + ], + "name": "OwnerCanceled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "pendingOwner", + "type": "address" + } + ], + "name": "OwnerPending", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "prevOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnerUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "contractAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "bool", + "name": "createdNewContract", + "type": "bool" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "uid", + "type": "uint32" + }, + { + "components": [ + { + "internalType": "address", + "name": "contractAdmin", + "type": "address" + }, + { + "internalType": "string", + "name": "contractURI", + "type": "string" + }, + { + "internalType": "string", + "name": "contractName", + "type": "string" + } + ], + "indexed": false, + "internalType": "struct ContractCreationConfig", + "name": "contractConfig", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "string", + "name": "tokenURI", + "type": "string" + }, + { + "internalType": "uint256", + "name": "maxSupply", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "maxTokensPerAddress", + "type": "uint64" + }, + { + "internalType": "uint96", + "name": "pricePerToken", + "type": "uint96" + }, + { + "internalType": "uint64", + "name": "mintStart", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "mintDuration", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "royaltyMintSchedule", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "royaltyBPS", + "type": "uint32" + }, + { + "internalType": "address", + "name": "royaltyRecipient", + "type": "address" + }, + { + "internalType": "address", + "name": "fixedPriceMinter", + "type": "address" + } + ], + "indexed": false, + "internalType": "struct TokenCreationConfig", + "name": "tokenConfig", + "type": "tuple" + }, + { + "indexed": false, + "internalType": "address", + "name": "minter", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "quantityMinted", + "type": "uint256" + } + ], + "name": "Preminted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "contractAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "bool", + "name": "createdNewContract", + "type": "bool" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "uid", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "address", + "name": "minter", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "quantityMinted", + "type": "uint256" + } + ], + "name": "PremintedV2", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "cancelOwnershipTransfer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "contractName", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "contractAdmin", + "type": "address" + }, + { + "internalType": "string", + "name": "contractURI", + "type": "string" + }, + { + "internalType": "string", + "name": "contractName", + "type": "string" + } + ], + "internalType": "struct ContractCreationConfig", + "name": "contractConfig", + "type": "tuple" + } + ], + "name": "getContractAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_initialOwner", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "signer", + "type": "address" + }, + { + "internalType": "address", + "name": "premintContractConfigContractAdmin", + "type": "address" + }, + { + "internalType": "address", + "name": "contractAddress", + "type": "address" + } + ], + "name": "isAuthorizedToCreatePremint", + "outputs": [ + { + "internalType": "bool", + "name": "isAuthorized", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "contractAdmin", + "type": "address" + }, + { + "internalType": "string", + "name": "contractURI", + "type": "string" + }, + { + "internalType": "string", + "name": "contractName", + "type": "string" + } + ], + "internalType": "struct ContractCreationConfig", + "name": "contractConfig", + "type": "tuple" + }, + { + "components": [ + { + "components": [ + { + "internalType": "string", + "name": "tokenURI", + "type": "string" + }, + { + "internalType": "uint256", + "name": "maxSupply", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "maxTokensPerAddress", + "type": "uint64" + }, + { + "internalType": "uint96", + "name": "pricePerToken", + "type": "uint96" + }, + { + "internalType": "uint64", + "name": "mintStart", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "mintDuration", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "royaltyMintSchedule", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "royaltyBPS", + "type": "uint32" + }, + { + "internalType": "address", + "name": "royaltyRecipient", + "type": "address" + }, + { + "internalType": "address", + "name": "fixedPriceMinter", + "type": "address" + } + ], + "internalType": "struct TokenCreationConfig", + "name": "tokenConfig", + "type": "tuple" + }, + { + "internalType": "uint32", + "name": "uid", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "version", + "type": "uint32" + }, + { + "internalType": "bool", + "name": "deleted", + "type": "bool" + } + ], + "internalType": "struct PremintConfig", + "name": "premintConfig", + "type": "tuple" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "name": "isValidSignature", + "outputs": [ + { + "internalType": "bool", + "name": "isValid", + "type": "bool" + }, + { + "internalType": "address", + "name": "contractAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "recoveredSigner", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "collectionAddress", + "type": "address" + } + ], + "name": "mintFee", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "contractAdmin", + "type": "address" + }, + { + "internalType": "string", + "name": "contractURI", + "type": "string" + }, + { + "internalType": "string", + "name": "contractName", + "type": "string" + } + ], + "internalType": "struct ContractCreationConfig", + "name": "contractConfig", + "type": "tuple" + }, + { + "components": [ + { + "components": [ + { + "internalType": "string", + "name": "tokenURI", + "type": "string" + }, + { + "internalType": "uint256", + "name": "maxSupply", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "royaltyBPS", + "type": "uint32" + }, + { + "internalType": "address", + "name": "payoutRecipient", + "type": "address" + }, + { + "internalType": "address", + "name": "createReferral", + "type": "address" + }, + { + "internalType": "address", + "name": "erc20Minter", + "type": "address" + }, + { + "internalType": "uint64", + "name": "mintStart", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "mintDuration", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "maxTokensPerAddress", + "type": "uint64" + }, + { + "internalType": "address", + "name": "currency", + "type": "address" + }, + { + "internalType": "uint256", + "name": "pricePerToken", + "type": "uint256" + } + ], + "internalType": "struct TokenCreationConfig", + "name": "tokenConfig", + "type": "tuple" + }, + { + "internalType": "uint32", + "name": "uid", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "version", + "type": "uint32" + }, + { + "internalType": "bool", + "name": "deleted", + "type": "bool" + } + ], + "internalType": "struct CreatorAttribution", + "name": "premintConfig", + "type": "tuple" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "quantityToMint", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "address", + "name": "mintRecipient", + "type": "address" + }, + { + "internalType": "string", + "name": "mintComment", + "type": "string" + }, + { + "internalType": "address[]", + "name": "mintRewardsRecipients", + "type": "address[]" + } + ], + "internalType": "struct MintArguments", + "name": "mintArguments", + "type": "tuple" + }, + { + "internalType": "address", + "name": "firstMinter", + "type": "address" + }, + { + "internalType": "address", + "name": "signerContract", + "type": "address" + } + ], + "name": "premintErc20V1", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "contractAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "createdNewContract", + "type": "bool" + } + ], + "internalType": "struct PremintResult", + "name": "result", + "type": "tuple" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "contractAddress", + "type": "address" + }, + { + "internalType": "uint32", + "name": "uid", + "type": "uint32" + } + ], + "name": "premintStatus", + "outputs": [ + { + "internalType": "bool", + "name": "contractCreated", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "tokenIdForPremint", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "proxiableUUID", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "resignOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_newOwner", + "type": "address" + } + ], + "name": "safeTransferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "contractAddress", + "type": "address" + } + ], + "name": "supportedPremintSignatureVersions", + "outputs": [ + { + "internalType": "string[]", + "name": "versions", + "type": "string[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "zora1155Factory", + "outputs": [ + { + "internalType": "contract IZoraCreator1155Factory", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } +] \ No newline at end of file diff --git a/src/rules.rs b/src/rules.rs index 2348298..7c62a3e 100644 --- a/src/rules.rs +++ b/src/rules.rs @@ -2,7 +2,6 @@ use std::error::Error; use std::fmt::{Display, Formatter}; use std::sync::Arc; -use alloy::network::Ethereum; use async_trait::async_trait; use futures::future::join_all; use serde::ser::SerializeStruct; @@ -242,11 +241,11 @@ macro_rules! metadata_rule { #[macro_export] macro_rules! typed_rule { - ($t:path, $fn:tt) => {{ + ($t:path, $fn:path) => {{ struct TypedRule; #[async_trait::async_trait] - impl $crate::rules::Rule for TypedRule { + impl $crate::rules::Rule for TypedRule { async fn check( &self, item: &$crate::types::PremintTypes, @@ -276,7 +275,7 @@ pub fn all_rules() -> Vec>> { let mut rules: Vec>> = Vec::new(); rules.append(&mut general::all_rules()); - rules.append(&mut crate::premints::zora_premint::rules::all_rules()); + rules.append(&mut crate::premints::zora_premint::v2::all_v2_rules()); rules } @@ -455,7 +454,7 @@ mod general { #[cfg(test)] mod test { - use crate::premints::zora_premint::v2::ZoraPremintV2; + use crate::premints::zora_premint::v2::V2; use crate::rules::general::existing_token_uri; use crate::rules::Evaluation::{Accept, Reject}; use crate::storage::{PremintStorage, Writer}; @@ -502,7 +501,7 @@ mod test { } async fn simple_typed_zora_rule( - _item: &ZoraPremintV2, + _item: &V2, _context: &RuleContext, ) -> eyre::Result { Ok(Accept) diff --git a/src/storage.rs b/src/storage.rs index 6ebb86e..eb18218 100644 --- a/src/storage.rs +++ b/src/storage.rs @@ -326,7 +326,7 @@ mod test { use std::ops::Sub; use crate::config::Config; - use crate::premints::zora_premint::v2::ZoraPremintV2; + use crate::premints::zora_premint::v2::V2; use crate::storage; use crate::storage::{ list_all, list_all_with_options, PremintStorage, QueryOptions, Reader, Writer, @@ -368,7 +368,7 @@ mod test { // now let's try to update - let mut premint = ZoraPremintV2::default(); + let mut premint = V2::default(); premint.premint.version = 2; let premint = PremintTypes::ZoraV2(premint); store.store(premint.clone()).await.unwrap(); @@ -513,7 +513,7 @@ mod test { let store = PremintStorage::new(&config).await; - let mut p = ZoraPremintV2::default(); + let mut p = V2::default(); p.premint.uid = 1; p.chain_id = 7777777; let premint_v2 = PremintTypes::ZoraV2(p); @@ -546,7 +546,7 @@ mod test { let store = PremintStorage::new(&config).await; // Make sure IDs are different - let mut p = ZoraPremintV2::default(); + let mut p = V2::default(); p.premint.uid = 1; p.chain_id = 7777777; let premint_v2 = PremintTypes::ZoraV2(p); diff --git a/src/types.rs b/src/types.rs index 141ea55..eb5f4d0 100644 --- a/src/types.rs +++ b/src/types.rs @@ -1,4 +1,4 @@ -use crate::premints::zora_premint::v2::ZoraPremintV2; +use crate::premints::zora_premint::v2; use alloy::primitives::{Address, B256, U256}; use alloy::rpc::types::eth::{Filter, Log, TransactionReceipt}; use async_trait::async_trait; @@ -7,6 +7,7 @@ use libp2p::{gossipsub, Multiaddr, PeerId}; use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize}; use std::fmt::Debug; +use std::format; #[derive(Debug, Clone)] pub struct PremintName(pub String); @@ -62,7 +63,7 @@ pub trait Premint: Serialize + DeserializeOwned + Debug + Clone { #[allow(clippy::large_enum_variant)] pub enum PremintTypes { Simple(SimplePremint), - ZoraV2(ZoraPremintV2), + ZoraV2(v2::V2), } impl PremintTypes { @@ -204,7 +205,7 @@ mod test { let premint = PremintTypes::from_json(json).unwrap(); println!("{:?}", premint); - let premint = PremintTypes::ZoraV2(ZoraPremintV2::default()); + let premint = PremintTypes::ZoraV2(v2::V2::default()); let json = premint.to_json().unwrap(); println!("{}", json); let premint: PremintTypes = PremintTypes::from_json(json).unwrap(); @@ -238,7 +239,7 @@ mod test { ..Default::default() }; - let claim = ZoraPremintV2::map_claim(7777777, log.clone()).unwrap(); + let claim = v2::V2::map_claim(7777777, log.clone()).unwrap(); let expected = InclusionClaim { premint_id: "7777777:0x65aae9d752ecac4965015664d0a6d0951e28d757:1".to_string(), chain_id: 7777777, @@ -305,8 +306,8 @@ mod test { IZoraPremintV2::PremintedV2::decode_raw_log(log.topics(), &log.data().data, true) .unwrap(); - let claim = ZoraPremintV2::map_claim(7777777, log.clone()).unwrap(); - let premint = ZoraPremintV2 { + let claim = ::map_claim(7777777, log.clone()).unwrap(); + let premint = v2::V2 { collection: ContractCreationConfig { contractAdmin: Default::default(), contractURI: "".to_string(), diff --git a/tests/e2e_test.rs b/tests/e2e_test.rs index e4ffedf..f7b8c49 100644 --- a/tests/e2e_test.rs +++ b/tests/e2e_test.rs @@ -18,7 +18,7 @@ use mintpool::config::{BootNodes, ChainInclusionMode, Config}; use mintpool::controller::{ControllerCommands, DBQuery}; use mintpool::premints::zora_premint::contract::IZoraPremintV2::MintArguments; use mintpool::premints::zora_premint::contract::{IZoraPremintV2, PREMINT_FACTORY_ADDR}; -use mintpool::premints::zora_premint::v2::ZoraPremintV2; +use mintpool::premints::zora_premint::v2::V2; use mintpool::rules::RulesEngine; use mintpool::run; use mintpool::types::PremintTypes; @@ -56,14 +56,14 @@ async fn test_zora_premint_v2_e2e() { let ctl = run::start_p2p_services(config.clone(), RulesEngine::new_with_default_rules(&config)) .await .unwrap(); - run::start_watch_chain::(&config, ctl.clone()).await; + run::start_watch_chain::(&config, ctl.clone()).await; // ============================================================================================ // Publish a premint to the mintpool // ============================================================================================ // Push a message to the mintpool - let premint: ZoraPremintV2 = serde_json::from_str(PREMINT_JSON).unwrap(); + let premint: V2 = serde_json::from_str(PREMINT_JSON).unwrap(); let (send, _recv) = tokio::sync::oneshot::channel(); ctl.send_command(ControllerCommands::Broadcast { @@ -210,7 +210,7 @@ async fn test_verify_e2e() { ) .await .unwrap(); - run::start_watch_chain::(&config1, ctl1.clone()).await; + run::start_watch_chain::(&config1, ctl1.clone()).await; let ctl2 = run::start_p2p_services( config2.clone(), @@ -243,7 +243,7 @@ async fn test_verify_e2e() { // ============================================================================================ // Publish a premint to the mintpool // ============================================================================================ - let premint: ZoraPremintV2 = serde_json::from_str(PREMINT_JSON).unwrap(); + let premint: V2 = serde_json::from_str(PREMINT_JSON).unwrap(); let (send, recv) = tokio::sync::oneshot::channel(); ctl1.send_command(ControllerCommands::Broadcast { From 55f7fc72a2ef53b873c014b36a16cd5b6d2bd28b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bierlein?= Date: Thu, 2 May 2024 18:47:44 +0200 Subject: [PATCH 04/10] Add erc20 premints --- src/premints/zora_premint/contract.rs | 11 +-- src/premints/zora_premint/erc20v1.rs | 70 +++++++++++++++++++ src/premints/zora_premint/mod.rs | 1 + src/premints/zora_premint/types.rs | 39 ----------- src/premints/zora_premint/v2.rs | 41 ++++++++++- ...n => zora1155PremintExecutor_erc20_1.json} | 0 src/types.rs | 5 +- 7 files changed, 117 insertions(+), 50 deletions(-) create mode 100644 src/premints/zora_premint/erc20v1.rs rename src/premints/zora_premint/{zora1155PremintExecutor_erc20v1.json => zora1155PremintExecutor_erc20_1.json} (100%) diff --git a/src/premints/zora_premint/contract.rs b/src/premints/zora_premint/contract.rs index 8664b28..a4fb205 100644 --- a/src/premints/zora_premint/contract.rs +++ b/src/premints/zora_premint/contract.rs @@ -1,14 +1,7 @@ -use std::sync::Arc; - -use alloy::primitives::{address, Address, Bytes, TxKind}; -use alloy::rpc::types::eth::{BlockId, TransactionInput, TransactionRequest}; +use alloy::primitives::{address, Address}; use alloy::sol; -use alloy::sol_types::SolCall; -use futures_util::StreamExt; use serde::{Deserialize, Serialize}; -use crate::chain_list::ChainListProvider; - pub static PREMINT_FACTORY_ADDR: Address = address!("7777773606e7e46C8Ba8B98C08f5cD218e31d340"); // we need to use separate namespaces for each premint version, @@ -17,7 +10,7 @@ pub static PREMINT_FACTORY_ADDR: Address = address!("7777773606e7e46C8Ba8B98C08f sol! { #[derive(Debug, Serialize, Deserialize, PartialEq)] IZoraPremintERC20V1, - "src/premints/zora_premint/zora1155PremintExecutor_erc20v1.json" + "src/premints/zora_premint/zora1155PremintExecutor_erc20_1.json" } sol! { diff --git a/src/premints/zora_premint/erc20v1.rs b/src/premints/zora_premint/erc20v1.rs new file mode 100644 index 0000000..8e032f9 --- /dev/null +++ b/src/premints/zora_premint/erc20v1.rs @@ -0,0 +1,70 @@ +use crate::{implement_zora_premint_traits, typed_rule}; +use alloy::primitives::Address; + +use crate::premints::zora_premint::contract::IZoraPremintERC20V1; +use crate::premints::zora_premint::contract::IZoraPremintV2::IZoraPremintV2Errors; + +use crate::rules::Rule; +use crate::storage::Reader; +use crate::types::PremintTypes; + +impl Default for IZoraPremintERC20V1::ContractCreationConfig { + fn default() -> Self { + Self { + contractAdmin: Default::default(), + contractURI: Default::default(), + contractName: Default::default(), + } + } +} + +impl Default for IZoraPremintERC20V1::TokenCreationConfig { + fn default() -> Self { + Self { + tokenURI: Default::default(), + maxSupply: Default::default(), + maxTokensPerAddress: Default::default(), + pricePerToken: Default::default(), + mintStart: Default::default(), + mintDuration: Default::default(), + royaltyBPS: Default::default(), + fixedPriceMinter: Default::default(), + royaltyMintSchedule: Default::default(), + royaltyRecipient: Default::default(), + } + } +} + +impl Default for IZoraPremintERC20V1::CreatorAttribution { + fn default() -> Self { + Self { + tokenConfig: Default::default(), + uid: Default::default(), + version: Default::default(), + deleted: Default::default(), + } + } +} + +implement_zora_premint_traits!( + IZoraPremintERC20V1, + ERC20V1, + "zora_premint_erc20v1", + "ERC20_1" +); + +pub fn all_v2_rules() -> Vec>> { + vec![ + typed_rule!( + PremintTypes::ZoraERC20V1, + ERC20V1::is_authorized_to_create_premint + ), + typed_rule!(PremintTypes::ZoraERC20V1, ERC20V1::is_valid_signature), + typed_rule!(PremintTypes::ZoraERC20V1, ERC20V1::is_chain_supported), + typed_rule!(PremintTypes::ZoraERC20V1, ERC20V1::not_minted), + typed_rule!( + PremintTypes::ZoraERC20V1, + ERC20V1::premint_version_supported + ), + ] +} diff --git a/src/premints/zora_premint/mod.rs b/src/premints/zora_premint/mod.rs index 16a3c29..343be18 100644 --- a/src/premints/zora_premint/mod.rs +++ b/src/premints/zora_premint/mod.rs @@ -1,4 +1,5 @@ pub mod contract; +pub mod erc20v1; pub mod rules; pub mod types; pub mod v2; diff --git a/src/premints/zora_premint/types.rs b/src/premints/zora_premint/types.rs index 06d1cdc..874a1ad 100644 --- a/src/premints/zora_premint/types.rs +++ b/src/premints/zora_premint/types.rs @@ -18,45 +18,6 @@ macro_rules! implement_zora_premint_traits { pub signature: String, } - - impl core::default::Default for $namespace::ContractCreationConfig { - fn default() -> Self { - Self { - contractAdmin: Default::default(), - contractURI: String::default(), - contractName: String::default(), - } - } - } - - impl core::default::Default for $namespace::TokenCreationConfig { - fn default() -> Self { - Self { - tokenURI: Default::default(), - maxSupply: Default::default(), - maxTokensPerAddress: Default::default(), - pricePerToken: Default::default(), - mintStart: Default::default(), - mintDuration: Default::default(), - royaltyBPS: Default::default(), - payoutRecipient: Default::default(), - fixedPriceMinter: Default::default(), - createReferral: Default::default(), - } - } - } - - impl core::default::Default for $namespace::CreatorAttribution { - fn default() -> Self { - Self { - tokenConfig: Default::default(), - uid: Default::default(), - version: Default::default(), - deleted: Default::default(), - } - } - } - impl $typ { fn event_to_guid(chain_id: u64, event: &$namespace::PremintedV2) -> String { format!( diff --git a/src/premints/zora_premint/v2.rs b/src/premints/zora_premint/v2.rs index 0af59f9..fed8a2f 100644 --- a/src/premints/zora_premint/v2.rs +++ b/src/premints/zora_premint/v2.rs @@ -2,11 +2,49 @@ use crate::{implement_zora_premint_traits, typed_rule}; use alloy::primitives::Address; use crate::premints::zora_premint::contract::IZoraPremintV2; -use crate::premints::zora_premint::contract::IZoraPremintV2::PremintedV2; + use crate::rules::Rule; use crate::storage::Reader; use crate::types::PremintTypes; +impl Default for IZoraPremintV2::ContractCreationConfig { + fn default() -> Self { + Self { + contractAdmin: Default::default(), + contractURI: Default::default(), + contractName: Default::default(), + } + } +} + +impl Default for IZoraPremintV2::TokenCreationConfig { + fn default() -> Self { + Self { + tokenURI: Default::default(), + maxSupply: Default::default(), + maxTokensPerAddress: Default::default(), + pricePerToken: Default::default(), + mintStart: Default::default(), + mintDuration: Default::default(), + royaltyBPS: Default::default(), + payoutRecipient: Default::default(), + fixedPriceMinter: Default::default(), + createReferral: Default::default(), + } + } +} + +impl Default for IZoraPremintV2::CreatorAttribution { + fn default() -> Self { + Self { + tokenConfig: Default::default(), + uid: Default::default(), + version: Default::default(), + deleted: Default::default(), + } + } +} + implement_zora_premint_traits!(IZoraPremintV2, V2, "zora_premint_v2", "2"); pub fn all_v2_rules() -> Vec>> { @@ -18,6 +56,7 @@ pub fn all_v2_rules() -> Vec>> { typed_rule!(PremintTypes::ZoraV2, V2::premint_version_supported), ] } + #[cfg(test)] mod test { use crate::rules::Evaluation::{Accept, Ignore, Reject}; diff --git a/src/premints/zora_premint/zora1155PremintExecutor_erc20v1.json b/src/premints/zora_premint/zora1155PremintExecutor_erc20_1.json similarity index 100% rename from src/premints/zora_premint/zora1155PremintExecutor_erc20v1.json rename to src/premints/zora_premint/zora1155PremintExecutor_erc20_1.json diff --git a/src/types.rs b/src/types.rs index eb5f4d0..c287a66 100644 --- a/src/types.rs +++ b/src/types.rs @@ -1,4 +1,4 @@ -use crate::premints::zora_premint::v2; +use crate::premints::zora_premint::{erc20v1, v2}; use alloy::primitives::{Address, B256, U256}; use alloy::rpc::types::eth::{Filter, Log, TransactionReceipt}; use async_trait::async_trait; @@ -64,6 +64,7 @@ pub trait Premint: Serialize + DeserializeOwned + Debug + Clone { pub enum PremintTypes { Simple(SimplePremint), ZoraV2(v2::V2), + ZoraERC20V1(erc20v1::ERC20V1), } impl PremintTypes { @@ -86,6 +87,7 @@ macro_rules! every_arm_fn { match self { PremintTypes::Simple(p) => p.$fn($($arg),*), PremintTypes::ZoraV2(p) => p.$fn($($arg),*), + PremintTypes::ZoraERC20V1(p) => p.$fn($($arg),*), } } } @@ -97,6 +99,7 @@ macro_rules! every_arm_fn { match self { PremintTypes::Simple(p) => p.$fn($($arg),*).await, PremintTypes::ZoraV2(p) => p.$fn($($arg),*).await, + PremintTypes::ZoraERC20V1(p) => p.$fn($($arg),*).await, } } } From 02232ac143e22945404a3195497f553360c664a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bierlein?= Date: Wed, 24 Apr 2024 01:09:32 +0200 Subject: [PATCH 05/10] Add ERC20 types --- .../zora1155PremintExecutor_erc20v1.json | 1135 +++++++++++++++++ 1 file changed, 1135 insertions(+) create mode 100644 src/premints/zora_premint/zora1155PremintExecutor_erc20v1.json diff --git a/src/premints/zora_premint/zora1155PremintExecutor_erc20v1.json b/src/premints/zora_premint/zora1155PremintExecutor_erc20v1.json new file mode 100644 index 0000000..6dc12b1 --- /dev/null +++ b/src/premints/zora_premint/zora1155PremintExecutor_erc20v1.json @@ -0,0 +1,1135 @@ +[ + { + "type": "constructor", + "inputs": [ + { + "name": "_factory", + "type": "address", + "internalType": "contract IZoraCreator1155Factory" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "acceptOwnership", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "cancelOwnershipTransfer", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "contractName", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "string", + "internalType": "string" + } + ], + "stateMutability": "pure" + }, + { + "type": "function", + "name": "getContractAddress", + "inputs": [ + { + "name": "contractConfig", + "type": "tuple", + "internalType": "struct ContractCreationConfig", + "components": [ + { + "name": "contractAdmin", + "type": "address", + "internalType": "address" + }, + { + "name": "contractURI", + "type": "string", + "internalType": "string" + }, + { + "name": "contractName", + "type": "string", + "internalType": "string" + } + ] + } + ], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "implementation", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "initialize", + "inputs": [ + { + "name": "_initialOwner", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "isAuthorizedToCreatePremint", + "inputs": [ + { + "name": "signer", + "type": "address", + "internalType": "address" + }, + { + "name": "premintContractConfigContractAdmin", + "type": "address", + "internalType": "address" + }, + { + "name": "contractAddress", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "isAuthorized", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "mintFee", + "inputs": [ + { + "name": "collectionAddress", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "owner", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "pendingOwner", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "premintStatus", + "inputs": [ + { + "name": "contractAddress", + "type": "address", + "internalType": "address" + }, + { + "name": "uid", + "type": "uint32", + "internalType": "uint32" + } + ], + "outputs": [ + { + "name": "contractCreated", + "type": "bool", + "internalType": "bool" + }, + { + "name": "tokenIdForPremint", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "contractAdmin", + "type": "address" + }, + { + "internalType": "string", + "name": "contractURI", + "type": "string" + }, + { + "internalType": "string", + "name": "contractName", + "type": "string" + } + ], + "internalType": "struct ContractCreationConfig", + "name": "contractConfig", + "type": "tuple" + }, + { + "components": [ + { + "components": [ + { + "internalType": "string", + "name": "tokenURI", + "type": "string" + }, + { + "internalType": "uint256", + "name": "maxSupply", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "royaltyBPS", + "type": "uint32" + }, + { + "internalType": "address", + "name": "payoutRecipient", + "type": "address" + }, + { + "internalType": "address", + "name": "createReferral", + "type": "address" + }, + { + "internalType": "address", + "name": "erc20Minter", + "type": "address" + }, + { + "internalType": "uint64", + "name": "mintStart", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "mintDuration", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "maxTokensPerAddress", + "type": "uint64" + }, + { + "internalType": "address", + "name": "currency", + "type": "address" + }, + { + "internalType": "uint256", + "name": "pricePerToken", + "type": "uint256" + } + ], + "internalType": "struct TokenCreationConfig", + "name": "tokenConfig", + "type": "tuple" + }, + { + "internalType": "uint32", + "name": "uid", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "version", + "type": "uint32" + }, + { + "internalType": "bool", + "name": "deleted", + "type": "bool" + } + ], + "internalType": "struct CreatorAttribution", + "name": "premintConfig", + "type": "tuple" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "quantityToMint", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "address", + "name": "mintRecipient", + "type": "address" + }, + { + "internalType": "string", + "name": "mintComment", + "type": "string" + }, + { + "internalType": "address[]", + "name": "mintRewardsRecipients", + "type": "address[]" + } + ], + "internalType": "struct MintArguments", + "name": "mintArguments", + "type": "tuple" + }, + { + "internalType": "address", + "name": "firstMinter", + "type": "address" + }, + { + "internalType": "address", + "name": "signerContract", + "type": "address" + } + ], + "name": "premintErc20V1", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "contractAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "createdNewContract", + "type": "bool" + } + ], + "internalType": "struct PremintResult", + "name": "result", + "type": "tuple" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "type": "function", + "name": "proxiableUUID", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "resignOwnership", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "safeTransferOwnership", + "inputs": [ + { + "name": "_newOwner", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "supportedPremintSignatureVersions", + "inputs": [ + { + "name": "contractAddress", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "versions", + "type": "string[]", + "internalType": "string[]" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "transferOwnership", + "inputs": [ + { + "name": "_newOwner", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "upgradeTo", + "inputs": [ + { + "name": "newImplementation", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "upgradeToAndCall", + "inputs": [ + { + "name": "newImplementation", + "type": "address", + "internalType": "address" + }, + { + "name": "data", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [], + "stateMutability": "payable" + }, + { + "type": "function", + "name": "zora1155Factory", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "contract IZoraCreator1155Factory" + } + ], + "stateMutability": "view" + }, + { + "type": "event", + "name": "AdminChanged", + "inputs": [ + { + "name": "previousAdmin", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "newAdmin", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "BeaconUpgraded", + "inputs": [ + { + "name": "beacon", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Initialized", + "inputs": [ + { + "name": "version", + "type": "uint8", + "indexed": false, + "internalType": "uint8" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "OwnerCanceled", + "inputs": [ + { + "name": "owner", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "canceledOwner", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "OwnerPending", + "inputs": [ + { + "name": "owner", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "pendingOwner", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "OwnerUpdated", + "inputs": [ + { + "name": "prevOwner", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "newOwner", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Preminted", + "inputs": [ + { + "name": "contractAddress", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "tokenId", + "type": "uint256", + "indexed": true, + "internalType": "uint256" + }, + { + "name": "createdNewContract", + "type": "bool", + "indexed": true, + "internalType": "bool" + }, + { + "name": "uid", + "type": "uint32", + "indexed": false, + "internalType": "uint32" + }, + { + "name": "contractConfig", + "type": "tuple", + "indexed": false, + "internalType": "struct ContractCreationConfig", + "components": [ + { + "name": "contractAdmin", + "type": "address", + "internalType": "address" + }, + { + "name": "contractURI", + "type": "string", + "internalType": "string" + }, + { + "name": "contractName", + "type": "string", + "internalType": "string" + } + ] + }, + { + "name": "tokenConfig", + "type": "tuple", + "indexed": false, + "internalType": "struct TokenCreationConfig", + "components": [ + { + "name": "tokenURI", + "type": "string", + "internalType": "string" + }, + { + "name": "maxSupply", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "maxTokensPerAddress", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "pricePerToken", + "type": "uint96", + "internalType": "uint96" + }, + { + "name": "mintStart", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "mintDuration", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "royaltyMintSchedule", + "type": "uint32", + "internalType": "uint32" + }, + { + "name": "royaltyBPS", + "type": "uint32", + "internalType": "uint32" + }, + { + "name": "royaltyRecipient", + "type": "address", + "internalType": "address" + }, + { + "name": "fixedPriceMinter", + "type": "address", + "internalType": "address" + } + ] + }, + { + "name": "minter", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "quantityMinted", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Upgraded", + "inputs": [ + { + "name": "implementation", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "error", + "name": "ADDRESS_DELEGATECALL_TO_NON_CONTRACT", + "inputs": [] + }, + { + "type": "error", + "name": "ADDRESS_LOW_LEVEL_CALL_FAILED", + "inputs": [] + }, + { + "type": "error", + "name": "Burn_NotOwnerOrApproved", + "inputs": [ + { + "name": "operator", + "type": "address", + "internalType": "address" + }, + { + "name": "user", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "CREATOR_FUNDS_RECIPIENT_NOT_SET", + "inputs": [] + }, + { + "type": "error", + "name": "CallFailed", + "inputs": [ + { + "name": "reason", + "type": "bytes", + "internalType": "bytes" + } + ] + }, + { + "type": "error", + "name": "Call_TokenIdMismatch", + "inputs": [] + }, + { + "type": "error", + "name": "CallerNotZoraCreator1155", + "inputs": [] + }, + { + "type": "error", + "name": "CannotMintMoreTokens", + "inputs": [ + { + "name": "tokenId", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "quantity", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "totalMinted", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "maxSupply", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "Config_TransferHookNotSupported", + "inputs": [ + { + "name": "proposedAddress", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "ERC1155_MINT_TO_ZERO_ADDRESS", + "inputs": [] + }, + { + "type": "error", + "name": "ERC1967_NEW_IMPL_NOT_CONTRACT", + "inputs": [] + }, + { + "type": "error", + "name": "ERC1967_NEW_IMPL_NOT_UUPS", + "inputs": [] + }, + { + "type": "error", + "name": "ERC1967_UNSUPPORTED_PROXIABLEUUID", + "inputs": [] + }, + { + "type": "error", + "name": "ETHWithdrawFailed", + "inputs": [ + { + "name": "recipient", + "type": "address", + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "FUNCTION_MUST_BE_CALLED_THROUGH_ACTIVE_PROXY", + "inputs": [] + }, + { + "type": "error", + "name": "FUNCTION_MUST_BE_CALLED_THROUGH_DELEGATECALL", + "inputs": [] + }, + { + "type": "error", + "name": "FundsWithdrawInsolvent", + "inputs": [ + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "contractValue", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "INITIALIZABLE_CONTRACT_ALREADY_INITIALIZED", + "inputs": [] + }, + { + "type": "error", + "name": "INITIALIZABLE_CONTRACT_IS_INITIALIZING", + "inputs": [] + }, + { + "type": "error", + "name": "INITIALIZABLE_CONTRACT_IS_NOT_INITIALIZING", + "inputs": [] + }, + { + "type": "error", + "name": "INVALID_ADDRESS_ZERO", + "inputs": [] + }, + { + "type": "error", + "name": "INVALID_ETH_AMOUNT", + "inputs": [] + }, + { + "type": "error", + "name": "InvalidMerkleProof", + "inputs": [ + { + "name": "mintTo", + "type": "address", + "internalType": "address" + }, + { + "name": "merkleProof", + "type": "bytes32[]", + "internalType": "bytes32[]" + }, + { + "name": "merkleRoot", + "type": "bytes32", + "internalType": "bytes32" + } + ] + }, + { + "type": "error", + "name": "InvalidMintSchedule", + "inputs": [] + }, + { + "type": "error", + "name": "InvalidSignatureVersion", + "inputs": [] + }, + { + "type": "error", + "name": "MintNotYetStarted", + "inputs": [] + }, + { + "type": "error", + "name": "Mint_InsolventSaleTransfer", + "inputs": [] + }, + { + "type": "error", + "name": "Mint_TokenIDMintNotAllowed", + "inputs": [] + }, + { + "type": "error", + "name": "Mint_UnknownCommand", + "inputs": [] + }, + { + "type": "error", + "name": "Mint_ValueTransferFail", + "inputs": [] + }, + { + "type": "error", + "name": "MinterContractAlreadyExists", + "inputs": [] + }, + { + "type": "error", + "name": "MinterContractDoesNotExist", + "inputs": [] + }, + { + "type": "error", + "name": "NewOwnerNeedsToBeAdmin", + "inputs": [] + }, + { + "type": "error", + "name": "ONLY_CREATE_REFERRAL", + "inputs": [] + }, + { + "type": "error", + "name": "ONLY_OWNER", + "inputs": [] + }, + { + "type": "error", + "name": "ONLY_PENDING_OWNER", + "inputs": [] + }, + { + "type": "error", + "name": "OWNER_CANNOT_BE_ZERO_ADDRESS", + "inputs": [] + }, + { + "type": "error", + "name": "PremintDeleted", + "inputs": [] + }, + { + "type": "error", + "name": "ProtocolRewardsWithdrawFailed", + "inputs": [ + { + "name": "caller", + "type": "address", + "internalType": "address" + }, + { + "name": "recipient", + "type": "address", + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "Renderer_NotValidRendererContract", + "inputs": [] + }, + { + "type": "error", + "name": "SaleEnded", + "inputs": [] + }, + { + "type": "error", + "name": "SaleHasNotStarted", + "inputs": [] + }, + { + "type": "error", + "name": "Sale_CannotCallNonSalesContract", + "inputs": [ + { + "name": "targetContract", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "TokenIdMismatch", + "inputs": [ + { + "name": "expected", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "actual", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "UUPS_UPGRADEABLE_MUST_NOT_BE_CALLED_THROUGH_DELEGATECALL", + "inputs": [] + }, + { + "type": "error", + "name": "UpgradeToMismatchedContractName", + "inputs": [ + { + "name": "expected", + "type": "string", + "internalType": "string" + }, + { + "name": "actual", + "type": "string", + "internalType": "string" + } + ] + }, + { + "type": "error", + "name": "UserExceedsMintLimit", + "inputs": [ + { + "name": "user", + "type": "address", + "internalType": "address" + }, + { + "name": "limit", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "requestedAmount", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "UserMissingRoleForToken", + "inputs": [ + { + "name": "user", + "type": "address", + "internalType": "address" + }, + { + "name": "tokenId", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "role", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "WrongValueSent", + "inputs": [] + } +] From 82149f4ea6e246c8ea26623709ceae6cca95f508 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bierlein?= Date: Fri, 26 Apr 2024 19:16:20 +0200 Subject: [PATCH 06/10] Post rebase fixes --- src/storage.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/storage.rs b/src/storage.rs index eb18218..33ae6eb 100644 --- a/src/storage.rs +++ b/src/storage.rs @@ -320,10 +320,11 @@ fn build_query(options: &QueryOptions) -> QueryBuilder { #[cfg(test)] mod test { + use std::ops::Sub; + use alloy::primitives::Address; use chrono::{Duration, Utc}; use sqlx::Row; - use std::ops::Sub; use crate::config::Config; use crate::premints::zora_premint::v2::V2; From 04ac2cde34a41417e1fbd4312796020fa9381ef6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bierlein?= Date: Fri, 26 Apr 2024 19:47:57 +0200 Subject: [PATCH 07/10] More fixes --- src/rules.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rules.rs b/src/rules.rs index 7c62a3e..529fc0e 100644 --- a/src/rules.rs +++ b/src/rules.rs @@ -252,7 +252,7 @@ macro_rules! typed_rule { context: &$crate::rules::RuleContext, ) -> eyre::Result<$crate::rules::Evaluation> { match item { - $t(premint) => $fn(&premint, context).await, + $t(premint) => $fn(premint, context).await, _ => $crate::ignore!("Wrong type"), } } From bf4b589a425383b53fe097ef3dbf25e4b458bbcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bierlein?= Date: Thu, 2 May 2024 18:58:07 +0200 Subject: [PATCH 08/10] Delete file --- .../zora1155PremintExecutor_erc20v1.json | 1135 ----------------- 1 file changed, 1135 deletions(-) delete mode 100644 src/premints/zora_premint/zora1155PremintExecutor_erc20v1.json diff --git a/src/premints/zora_premint/zora1155PremintExecutor_erc20v1.json b/src/premints/zora_premint/zora1155PremintExecutor_erc20v1.json deleted file mode 100644 index 6dc12b1..0000000 --- a/src/premints/zora_premint/zora1155PremintExecutor_erc20v1.json +++ /dev/null @@ -1,1135 +0,0 @@ -[ - { - "type": "constructor", - "inputs": [ - { - "name": "_factory", - "type": "address", - "internalType": "contract IZoraCreator1155Factory" - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "acceptOwnership", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "cancelOwnershipTransfer", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "contractName", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "string", - "internalType": "string" - } - ], - "stateMutability": "pure" - }, - { - "type": "function", - "name": "getContractAddress", - "inputs": [ - { - "name": "contractConfig", - "type": "tuple", - "internalType": "struct ContractCreationConfig", - "components": [ - { - "name": "contractAdmin", - "type": "address", - "internalType": "address" - }, - { - "name": "contractURI", - "type": "string", - "internalType": "string" - }, - { - "name": "contractName", - "type": "string", - "internalType": "string" - } - ] - } - ], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "implementation", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "initialize", - "inputs": [ - { - "name": "_initialOwner", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "isAuthorizedToCreatePremint", - "inputs": [ - { - "name": "signer", - "type": "address", - "internalType": "address" - }, - { - "name": "premintContractConfigContractAdmin", - "type": "address", - "internalType": "address" - }, - { - "name": "contractAddress", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "isAuthorized", - "type": "bool", - "internalType": "bool" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "mintFee", - "inputs": [ - { - "name": "collectionAddress", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "owner", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "pendingOwner", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "premintStatus", - "inputs": [ - { - "name": "contractAddress", - "type": "address", - "internalType": "address" - }, - { - "name": "uid", - "type": "uint32", - "internalType": "uint32" - } - ], - "outputs": [ - { - "name": "contractCreated", - "type": "bool", - "internalType": "bool" - }, - { - "name": "tokenIdForPremint", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "address", - "name": "contractAdmin", - "type": "address" - }, - { - "internalType": "string", - "name": "contractURI", - "type": "string" - }, - { - "internalType": "string", - "name": "contractName", - "type": "string" - } - ], - "internalType": "struct ContractCreationConfig", - "name": "contractConfig", - "type": "tuple" - }, - { - "components": [ - { - "components": [ - { - "internalType": "string", - "name": "tokenURI", - "type": "string" - }, - { - "internalType": "uint256", - "name": "maxSupply", - "type": "uint256" - }, - { - "internalType": "uint32", - "name": "royaltyBPS", - "type": "uint32" - }, - { - "internalType": "address", - "name": "payoutRecipient", - "type": "address" - }, - { - "internalType": "address", - "name": "createReferral", - "type": "address" - }, - { - "internalType": "address", - "name": "erc20Minter", - "type": "address" - }, - { - "internalType": "uint64", - "name": "mintStart", - "type": "uint64" - }, - { - "internalType": "uint64", - "name": "mintDuration", - "type": "uint64" - }, - { - "internalType": "uint64", - "name": "maxTokensPerAddress", - "type": "uint64" - }, - { - "internalType": "address", - "name": "currency", - "type": "address" - }, - { - "internalType": "uint256", - "name": "pricePerToken", - "type": "uint256" - } - ], - "internalType": "struct TokenCreationConfig", - "name": "tokenConfig", - "type": "tuple" - }, - { - "internalType": "uint32", - "name": "uid", - "type": "uint32" - }, - { - "internalType": "uint32", - "name": "version", - "type": "uint32" - }, - { - "internalType": "bool", - "name": "deleted", - "type": "bool" - } - ], - "internalType": "struct CreatorAttribution", - "name": "premintConfig", - "type": "tuple" - }, - { - "internalType": "bytes", - "name": "signature", - "type": "bytes" - }, - { - "internalType": "uint256", - "name": "quantityToMint", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "address", - "name": "mintRecipient", - "type": "address" - }, - { - "internalType": "string", - "name": "mintComment", - "type": "string" - }, - { - "internalType": "address[]", - "name": "mintRewardsRecipients", - "type": "address[]" - } - ], - "internalType": "struct MintArguments", - "name": "mintArguments", - "type": "tuple" - }, - { - "internalType": "address", - "name": "firstMinter", - "type": "address" - }, - { - "internalType": "address", - "name": "signerContract", - "type": "address" - } - ], - "name": "premintErc20V1", - "outputs": [ - { - "components": [ - { - "internalType": "address", - "name": "contractAddress", - "type": "address" - }, - { - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - }, - { - "internalType": "bool", - "name": "createdNewContract", - "type": "bool" - } - ], - "internalType": "struct PremintResult", - "name": "result", - "type": "tuple" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "type": "function", - "name": "proxiableUUID", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "bytes32", - "internalType": "bytes32" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "resignOwnership", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "safeTransferOwnership", - "inputs": [ - { - "name": "_newOwner", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "supportedPremintSignatureVersions", - "inputs": [ - { - "name": "contractAddress", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "versions", - "type": "string[]", - "internalType": "string[]" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "transferOwnership", - "inputs": [ - { - "name": "_newOwner", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "upgradeTo", - "inputs": [ - { - "name": "newImplementation", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "upgradeToAndCall", - "inputs": [ - { - "name": "newImplementation", - "type": "address", - "internalType": "address" - }, - { - "name": "data", - "type": "bytes", - "internalType": "bytes" - } - ], - "outputs": [], - "stateMutability": "payable" - }, - { - "type": "function", - "name": "zora1155Factory", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "contract IZoraCreator1155Factory" - } - ], - "stateMutability": "view" - }, - { - "type": "event", - "name": "AdminChanged", - "inputs": [ - { - "name": "previousAdmin", - "type": "address", - "indexed": false, - "internalType": "address" - }, - { - "name": "newAdmin", - "type": "address", - "indexed": false, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "BeaconUpgraded", - "inputs": [ - { - "name": "beacon", - "type": "address", - "indexed": true, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "Initialized", - "inputs": [ - { - "name": "version", - "type": "uint8", - "indexed": false, - "internalType": "uint8" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "OwnerCanceled", - "inputs": [ - { - "name": "owner", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "canceledOwner", - "type": "address", - "indexed": true, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "OwnerPending", - "inputs": [ - { - "name": "owner", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "pendingOwner", - "type": "address", - "indexed": true, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "OwnerUpdated", - "inputs": [ - { - "name": "prevOwner", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "newOwner", - "type": "address", - "indexed": true, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "Preminted", - "inputs": [ - { - "name": "contractAddress", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "tokenId", - "type": "uint256", - "indexed": true, - "internalType": "uint256" - }, - { - "name": "createdNewContract", - "type": "bool", - "indexed": true, - "internalType": "bool" - }, - { - "name": "uid", - "type": "uint32", - "indexed": false, - "internalType": "uint32" - }, - { - "name": "contractConfig", - "type": "tuple", - "indexed": false, - "internalType": "struct ContractCreationConfig", - "components": [ - { - "name": "contractAdmin", - "type": "address", - "internalType": "address" - }, - { - "name": "contractURI", - "type": "string", - "internalType": "string" - }, - { - "name": "contractName", - "type": "string", - "internalType": "string" - } - ] - }, - { - "name": "tokenConfig", - "type": "tuple", - "indexed": false, - "internalType": "struct TokenCreationConfig", - "components": [ - { - "name": "tokenURI", - "type": "string", - "internalType": "string" - }, - { - "name": "maxSupply", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "maxTokensPerAddress", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "pricePerToken", - "type": "uint96", - "internalType": "uint96" - }, - { - "name": "mintStart", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "mintDuration", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "royaltyMintSchedule", - "type": "uint32", - "internalType": "uint32" - }, - { - "name": "royaltyBPS", - "type": "uint32", - "internalType": "uint32" - }, - { - "name": "royaltyRecipient", - "type": "address", - "internalType": "address" - }, - { - "name": "fixedPriceMinter", - "type": "address", - "internalType": "address" - } - ] - }, - { - "name": "minter", - "type": "address", - "indexed": false, - "internalType": "address" - }, - { - "name": "quantityMinted", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "Upgraded", - "inputs": [ - { - "name": "implementation", - "type": "address", - "indexed": true, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "error", - "name": "ADDRESS_DELEGATECALL_TO_NON_CONTRACT", - "inputs": [] - }, - { - "type": "error", - "name": "ADDRESS_LOW_LEVEL_CALL_FAILED", - "inputs": [] - }, - { - "type": "error", - "name": "Burn_NotOwnerOrApproved", - "inputs": [ - { - "name": "operator", - "type": "address", - "internalType": "address" - }, - { - "name": "user", - "type": "address", - "internalType": "address" - } - ] - }, - { - "type": "error", - "name": "CREATOR_FUNDS_RECIPIENT_NOT_SET", - "inputs": [] - }, - { - "type": "error", - "name": "CallFailed", - "inputs": [ - { - "name": "reason", - "type": "bytes", - "internalType": "bytes" - } - ] - }, - { - "type": "error", - "name": "Call_TokenIdMismatch", - "inputs": [] - }, - { - "type": "error", - "name": "CallerNotZoraCreator1155", - "inputs": [] - }, - { - "type": "error", - "name": "CannotMintMoreTokens", - "inputs": [ - { - "name": "tokenId", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "quantity", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "totalMinted", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "maxSupply", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { - "type": "error", - "name": "Config_TransferHookNotSupported", - "inputs": [ - { - "name": "proposedAddress", - "type": "address", - "internalType": "address" - } - ] - }, - { - "type": "error", - "name": "ERC1155_MINT_TO_ZERO_ADDRESS", - "inputs": [] - }, - { - "type": "error", - "name": "ERC1967_NEW_IMPL_NOT_CONTRACT", - "inputs": [] - }, - { - "type": "error", - "name": "ERC1967_NEW_IMPL_NOT_UUPS", - "inputs": [] - }, - { - "type": "error", - "name": "ERC1967_UNSUPPORTED_PROXIABLEUUID", - "inputs": [] - }, - { - "type": "error", - "name": "ETHWithdrawFailed", - "inputs": [ - { - "name": "recipient", - "type": "address", - "internalType": "address" - }, - { - "name": "amount", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { - "type": "error", - "name": "FUNCTION_MUST_BE_CALLED_THROUGH_ACTIVE_PROXY", - "inputs": [] - }, - { - "type": "error", - "name": "FUNCTION_MUST_BE_CALLED_THROUGH_DELEGATECALL", - "inputs": [] - }, - { - "type": "error", - "name": "FundsWithdrawInsolvent", - "inputs": [ - { - "name": "amount", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "contractValue", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { - "type": "error", - "name": "INITIALIZABLE_CONTRACT_ALREADY_INITIALIZED", - "inputs": [] - }, - { - "type": "error", - "name": "INITIALIZABLE_CONTRACT_IS_INITIALIZING", - "inputs": [] - }, - { - "type": "error", - "name": "INITIALIZABLE_CONTRACT_IS_NOT_INITIALIZING", - "inputs": [] - }, - { - "type": "error", - "name": "INVALID_ADDRESS_ZERO", - "inputs": [] - }, - { - "type": "error", - "name": "INVALID_ETH_AMOUNT", - "inputs": [] - }, - { - "type": "error", - "name": "InvalidMerkleProof", - "inputs": [ - { - "name": "mintTo", - "type": "address", - "internalType": "address" - }, - { - "name": "merkleProof", - "type": "bytes32[]", - "internalType": "bytes32[]" - }, - { - "name": "merkleRoot", - "type": "bytes32", - "internalType": "bytes32" - } - ] - }, - { - "type": "error", - "name": "InvalidMintSchedule", - "inputs": [] - }, - { - "type": "error", - "name": "InvalidSignatureVersion", - "inputs": [] - }, - { - "type": "error", - "name": "MintNotYetStarted", - "inputs": [] - }, - { - "type": "error", - "name": "Mint_InsolventSaleTransfer", - "inputs": [] - }, - { - "type": "error", - "name": "Mint_TokenIDMintNotAllowed", - "inputs": [] - }, - { - "type": "error", - "name": "Mint_UnknownCommand", - "inputs": [] - }, - { - "type": "error", - "name": "Mint_ValueTransferFail", - "inputs": [] - }, - { - "type": "error", - "name": "MinterContractAlreadyExists", - "inputs": [] - }, - { - "type": "error", - "name": "MinterContractDoesNotExist", - "inputs": [] - }, - { - "type": "error", - "name": "NewOwnerNeedsToBeAdmin", - "inputs": [] - }, - { - "type": "error", - "name": "ONLY_CREATE_REFERRAL", - "inputs": [] - }, - { - "type": "error", - "name": "ONLY_OWNER", - "inputs": [] - }, - { - "type": "error", - "name": "ONLY_PENDING_OWNER", - "inputs": [] - }, - { - "type": "error", - "name": "OWNER_CANNOT_BE_ZERO_ADDRESS", - "inputs": [] - }, - { - "type": "error", - "name": "PremintDeleted", - "inputs": [] - }, - { - "type": "error", - "name": "ProtocolRewardsWithdrawFailed", - "inputs": [ - { - "name": "caller", - "type": "address", - "internalType": "address" - }, - { - "name": "recipient", - "type": "address", - "internalType": "address" - }, - { - "name": "amount", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { - "type": "error", - "name": "Renderer_NotValidRendererContract", - "inputs": [] - }, - { - "type": "error", - "name": "SaleEnded", - "inputs": [] - }, - { - "type": "error", - "name": "SaleHasNotStarted", - "inputs": [] - }, - { - "type": "error", - "name": "Sale_CannotCallNonSalesContract", - "inputs": [ - { - "name": "targetContract", - "type": "address", - "internalType": "address" - } - ] - }, - { - "type": "error", - "name": "TokenIdMismatch", - "inputs": [ - { - "name": "expected", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "actual", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { - "type": "error", - "name": "UUPS_UPGRADEABLE_MUST_NOT_BE_CALLED_THROUGH_DELEGATECALL", - "inputs": [] - }, - { - "type": "error", - "name": "UpgradeToMismatchedContractName", - "inputs": [ - { - "name": "expected", - "type": "string", - "internalType": "string" - }, - { - "name": "actual", - "type": "string", - "internalType": "string" - } - ] - }, - { - "type": "error", - "name": "UserExceedsMintLimit", - "inputs": [ - { - "name": "user", - "type": "address", - "internalType": "address" - }, - { - "name": "limit", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "requestedAmount", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { - "type": "error", - "name": "UserMissingRoleForToken", - "inputs": [ - { - "name": "user", - "type": "address", - "internalType": "address" - }, - { - "name": "tokenId", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "role", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { - "type": "error", - "name": "WrongValueSent", - "inputs": [] - } -] From 20a889fafeb9910d0ddf7db30f0497b1759b9ed5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bierlein?= Date: Thu, 2 May 2024 19:03:39 +0200 Subject: [PATCH 09/10] Formatting --- src/storage.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/storage.rs b/src/storage.rs index 33ae6eb..3c60516 100644 --- a/src/storage.rs +++ b/src/storage.rs @@ -1,5 +1,5 @@ -use crate::config::Config; -use crate::types::{InclusionClaim, Premint, PremintName, PremintTypes}; +use std::str::FromStr; + use alloy::primitives::Address; use async_trait::async_trait; use eyre::WrapErr; @@ -7,7 +7,9 @@ use serde::{Deserialize, Serialize}; use sqlx::sqlite::SqliteConnectOptions; use sqlx::Row; use sqlx::{QueryBuilder, Sqlite, SqlitePool}; -use std::str::FromStr; + +use crate::config::Config; +use crate::types::{InclusionClaim, Premint, PremintName, PremintTypes}; async fn init_db(config: &Config) -> SqlitePool { let expect_msg = From b482c1f2e89a83756a4deec57e4f89cf406c421d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bierlein?= Date: Fri, 3 May 2024 18:06:22 +0200 Subject: [PATCH 10/10] Go back to ubuntu runner --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 06de4d4..f2bd5a3 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -12,7 +12,7 @@ env: jobs: build_and_test: - runs-on: rust_oss_runner + runs-on: ubuntu-latest environment: Testing steps: