From c7b8890202c63a0286587b14beacc08edfd5c056 Mon Sep 17 00:00:00 2001 From: alnoki <43892045+alnoki@users.noreply.github.com> Date: Sun, 14 Apr 2024 15:58:06 -0700 Subject: [PATCH] [ECO-1562] Begin preliminary struct architecture (#6) --- cfg/cspell-dictionary.txt | 34 ++++++++++++ src/move/Move.toml | 6 +-- .../{main.move => emojicoin_dot_fun.move} | 52 +++++++++++++++++-- src/python/move_emojis/emojis_to_const.py | 4 +- 4 files changed, 89 insertions(+), 7 deletions(-) rename src/move/sources/{main.move => emojicoin_dot_fun.move} (98%) diff --git a/cfg/cspell-dictionary.txt b/cfg/cspell-dictionary.txt index 4433bbc11..78f9c933d 100644 --- a/cfg/cspell-dictionary.txt +++ b/cfg/cspell-dictionary.txt @@ -1,7 +1,41 @@ +aland aptos +barthelemy +bento +bouvet +burkina +caicos +clipperton +cunha +dango +diya econia emojicoin +eswatini +faso +fleur +futuna +hamsa +ivoire +keycap +khanda +kitts +leste +maarten +marino +mayen +melilla +merperson +moai +nazar +oden precommit +rica +sint struct subdir +supervillain +tanabata +tokelau +turkiye xbtmatt diff --git a/src/move/Move.toml b/src/move/Move.toml index 2bc507f00..98f7aa05c 100644 --- a/src/move/Move.toml +++ b/src/move/Move.toml @@ -1,5 +1,5 @@ [addresses] -emoji = "_" +emojicoin_dot_fun = "_" [dependencies.AptosFramework] git = "https://github.com/aptos-labs/aptos-core.git" @@ -7,10 +7,10 @@ rev = "mainnet" subdir = "aptos-move/framework/aptos-framework" [dev-addresses] -emoji = "0xc0de" +emojicoin_dot_fun = "0xc0de" [package] authors = ["Econia Labs (developers@econialabs.com)"] -name = "Move Emojis" +name = "EmojicoinDotFun" upgrade_policy = "immutable" version = "1.0.0" diff --git a/src/move/sources/main.move b/src/move/sources/emojicoin_dot_fun.move similarity index 98% rename from src/move/sources/main.move rename to src/move/sources/emojicoin_dot_fun.move index 6ee0e196a..c808f688c 100644 --- a/src/move/sources/main.move +++ b/src/move/sources/emojicoin_dot_fun.move @@ -1,5 +1,7 @@ -// cspell:disable -module emoji::main { +module emojicoin_dot_fun::emojicoin_dot_fun { + + use aptos_std::smart_table::{Self, SmartTable}; + use aptos_framework::object::{Self, ExtendRef, ObjectGroup}; const ABACUS: vector = x"f09fa7ae"; const AB_BUTTON_BLOOD_TYPE: vector = x"f09f868e"; @@ -2437,8 +2439,52 @@ module emoji::main { const ZOMBIE: vector = x"f09fa79f"; const ZZZ: vector = x"f09f92a4"; - fun init_module(_: &signer) { + #[resource_group = ObjectGroup] + struct Market has key { + market_id: address, + market_address: address, + emoji_bytes: vector, + extend_ref: ExtendRef, + } + + #[resource_group = ObjectGroup] + struct Registry has key { + registry_address: address, + supported_emojis: SmartTable, u8>, + markets_by_emoji_bytes: SmartTable, address>, + markets_by_market_id: SmartTable, + extend_ref: ExtendRef, + } + + struct RegistryAddress has key { + registry_address: address, + } + fun init_module(emojicoin_dot_fun: &signer) { + let constructor_ref = object::create_object(@emojicoin_dot_fun); + let extend_ref = object::generate_extend_ref(&constructor_ref); + let registry_signer = object::generate_signer(&constructor_ref); + let registry_address = object::address_from_constructor_ref(&constructor_ref); + move_to(emojicoin_dot_fun, RegistryAddress { registry_address }); + let registry = Registry { + registry_address, + supported_emojis: smart_table::new(), + markets_by_emoji_bytes: smart_table::new(), + markets_by_market_id: smart_table::new(), + extend_ref, + }; + smart_table::add_all( + &mut registry.supported_emojis, + vector[ + ABACUS, + AB_BUTTON_BLOOD_TYPE, + ], + vector[ + 0, + 0, + ], + ); + move_to(®istry_signer, registry); } } diff --git a/src/python/move_emojis/emojis_to_const.py b/src/python/move_emojis/emojis_to_const.py index 8e1146d2e..d653082c4 100644 --- a/src/python/move_emojis/emojis_to_const.py +++ b/src/python/move_emojis/emojis_to_const.py @@ -290,4 +290,6 @@ def convert_to_move_const(viable_emojis: dict[str, EmojiData]) -> dict[str, str] consts = dict(list(sorted(consts.items(), key=lambda x: x[0]))) with open("move_consts.txt", "w") as outfile: for name, move_string in consts.items(): - _ = outfile.write(f'const {name}: vector = x"{move_string}";\n') + _ = outfile.write( + f'const {name}: vector = x"{move_string}";\n' # noqa: E231,E702 + )