Skip to content

Commit db011f2

Browse files
committed
docs & refactor: update docs and refactor event ids in the ui folder
1 parent 21cb734 commit db011f2

File tree

13 files changed

+104
-98
lines changed

13 files changed

+104
-98
lines changed

move/sources/arena.move

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,29 @@ public struct ArenaCompleted has copy, drop {
2727
// ========= FUNCTIONS =========
2828

2929
public fun create_arena(hero: Hero, ctx: &mut TxContext) {
30-
// TODO: Create a Arena struct
31-
// Hints:
32-
// - Use object::new(ctx) for unique ID
33-
// - Set warrior field to the hero parameter
34-
// - Set owner to ctx.sender()
35-
// - Emit ArenaCreated event with arena ID and timestamp (Don't forget to use ctx.epoch_timestamp_ms(), object::id(&arena))
36-
// - Use transfer::share_object() to make it publicly accessible
30+
31+
// TODO: Create an arena object
32+
// Hints:
33+
// Use object::new(ctx) for unique ID
34+
// Set warrior field to the hero parameter
35+
// Set owner to ctx.sender()
36+
// TODO: Emit ArenaCreated event with arena ID and timestamp (Don't forget to use ctx.epoch_timestamp_ms(), object::id(&arena))
37+
// TODO: Use transfer::share_object() to make it publicly tradeable
3738
}
3839

3940
#[allow(lint(self_transfer))]
4041
public fun battle(hero: Hero, arena: Arena, ctx: &mut TxContext) {
42+
4143
// TODO: Implement battle logic
42-
// Hints:
43-
// - Destructure arena to get id, warrior, and owner
44-
// - Compare hero.hero_power() with warrior.hero_power()
45-
// - If hero wins: both heroes go to ctx.sender()
46-
// - If warrior wins: both heroes go to battle place owner
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
49-
// - Don't forget to delete the battle place ID at the end
44+
// Hints:
45+
// Destructure arena to get id, warrior, and owner
46+
// TODO: Compare hero.hero_power() with warrior.hero_power()
47+
// Hints:
48+
// If hero wins: both heroes go to ctx.sender()
49+
// If warrior wins: both heroes go to battle place owner
50+
// TODO: Emit BattlePlaceCompleted event with winner/loser IDs (Don't forget to use object::id(&warrior) or object::id(&hero) ).
51+
// Hints:
52+
// You have to emit this inside of the if else statements
53+
// TODO: Delete the battle place ID
5054
}
5155

move/sources/hero.move

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,16 @@ public struct HeroMetadata has key, store {
1919

2020
#[allow(lint(self_transfer))]
2121
public fun create_hero(name: String, image_url: String, power: u64, ctx: &mut TxContext) {
22+
2223
// TODO: Create a new Hero struct with the given parameters
23-
// Hints:
24-
// - Use object::new(ctx) to create a unique ID
25-
// - Set name, image_url, and power fields
26-
// - Transfer the hero to the transaction sender
27-
//
28-
// Also create HeroMetadata and freeze it for tracking
29-
// - Use ctx.epoch_timestamp_ms() for timestamp
30-
// - Use transfer::freeze_object() to make metadata immutable
24+
// Hints:
25+
// Use object::new(ctx) to create a unique ID
26+
// Set name, image_url, and power fields
27+
// TODO: Transfer the hero to the transaction sender
28+
// TODO: Create HeroMetadata and freeze it for tracking
29+
// Hints:
30+
// Use ctx.epoch_timestamp_ms() for timestamp
31+
//TODO: Use transfer::freeze_object() to make metadata immutable
3132
}
3233

3334
// ========= GETTER FUNCTIONS =========

move/sources/marketplace.move

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -44,55 +44,56 @@ public struct HeroBought has copy, drop {
4444
// ========= FUNCTIONS =========
4545

4646
fun 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

5455
public 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))]
6466
public 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

8180
public 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

9090
public 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 =========

ui/src/components/EventsHistory.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ export default function EventsHistory() {
185185
color="gray"
186186
style={{ fontFamily: "monospace" }}
187187
>
188-
ID: {eventData.id.slice(0, 8)}...
188+
ID: {eventData.list_hero_id.slice(0, 8)}...
189189
</Text>
190190
</>
191191
)}
@@ -200,7 +200,7 @@ export default function EventsHistory() {
200200
color="gray"
201201
style={{ fontFamily: "monospace" }}
202202
>
203-
ID: {eventData.id.slice(0, 8)}...
203+
ID: {eventData.arena_id.slice(0, 8)}...
204204
</Text>
205205
</>
206206
)}
@@ -209,11 +209,11 @@ export default function EventsHistory() {
209209
<>
210210
<Text size="3">
211211
<strong>🏆 Winner:</strong> ...
212-
{eventData.winner.slice(-8)}
212+
{eventData.winner_hero_id.slice(-8)}
213213
</Text>
214214
<Text size="3">
215215
<strong>💀 Loser:</strong> ...
216-
{eventData.loser.slice(-8)}
216+
{eventData.loser_hero_id.slice(-8)}
217217
</Text>
218218
</>
219219
)}

ui/src/components/SharedObjects.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ export default function SharedObjects({ refreshKey, setRefreshKey }: RefreshProp
5757
const { data, isPending, error } = useSuiClientQuery(
5858
"multiGetObjects",
5959
{
60-
ids: listedEvents?.data?.map(event => (event.parsedJson as any).id) || [],
60+
ids: listedEvents?.data?.map(event => (event.parsedJson as any).list_hero_id) || [],
6161
options: {
6262
showContent: true,
6363
showType: true
6464
}
6565
},
6666
{
6767
enabled: !!packageId && !!listedEvents?.data?.length,
68-
queryKey: ["multiGetObjects", listedEvents?.data?.map(event => (event.parsedJson as any).id), refreshKey],
68+
queryKey: ["multiGetObjects", listedEvents?.data?.map(event => (event.parsedJson as any).list_hero_id), refreshKey],
6969
}
7070
);
7171

ui/src/utility/admin/change_price.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ export const changePrice = (packageId: string, listHeroId: string, newPriceInSui
44
const tx = new Transaction();
55

66
// TODO: Convert SUI to MIST (1 SUI = 1,000,000,000 MIST)
7-
// const newPriceInMist = ?
8-
7+
//Hintz:
8+
// const newPriceInMist = ?
99
// TODO: Add moveCall to change hero price (Admin only)
1010
// Function: `${packageId}::marketplace::change_the_price`
1111
// Arguments: adminCapId (object), listHeroId (object), newPriceInMist (u64)
12-
// Hints:
13-
// - Use tx.object() for objects
14-
// - Use tx.pure.u64() for the new price
15-
// - Convert price from SUI to MIST before sending
12+
// Hints:
13+
// Use tx.object() for objects
14+
// Use tx.pure.u64() for the new price
15+
// Convert price from SUI to MIST before sending
1616

1717
return tx;
1818
};

ui/src/utility/admin/delist.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ export const delist = (
1010
// TODO: Add moveCall to delist a hero (Admin only)
1111
// Function: `${packageId}::marketplace::delist`
1212
// Arguments: adminCapId (object), listHeroId (object)
13-
// Hints:
14-
// - Use tx.object() for both objects
15-
// - This requires admin capability verification
16-
// - Returns the hero to the original seller
13+
// Hints:
14+
// Use tx.object() for both objects
15+
// This requires admin capability verification
16+
// Returns the hero to the original seller
1717

1818
return tx;
1919
};

ui/src/utility/arena/battle.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ export const battle = (packageId: string, heroId: string, arenaId: string) => {
66
// TODO: Add moveCall to start a battle
77
// Function: `${packageId}::arena::battle`
88
// Arguments: heroId (object), arenaId (object)
9-
// Hints:
10-
// - Use tx.object() for both hero and battle place objects
11-
// - The battle winner is determined by hero power comparison
12-
// - Winner takes both heroes
9+
// Hints:
10+
// Use tx.object() for both hero and battle place objects
11+
// The battle winner is determined by hero power comparison
12+
// Winner takes both heroes
1313

1414
return tx;
1515
};

ui/src/utility/arena/create_arena.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ export const createArena = (packageId: string, heroId: string) => {
66
// TODO: Add moveCall to create a battle place
77
// Function: `${packageId}::arena::create_arena`
88
// Arguments: heroId (object)
9-
// Hints:
10-
// - Use tx.object() for the hero object
11-
// - This creates a shared object that others can battle against
9+
// Hints:
10+
// Use tx.object() for the hero object
11+
// This creates a shared object that others can battle against
1212

1313
return tx;
1414
};

ui/src/utility/helpers/transfer_admin_cap.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ export const transferAdminCap = (adminCapId: string, to: string) => {
66
// TODO: Transfer admin capability to another address
77
// Use tx.transferObjects() method
88
// Arguments: [objects array], recipient address
9-
// Hints:
10-
// - Use tx.object() to reference the admin cap
11-
// - This is a simple object transfer, not a moveCall
12-
// - The recipient becomes the new admin
9+
// Hints:
10+
// Use tx.object() to reference the admin cap
11+
// This is a simple object transfer, not a moveCall
12+
// The recipient becomes the new admin
1313

1414
return tx;
1515
};

0 commit comments

Comments
 (0)