From c4241aeb98007d1da1387efc03eb604944931c37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Ott?= Date: Sat, 17 Dec 2022 17:01:00 +0100 Subject: [PATCH] Changes return value of mint_root to return MintRootResult --- contract/src/metadata.rs | 7 +++++++ contract/src/mint.rs | 9 +++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/contract/src/metadata.rs b/contract/src/metadata.rs index e16041d..6c76da1 100644 --- a/contract/src/metadata.rs +++ b/contract/src/metadata.rs @@ -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 } \ No newline at end of file diff --git a/contract/src/mint.rs b/contract/src/mint.rs index 58d3986..1b0c08a 100644 --- a/contract/src/mint.rs +++ b/contract/src/mint.rs @@ -14,7 +14,7 @@ impl Contract { &mut self, metadata: TokenMetadata, receiver_id: AccountId, - ) { + ) -> MintRootResult { log!("Starting MintRoot..."); assert_eq!( @@ -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 + } }