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
16 changes: 11 additions & 5 deletions creator-keys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ pub struct CreatorProfile {
#[contract]
pub struct CreatorKeysContract;

impl CreatorKeysContract {
fn require_creator(env: &Env, creator: &Address) -> CreatorProfile {
let key = DataKey::Creator(creator.clone());
env.storage()
.persistent()
.get(&key)
.unwrap_or_else(|| panic!("creator not registered"))
}
}

#[contractimpl]
impl CreatorKeysContract {
pub fn register_creator(env: Env, creator: Address, handle: String) {
Expand Down Expand Up @@ -101,11 +111,7 @@ impl CreatorKeysContract {
}

let key = DataKey::Creator(creator.clone());
let mut profile: CreatorProfile = env
.storage()
.persistent()
.get(&key)
.unwrap_or_else(|| panic!("creator not registered"));
let mut profile = Self::require_creator(&env, &creator);

profile.supply += 1;
env.storage().persistent().set(&key, &profile);
Expand Down
Loading