Skip to content
Merged
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
20 changes: 19 additions & 1 deletion creator-keys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,24 @@ pub fn read_key_balance(env: &Env, creator: &Address) -> u32 {
.unwrap_or(0)
}

/// Reads an empty string for use as a default in read-only view methods.
///
/// Use this helper wherever an empty string is needed to maintain consistency
/// and reduce duplication of string allocation logic.
pub fn read_none_string(env: &Env) -> String {
String::from_str(env, "")
}

/// Reads the handle for a creator, returning an empty string for unregistered creators.
///
/// Use this helper wherever repeated handle read logic is needed to maintain
/// missing-handle behavior consistency across the contract.
pub fn read_creator_handle(env: &Env, creator: &Address) -> String {
read_creator_profile(env, creator)
.map(|p| p.handle)
.unwrap_or_else(|| read_none_string(env))
}

fn read_protocol_fee_config(env: &Env) -> Option<fee::FeeConfig> {
env.storage()
.persistent()
Expand Down Expand Up @@ -491,7 +509,7 @@ impl CreatorKeysContract {
},
None => CreatorDetailsView {
creator,
handle: String::from_str(&env, ""),
handle: read_none_string(&env),
supply: 0,
is_registered: false,
},
Expand Down
Loading