Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions nft/candid/nft.did
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
Ok: principal;
};

type AddFleekUserResult =
variant {
Err: ApiError;
Ok: opt bool;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Ok: opt bool;
Ok: opt text;

I think this might be better since a boolean can cause some confusion and afaik all psychedelic canisters use Ok(()) to pass the result.

};

type TxReceipt =
variant {
Err: ApiError;
Expand Down Expand Up @@ -299,6 +305,9 @@ type AccountIdentifier = text;
supply: (TokenIdentifier) -> (BalanceReturn) query;
metadata: (TokenIdentifier) -> (MetadataReturn) query;
add: (TransferRequest) -> (TransactionId);

// Management //
add_fleek_user: (account: Principal) -> (AddFleekUserResult);
};

service : (principal, text, text, principal) -> erc721_token
4 changes: 4 additions & 0 deletions nft/src/management.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ impl Default for Fleek {
pub fn is_fleek(account: &Principal) -> bool {
ic::get::<Fleek>().0.contains(account)
}

pub fn add_fleek_user(account: &Principal) {
ic::get_mut::<Fleek>().0.push(*account)
}
11 changes: 11 additions & 0 deletions nft/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use ic_kit::ic;
use ic_kit::ic::caller;
use ic_kit::ic::trap;
use ic_kit::macros::*;
use ic_kit::Principal as ic_kit_Principal;

use cap_sdk::handshake;
use cap_sdk::DetailValue;
Expand Down Expand Up @@ -168,6 +169,16 @@ async fn mint_dip721(to: Principal, metadata_desc: MetadataDesc) -> MintReceipt

/// END DIP-721 ///

#[update]
async fn add_fleek_user(account: ic_kit_Principal) -> Result<Option<bool>, ApiError> {
if !is_fleek(&ic::caller()) {
return Err(ApiError::Unauthorized);
}

add_fleek_user(account);
Ok(None)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

related to my suggestion

}

#[update]
async fn transfer(transfer_request: TransferRequest) -> TransferResponse {
if !is_fleek(&ic::caller()) {
Expand Down