Skip to content
Merged
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
18 changes: 7 additions & 11 deletions contracts/src/profile_nft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
use crate::utils::pause::PauseUtils;
use crate::utils::storage::StorageUtils;
use crate::utils::validation::{
validate_non_zero_address, validate_string_length,
MAX_DESCRIPTION_LENGTH, MAX_SHORT_TEXT_LENGTH, MAX_TITLE_LENGTH, MAX_URI_LENGTH,
validate_non_zero_address, validate_string_length, MAX_DESCRIPTION_LENGTH, MAX_TITLE_LENGTH,
MAX_URI_LENGTH,
};
use soroban_sdk::{contracttype, symbol_short, Address, Env, String, Symbol, Vec};
use soroban_sdk::{contracttype, symbol_short, Address, Env, String, Vec};

/// Maximum number of skills per profile NFT
pub const MAX_SKILLS: u32 = 20;
Expand Down Expand Up @@ -192,18 +192,14 @@ pub fn get_profile_nft(env: &Env, token_id: u64) -> ProfileNFT {
env.storage()
.persistent()
.get(&ProfileNFTKey::Token(token_id))
.unwrap_or_else(|| panic!("Profile NFT not found"));
.unwrap_or_else(|| panic!("Profile NFT not found"))
}

/// Get a profile NFT by owner address.
///
/// Returns `None` if the owner has not minted a profile NFT yet.
pub fn get_profile_nft_by_owner(env: &Env, owner: Address) -> Option<ProfileNFT> {
if let Some(token_id) = get_token_id_for_owner(env, owner) {
Some(get_profile_nft(env, token_id))
} else {
None
}
get_token_id_for_owner(env, owner).map(|token_id| get_profile_nft(env, token_id))
}

/// Get the token ID for an owner, if one exists.
Expand All @@ -218,7 +214,7 @@ pub fn owner_of(env: &Env, token_id: u64) -> Address {
env.storage()
.persistent()
.get(&ProfileNFTKey::TokenOwner(token_id))
.unwrap_or_else(|| panic!("Profile NFT not found"));
.unwrap_or_else(|| panic!("Profile NFT not found"))
}

/// Check whether a profile NFT exists for a given token ID.
Expand Down Expand Up @@ -298,7 +294,7 @@ pub fn unverify_profile_nft(env: &Env, admin: Address, token_id: u64) -> bool {
.set(&ProfileNFTKey::Token(token_id), &nft);

env.events().publish(
(symbol_short!("profile"), symbol_short!("unverified")),
(symbol_short!("profile"), symbol_short!("unverify")),
(token_id, admin),
);

Expand Down
Loading
Loading