Skip to content

Commit

Permalink
Move get functions to the top
Browse files Browse the repository at this point in the history
  • Loading branch information
d0rich committed Nov 12, 2023
1 parent d326838 commit e1ad7cb
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 59 deletions.
56 changes: 28 additions & 28 deletions contracts/contracts/lib/trait_nft_collection.tact
Original file line number Diff line number Diff line change
Expand Up @@ -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 ------------------ //


Expand Down Expand Up @@ -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 ===== //

}
20 changes: 10 additions & 10 deletions contracts/contracts/lib/trait_nft_collection_royalty_extention.tact
Original file line number Diff line number Diff line change
Expand Up @@ -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 ------------------ //
Expand All @@ -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;
}
}
42 changes: 21 additions & 21 deletions contracts/contracts/lib/trait_nft_item.tact
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit e1ad7cb

Please sign in to comment.