Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions common/src/queries/assets.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::queries::errors::QueryError;
use crate::{
AssetAddressEntry, AssetInfoRecord, AssetMintRecord, AssetName, PolicyAsset, PolicyId,
TxIdentifier,
AssetAddressEntry, AssetInfoRecord, AssetMetadata, AssetMintRecord, AssetName, NativeAssets,
PolicyAsset, PolicyId, TxIdentifier,
};

pub const DEFAULT_ASSETS_QUERY_TOPIC: (&str, &str) =
Expand All @@ -27,6 +27,7 @@ pub enum AssetsStateQuery {
GetPolicyIdAssets { policy: PolicyId },
GetAssetAddresses { policy: PolicyId, name: AssetName },
GetAssetTransactions { policy: PolicyId, name: AssetName },
GetAssetsMetadata { assets: NativeAssets },
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
Expand All @@ -37,5 +38,6 @@ pub enum AssetsStateQueryResponse {
AssetAddresses(AssetAddresses),
AssetTransactions(AssetTransactions),
PolicyIdAssets(PolicyAssets),
AssetsMetadata(Vec<AssetMetadata>),
Error(QueryError),
}
11 changes: 9 additions & 2 deletions common/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2121,8 +2121,15 @@ pub struct TxCertificateWithPos {
pub struct AssetInfoRecord {
pub initial_mint_tx: TxIdentifier,
pub mint_or_burn_count: u64,
pub onchain_metadata: Option<Vec<u8>>,
pub metadata_standard: Option<AssetMetadataStandard>,
pub metadata: AssetMetadata,
}

#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
pub struct AssetMetadata {
pub cip25_metadata: Option<Vec<u8>>,
pub cip25_version: Option<AssetMetadataStandard>,
pub cip68_metadata: Option<Vec<u8>>,
pub cip68_version: Option<AssetMetadataStandard>,
}

#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
Expand Down
12 changes: 12 additions & 0 deletions modules/assets_state/src/assets_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,18 @@ impl AssetsState {
)),
}
}
AssetsStateQuery::GetAssetsMetadata { assets } => {
let reg = registry.lock().await;
match state.get_assets_metadata(assets, &reg) {
Ok(Some(assets)) => AssetsStateQueryResponse::AssetsMetadata(assets),
Ok(None) => AssetsStateQueryResponse::Error(QueryError::not_found(
"One or more assets not found in registry".to_string(),
)),
Err(e) => AssetsStateQueryResponse::Error(QueryError::internal_error(
e.to_string(),
)),
}
}
};
Arc::new(Message::StateQueryResponse(StateQueryResponse::Assets(
response,
Expand Down
Loading