Skip to content

Commit

Permalink
fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
0xaptosj committed Feb 3, 2024
1 parent 015ad12 commit a5c3236
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 26 deletions.
2 changes: 1 addition & 1 deletion frontend/.env
Original file line number Diff line number Diff line change
@@ -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
Expand Down
44 changes: 19 additions & 25 deletions move/sources/aptogotchi.move
Original file line number Diff line number Diff line change
Expand Up @@ -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<MintAptogotchiEvent>,
}

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,
Expand All @@ -57,6 +46,16 @@ module aptogotchi::main {
burn_ref: token::BurnRef,
}

struct MintAptogotchiEvents has key {
mint_aptogotchi_events: event::EventHandle<MintAptogotchiEvent>,
}

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,
Expand Down Expand Up @@ -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(
Expand All @@ -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,
};
Expand All @@ -178,9 +178,7 @@ module aptogotchi::main {
MintAptogotchiEvent {
token_name,
aptogotchi_name: name,
body,
ear,
face,
parts,
},
);

Expand Down Expand Up @@ -280,11 +278,7 @@ module aptogotchi::main {
let gotchi = borrow_global<Aptogotchi>(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 ====
Expand Down

0 comments on commit a5c3236

Please sign in to comment.