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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ members = [
"contracts/subscription",
"contracts/achievement_collection",
"contracts/achievement_nft",
"contracts/fractional_nft",
"contracts/achievement_sets",
"contracts/auction",
"contracts/battle_pass",
Expand Down
12 changes: 11 additions & 1 deletion contracts/achievement_nft/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#![no_std]

use soroban_sdk::{
contract, contractimpl, contracttype, symbol_short, Address, Env, String, Vec,
};
use soroban_sdk::{contract, contractimpl, contracttype, symbol_short, Address, Env, String, Vec};

#[contracttype]
Expand Down Expand Up @@ -36,15 +39,21 @@ impl AchievementNFT {
env.storage().instance().set(&DataKey::TotalSupply, &0u32);
}

/// Mark a puzzle as completed by a user.
/// Admin function to mark a puzzle as completed for a user.
pub fn mark_puzzle_completed(env: Env, user: Address, puzzle_id: u32) {
let admin: Address = env.storage().instance().get(&DataKey::Admin).unwrap();
admin.require_auth();
let key = DataKey::PuzzleCompleted(user.clone(), puzzle_id);
env.storage()
.persistent()
.set(&DataKey::PuzzleCompleted(user, puzzle_id), &true);
.set(&key, &true);
env.storage()
.persistent()
.extend_ttl(&key, 100_000, 500_000);
}

/// Mint a new achievement NFT
/// Mint a new achievement NFT (requires that the puzzle was previously marked completed).
pub fn mint(env: Env, to: Address, puzzle_id: u32, metadata: String) -> u32 {
to.require_auth();
Expand All @@ -59,6 +68,7 @@ impl AchievementNFT {
panic!("Puzzle not completed");
}

Self::craftmint(env, to, puzzle_id, metadata)
Self::mint_internal(env, to, puzzle_id, metadata)
}

Expand Down
16 changes: 16 additions & 0 deletions contracts/fractional_nft/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "fractional-nft"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[dependencies]
soroban-sdk = { workspace = true }

[dev-dependencies]
soroban-sdk = { workspace = true, features = ["testutils"] }

[features]
testutils = ["soroban-sdk/testutils"]
Loading