@@ -44,55 +44,56 @@ public struct HeroBought has copy, drop {
4444// ========= FUNCTIONS =========
4545
4646fun init (ctx: &mut TxContext ) {
47+
48+ // NOTE: The init function runs once when the module is published
4749 // TODO: Initialize the module by creating AdminCap
48- // Hints:
49- // - Create AdminCap id with object::new(ctx)
50- // - Transfer it to the module publisher (ctx.sender()) using transfer::public_transfer() function
51- // - This runs once when the module is published
50+ // Hints:
51+ // Create AdminCap id with object::new(ctx)
52+ // TODO: Transfer it to the module publisher (ctx.sender()) using transfer::public_transfer() function
5253}
5354
5455public fun list_hero (nft: Hero , price: u64 , ctx: &mut TxContext ) {
55- // TODO: Create a ListHero struct for marketplace
56- // Hints:
57- // - Use object::new(ctx) for unique ID
58- // - Set nft, price, and seller (ctx.sender()) fields
59- // - Emit HeroListed event with listing details (Don't forget to use object::id(&list_hero) )
60- // - Use transfer::share_object() to make it publicly tradeable
56+
57+ // TODO: Create a list_hero object for marketplace
58+ // Hints:
59+ // - Use object::new(ctx) for unique ID
60+ // - Set nft, price, and seller (ctx.sender()) fields
61+ // TODO: Emit HeroListed event with listing details (Don't forget to use object::id(&list_hero) )
62+ // TODO: Use transfer::share_object() to make it publicly tradeable
6163}
6264
6365#[allow(lint(self_transfer))]
6466public fun buy_hero (list_hero: ListHero , coin: Coin <SUI >, ctx: &mut TxContext ) {
65- // TODO: Implement hero purchase logic
66- // Hints:
67- //
68- // Example:
69- // let ListHero { id, nft, price, seller } = list_hero;
70- //
71- // - Destructure list_hero to get id, nft, price, and seller
72- // - Use assert! to verify coin value equals listing price (coin::value(&coin) == price) else abort with `EInvalidPayment`
73- // - Transfer coin to seller (use transfer::public_transfer() function)
74- // - Transfer hero NFT to buyer (ctx.sender())
75- // - Emit HeroBought event with transaction details (Don't forget to use object::uid_to_inner(&id) )
76- // - Delete the listing ID (object::delete(id))
67+
68+ // TODO: Destructure list_hero to get id, nft, price, and seller
69+ // Hints:
70+ // let ListHero { id, nft, price, seller } = list_hero;
71+ // TODO: Use assert! to verify coin value equals listing price (coin::value(&coin) == price) else abort with `EInvalidPayment`
72+ // TODO: Transfer coin to seller (use transfer::public_transfer() function)
73+ // TODO: Transfer hero NFT to buyer (ctx.sender())
74+ // TODO: Emit HeroBought event with transaction details (Don't forget to use object::uid_to_inner(&id) )
75+ // TODO: Delete the listing ID (object::delete(id))
7776}
7877
7978// ========= ADMIN FUNCTIONS =========
8079
8180public fun delist (_: &AdminCap , list_hero: ListHero ) {
81+
82+ // NOTE: The AdminCap parameter ensures only admin can call this
8283 // TODO: Implement admin delist functionality
83- // Hints:
84- // - Destructure list_hero (ignore price with "price: _")
85- // - Transfer NFT back to original seller
86- // - Delete the listing ID (object::delete(id))
87- // - The AdminCap parameter ensures only admin can call this
84+ // Hints:
85+ // Destructure list_hero (ignore price with "price: _")
86+ // TODO:Transfer NFT back to original seller
87+ // TODO:Delete the listing ID (object::delete(id))
8888}
8989
9090public fun change_the_price (_: &AdminCap , list_hero: &mut ListHero , new_price: u64 ) {
91+
92+ // NOTE: The AdminCap parameter ensures only admin can call this
93+ // list_hero has &mut so price can be modified
9194 // TODO: Update the listing price
92- // Hints:
93- // - Access the price field of list_hero and update it
94- // - Use mutable reference (&mut) to modify the object
95- // - The AdminCap parameter ensures only admin can call this
95+ // Hints:
96+ // Access the price field of list_hero and update it
9697}
9798
9899// ========= GETTER FUNCTIONS =========
0 commit comments