Skip to content

Commit c54e5ac

Browse files
authored
Merge pull request #368 from input-output-hk/whankinsiv/address-extended-endpoint
feat: addresses extended endpoint
2 parents c8d34b4 + 94b2b14 commit c54e5ac

File tree

7 files changed

+534
-115
lines changed

7 files changed

+534
-115
lines changed

common/src/queries/assets.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::queries::errors::QueryError;
22
use crate::{
3-
AssetAddressEntry, AssetInfoRecord, AssetMintRecord, AssetName, PolicyAsset, PolicyId,
4-
TxIdentifier,
3+
AssetAddressEntry, AssetInfoRecord, AssetMetadata, AssetMintRecord, AssetName, NativeAssets,
4+
PolicyAsset, PolicyId, TxIdentifier,
55
};
66

77
pub const DEFAULT_ASSETS_QUERY_TOPIC: (&str, &str) =
@@ -27,6 +27,7 @@ pub enum AssetsStateQuery {
2727
GetPolicyIdAssets { policy: PolicyId },
2828
GetAssetAddresses { policy: PolicyId, name: AssetName },
2929
GetAssetTransactions { policy: PolicyId, name: AssetName },
30+
GetAssetsMetadata { assets: NativeAssets },
3031
}
3132

3233
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
@@ -37,5 +38,6 @@ pub enum AssetsStateQueryResponse {
3738
AssetAddresses(AssetAddresses),
3839
AssetTransactions(AssetTransactions),
3940
PolicyIdAssets(PolicyAssets),
41+
AssetsMetadata(Vec<AssetMetadata>),
4042
Error(QueryError),
4143
}

common/src/types.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2121,8 +2121,15 @@ pub struct TxCertificateWithPos {
21212121
pub struct AssetInfoRecord {
21222122
pub initial_mint_tx: TxIdentifier,
21232123
pub mint_or_burn_count: u64,
2124-
pub onchain_metadata: Option<Vec<u8>>,
2125-
pub metadata_standard: Option<AssetMetadataStandard>,
2124+
pub metadata: AssetMetadata,
2125+
}
2126+
2127+
#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
2128+
pub struct AssetMetadata {
2129+
pub cip25_metadata: Option<Vec<u8>>,
2130+
pub cip25_version: Option<AssetMetadataStandard>,
2131+
pub cip68_metadata: Option<Vec<u8>>,
2132+
pub cip68_version: Option<AssetMetadataStandard>,
21262133
}
21272134

21282135
#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]

modules/assets_state/src/assets_state.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,18 @@ impl AssetsState {
443443
)),
444444
}
445445
}
446+
AssetsStateQuery::GetAssetsMetadata { assets } => {
447+
let reg = registry.lock().await;
448+
match state.get_assets_metadata(assets, &reg) {
449+
Ok(Some(assets)) => AssetsStateQueryResponse::AssetsMetadata(assets),
450+
Ok(None) => AssetsStateQueryResponse::Error(QueryError::not_found(
451+
"One or more assets not found in registry".to_string(),
452+
)),
453+
Err(e) => AssetsStateQueryResponse::Error(QueryError::internal_error(
454+
e.to_string(),
455+
)),
456+
}
457+
}
446458
};
447459
Arc::new(Message::StateQueryResponse(StateQueryResponse::Assets(
448460
response,

0 commit comments

Comments
 (0)