Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 07/27 #154

Merged
merged 42 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
0def792
refactor: switch from drops to collections
kespinola Jul 6, 2023
6f3a929
feat: restore drops and add collection and mint to collection mutatio…
kespinola Jul 12, 2023
d892ca6
refactor: add creators and compressed to collection mints. finish min…
kespinola Jul 13, 2023
db573a8
add dataloaders for collection drop and project collections
alchemistgo87 Jul 17, 2023
cb7f1c7
update loaders, objects, fix bug
alchemistgo87 Jul 17, 2023
1282576
Inputtype fix
alchemistgo87 Jul 17, 2023
b56c833
minor update in collection drop loader, cargo fmt
alchemistgo87 Jul 18, 2023
558ca67
fix: run cargo fmt
kespinola Jul 18, 2023
a7fa3fd
Merge pull request #140 from holaplex/anshul/collections-api
kespinola Jul 18, 2023
fe25471
feat: add created_at and created_by to collections backfill based on …
kespinola Jul 18, 2023
7d18042
Merge pull request #139 from holaplex/espi/1-of-1-mints
kespinola Jul 18, 2023
ee9e98a
fix: create index if it doesnt exist
kespinola Jul 18, 2023
8bb2982
refactor: use master edition transaction message for mcc
kespinola Jul 19, 2023
1d57f2e
fix: update proto lock after recreating version 20 of nfts proto
kespinola Jul 19, 2023
6d61e92
project collection loader fix
alchemistgo87 Jul 19, 2023
617b882
Merge pull request #141 from holaplex/anshul/collection-fix
kespinola Jul 19, 2023
0fa7603
update status on retries
mpwsh Jul 19, 2023
9782689
Merge pull request #143 from holaplex/mpw/retry-status
mpwsh Jul 19, 2023
dcfd7e6
feat: add mcc submitted and failure event handlers
kespinola Jul 21, 2023
4fff0f4
Merge pull request #145 from holaplex/espi/on-submitted-mcc
kespinola Jul 21, 2023
6dd5693
fix: set seller fee to 0 on mcc
kespinola Jul 22, 2023
774df7a
feat: handle submittion failure and sucess for mint to collection
kespinola Jul 24, 2023
e183911
Merge pull request #148 from holaplex/espi/mint-to-collections
kespinola Jul 24, 2023
e47e0f7
feat: add creation of events for collection and minting to a collection
kespinola Jul 25, 2023
531f348
Merge pull request #149 from holaplex/espi/mint-to-collections
kespinola Jul 25, 2023
a98038d
Import collection mutation & indexing
imabdulbasit Jul 20, 2023
12bd742
delete collection & mints if already exists
imabdulbasit Jul 25, 2023
ea11461
Merge pull request #144 from holaplex/abdul/import-collection
imabdulbasit Jul 26, 2023
d93b88e
Mint history
imabdulbasit Jul 25, 2023
d383356
insert mint_history record for mint_to_collection
imabdulbasit Jul 25, 2023
a35d705
mint_history -> mint_histories & make purchases as deprecated field
imabdulbasit Jul 26, 2023
f9435e2
make collection_id not null
imabdulbasit Jul 26, 2023
910a211
Merge pull request #150 from holaplex/abdul/mint-history
kespinola Jul 26, 2023
aa26fc8
Adjust mint_histories.collection_id constraints for backfill
imabdulbasit Jul 26, 2023
7d9e761
Merge pull request #151 from holaplex/abdul/adjust-collection-contraint
imabdulbasit Jul 26, 2023
67e6da3
Update total_mints when indexing each mint & fix metadata_json indexing
imabdulbasit Jul 26, 2023
07676e5
Merge pull request #152 from holaplex/abdul/total-mints
imabdulbasit Jul 26, 2023
4fde4d4
Fix: Update total_mints
imabdulbasit Jul 26, 2023
f7a5c4d
Merge pull request #153 from holaplex/abdul/fix-total-mints-update
imabdulbasit Jul 26, 2023
5a13b0c
fix: change graphql object name of mint history
kespinola Jul 27, 2023
c845984
Support import of collection for multiple projects
imabdulbasit Jul 27, 2023
dda0525
Merge pull request #155 from holaplex/abdul/multi-proj-coll
imabdulbasit Jul 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions api/proto.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ sha512 = "d75800df0d4744c6b0f4d9a9952d3bfd0bb6b24a8babd19104cc11b54a525f85551b3c

[[schemas]]
subject = "nfts"
version = 19
sha512 = "94be29cc87e02f9622ba880302349b275262bc30546e6a6daacea541a6c1c740df9a185d0e18de782eda77ebf9c51c0e46c295d89abb9f7fb725b0ce9cfaf6f1"
version = 22
sha512 = "c9920f6a5792b067396c88e40b9bd2adfcb55b582734aff924a67a9d5841a5e2839fc734c1bbff66f402f9a9d8852ca5fef1339aaaa3d5b05aa7868ddfa375c1"

[[schemas]]
subject = "organization"
Expand All @@ -20,8 +20,8 @@ sha512 = "c5ddf43d2958ec690ee2261d0ff9808b67ce810d2fc4b6077f96f561929a920f03509f

[[schemas]]
subject = "solana_nfts"
version = 4
sha512 = "272f1aed7d792a5fe5750cdca659091ca1a4a8dd4f36b35f5066ea6bb09cf4f1e905e7e5817dfa6c68d7ea3a8644192b4ff82e7ffcd85b2d9a58e48112a4a8bc"
version = 7
sha512 = "73570b9e58f91a06901ba6455986ce1a0d3675e33860d2447160d711a8cebcfb78cfc714fb08644ad83495dc8612b0b123203561af6d93d29ffb0256725047ba"

[[schemas]]
subject = "timestamp"
Expand Down
4 changes: 2 additions & 2 deletions api/proto.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ endpoint = "https://schemas.holaplex.tools"

[schemas]
organization = 5
nfts = 19
nfts = 22
customer = 2
treasury = 17
solana_nfts = 4
solana_nfts = 7
polygon_nfts = 6
timestamp = 1
51 changes: 17 additions & 34 deletions api/src/blockchains/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub mod polygon;
pub mod solana;

use hub_core::{anyhow::Result, uuid::Uuid};
use hub_core::anyhow::Result;

use crate::proto::NftEventKey;

Expand All @@ -15,42 +15,25 @@ pub struct TransactionResponse {
pub signed_message_signatures: Vec<String>,
}

/// A trait that defines the fundamental operations that can be performed
/// on a given blockchain for a specific edition of an NFT.
#[async_trait::async_trait]
pub trait Edition<A, B, C, D, E, M> {
/// Creates a new NFT on the blockchain. The specifics of the creation
/// process, such as the parameters it takes and the values it returns,
/// are dependent on the implementation of this method for the specific blockchain.
async fn create(&self, payload: A) -> Result<(M, TransactionResponse)>;

/// Mints a new instance of the NFT on the blockchain. The specifics of the minting
/// process, such as the parameters it takes and the values it returns,
/// are dependent on the implementation of this method for the specific blockchain.
async fn mint(&self, payload: B) -> Result<(M, TransactionResponse)>;

/// Updates an existing collection on the blockchain. The specifics of the update
/// process, such as the parameters it takes and the values it returns,
/// are dependent on the implementation of this method for the specific blockchain.
async fn update(&self, payload: C) -> Result<(M, TransactionResponse)>;

/// Transfers an NFT from one account to another on the blockchain. The specifics of the transfer
/// process, such as the parameters it takes and the values it returns,
/// are dependent on the implementation of this method for the specific blockchain.
async fn transfer(&self, payload: D) -> Result<(Uuid, TransactionResponse)>;

/// Retries a failed drop of an NFT on the blockchain. The specifics of the retry drop
/// process, such as the parameters it takes and the values it returns,
/// are dependent on the implementation of this method for the specific blockchain.
async fn retry_drop(&self, payload: E) -> Result<(M, TransactionResponse)>;
}

#[async_trait::async_trait]
pub trait Event<A, B, C, D> {
pub trait DropEvent<A, B, C> {
async fn create_drop(&self, key: NftEventKey, payload: A) -> Result<()>;
async fn retry_create_drop(&self, key: NftEventKey, payload: A) -> Result<()>;
async fn update_drop(&self, key: NftEventKey, payload: D) -> Result<()>;
async fn update_drop(&self, key: NftEventKey, payload: C) -> Result<()>;
async fn mint_drop(&self, key: NftEventKey, payload: B) -> Result<()>;
async fn retry_mint_drop(&self, key: NftEventKey, payload: B) -> Result<()>;
async fn transfer_asset(&self, key: NftEventKey, payload: C) -> Result<()>;
}

#[async_trait::async_trait]
pub trait CollectionEvent<A, B, C> {
async fn create_collection(&self, key: NftEventKey, payload: A) -> Result<()>;
async fn retry_create_collection(&self, key: NftEventKey, payload: A) -> Result<()>;
async fn update_collection(&self, key: NftEventKey, payload: B) -> Result<()>;
async fn mint_to_collection(&self, key: NftEventKey, payload: C) -> Result<()>;
async fn retry_mint_to_collection(&self, key: NftEventKey, payload: C) -> Result<()>;
}

#[async_trait::async_trait]
pub trait TransferEvent<A> {
async fn transfer_asset(&self, key: NftEventKey, payload: A) -> Result<()>;
}
23 changes: 9 additions & 14 deletions api/src/blockchains/polygon.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use hub_core::{anyhow::Result, producer::Producer};

use super::Event;
use super::{DropEvent, TransferEvent};
use crate::proto::{
nft_events::Event::{
PolygonCreateDrop, PolygonMintDrop, PolygonRetryDrop, PolygonRetryMintDrop,
Expand All @@ -24,24 +24,15 @@ impl Polygon {
#[must_use]
pub fn event(
&self,
) -> impl Event<
CreateEditionTransaction,
MintEditionTransaction,
TransferPolygonAsset,
UpdateEdtionTransaction,
> {
) -> impl DropEvent<CreateEditionTransaction, MintEditionTransaction, UpdateEdtionTransaction>
+ TransferEvent<TransferPolygonAsset> {
self.clone()
}
}

#[async_trait::async_trait]
impl
Event<
CreateEditionTransaction,
MintEditionTransaction,
TransferPolygonAsset,
UpdateEdtionTransaction,
> for Polygon
impl DropEvent<CreateEditionTransaction, MintEditionTransaction, UpdateEdtionTransaction>
for Polygon
{
async fn create_drop(&self, key: NftEventKey, payload: CreateEditionTransaction) -> Result<()> {
let event = NftEvents {
Expand Down Expand Up @@ -100,13 +91,17 @@ impl

Ok(())
}
}

#[async_trait::async_trait]
impl TransferEvent<TransferPolygonAsset> for Polygon {
async fn transfer_asset(&self, key: NftEventKey, payload: TransferPolygonAsset) -> Result<()> {
let event = NftEvents {
event: Some(PolygonTransferAsset(payload)),
};

self.producer.send(Some(&event), Some(&key)).await?;

Ok(())
}
}
106 changes: 96 additions & 10 deletions api/src/blockchains/solana.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use hub_core::{anyhow::Result, producer::Producer};

use super::Event;
use super::{CollectionEvent, DropEvent, TransferEvent};
use crate::proto::{
nft_events::Event::{
SolanaCreateDrop, SolanaMintDrop, SolanaRetryDrop, SolanaRetryMintDrop,
SolanaTransferAsset, SolanaUpdateDrop,
SolanaCreateCollection, SolanaCreateDrop, SolanaMintDrop, SolanaMintToCollection,
SolanaRetryCreateCollection, SolanaRetryDrop, SolanaRetryMintDrop,
SolanaRetryMintToCollection, SolanaTransferAsset, SolanaUpdateCollection, SolanaUpdateDrop,
},
MetaplexMasterEditionTransaction, MintMetaplexEditionTransaction, NftEventKey, NftEvents,
TransferMetaplexAssetTransaction,
MetaplexMasterEditionTransaction, MintMetaplexEditionTransaction,
MintMetaplexMetadataTransaction, NftEventKey, NftEvents, TransferMetaplexAssetTransaction,
};

#[derive(Clone)]
Expand All @@ -24,22 +25,25 @@ impl Solana {
#[must_use]
pub fn event(
&self,
) -> impl Event<
) -> impl DropEvent<
MetaplexMasterEditionTransaction,
MintMetaplexEditionTransaction,
TransferMetaplexAssetTransaction,
MetaplexMasterEditionTransaction,
> + TransferEvent<TransferMetaplexAssetTransaction>
+ CollectionEvent<
MetaplexMasterEditionTransaction,
MetaplexMasterEditionTransaction,
MintMetaplexMetadataTransaction,
> {
self.clone()
}
}

#[async_trait::async_trait]
impl
Event<
DropEvent<
MetaplexMasterEditionTransaction,
MintMetaplexEditionTransaction,
TransferMetaplexAssetTransaction,
MetaplexMasterEditionTransaction,
> for Solana
{
Expand Down Expand Up @@ -112,13 +116,16 @@ impl

Ok(())
}
}

#[async_trait::async_trait]
impl TransferEvent<TransferMetaplexAssetTransaction> for Solana {
async fn transfer_asset(
&self,
key: NftEventKey,
payload: TransferMetaplexAssetTransaction,
) -> Result<()> {
let event: NftEvents = NftEvents {
let event = NftEvents {
event: Some(SolanaTransferAsset(payload)),
};

Expand All @@ -127,3 +134,82 @@ impl
Ok(())
}
}

#[async_trait::async_trait]
impl
CollectionEvent<
MetaplexMasterEditionTransaction,
MetaplexMasterEditionTransaction,
MintMetaplexMetadataTransaction,
> for Solana
{
async fn create_collection(
&self,
key: NftEventKey,
payload: MetaplexMasterEditionTransaction,
) -> Result<()> {
let event = NftEvents {
event: Some(SolanaCreateCollection(payload)),
};

self.producer.send(Some(&event), Some(&key)).await?;

Ok(())
}

async fn retry_create_collection(
&self,
key: NftEventKey,
payload: MetaplexMasterEditionTransaction,
) -> Result<()> {
let event = NftEvents {
event: Some(SolanaRetryCreateCollection(payload)),
};

self.producer.send(Some(&event), Some(&key)).await?;

Ok(())
}

async fn update_collection(
&self,
key: NftEventKey,
payload: MetaplexMasterEditionTransaction,
) -> Result<()> {
let event = NftEvents {
event: Some(SolanaUpdateCollection(payload)),
};

self.producer.send(Some(&event), Some(&key)).await?;

Ok(())
}

async fn mint_to_collection(
&self,
key: NftEventKey,
payload: MintMetaplexMetadataTransaction,
) -> Result<()> {
let event = NftEvents {
event: Some(SolanaMintToCollection(payload)),
};

self.producer.send(Some(&event), Some(&key)).await?;

Ok(())
}

async fn retry_mint_to_collection(
&self,
key: NftEventKey,
payload: MintMetaplexMetadataTransaction,
) -> Result<()> {
let event = NftEvents {
event: Some(SolanaRetryMintToCollection(payload)),
};

self.producer.send(Some(&event), Some(&key)).await?;

Ok(())
}
}
6 changes: 3 additions & 3 deletions api/src/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ use crate::{
collection_creators::ActiveModel as CollectionCreatorActiveModel,
collections::{ActiveModel, Model},
},
objects::CollectionCreator,
objects::Creator,
};

#[derive(Debug, Clone)]
pub struct Collection {
collection: ActiveModel,
creators: Option<Vec<CollectionCreator>>,
creators: Option<Vec<Creator>>,
}

impl Collection {
Expand All @@ -25,7 +25,7 @@ impl Collection {
}
}

pub fn creators(&mut self, creators: Vec<CollectionCreator>) -> &Collection {
pub fn creators(&mut self, creators: Vec<Creator>) -> &Collection {
self.creators = Some(creators);

self
Expand Down
54 changes: 54 additions & 0 deletions api/src/dataloaders/collection_drop.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
use std::collections::HashMap;

use async_graphql::{dataloader::Loader as DataLoader, FieldError, Result};
use poem::async_trait;
use sea_orm::{prelude::*, JoinType, QuerySelect};

use crate::{
db::Connection,
entities::{collections, drops},
objects::Drop,
};

#[derive(Debug, Clone)]
pub struct Loader {
pub db: Connection,
}

impl Loader {
#[must_use]
pub fn new(db: Connection) -> Self {
Self { db }
}
}

#[async_trait]
impl DataLoader<Uuid> for Loader {
type Error = FieldError;
type Value = Drop;

async fn load(&self, keys: &[Uuid]) -> Result<HashMap<Uuid, Self::Value>, Self::Error> {
let drops = drops::Entity::find()
.join(JoinType::InnerJoin, drops::Relation::Collections.def())
.select_also(collections::Entity)
.filter(drops::Column::CollectionId.is_in(keys.iter().map(ToOwned::to_owned)))
.all(self.db.get())
.await?;

drops
.into_iter()
.map(|(drop, collection)| {
Ok((
drop.collection_id,
Drop::new(
drop.clone(),
collection.ok_or(FieldError::new(format!(
"no collection for the drop {}",
drop.id
)))?,
),
))
})
.collect::<Result<HashMap<Uuid, Self::Value>>>()
}
}
Loading
Loading