From 8336d8113c74a3a0dc306ae4e87b400006389bbb Mon Sep 17 00:00:00 2001 From: Ulf Wiger Date: Mon, 15 Jul 2024 16:39:04 +0200 Subject: [PATCH 1/2] Add native_token encoding support --- rebar.config | 2 +- rebar.lock | 4 ++-- src/aeser_api_encoder.erl | 7 +++++++ test/aeser_api_encoder_tests.erl | 1 + 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/rebar.config b/rebar.config index cee7ddb..084d1f6 100644 --- a/rebar.config +++ b/rebar.config @@ -1,4 +1,4 @@ {erl_opts, [debug_info]}. {deps, [ {base58, {git, "https://github.com/aeternity/erl-base58.git", {ref, "60a3356"}}} - , {enacl, {git, "https://github.com/aeternity/enacl.git", {ref, "67fceef"}}} + , {enacl, {git, "https://gitlab.com/ioecs/enacl.git", {ref, "4eb7ec70"}}} ]}. diff --git a/rebar.lock b/rebar.lock index 6e807c8..7a63cfc 100644 --- a/rebar.lock +++ b/rebar.lock @@ -3,6 +3,6 @@ {ref,"60a335668a60328a29f9731b67c4a0e9e3d50ab6"}}, 0}, {<<"enacl">>, - {git,"https://github.com/aeternity/enacl.git", - {ref,"67fceef42c0d055570f2e67b571f8d1f8de2f204"}}, + {git,"https://gitlab.com/ioecs/enacl.git", + {ref,"4eb7ec70084ba7c87b1af8797c4c4e90c84f95a2"}}, 0}]. diff --git a/src/aeser_api_encoder.erl b/src/aeser_api_encoder.erl index 1f2800b..ec449cb 100644 --- a/src/aeser_api_encoder.erl +++ b/src/aeser_api_encoder.erl @@ -35,6 +35,7 @@ | associate_chain | signature | name + | native_token | commitment | peer_pubkey | state @@ -170,6 +171,7 @@ id2type(channel) -> channel; id2type(commitment) -> commitment; id2type(contract) -> contract_pubkey; id2type(name) -> name; +id2type(native_token) -> native_token; id2type(oracle) -> oracle_pubkey. type2id(account_pubkey) -> account; @@ -178,6 +180,7 @@ type2id(channel) -> channel; type2id(commitment) -> commitment; type2id(contract_pubkey) -> contract; type2id(name) -> name; +type2id(native_token) -> native_token; type2id(oracle_pubkey) -> oracle. type2enc(key_block_hash) -> ?BASE58; @@ -204,6 +207,7 @@ type2enc(signature) -> ?BASE58; type2enc(commitment) -> ?BASE58; type2enc(peer_pubkey) -> ?BASE58; type2enc(name) -> ?BASE58; +type2enc(native_token) -> ?BASE58; type2enc(state) -> ?BASE64; type2enc(poi) -> ?BASE64; type2enc(state_trees) -> ?BASE64; @@ -237,6 +241,7 @@ type2pfx(signature) -> <<"sg">>; type2pfx(commitment) -> <<"cm">>; type2pfx(peer_pubkey) -> <<"pp">>; type2pfx(name) -> <<"nm">>; +type2pfx(native_token) -> <<"nt">>; type2pfx(state) -> <<"st">>; type2pfx(poi) -> <<"pi">>; type2pfx(state_trees) -> <<"ss">>; @@ -269,6 +274,7 @@ pfx2type(<<"sg">>) -> signature; pfx2type(<<"cm">>) -> commitment; pfx2type(<<"pp">>) -> peer_pubkey; pfx2type(<<"nm">>) -> name; +pfx2type(<<"nt">>) -> native_token; pfx2type(<<"st">>) -> state; pfx2type(<<"pi">>) -> poi; pfx2type(<<"ss">>) -> state_trees; @@ -301,6 +307,7 @@ byte_size_for_type(account_seckey) -> 32; byte_size_for_type(associate_chain) -> 32; byte_size_for_type(signature) -> 64; byte_size_for_type(name) -> not_applicable; +byte_size_for_type(native_token) -> 32; byte_size_for_type(commitment) -> 32; byte_size_for_type(peer_pubkey) -> 32; byte_size_for_type(state) -> 32; diff --git a/test/aeser_api_encoder_tests.erl b/test/aeser_api_encoder_tests.erl index 732b32d..b02bbf0 100644 --- a/test/aeser_api_encoder_tests.erl +++ b/test/aeser_api_encoder_tests.erl @@ -20,6 +20,7 @@ , {account_pubkey , 32} , {signature , 64} , {name , not_applicable} + , {native_token , 32} , {commitment , 32} , {peer_pubkey , 32} , {state , 32} -- 2.30.2 From 5139f130f5292526dcd65229d0808f79bd5132d5 Mon Sep 17 00:00:00 2001 From: Ulf Wiger Date: Mon, 15 Jul 2024 17:38:23 +0200 Subject: [PATCH 2/2] Add native token chain obj info --- src/aeser_chain_objects.erl | 12 ++++++++++++ src/aeser_id.erl | 2 ++ 2 files changed, 14 insertions(+) diff --git a/src/aeser_chain_objects.erl b/src/aeser_chain_objects.erl index 40feb16..8743a2e 100644 --- a/src/aeser_chain_objects.erl +++ b/src/aeser_chain_objects.erl @@ -105,6 +105,12 @@ tag(micro_block) -> 101; tag(light_micro_block) -> 102; tag(testimony) -> 110; tag(testimony_tx) -> 111; +tag(nt_native_token) -> 120; +tag(nt_create_tx) -> 121; +tag(nt_mint_tx) -> 122; +tag(nt_finalize_tx) -> 123; +tag(nt_trade_tx) -> 124; +tag(nt_burn_tx) -> 125; tag(pof) -> 200. rev_tag(10) -> account; @@ -176,4 +182,10 @@ rev_tag(101) -> micro_block; rev_tag(102) -> light_micro_block; rev_tag(110) -> testimony; rev_tag(111) -> testimony_tx; +rev_tag(120) -> nt_native_token; +rev_tag(121) -> nt_create_tx; +rev_tag(122) -> nt_mint_tx; +rev_tag(123) -> nt_finalize_tx; +rev_tag(124) -> nt_trade_tx; +rev_tag(125) -> nt_burn_tx; rev_tag(200) -> pof. diff --git a/src/aeser_id.erl b/src/aeser_id.erl index f534044..ba47beb 100644 --- a/src/aeser_id.erl +++ b/src/aeser_id.erl @@ -103,6 +103,7 @@ encode_tag(oracle) -> 4; encode_tag(contract) -> 5; encode_tag(channel) -> 6; encode_tag(associate_chain) -> 7; +encode_tag(native_token) -> 8; encode_tag(Other) -> error({illegal_id_tag_name, Other}). decode_tag(1) -> account; @@ -112,4 +113,5 @@ decode_tag(4) -> oracle; decode_tag(5) -> contract; decode_tag(6) -> channel; decode_tag(7) -> associate_chain; +decode_tag(8) -> native_token; decode_tag(X) -> error({illegal_id_tag, X}). -- 2.30.2