Skip to main content

goldrush_sdk/models/
nfts.rs

1use serde::Deserialize;
2
3/// Represents an NFT item returned by the API.
4#[derive(Debug, Clone, Deserialize)]
5pub struct NftItem {
6    /// The contract address of the NFT collection.
7    pub contract_address: String,
8    
9    /// The token ID within the collection.
10    pub token_id: String,
11    
12    /// The owner's balance of this NFT (usually 1 for ERC-721, can be >1 for ERC-1155).
13    pub token_balance: Option<String>,
14    
15    /// URL for the token metadata.
16    pub token_url: Option<String>,
17    
18    /// Collection name.
19    pub contract_name: Option<String>,
20    
21    /// Collection symbol/ticker.
22    pub contract_ticker_symbol: Option<String>,
23    
24    /// Whether this is an ERC-721 or ERC-1155 token.
25    pub supports_erc: Option<Vec<String>>,
26    
27    /// External metadata for the NFT.
28    pub nft_data: Option<NftMetadata>,
29}
30
31/// Metadata for an NFT token.
32#[derive(Debug, Clone, Deserialize)]
33pub struct NftMetadata {
34    /// Token URI pointing to metadata.
35    pub token_uri: Option<String>,
36    
37    /// External metadata loaded from token URI.
38    pub external_data: Option<ExternalNftData>,
39    
40    /// Original owner of the NFT.
41    pub original_owner: Option<String>,
42    
43    /// Current owner of the NFT.
44    pub current_owner: Option<String>,
45    
46    /// Asset details.
47    pub asset_original_url: Option<String>,
48    pub asset_cached_url: Option<String>,
49    pub asset_file_extension: Option<String>,
50    pub asset_mime_type: Option<String>,
51}
52
53/// External NFT metadata loaded from token URI.
54#[derive(Debug, Clone, Deserialize)]
55pub struct ExternalNftData {
56    /// Name of the NFT.
57    pub name: Option<String>,
58    
59    /// Description of the NFT.
60    pub description: Option<String>,
61    
62    /// Image URL.
63    pub image: Option<String>,
64    
65    /// Animation URL (for video/interactive content).
66    pub animation_url: Option<String>,
67    
68    /// External URL for more information.
69    pub external_url: Option<String>,
70    
71    /// Attributes/traits of the NFT.
72    pub attributes: Option<Vec<NftAttribute>>,
73}
74
75/// An attribute/trait of an NFT.
76#[derive(Debug, Clone, Deserialize)]
77pub struct NftAttribute {
78    /// The trait type/name.
79    pub trait_type: Option<String>,
80    
81    /// The trait value.
82    pub value: Option<serde_json::Value>,
83    
84    /// Display type for the trait.
85    pub display_type: Option<String>,
86}
87
88/// Container for NFT items.
89#[derive(Debug, Clone, Deserialize)]
90pub struct NftsData {
91    /// The address these NFTs belong to.
92    pub address: Option<String>,
93    
94    /// The chain ID.
95    pub chain_id: Option<u64>,
96    
97    /// The chain name.
98    pub chain_name: Option<String>,
99    
100    /// List of NFT items.
101    pub items: Vec<NftItem>,
102}
103
104/// Response structure for NFT queries.
105pub type NftsResponse = crate::models::ApiResponse<NftsData>;
106
107/// Represents detailed NFT metadata for a specific token.
108#[derive(Debug, Clone, Deserialize)]
109pub struct NftMetadataItem {
110    /// The contract address.
111    pub contract_address: String,
112    
113    /// The token ID.
114    pub token_id: String,
115    
116    /// The token URI.
117    pub token_uri: Option<String>,
118    
119    /// The loaded metadata.
120    pub metadata: Option<serde_json::Value>,
121    
122    /// External data.
123    pub external_data: Option<ExternalNftData>,
124    
125    /// Asset information.
126    pub asset_original_url: Option<String>,
127    pub asset_cached_url: Option<String>,
128    pub asset_file_extension: Option<String>,
129    pub asset_mime_type: Option<String>,
130}
131
132/// Response structure for NFT metadata queries.
133pub type NftMetadataResponse = crate::models::ApiResponse<Vec<NftMetadataItem>>;