Skip to content

Commit

Permalink
fix details extraction of received nia
Browse files Browse the repository at this point in the history
  • Loading branch information
zoedberg committed Dec 11, 2023
1 parent f33fc55 commit 837ace6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions rgb-lib-ffi/src/rgb-lib.udl
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ dictionary AssetNIA {
AssetIface asset_iface;
string ticker;
string name;
string? details;
u8 precision;
u64 issued_supply;
i64 timestamp;
Expand Down
13 changes: 7 additions & 6 deletions src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ impl AssetIface {
asset_iface: self.clone(),
ticker: asset.ticker.clone().unwrap(),
name: asset.name.clone(),
details: asset.details.clone(),
precision: asset.precision,
issued_supply,
timestamp: asset.timestamp,
Expand All @@ -204,8 +205,8 @@ impl AssetIface {
AssetIface::RGB25 => AssetType::AssetCFA(AssetCFA {
asset_id: asset.asset_id.clone(),
asset_iface: self.clone(),
details: asset.details.clone(),
name: asset.name.clone(),
details: asset.details.clone(),
precision: asset.precision,
issued_supply,
timestamp: asset.timestamp,
Expand Down Expand Up @@ -281,6 +282,8 @@ pub struct AssetNIA {
pub ticker: String,
/// Name of the asset
pub name: String,
/// Details of the asset
pub details: Option<String>,
/// Precision, also known as divisibility, of the asset
pub precision: u8,
/// Total issued amount
Expand Down Expand Up @@ -3484,19 +3487,17 @@ impl Wallet {
let spec = iface_nia.spec();
let ticker = spec.ticker().to_string();
let name = spec.name().to_string();
let details = spec.details().map(|d| d.to_string());
let precision = spec.precision.into();
let issued_supply = iface_nia.total_issued_supply().into();
(name, precision, issued_supply, Some(ticker), None)
(name, precision, issued_supply, Some(ticker), details)
}
AssetSchema::Cfa => {
let iface_cfa = Rgb25::from(contract_iface.clone());
let name = iface_cfa.name().to_string();
let details = iface_cfa.details().map(|d| d.to_string());
let precision = iface_cfa.precision().into();
let issued_supply = iface_cfa.total_issued_supply().into();
let mut details = None;
if let Some(det) = iface_cfa.details() {
details = Some(det.to_string());
}
(name, precision, issued_supply, None, details)
}
};
Expand Down
1 change: 1 addition & 0 deletions src/wallet/test/issue_asset_nia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ fn success() {
show_unspent_colorings(&wallet, "after issuance");
assert_eq!(asset.ticker, TICKER.to_string());
assert_eq!(asset.name, NAME.to_string());
assert_eq!(asset.details, None);
assert_eq!(asset.precision, PRECISION);
assert_eq!(
asset.balance,
Expand Down

0 comments on commit 837ace6

Please sign in to comment.