Skip to content

Commit

Permalink
Merge pull request #7 from metaplex-foundation/feature/grpc-client
Browse files Browse the repository at this point in the history
[MET-44] Gapfiller api design
  • Loading branch information
StanChe authored Dec 22, 2023
2 parents 1262ef1 + 04a58d9 commit 84172d1
Show file tree
Hide file tree
Showing 10 changed files with 1,058 additions and 86 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler

- name: Install Rust specific version
uses: actions-rs/toolchain@v1
with:
Expand Down
103 changes: 103 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ members = [
"rocks-db",
"postgre-client",
"entities",
"grpc",
]

[profile.release]
Expand Down
38 changes: 18 additions & 20 deletions entities/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,32 +46,32 @@ pub struct CompleteAssetDetails {
pub pubkey: Pubkey,
pub specification_asset_class: SpecificationAssetClass,
pub royalty_target_type: RoyaltyTargetType,
pub created_at: i64,
pub slot_created: u64,

// From AssetDynamicDetails as Tuples
pub is_compressible: (bool, u64, Option<u64>),
pub is_compressed: (bool, u64, Option<u64>),
pub is_frozen: (bool, u64, Option<u64>),
pub supply: (Option<u64>, u64, Option<u64>),
pub seq: (Option<u64>, u64, Option<u64>),
pub is_burnt: (bool, u64, Option<u64>),
pub was_decompressed: (bool, u64, Option<u64>),
pub onchain_data: (Option<ChainDataV1>, u64, Option<u64>), // Serialized ChainDataV1
pub creators: (Vec<Creator>, u64, Option<u64>),
pub royalty_amount: (u16, u64, Option<u64>),
pub is_compressible: Updated<bool>,
pub is_compressed: Updated<bool>,
pub is_frozen: Updated<bool>,
pub supply: Option<Updated<u64>>,
pub seq: Option<Updated<u64>>,
pub is_burnt: Updated<bool>,
pub was_decompressed: Updated<bool>,
pub onchain_data: Option<Updated<ChainDataV1>>,
pub creators: Updated<Vec<Creator>>,
pub royalty_amount: Updated<u16>,

// From AssetAuthority as Tuple
pub authority: (Pubkey, u64, Option<u64>),
pub authority: Updated<Pubkey>,

// From AssetOwner as Tuples
pub owner: (Pubkey, u64, Option<u64>),
pub delegate: (Option<Pubkey>, u64, Option<u64>),
pub owner_type: (OwnerType, u64, Option<u64>),
pub owner_delegate_seq: (Option<u64>, u64, Option<u64>),
pub owner: Updated<Pubkey>,
pub delegate: Option<Updated<Pubkey>>,
pub owner_type: Updated<OwnerType>,
pub owner_delegate_seq: Option<Updated<u64>>,

// Separate fields
pub leaves: Vec<AssetLeaf>,
pub collection: AssetCollection,
pub leaves: Vec<Updated<AssetLeaf>>,
pub collection: Option<Updated<AssetCollection>>,
}

/// Leaf information about compressed asset
Expand All @@ -85,7 +85,6 @@ pub struct AssetLeaf {
pub data_hash: Option<Hash>,
pub creator_hash: Option<Hash>,
pub leaf_seq: Option<u64>,
pub slot_updated: u64,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
Expand Down Expand Up @@ -120,7 +119,6 @@ pub struct AssetCollection {
pub collection: Pubkey,
pub is_collection_verified: bool,
pub collection_seq: Option<u64>,
pub slot_updated: u64,
}

#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq)]
Expand Down
13 changes: 13 additions & 0 deletions grpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "grpc"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tonic = "0.10.2"
prost = "0.12.3"

[build-dependencies]
tonic-build = "0.10.2" # Corresponding build tool for tonic
9 changes: 9 additions & 0 deletions grpc/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
fn main() -> Result<(), Box<dyn std::error::Error>> {
tonic_build::configure()
.out_dir("src") // Output directory for the generated Rust code within grpc module
.compile(
&["proto/gap_filler.proto"], // Paths to the .proto files
&["proto"], // Include paths for proto file dependencies
)?;
Ok(())
}
Loading

0 comments on commit 84172d1

Please sign in to comment.