diff --git a/Cargo.lock b/Cargo.lock index f3111c1..66f4940 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1635,8 +1635,8 @@ dependencies = [ [[package]] name = "holaplex-hub-core" -version = "0.2.1" -source = "git+https://github.com/holaplex/hub-core?branch=stable#c8eaef51ea8729686a1d74e2e8d9fc1a14f4dcb8" +version = "0.3.1" +source = "git+https://github.com/holaplex/hub-core?branch=stable#64b4ace7aa493d2fa0ab8d1e2a132f0dec98029a" dependencies = [ "anyhow", "async-trait", @@ -1670,7 +1670,7 @@ dependencies = [ [[package]] name = "holaplex-hub-core-build" version = "0.2.1" -source = "git+https://github.com/holaplex/hub-core?branch=stable#c8eaef51ea8729686a1d74e2e8d9fc1a14f4dcb8" +source = "git+https://github.com/holaplex/hub-core?branch=stable#64b4ace7aa493d2fa0ab8d1e2a132f0dec98029a" dependencies = [ "anyhow", "dotenv", @@ -1688,8 +1688,8 @@ dependencies = [ [[package]] name = "holaplex-hub-core-schemas" -version = "0.2.1" -source = "git+https://github.com/holaplex/hub-core?branch=stable#c8eaef51ea8729686a1d74e2e8d9fc1a14f4dcb8" +version = "0.3.1" +source = "git+https://github.com/holaplex/hub-core?branch=stable#64b4ace7aa493d2fa0ab8d1e2a132f0dec98029a" dependencies = [ "holaplex-hub-core-build", "prost", diff --git a/api/Cargo.toml b/api/Cargo.toml index 80a395f..d9eac55 100644 --- a/api/Cargo.toml +++ b/api/Cargo.toml @@ -42,7 +42,7 @@ strum = { version = "0.24.1", features = ["derive"] } [dependencies.hub-core] package = "holaplex-hub-core" -version = "0.2.1" +version = "0.3.1" git = "https://github.com/holaplex/hub-core" branch = "stable" features = ["kafka", "credits", "asset_proxy"] diff --git a/api/src/entities/customer_wallets.rs b/api/src/entities/customer_wallets.rs index 7b1a9a7..5145f92 100644 --- a/api/src/entities/customer_wallets.rs +++ b/api/src/entities/customer_wallets.rs @@ -19,3 +19,9 @@ pub struct Model { pub enum Relation {} impl ActiveModelBehavior for ActiveModel {} + +impl Entity { + pub fn find_by_address(address: String) -> Select { + Self::find().filter(Column::Address.eq(address)) + } +} diff --git a/api/src/events.rs b/api/src/events.rs index 29b5652..b973759 100644 --- a/api/src/events.rs +++ b/api/src/events.rs @@ -709,7 +709,7 @@ impl Processor { let transfer_id = Uuid::from_str(&id)?; let transfer_charge = transfer_charges::Entity::find() - .filter(transfer_charges::Column::CreditsDeductionId.eq(transfer_id)) + .filter(transfer_charges::Column::Id.eq(transfer_id)) .one(conn) .await? .context("failed to load transfer charge from db")?; diff --git a/api/src/lib.rs b/api/src/lib.rs index 31b5dd4..d3ec7cd 100644 --- a/api/src/lib.rs +++ b/api/src/lib.rs @@ -199,6 +199,10 @@ pub enum Actions { RetryMint, RetryDrop, TransferAsset, + Mint, + MintCompressed, + CreateCollection, + RetryCollection, } impl From for hub_core::credits::Action { @@ -209,6 +213,10 @@ impl From for hub_core::credits::Action { Actions::RetryMint => hub_core::credits::Action::RetryMint, Actions::RetryDrop => hub_core::credits::Action::RetryDrop, Actions::TransferAsset => hub_core::credits::Action::TransferAsset, + Actions::Mint => hub_core::credits::Action::Mint, + Actions::MintCompressed => hub_core::credits::Action::MintCompressed, + Actions::CreateCollection => hub_core::credits::Action::CreateCollection, + Actions::RetryCollection => hub_core::credits::Action::RetryCollection, } } } diff --git a/api/src/mutations/collection.rs b/api/src/mutations/collection.rs index a3894c8..052b962 100644 --- a/api/src/mutations/collection.rs +++ b/api/src/mutations/collection.rs @@ -130,7 +130,7 @@ impl Mutation { balance, collection: collection.id, blockchain: input.blockchain, - action: Actions::CreateDrop, + action: Actions::CreateCollection, }) .await?; @@ -246,7 +246,7 @@ impl Mutation { org_id, collection: collection.id, blockchain: collection.blockchain, - action: Actions::RetryDrop, + action: Actions::RetryCollection, }) .await?; diff --git a/api/src/mutations/mint.rs b/api/src/mutations/mint.rs index 10958f4..277df84 100644 --- a/api/src/mutations/mint.rs +++ b/api/src/mutations/mint.rs @@ -357,15 +357,16 @@ impl Mutation { let collection = collection.ok_or(Error::new("collection not found"))?; let blockchain = collection.blockchain; + let compressed = input.compressed.unwrap_or_default(); validate_creators(blockchain, &creators)?; validate_json(blockchain, &input.metadata_json)?; check_collection_status(&collection)?; - validate_compress(blockchain, input.compressed)?; + validate_compress(blockchain, compressed)?; let seller_fee_basis_points = input.seller_fee_basis_points.unwrap_or_default(); - let owner_address = fetch_owner(conn, collection.project_id, collection.blockchain).await?; + let owner_address = fetch_owner(conn, collection.project_id, blockchain).await?; if collection.blockchain == BlockchainEnum::Solana { validate_solana_creator_verification(&owner_address, &creators)?; @@ -378,7 +379,7 @@ impl Mutation { creation_status: Set(CreationStatus::Pending), seller_fee_basis_points: Set(collection.seller_fee_basis_points), created_by: Set(user_id), - compressed: Set(input.compressed), + compressed: Set(compressed), ..Default::default() }; @@ -424,7 +425,7 @@ impl Mutation { .collect::>()?, }), recipient_address: input.recipient.to_string(), - compressed: input.compressed, + compressed, collection_id: collection.id.to_string(), }) .await?; @@ -456,7 +457,11 @@ impl Mutation { org_id, mint: collection_mint_model.id, blockchain: collection.blockchain, - action: Actions::MintEdition, + action: if compressed { + Actions::MintCompressed + } else { + Actions::Mint + }, }) .await?; @@ -715,7 +720,7 @@ pub struct MintToCollectionInput { metadata_json: MetadataJsonInput, seller_fee_basis_points: Option, creators: Vec, - compressed: bool, + compressed: Option, } #[derive(Debug, Clone, SimpleObject)] diff --git a/api/src/mutations/transfer.rs b/api/src/mutations/transfer.rs index 51d6f42..101a770 100644 --- a/api/src/mutations/transfer.rs +++ b/api/src/mutations/transfer.rs @@ -1,6 +1,6 @@ use async_graphql::{Context, Error, InputObject, Object, Result, SimpleObject}; use hub_core::credits::CreditsClient; -use sea_orm::{prelude::*, JoinType, QuerySelect, Set}; +use sea_orm::{prelude::*, Set}; use serde::{Deserialize, Serialize}; use super::collection::{validate_evm_address, validate_solana_address}; @@ -9,8 +9,7 @@ use crate::{ db::Connection, entities::{ collection_mints::{self, CollectionMint}, - collections, customer_wallets, drops, - prelude::{Collections, CustomerWallets, Drops}, + prelude::CustomerWallets, sea_orm_active_enums::{Blockchain, CreationStatus}, transfer_charges, }, @@ -68,11 +67,11 @@ impl Mutation { let TransferAssetInput { id, recipient } = input.clone(); - let (collection_mint_model, collection) = collection_mints::Entity::find_by_id(id) - .find_also_related(Collections) - .one(conn) - .await? - .ok_or(Error::new("mint not found"))?; + let (collection_mint_model, collection) = + collection_mints::Entity::find_by_id_with_collection(id) + .one(conn) + .await? + .ok_or(Error::new("mint not found"))?; if collection_mint_model.creation_status != CreationStatus::Created { return Err(Error::new("NFT is not minted")); @@ -81,20 +80,12 @@ impl Mutation { let collection = collection.ok_or(Error::new("collection not found"))?; input.validate_recipient_address(collection.blockchain)?; - let drop = Drops::find() - .join(JoinType::InnerJoin, drops::Relation::Collections.def()) - .filter(collections::Column::Id.eq(collection.id)) - .one(conn) - .await? - .ok_or(Error::new("drop not found"))?; - let owner_address = collection_mint_model.owner.clone(); - CustomerWallets::find() - .filter(customer_wallets::Column::Address.eq(owner_address.clone())) + CustomerWallets::find_by_address(owner_address.clone()) .one(conn) .await? - .ok_or(Error::new("Sender wallet is not managed by Hub"))?; + .ok_or(Error::new("Sender wallet is not managed by HUB"))?; let transfer_charges_am = transfer_charges::ActiveModel { ..Default::default() @@ -104,7 +95,7 @@ impl Mutation { let event_key = NftEventKey { id: transfer_charge_model.id.to_string(), user_id: user_id.to_string(), - project_id: drop.project_id.to_string(), + project_id: collection.project_id.to_string(), }; let collection_mint_id = collection_mint_model.id.to_string(); diff --git a/credits.toml b/credits.toml index d4e037c..2eb9c0e 100644 --- a/credits.toml +++ b/credits.toml @@ -1,19 +1,39 @@ [MintEdition] -solana = 5 -polygon = 10 +solana = 60 +polygon = 25 + +[Mint] +solana = 60 +polygon = 25 [CreateDrop] -solana = 5 -polygon = 15 +solana = 40 +polygon = 40 [RetryMint] -solana = 5 -polygon = 10 +solana = 0 +polygon = 0 [TransferAsset] -solana = 5 +solana = 10 +polygon = 10 + +[CreateWallet] +solana = 10 polygon = 10 [RetryDrop] -solana = 5 -polygon = 10 \ No newline at end of file +solana = 0 +polygon = 0 + +[CreateCollection] +solana = 40 +polygon = 0 + +[MintCompressed] +solana = 1 +polygon = 0 + +[RetryCollection] +solana = 0 +polygon = 0 \ No newline at end of file