diff --git a/frontend/.env b/frontend/.env index 8c705ce4..2056bab4 100644 --- a/frontend/.env +++ b/frontend/.env @@ -1,4 +1,4 @@ -NEXT_PUBLIC_CONTRACT_ADDRESS="81e3edd3143b99880a484e7c061d721a961e21953fb6df6532464765af5167e8" +NEXT_PUBLIC_CONTRACT_ADDRESS="0xcab918f5f28bab478e237cd15c3750b3fa3f95ec0505510a24aa663efb348dd3" NEXT_PUBLIC_BODY_OPTIONS=5 NEXT_PUBLIC_EAR_OPTIONS=6 NEXT_PUBLIC_FACE_OPTIONS=4 diff --git a/move/sources/aptogotchi.move b/move/sources/aptogotchi.move index f773c68e..608a73cd 100644 --- a/move/sources/aptogotchi.move +++ b/move/sources/aptogotchi.move @@ -30,19 +30,8 @@ module aptogotchi::main { const ENERGY_UPPER_BOUND: u64 = 10; const NAME_UPPER_BOUND: u64 = 40; - struct MintAptogotchiEvents has key { - mint_aptogotchi_events: event::EventHandle, - } - - struct MintAptogotchiEvent has drop, store { - token_name: String, - aptogotchi_name: String, - body: u8, - ear: u8, - face: u8, - } - struct AptogotchiParts has key, store { + struct AptogotchiParts has copy, drop, key, store { body: u8, ear: u8, face: u8, @@ -57,6 +46,16 @@ module aptogotchi::main { burn_ref: token::BurnRef, } + struct MintAptogotchiEvents has key { + mint_aptogotchi_events: event::EventHandle, + } + + struct MintAptogotchiEvent has drop, store { + token_name: String, + aptogotchi_name: String, + parts: AptogotchiParts, + } + // Tokens require a signer to create, so this is the signer for the collection struct CollectionCapability has key { extend_ref: ExtendRef, @@ -140,6 +139,11 @@ module aptogotchi::main { let description = string::utf8(APTOGOTCHI_COLLECTION_DESCRIPTION); let user_addr = address_of(user); let token_name = to_string(&user_addr); + let parts = AptogotchiParts { + body, + ear, + face, + }; assert!(!has_aptogotchi(user_addr), error::already_exists(EUSER_ALREADY_HAS_APTOGOTCHI)); let constructor_ref = token::create_named_token( @@ -161,11 +165,7 @@ module aptogotchi::main { name, birthday: timestamp::now_seconds(), energy_points: ENERGY_UPPER_BOUND, - parts: AptogotchiParts { - body, - ear, - face, - }, + parts, mutator_ref, burn_ref, }; @@ -178,9 +178,7 @@ module aptogotchi::main { MintAptogotchiEvent { token_name, aptogotchi_name: name, - body, - ear, - face, + parts, }, ); @@ -280,11 +278,7 @@ module aptogotchi::main { let gotchi = borrow_global(token_address); // view function can only return primitive types. - (gotchi.name, gotchi.birthday, gotchi.energy_points, AptogotchiParts { - body: gotchi.parts.body, - ear: gotchi.parts.ear, - face: gotchi.parts.face, - }) + (gotchi.name, gotchi.birthday, gotchi.energy_points, gotchi.parts) } // ==== TESTS ====