Skip to content

Commit

Permalink
Changes return value of mint_root to return MintRootResult
Browse files Browse the repository at this point in the history
  • Loading branch information
ottpeter committed Dec 17, 2022
1 parent 91da1bf commit c4241ae
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 7 additions & 0 deletions contract/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,11 @@ impl NonFungibleTokenMetadata for Contract {
fn nft_metadata(&self) -> NFTContractMetadata {
self.metadata.get().unwrap()
}
}

#[derive(Serialize, Deserialize, Debug)]
#[serde(crate = "near_sdk::serde")]
pub struct MintRootResult {
pub contract: AccountId, // Name of the minting contract
pub root_id: TokenId, // ID of the RootNFT
}
9 changes: 7 additions & 2 deletions contract/src/mint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ impl Contract {
&mut self,
metadata: TokenMetadata,
receiver_id: AccountId,
) {
) -> MintRootResult {
log!("Starting MintRoot...");

assert_eq!(
Expand Down Expand Up @@ -65,10 +65,15 @@ impl Contract {

env::log_str(&nft_mint_log.to_string()); // Log the serialized json.

self.create_children(token_id.clone(), token_id); // This has to happen before the refund
self.create_children(token_id.clone(), token_id.clone()); // This has to happen before the refund

let required_storage_in_bytes = env::storage_usage() - initial_storage_usage;
refund_deposit(required_storage_in_bytes); // Refund not-used storage

MintRootResult {
contract: env::current_account_id(),
root_id: token_id
}
}


Expand Down

0 comments on commit c4241ae

Please sign in to comment.