@@ -118,6 +118,14 @@ pub struct NftMetadataInfo {
118118 pub collection_id : Option < Bytes32 > ,
119119}
120120
121+ #[ derive( Debug , Clone ) ]
122+ pub struct RequestedNft {
123+ pub metadata : Program ,
124+ pub metadata_updater_puzzle_hash : Bytes32 ,
125+ pub royalty_puzzle_hash : Bytes32 ,
126+ pub royalty_basis_points : u16 ,
127+ }
128+
121129impl Database {
122130 pub async fn asset_kind ( & self , asset_id : Bytes32 ) -> Result < Option < AssetKind > > {
123131 asset_kind ( & self . pool , asset_id) . await
@@ -180,6 +188,10 @@ impl Database {
180188 pub async fn did_assets ( & self ) -> Result < Vec < DidAsset > > {
181189 did_assets ( & self . pool ) . await
182190 }
191+
192+ pub async fn requested_nft ( & self , launcher_id : Bytes32 ) -> Result < Option < RequestedNft > > {
193+ requested_nft ( & self . pool , launcher_id) . await
194+ }
183195}
184196
185197impl DatabaseTx < ' _ > {
@@ -928,3 +940,32 @@ async fn did_assets(conn: impl SqliteExecutor<'_>) -> Result<Vec<DidAsset>> {
928940 } )
929941 . collect ( )
930942}
943+
944+ async fn requested_nft (
945+ conn : impl SqliteExecutor < ' _ > ,
946+ launcher_id : Bytes32 ,
947+ ) -> Result < Option < RequestedNft > > {
948+ let launcher_id = launcher_id. as_ref ( ) ;
949+
950+ query ! (
951+ "
952+ SELECT
953+ metadata, metadata_updater_puzzle_hash, royalty_puzzle_hash, royalty_basis_points
954+ FROM nfts
955+ INNER JOIN assets ON assets.id = nfts.asset_id
956+ WHERE hash = ?
957+ " ,
958+ launcher_id
959+ )
960+ . fetch_optional ( conn)
961+ . await ?
962+ . map ( |row| {
963+ Ok ( RequestedNft {
964+ metadata : Program :: from ( row. metadata ) ,
965+ metadata_updater_puzzle_hash : row. metadata_updater_puzzle_hash . convert ( ) ?,
966+ royalty_puzzle_hash : row. royalty_puzzle_hash . convert ( ) ?,
967+ royalty_basis_points : row. royalty_basis_points . convert ( ) ?,
968+ } )
969+ } )
970+ . transpose ( )
971+ }
0 commit comments