From e1ad7cb0cbfe76911bef16159941d29b53a63d65 Mon Sep 17 00:00:00 2001 From: Nikolay Dorofeev Date: Sun, 12 Nov 2023 11:12:51 +0400 Subject: [PATCH] Move get functions to the top --- .../contracts/lib/trait_nft_collection.tact | 56 +++++++++---------- ...rait_nft_collection_royalty_extention.tact | 20 +++---- contracts/contracts/lib/trait_nft_item.tact | 42 +++++++------- 3 files changed, 59 insertions(+), 59 deletions(-) diff --git a/contracts/contracts/lib/trait_nft_collection.tact b/contracts/contracts/lib/trait_nft_collection.tact index b56c9e12..6839a297 100644 --- a/contracts/contracts/lib/trait_nft_collection.tact +++ b/contracts/contracts/lib/trait_nft_collection.tact @@ -13,34 +13,6 @@ trait NftCollection with Deployable, Accounting { require(false, "Not implemented"); } - // ===== Recievers ===== // - - receive("Mint"){ - let ctx: Context = context(); - require(self.next_item_index >= 0, "non-sequential NFTs"); - let nft_init: StateInit = self.getNftItemInit(self.next_item_index); - send(SendParameters{ - to: contractAddress(nft_init), - value: self.getFullAmountForSending(), - bounce: false, - mode: SendIgnoreErrors, - body: Transfer { - query_id: 0, - new_owner: ctx.sender, - response_destination: self.owner_address, - custom_payload: emptyCell(), - forward_amount: 0, - forward_payload: emptySlice() - }.toCell(), - code: nft_init.code, - data: nft_init.data - }); - self.next_item_index = self.next_item_index + 1; - } - - // ===== Private Methods ===== // - - // ------------------ Get Function ------------------ // @@ -70,4 +42,32 @@ trait NftCollection with Deployable, Accounting { b.append(ic); return b.toCell(); } + + // ===== Recievers ===== // + + receive("Mint"){ + let ctx: Context = context(); + require(self.next_item_index >= 0, "non-sequential NFTs"); + let nft_init: StateInit = self.getNftItemInit(self.next_item_index); + send(SendParameters{ + to: contractAddress(nft_init), + value: self.getFullAmountForSending(), + bounce: false, + mode: SendIgnoreErrors, + body: Transfer { + query_id: 0, + new_owner: ctx.sender, + response_destination: self.owner_address, + custom_payload: emptyCell(), + forward_amount: 0, + forward_payload: emptySlice() + }.toCell(), + code: nft_init.code, + data: nft_init.data + }); + self.next_item_index = self.next_item_index + 1; + } + + // ===== Private Methods ===== // + } diff --git a/contracts/contracts/lib/trait_nft_collection_royalty_extention.tact b/contracts/contracts/lib/trait_nft_collection_royalty_extention.tact index 7badb74f..16dc194a 100644 --- a/contracts/contracts/lib/trait_nft_collection_royalty_extention.tact +++ b/contracts/contracts/lib/trait_nft_collection_royalty_extention.tact @@ -7,6 +7,16 @@ trait NftCollectionRoyaltyExtention { // ===== Customizable functions ===== // + // ------------------ Get Function ------------------ // + + + // ------------------ NFT standard getters ------------------ // + // https://github.com/ton-blockchain/TEPs/blob/master/text/0066-nft-royalty-standard.md#get-methods + + get fun royalty_params(): RoyaltyParams { + return self.royalty_params; + } + // ===== Recievers ===== // // ------------------ NFT standard recievers ------------------ // @@ -29,14 +39,4 @@ trait NftCollectionRoyaltyExtention { } // ===== Private Methods ===== // - - // ------------------ Get Function ------------------ // - - - // ------------------ NFT standard getters ------------------ // - // https://github.com/ton-blockchain/TEPs/blob/master/text/0066-nft-royalty-standard.md#get-methods - - get fun royalty_params(): RoyaltyParams { - return self.royalty_params; - } } diff --git a/contracts/contracts/lib/trait_nft_item.tact b/contracts/contracts/lib/trait_nft_item.tact index ce38a96f..a576830d 100644 --- a/contracts/contracts/lib/trait_nft_item.tact +++ b/contracts/contracts/lib/trait_nft_item.tact @@ -10,6 +10,27 @@ trait NftItem with Deployable, Ownable, Accounting { individual_content: Cell; is_initialized: Bool; + // --------- Get Function --------- // + + + // ------------------ NFT standard getters ------------------ // + // https://github.com/ton-blockchain/TEPs/blob/master/text/0062-nft-standard.md#get-methods + get fun get_nft_data(): GetNftData { + let b: StringBuilder = beginString(); + let collectionData: String = self.individual_content.asSlice().asString(); + b.append(collectionData); + b.append(self.item_index.toString()); + b.append(".json"); + + return GetNftData { + is_initialized: self.is_initialized, + index: self.item_index, + collection_address: self.collection_address, + owner_address: self.owner, + individual_content: b.toCell() + }; + } + // ===== Recievers ===== // receive(msg: Transfer){ @@ -39,27 +60,6 @@ trait NftItem with Deployable, Ownable, Accounting { }); } - // --------- Get Function --------- // - - - // ------------------ NFT standard getters ------------------ // - // https://github.com/ton-blockchain/TEPs/blob/master/text/0062-nft-standard.md#get-methods - get fun get_nft_data(): GetNftData { - let b: StringBuilder = beginString(); - let collectionData: String = self.individual_content.asSlice().asString(); - b.append(collectionData); - b.append(self.item_index.toString()); - b.append(".json"); - - return GetNftData { - is_initialized: self.is_initialized, - index: self.item_index, - collection_address: self.collection_address, - owner_address: self.owner, - individual_content: b.toCell() - }; - } - // ===== Private Methods ===== // fun initializeNftItem(msg: Transfer) { self.requireOwner();