Skip to content

Commit

Permalink
fix(dan): nft format comment
Browse files Browse the repository at this point in the history
  • Loading branch information
therealdannzor committed Sep 3, 2024
1 parent 8345396 commit 5d5385a
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions dan_layer/template_lib/src/models/non_fungible.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ impl FromStr for NonFungibleAddress {
type Err = ParseNonFungibleAddressError;

fn from_str(s: &str) -> Result<Self, Self::Err> {
// the expected format is nft_{resource_hex}_{type}_{"
// the expected format is nft_{resource_hex}_{type}_{id}
let mut splitted = s.split('_');

if let Some(token) = splitted.next() {
Expand Down Expand Up @@ -347,22 +347,28 @@ impl NonFungible {
/// Returns a copy of the immutable data of the token.
/// This data is set up during the token minting process and cannot be updated
pub fn get_data<T: DeserializeOwned>(&self) -> T {
let resp: InvokeResult = call_engine(EngineOp::NonFungibleInvoke, &NonFungibleInvokeArg {
address: self.address.clone(),
action: NonFungibleAction::GetData,
args: vec![],
});
let resp: InvokeResult = call_engine(
EngineOp::NonFungibleInvoke,
&NonFungibleInvokeArg {
address: self.address.clone(),
action: NonFungibleAction::GetData,
args: vec![],
},
);

resp.decode().expect("[get_data] Failed to decode NonFungible data")
}

/// Returns a copy of the mutable data of the token
pub fn get_mutable_data<T: DeserializeOwned>(&self) -> T {
let resp: InvokeResult = call_engine(EngineOp::NonFungibleInvoke, &NonFungibleInvokeArg {
address: self.address.clone(),
action: NonFungibleAction::GetMutableData,
args: vec![],
});
let resp: InvokeResult = call_engine(
EngineOp::NonFungibleInvoke,
&NonFungibleInvokeArg {
address: self.address.clone(),
action: NonFungibleAction::GetMutableData,
args: vec![],
},
);

resp.decode()
.expect("[get_mutable_data] Failed to decode raw NonFungible mutable data")
Expand Down

0 comments on commit 5d5385a

Please sign in to comment.