Skip to content

Commit 487431e

Browse files
refactor: Clarify comments in arena and marketplace modules regarding event emissions and parameter handling
1 parent 1401fef commit 487431e

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

STUDENT_GUIDE.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public fun create_arena(hero: Hero, ctx: &mut TxContext) {
3131
// - Use object::new(ctx) for unique ID
3232
// - Set warrior field to the hero parameter
3333
// - Set owner to ctx.sender()
34-
// - Emit ArenaCreated event with arena ID and timestamp (Don't forget to use ctx.epoch_timestamp_ms())
34+
// - Emit ArenaCreated event with arena ID and timestamp (Don't forget to use ctx.epoch_timestamp_ms(), object::id(&arena))
3535
// - Use transfer::share_object() to make it publicly accessible
3636
}
3737
```
@@ -46,7 +46,8 @@ public fun battle(hero: Hero, arena: Arena, ctx: &mut TxContext) {
4646
// - Compare hero.hero_power() with warrior.hero_power()
4747
// - If hero wins: both heroes go to ctx.sender()
4848
// - If warrior wins: both heroes go to battle place owner
49-
// - Emit BattlePlaceCompleted event with winner/loser IDs (Don't forget to use object::to_inner(winner.id) or object::to_inner(loser.id) )
49+
// - Emit BattlePlaceCompleted event with winner/loser IDs (Don't forget to use object::id(&warrior) or object::id(&hero)).
50+
// - Note: You have to emit this inside of the if else statements
5051
// - Don't forget to delete the battle place ID at the end
5152
}
5253
```
@@ -90,7 +91,7 @@ public fun buy_hero(list_hero: ListHero, coin: Coin<SUI>, ctx: &mut TxContext) {
9091
// - Use assert! to verify coin value equals listing price (coin::value(&coin) == price) else abort with `EInvalidPayment`
9192
// - Transfer coin to seller (use transfer::public_transfer() function)
9293
// - Transfer hero NFT to buyer (ctx.sender())
93-
// - Emit HeroBought event with transaction details (Don't forget to use object::to_inner(id) )
94+
// - Emit HeroBought event with transaction details (Don't forget to use object::uid_to_inner(&id) )
9495
// - Delete the listing ID (object::delete(id))
9596
}
9697
```
@@ -101,7 +102,7 @@ public fun buy_hero(list_hero: ListHero, coin: Coin<SUI>, ctx: &mut TxContext) {
101102
public fun delist(_: &AdminCap, list_hero: ListHero) {
102103
// TODO: Implement admin delist functionality
103104
// Hints:
104-
// - Destructure list_hero (ignore price with "_price")
105+
// - Destructure list_hero (ignore price with "price: _")
105106
// - Transfer NFT back to original seller
106107
// - Delete the listing ID
107108
// - The AdminCap parameter ensures only admin can call this

move/sources/arena.move

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public fun create_arena(hero: Hero, ctx: &mut TxContext) {
3232
// - Use object::new(ctx) for unique ID
3333
// - Set warrior field to the hero parameter
3434
// - Set owner to ctx.sender()
35-
// - Emit ArenaCreated event with arena ID and timestamp (Don't forget to use ctx.epoch_timestamp_ms())
35+
// - Emit ArenaCreated event with arena ID and timestamp (Don't forget to use ctx.epoch_timestamp_ms(), object::id(&arena))
3636
// - Use transfer::share_object() to make it publicly accessible
3737
}
3838

@@ -44,7 +44,8 @@ public fun battle(hero: Hero, arena: Arena, ctx: &mut TxContext) {
4444
// - Compare hero.hero_power() with warrior.hero_power()
4545
// - If hero wins: both heroes go to ctx.sender()
4646
// - If warrior wins: both heroes go to battle place owner
47-
// - Emit BattlePlaceCompleted event with winner/loser IDs (Don't forget to use object::to_inner(winner.id) or object::to_inner(loser.id) )
47+
// - Emit BattlePlaceCompleted event with winner/loser IDs (Don't forget to use object::id(&warrior) or object::id(&hero) ).
48+
// - Note: You have to emit this inside of the if else statements
4849
// - Don't forget to delete the battle place ID at the end
4950
}
5051

move/sources/marketplace.move

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
module challenge::marketplace;
22

33
use challenge::hero::Hero;
4-
use std::string::String;
54
use sui::coin::{Self, Coin};
65
use sui::event;
76
use sui::sui::SUI;
@@ -73,7 +72,7 @@ public fun buy_hero(list_hero: ListHero, coin: Coin<SUI>, ctx: &mut TxContext) {
7372
// - Use assert! to verify coin value equals listing price (coin::value(&coin) == price) else abort with `EInvalidPayment`
7473
// - Transfer coin to seller (use transfer::public_transfer() function)
7574
// - Transfer hero NFT to buyer (ctx.sender())
76-
// - Emit HeroBought event with transaction details (Don't forget to use object::to_inner(id) )
75+
// - Emit HeroBought event with transaction details (Don't forget to use object::uid_to_inner(&id) )
7776
// - Delete the listing ID (object::delete(id))
7877
}
7978

@@ -82,7 +81,7 @@ public fun buy_hero(list_hero: ListHero, coin: Coin<SUI>, ctx: &mut TxContext) {
8281
public fun delist(_: &AdminCap, list_hero: ListHero) {
8382
// TODO: Implement admin delist functionality
8483
// Hints:
85-
// - Destructure list_hero (ignore price with "_price")
84+
// - Destructure list_hero (ignore price with "price: _")
8685
// - Transfer NFT back to original seller
8786
// - Delete the listing ID (object::delete(id))
8887
// - The AdminCap parameter ensures only admin can call this

0 commit comments

Comments
 (0)