From dcd1e56025ba9a1ec54778726aa450a9af48a762 Mon Sep 17 00:00:00 2001 From: alnoki <43892045+alnoki@users.noreply.github.com> Date: Fri, 3 Jan 2025 12:51:11 -0800 Subject: [PATCH] Change table style --- .../sources/emojicoin_arena.move | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/move/emojicoin_arena/sources/emojicoin_arena.move b/src/move/emojicoin_arena/sources/emojicoin_arena.move index 042c6eb19..ec831d9ee 100644 --- a/src/move/emojicoin_arena/sources/emojicoin_arena.move +++ b/src/move/emojicoin_arena/sources/emojicoin_arena.move @@ -10,7 +10,8 @@ module arena::emojicoin_arena { use aptos_framework::randomness::Self; use aptos_framework::timestamp; use aptos_std::math64::min; - use aptos_std::smart_table::{Self, SmartTable}; + use aptos_std::table::{Self, Table}; + use aptos_std::table_with_length::{Self, TableWithLength}; use aptos_std::type_info; use arena::pseudo_randomness; use emojicoin_dot_fun::emojicoin_dot_fun; @@ -78,10 +79,12 @@ module arena::emojicoin_arena { } struct Registry has key { - /// A map of each `Melee`'s `melee_id` to the `Melee` itself. - melees_by_id: SmartTable, - /// Map from a sorted combination of market IDs (lower ID first) to the `Melee` serial ID. - melee_ids_by_market_ids: SmartTable, u64>, + /// A map of each `Melee`'s `melee_id` to the `Melee` itself. 1-indexed for conformity with + /// emojicoin market ID indexing. + melees_by_id: TableWithLength, + /// Map from a sorted combination of market IDs (lower ID first) to the `Melee` serial ID, + /// used to prevent duplicate melees by reverse lookup during crank time. + melee_ids_by_market_ids: Table, u64>, /// Approves transfers from the vault. signer_capability: SignerCapability, /// `Melee.duration` for next melee. @@ -452,8 +455,8 @@ module arena::emojicoin_arena { move_to( arena, Registry { - melees_by_id: smart_table::new(), - melee_ids_by_market_ids: smart_table::new(), + melees_by_id: table_with_length::new(), + melee_ids_by_market_ids: table::new(), signer_capability, next_melee_duration: DEFAULT_DURATION, next_melee_available_rewards: DEFAULT_AVAILABLE_REWARDS,