1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
//! Asset types for Tenzro Network
//!
//! This module defines asset representations including TNZO tokens,
//! stablecoins, and other digital assets on the network.
use crate::primitives::Address;
use serde::{Deserialize, Serialize};
/// Unique identifier for an asset on Tenzro Network
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct AssetId(pub String);
impl AssetId {
/// Creates a new AssetId
pub fn new(id: impl Into<String>) -> Self {
Self(id.into())
}
/// Returns the TNZO native token asset ID
pub fn tnzo() -> Self {
Self("TNZO".to_string())
}
/// Returns a USD stablecoin asset ID
pub fn usd_stablecoin() -> Self {
Self("USDT".to_string())
}
/// Returns the asset ID as a string
pub fn as_str(&self) -> &str {
&self.0
}
}
impl From<String> for AssetId {
fn from(id: String) -> Self {
Self(id)
}
}
impl From<&str> for AssetId {
fn from(id: &str) -> Self {
Self(id.to_string())
}
}
/// Types of stablecoins supported on Tenzro Network
///
/// Stablecoins are used for stable-value settlements and payments.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum StablecoinType {
/// US Dollar stablecoin
USD,
/// Euro stablecoin
EUR,
/// British Pound stablecoin
GBP,
/// Japanese Yen stablecoin
JPY,
/// Custom algorithmic stablecoin
Algorithmic,
}
impl StablecoinType {
/// Returns the asset ID for this stablecoin type
pub fn asset_id(&self) -> AssetId {
match self {
Self::USD => AssetId::new("USDT"),
Self::EUR => AssetId::new("EURT"),
Self::GBP => AssetId::new("GBPT"),
Self::JPY => AssetId::new("JPYT"),
Self::Algorithmic => AssetId::new("TNZO-STABLE"),
}
}
/// Returns the symbol for this stablecoin
pub fn symbol(&self) -> &str {
match self {
Self::USD => "USDT",
Self::EUR => "EURT",
Self::GBP => "GBPT",
Self::JPY => "JPYT",
Self::Algorithmic => "TNZO-STABLE",
}
}
}
/// Information about an asset on Tenzro Network
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct AssetInfo {
/// Unique asset identifier
pub asset_id: AssetId,
/// Asset name
pub name: String,
/// Asset symbol
pub symbol: String,
/// Number of decimal places
pub decimals: u8,
/// Total supply (in smallest unit)
pub total_supply: u64,
/// Asset type
pub asset_type: AssetType,
/// Asset issuer address
pub issuer: Option<Address>,
/// Whether the asset is mintable
pub mintable: bool,
/// Whether the asset is burnable
pub burnable: bool,
/// Asset metadata
pub metadata: AssetMetadata,
}
impl AssetInfo {
/// Creates a new AssetInfo
pub fn new(
asset_id: AssetId,
name: String,
symbol: String,
decimals: u8,
total_supply: u64,
asset_type: AssetType,
) -> Self {
Self {
asset_id,
name,
symbol,
decimals,
total_supply,
asset_type,
issuer: None,
mintable: false,
burnable: false,
metadata: AssetMetadata::default(),
}
}
/// Returns the TNZO native token info
pub fn tnzo() -> Self {
Self {
asset_id: AssetId::tnzo(),
name: "Tenzro Network Token".to_string(),
symbol: "TNZO".to_string(),
decimals: 18,
total_supply: 1_000_000_000, // 1 billion TNZO (in whole tokens, decimals applied separately)
asset_type: AssetType::Native,
issuer: None,
mintable: false,
burnable: true,
metadata: AssetMetadata::default(),
}
}
/// Sets the issuer address
pub fn with_issuer(mut self, issuer: Address) -> Self {
self.issuer = Some(issuer);
self
}
/// Sets mintable flag
pub fn with_mintable(mut self, mintable: bool) -> Self {
self.mintable = mintable;
self
}
/// Sets burnable flag
pub fn with_burnable(mut self, burnable: bool) -> Self {
self.burnable = burnable;
self
}
}
/// The type of asset
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum AssetType {
/// Native TNZO token
Native,
/// Stablecoin
Stablecoin(StablecoinType),
/// Fungible token
Fungible,
/// Non-fungible token (NFT)
NonFungible,
/// Synthetic asset
Synthetic,
}
/// Additional metadata for an asset
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default)]
pub struct AssetMetadata {
/// Asset description
pub description: Option<String>,
/// Asset icon URI
pub icon_uri: Option<String>,
/// Website URL
pub website: Option<String>,
/// Whitepaper URL
pub whitepaper: Option<String>,
/// Social media links
pub social: Option<SocialLinks>,
}
/// Social media links for an asset
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SocialLinks {
/// Twitter handle
pub twitter: Option<String>,
/// Discord server
pub discord: Option<String>,
/// Telegram channel
pub telegram: Option<String>,
/// GitHub repository
pub github: Option<String>,
}