Remove old type references, update naming, add license notices #43
@ -1,37 +0,0 @@
|
|||||||
version: 2.1
|
|
||||||
|
|
||||||
executors:
|
|
||||||
aebuilder:
|
|
||||||
docker:
|
|
||||||
- image: aeternity/builder:bionic-otp23
|
|
||||||
user: builder
|
|
||||||
working_directory: ~/src
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
executor: aebuilder
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- dialyzer-cache-v1-{{ .Branch }}-{{ .Revision }}
|
|
||||||
- dialyzer-cache-v1-{{ .Branch }}-
|
|
||||||
- dialyzer-cache-v1-
|
|
||||||
- run:
|
|
||||||
name: Build
|
|
||||||
command: rebar3 compile
|
|
||||||
- run:
|
|
||||||
name: Static Analysis
|
|
||||||
command: rebar3 dialyzer
|
|
||||||
- run:
|
|
||||||
name: Eunit
|
|
||||||
command: rebar3 eunit
|
|
||||||
- run:
|
|
||||||
name: Common Tests
|
|
||||||
command: rebar3 ct
|
|
||||||
- save_cache:
|
|
||||||
key: dialyzer-cache-v1-{{ .Branch }}-{{ .Revision }}
|
|
||||||
paths:
|
|
||||||
- _build/default/rebar3_20.3.8_plt
|
|
||||||
- store_artifacts:
|
|
||||||
path: _build/test/logs
|
|
14
.gitea/workflows/test.yaml
Normal file
14
.gitea/workflows/test.yaml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
name: Gajumaru Serialization Tests
|
||||||
|
run-name: ${{ gitea.actor }} testing Gajumaru Serialization
|
||||||
|
on: [push, workflow_dispatch]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
tests:
|
||||||
|
runs-on: linux_amd64
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: eunit
|
||||||
|
run: |
|
||||||
|
. /opt/act_runner/erts/27.2/activate
|
||||||
|
./rebar3 eunit
|
1
LICENSE
1
LICENSE
@ -1,5 +1,6 @@
|
|||||||
ISC License
|
ISC License
|
||||||
|
|
||||||
|
Copyright (c) 2025, QPQ AG
|
||||||
Copyright (c) 2017, aeternity developers
|
Copyright (c) 2017, aeternity developers
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
10
README.md
10
README.md
@ -1,9 +1,15 @@
|
|||||||
aeserialization
|
GM Serialization
|
||||||
=====
|
=====
|
||||||
|
|
||||||
Serialization helpers for Aeternity node.
|
Serialization helpers for the Gajumaru.
|
||||||
|
|
||||||
Build
|
Build
|
||||||
-----
|
-----
|
||||||
|
|
||||||
$ rebar3 compile
|
$ rebar3 compile
|
||||||
|
|
||||||
|
|
||||||
|
Test
|
||||||
|
----
|
||||||
|
|
||||||
|
$ rebar3 eunit
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{erl_opts, [debug_info]}.
|
{erl_opts, [debug_info]}.
|
||||||
{deps, [ {base58, {git, "https://github.com/aeternity/erl-base58.git", {ref, "60a3356"}}}
|
{deps, [ {base58, {git, "https://git.qpq.swiss/QPQ-AG/erl-base58.git", {ref, "b6c41ff2f86f679675b95a780bfc6475e973d796"}}}
|
||||||
, {enacl, {git, "https://gitlab.com/ioecs/enacl.git", {ref, "4eb7ec70"}}}
|
, {enacl, {git, "https://git.qpq.swiss/QPQ-AG/enacl.git", {ref, "4eb7ec70084ba7c87b1af8797c4c4e90c84f95a2"}}}
|
||||||
]}.
|
]}.
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
[{<<"base58">>,
|
[{<<"base58">>,
|
||||||
{git,"https://github.com/aeternity/erl-base58.git",
|
{git,"https://git.qpq.swiss/QPQ-AG/erl-base58.git",
|
||||||
{ref,"60a335668a60328a29f9731b67c4a0e9e3d50ab6"}},
|
{ref,"b6c41ff2f86f679675b95a780bfc6475e973d796"}},
|
||||||
0},
|
0},
|
||||||
{<<"enacl">>,
|
{<<"enacl">>,
|
||||||
{git,"https://gitlab.com/ioecs/enacl.git",
|
{git,"https://git.qpq.swiss/QPQ-AG/enacl.git",
|
||||||
{ref,"4eb7ec70084ba7c87b1af8797c4c4e90c84f95a2"}},
|
{ref,"4eb7ec70084ba7c87b1af8797c4c4e90c84f95a2"}},
|
||||||
0}].
|
0}].
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
|
%%% @copyright (C) 2025, QPQ AG
|
||||||
%%% @copyright (C) 2017, Aeternity Anstalt
|
%%% @copyright (C) 2017, Aeternity Anstalt
|
||||||
%%% @doc
|
%%% @doc
|
||||||
%%% API encoding for the Aeternity node.
|
%%% API encoding for the Gajumaru
|
||||||
%%% @end
|
%%% @end
|
||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
-module(aeser_api_encoder).
|
-module(gmser_api_encoder).
|
||||||
|
|
||||||
-export([encode/2,
|
-export([encode/2,
|
||||||
decode/1,
|
decode/1,
|
||||||
@ -27,10 +28,6 @@
|
|||||||
| contract_source
|
| contract_source
|
||||||
| transaction
|
| transaction
|
||||||
| tx_hash
|
| tx_hash
|
||||||
| oracle_pubkey
|
|
||||||
| oracle_query
|
|
||||||
| oracle_query_id
|
|
||||||
| oracle_response
|
|
||||||
| account_pubkey
|
| account_pubkey
|
||||||
| account_seckey
|
| account_seckey
|
||||||
| associate_chain
|
| associate_chain
|
||||||
@ -56,9 +53,9 @@
|
|||||||
-define(BASE58, 1).
|
-define(BASE58, 1).
|
||||||
-define(BASE64, 2).
|
-define(BASE64, 2).
|
||||||
|
|
||||||
-spec encode(known_type(), payload() | aeser_id:id()) -> encoded().
|
-spec encode(known_type(), payload() | gmser_id:id()) -> encoded().
|
||||||
encode(id_hash, Payload) ->
|
encode(id_hash, Payload) ->
|
||||||
{IdType, Val} = aeser_id:specialize(Payload),
|
{IdType, Val} = gmser_id:specialize(Payload),
|
||||||
encode(id2type(IdType), Val);
|
encode(id2type(IdType), Val);
|
||||||
encode(Type, Payload) ->
|
encode(Type, Payload) ->
|
||||||
Pfx = type2pfx(Type),
|
Pfx = type2pfx(Type),
|
||||||
@ -94,14 +91,14 @@ type_size_check(Type, Bin) ->
|
|||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec safe_decode(extended_type(), encoded()) -> {'ok', payload() | aeser_id:id()}
|
-spec safe_decode(extended_type(), encoded()) -> {'ok', payload() | gmser_id:id()}
|
||||||
| {'error', atom()}.
|
| {'error', atom()}.
|
||||||
safe_decode({id_hash, AllowedTypes}, Enc) ->
|
safe_decode({id_hash, AllowedTypes}, Enc) ->
|
||||||
try decode(Enc) of
|
try decode(Enc) of
|
||||||
{ActualType, Dec} ->
|
{ActualType, Dec} ->
|
||||||
case lists:member(ActualType, AllowedTypes) of
|
case lists:member(ActualType, AllowedTypes) of
|
||||||
true ->
|
true ->
|
||||||
try {ok, aeser_id:create(type2id(ActualType), Dec)}
|
try {ok, gmser_id:create(type2id(ActualType), Dec)}
|
||||||
catch error:_ -> {error, invalid_prefix}
|
catch error:_ -> {error, invalid_prefix}
|
||||||
end;
|
end;
|
||||||
false ->
|
false ->
|
||||||
@ -175,8 +172,7 @@ id2type(contract) -> contract_pubkey;
|
|||||||
id2type(contract_source) -> contract_source;
|
id2type(contract_source) -> contract_source;
|
||||||
id2type(name) -> name;
|
id2type(name) -> name;
|
||||||
id2type(native_token) -> native_token;
|
id2type(native_token) -> native_token;
|
||||||
id2type(entry) -> entry;
|
id2type(entry) -> entry.
|
||||||
id2type(oracle) -> oracle_pubkey.
|
|
||||||
|
|
||||||
type2id(account_pubkey) -> account;
|
type2id(account_pubkey) -> account;
|
||||||
type2id(associate_chain) -> associate_chain;
|
type2id(associate_chain) -> associate_chain;
|
||||||
@ -186,8 +182,7 @@ type2id(contract_pubkey) -> contract;
|
|||||||
type2id(contract_source) -> contract_source;
|
type2id(contract_source) -> contract_source;
|
||||||
type2id(name) -> name;
|
type2id(name) -> name;
|
||||||
type2id(native_token) -> native_token;
|
type2id(native_token) -> native_token;
|
||||||
type2id(entry) -> entry;
|
type2id(entry) -> entry.
|
||||||
type2id(oracle_pubkey) -> oracle.
|
|
||||||
|
|
||||||
type2enc(key_block_hash) -> ?BASE58;
|
type2enc(key_block_hash) -> ?BASE58;
|
||||||
type2enc(micro_block_hash) -> ?BASE58;
|
type2enc(micro_block_hash) -> ?BASE58;
|
||||||
@ -203,10 +198,6 @@ type2enc(contract_store_value) -> ?BASE64;
|
|||||||
type2enc(contract_source) -> ?BASE64;
|
type2enc(contract_source) -> ?BASE64;
|
||||||
type2enc(transaction) -> ?BASE64;
|
type2enc(transaction) -> ?BASE64;
|
||||||
type2enc(tx_hash) -> ?BASE58;
|
type2enc(tx_hash) -> ?BASE58;
|
||||||
type2enc(oracle_pubkey) -> ?BASE58;
|
|
||||||
type2enc(oracle_query) -> ?BASE64;
|
|
||||||
type2enc(oracle_query_id) -> ?BASE58;
|
|
||||||
type2enc(oracle_response) -> ?BASE64;
|
|
||||||
type2enc(account_pubkey) -> ?BASE58;
|
type2enc(account_pubkey) -> ?BASE58;
|
||||||
type2enc(account_seckey) -> ?BASE58;
|
type2enc(account_seckey) -> ?BASE58;
|
||||||
type2enc(associate_chain) -> ?BASE58;
|
type2enc(associate_chain) -> ?BASE58;
|
||||||
@ -239,10 +230,6 @@ type2pfx(contract_store_value) -> <<"cv">>;
|
|||||||
type2pfx(contract_source) -> <<"cx">>;
|
type2pfx(contract_source) -> <<"cx">>;
|
||||||
type2pfx(transaction) -> <<"tx">>;
|
type2pfx(transaction) -> <<"tx">>;
|
||||||
type2pfx(tx_hash) -> <<"th">>;
|
type2pfx(tx_hash) -> <<"th">>;
|
||||||
type2pfx(oracle_pubkey) -> <<"ok">>;
|
|
||||||
type2pfx(oracle_query) -> <<"ov">>;
|
|
||||||
type2pfx(oracle_query_id) -> <<"oq">>;
|
|
||||||
type2pfx(oracle_response) -> <<"or">>;
|
|
||||||
type2pfx(account_pubkey) -> <<"ak">>;
|
type2pfx(account_pubkey) -> <<"ak">>;
|
||||||
type2pfx(account_seckey) -> <<"sk">>;
|
type2pfx(account_seckey) -> <<"sk">>;
|
||||||
type2pfx(associate_chain) -> <<"ac">>;
|
type2pfx(associate_chain) -> <<"ac">>;
|
||||||
@ -274,10 +261,6 @@ pfx2type(<<"ct">>) -> contract_pubkey;
|
|||||||
pfx2type(<<"cx">>) -> contract_source;
|
pfx2type(<<"cx">>) -> contract_source;
|
||||||
pfx2type(<<"tx">>) -> transaction;
|
pfx2type(<<"tx">>) -> transaction;
|
||||||
pfx2type(<<"th">>) -> tx_hash;
|
pfx2type(<<"th">>) -> tx_hash;
|
||||||
pfx2type(<<"ok">>) -> oracle_pubkey;
|
|
||||||
pfx2type(<<"ov">>) -> oracle_query;
|
|
||||||
pfx2type(<<"oq">>) -> oracle_query_id;
|
|
||||||
pfx2type(<<"or">>) -> oracle_response;
|
|
||||||
pfx2type(<<"ak">>) -> account_pubkey;
|
pfx2type(<<"ak">>) -> account_pubkey;
|
||||||
pfx2type(<<"sk">>) -> account_seckey;
|
pfx2type(<<"sk">>) -> account_seckey;
|
||||||
pfx2type(<<"ac">>) -> associate_chain;
|
pfx2type(<<"ac">>) -> associate_chain;
|
||||||
@ -311,10 +294,6 @@ byte_size_for_type(contract_store_value) -> not_applicable;
|
|||||||
byte_size_for_type(contract_source) -> not_applicable;
|
byte_size_for_type(contract_source) -> not_applicable;
|
||||||
byte_size_for_type(transaction) -> not_applicable;
|
byte_size_for_type(transaction) -> not_applicable;
|
||||||
byte_size_for_type(tx_hash) -> 32;
|
byte_size_for_type(tx_hash) -> 32;
|
||||||
byte_size_for_type(oracle_pubkey) -> 32;
|
|
||||||
byte_size_for_type(oracle_query) -> not_applicable;
|
|
||||||
byte_size_for_type(oracle_query_id) -> 32;
|
|
||||||
byte_size_for_type(oracle_response) -> not_applicable;
|
|
||||||
byte_size_for_type(account_pubkey) -> 32;
|
byte_size_for_type(account_pubkey) -> 32;
|
||||||
byte_size_for_type(account_seckey) -> 32;
|
byte_size_for_type(account_seckey) -> 32;
|
||||||
byte_size_for_type(associate_chain) -> 32;
|
byte_size_for_type(associate_chain) -> 32;
|
@ -1,20 +1,21 @@
|
|||||||
%%% -*- erlang-indent-level:4; indent-tabs-mode: nil -*-
|
%%% -*- erlang-indent-level:4; indent-tabs-mode: nil -*-
|
||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
|
%%% @copyright (C) 2025, QPQ AG
|
||||||
%%% @copyright (C) 2018, Aeternity Anstalt
|
%%% @copyright (C) 2018, Aeternity Anstalt
|
||||||
%%% @doc
|
%%% @doc
|
||||||
%%% Functions for serializing chain objects to binary format.
|
%%% Functions for serializing chain objects to binary format.
|
||||||
%%% @end
|
%%% @end
|
||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
|
|
||||||
-module(aeser_chain_objects).
|
-module(gmser_chain_objects).
|
||||||
|
|
||||||
-export([ serialize/4
|
-export([ serialize/4
|
||||||
, deserialize/4
|
, deserialize/4
|
||||||
, deserialize_type_and_vsn/1
|
, deserialize_type_and_vsn/1
|
||||||
]).
|
]).
|
||||||
|
|
||||||
-type template() :: aeserialization:template().
|
-type template() :: gmserialization:template().
|
||||||
-type fields() :: aeserialization:fields().
|
-type fields() :: gmserialization:fields().
|
||||||
|
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
%%% API
|
%%% API
|
||||||
@ -22,15 +23,15 @@
|
|||||||
|
|
||||||
-spec serialize(atom(), non_neg_integer(), template(), fields()) -> binary().
|
-spec serialize(atom(), non_neg_integer(), template(), fields()) -> binary().
|
||||||
serialize(Type, Vsn, Template, Fields) ->
|
serialize(Type, Vsn, Template, Fields) ->
|
||||||
aeserialization:serialize(tag(Type), Vsn, Template, Fields).
|
gmserialization:serialize(tag(Type), Vsn, Template, Fields).
|
||||||
|
|
||||||
deserialize_type_and_vsn(Binary) ->
|
deserialize_type_and_vsn(Binary) ->
|
||||||
{Tag, Vsn, Fields} = aeserialization:deserialize_tag_and_vsn(Binary),
|
{Tag, Vsn, Fields} = gmserialization:deserialize_tag_and_vsn(Binary),
|
||||||
{rev_tag(Tag), Vsn, Fields}.
|
{rev_tag(Tag), Vsn, Fields}.
|
||||||
|
|
||||||
-spec deserialize(atom(), non_neg_integer(), template(), binary()) -> fields().
|
-spec deserialize(atom(), non_neg_integer(), template(), binary()) -> fields().
|
||||||
deserialize(Type, Vsn, Template, Binary) ->
|
deserialize(Type, Vsn, Template, Binary) ->
|
||||||
aeserialization:deserialize(Type, tag(Type), Vsn, Template, Binary).
|
gmserialization:deserialize(Type, tag(Type), Vsn, Template, Binary).
|
||||||
|
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
%%% Internal functions
|
%%% Internal functions
|
||||||
@ -40,12 +41,6 @@ tag(account) -> 10;
|
|||||||
tag(signed_tx) -> 11;
|
tag(signed_tx) -> 11;
|
||||||
tag(spend_tx) -> 12;
|
tag(spend_tx) -> 12;
|
||||||
tag(data_extend_tx) -> 13;
|
tag(data_extend_tx) -> 13;
|
||||||
tag(oracle) -> 20;
|
|
||||||
tag(oracle_query) -> 21;
|
|
||||||
tag(oracle_register_tx) -> 22;
|
|
||||||
tag(oracle_query_tx) -> 23;
|
|
||||||
tag(oracle_response_tx) -> 24;
|
|
||||||
tag(oracle_extend_tx) -> 25;
|
|
||||||
tag(name) -> 30;
|
tag(name) -> 30;
|
||||||
tag(name_commitment) -> 31;
|
tag(name_commitment) -> 31;
|
||||||
tag(name_claim_tx) -> 32;
|
tag(name_claim_tx) -> 32;
|
||||||
@ -88,7 +83,6 @@ tag(contracts_mtree) -> 621;
|
|||||||
tag(calls_mtree) -> 622;
|
tag(calls_mtree) -> 622;
|
||||||
tag(channels_mtree) -> 623;
|
tag(channels_mtree) -> 623;
|
||||||
tag(nameservice_mtree) -> 624;
|
tag(nameservice_mtree) -> 624;
|
||||||
tag(oracles_mtree) -> 625;
|
|
||||||
tag(accounts_mtree) -> 626;
|
tag(accounts_mtree) -> 626;
|
||||||
tag(acs_mtree) -> 627;
|
tag(acs_mtree) -> 627;
|
||||||
tag(entries_mtree) -> 628;
|
tag(entries_mtree) -> 628;
|
||||||
@ -104,6 +98,7 @@ tag(ac_create_tx) -> 93;
|
|||||||
tag(ac_deposit_tx) -> 94;
|
tag(ac_deposit_tx) -> 94;
|
||||||
tag(ac_update_cops_tx) -> 95;
|
tag(ac_update_cops_tx) -> 95;
|
||||||
tag(ac_rollup_tx) -> 96;
|
tag(ac_rollup_tx) -> 96;
|
||||||
|
tag(ac_proposal_tx) -> 97;
|
||||||
tag(key_block) -> 100;
|
tag(key_block) -> 100;
|
||||||
tag(micro_block) -> 101;
|
tag(micro_block) -> 101;
|
||||||
tag(light_micro_block) -> 102;
|
tag(light_micro_block) -> 102;
|
||||||
@ -125,12 +120,6 @@ rev_tag(10) -> account;
|
|||||||
rev_tag(11) -> signed_tx;
|
rev_tag(11) -> signed_tx;
|
||||||
rev_tag(12) -> spend_tx;
|
rev_tag(12) -> spend_tx;
|
||||||
rev_tag(13) -> data_extend_tx;
|
rev_tag(13) -> data_extend_tx;
|
||||||
rev_tag(20) -> oracle;
|
|
||||||
rev_tag(21) -> oracle_query;
|
|
||||||
rev_tag(22) -> oracle_register_tx;
|
|
||||||
rev_tag(23) -> oracle_query_tx;
|
|
||||||
rev_tag(24) -> oracle_response_tx;
|
|
||||||
rev_tag(25) -> oracle_extend_tx;
|
|
||||||
rev_tag(30) -> name;
|
rev_tag(30) -> name;
|
||||||
rev_tag(31) -> name_commitment;
|
rev_tag(31) -> name_commitment;
|
||||||
rev_tag(32) -> name_claim_tx;
|
rev_tag(32) -> name_claim_tx;
|
||||||
@ -173,7 +162,6 @@ rev_tag(621) -> contracts_mtree;
|
|||||||
rev_tag(622) -> calls_mtree;
|
rev_tag(622) -> calls_mtree;
|
||||||
rev_tag(623) -> channels_mtree;
|
rev_tag(623) -> channels_mtree;
|
||||||
rev_tag(624) -> nameservice_mtree;
|
rev_tag(624) -> nameservice_mtree;
|
||||||
rev_tag(625) -> oracles_mtree;
|
|
||||||
rev_tag(626) -> accounts_mtree;
|
rev_tag(626) -> accounts_mtree;
|
||||||
rev_tag(627) -> acs_mtree;
|
rev_tag(627) -> acs_mtree;
|
||||||
rev_tag(628) -> entries_mtree;
|
rev_tag(628) -> entries_mtree;
|
||||||
@ -189,6 +177,7 @@ rev_tag(93) -> ac_create_tx;
|
|||||||
rev_tag(94) -> ac_deposit_tx;
|
rev_tag(94) -> ac_deposit_tx;
|
||||||
rev_tag(95) -> ac_update_cops_tx;
|
rev_tag(95) -> ac_update_cops_tx;
|
||||||
rev_tag(96) -> ac_rollup_tx;
|
rev_tag(96) -> ac_rollup_tx;
|
||||||
|
rev_tag(97) -> ac_proposal_tx;
|
||||||
rev_tag(100) -> key_block;
|
rev_tag(100) -> key_block;
|
||||||
rev_tag(101) -> micro_block;
|
rev_tag(101) -> micro_block;
|
||||||
rev_tag(102) -> light_micro_block;
|
rev_tag(102) -> light_micro_block;
|
@ -1,12 +1,13 @@
|
|||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
|
%%% @copyright (C) 2025, QPQ AG
|
||||||
%%% @copyright (C) 2019, Aeternity Anstalt
|
%%% @copyright (C) 2019, Aeternity Anstalt
|
||||||
%%% @doc
|
%%% @doc
|
||||||
%%% Serialization of contract code
|
%%% Serialization of contract code
|
||||||
%%% @end
|
%%% @end
|
||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
-module(aeser_contract_code).
|
-module(gmser_contract_code).
|
||||||
|
|
||||||
-include("aeser_contract_code.hrl").
|
-include("gmser_contract_code.hrl").
|
||||||
|
|
||||||
-export([ deserialize/1
|
-export([ deserialize/1
|
||||||
, serialize/1
|
, serialize/1
|
||||||
@ -42,20 +43,20 @@ serialize(CodeMap = #{ byte_code := ByteCode
|
|||||||
|| SophiaContractVersion > ?SOPHIA_CONTRACT_VSN_1 ] ++
|
|| SophiaContractVersion > ?SOPHIA_CONTRACT_VSN_1 ] ++
|
||||||
[ {payable, Payable}
|
[ {payable, Payable}
|
||||||
|| SophiaContractVersion > ?SOPHIA_CONTRACT_VSN_2 ],
|
|| SophiaContractVersion > ?SOPHIA_CONTRACT_VSN_2 ],
|
||||||
aeser_chain_objects:serialize(compiler_sophia,
|
gmser_chain_objects:serialize(compiler_sophia,
|
||||||
SophiaContractVersion,
|
SophiaContractVersion,
|
||||||
serialization_template(SophiaContractVersion),
|
serialization_template(SophiaContractVersion),
|
||||||
Fields).
|
Fields).
|
||||||
|
|
||||||
-spec deserialize(binary()) -> map().
|
-spec deserialize(binary()) -> map().
|
||||||
deserialize(Binary) ->
|
deserialize(Binary) ->
|
||||||
case aeser_chain_objects:deserialize_type_and_vsn(Binary) of
|
case gmser_chain_objects:deserialize_type_and_vsn(Binary) of
|
||||||
{compiler_sophia = Type, ?SOPHIA_CONTRACT_VSN_1 = Vsn, _Rest} ->
|
{compiler_sophia = Type, ?SOPHIA_CONTRACT_VSN_1 = Vsn, _Rest} ->
|
||||||
Template = serialization_template(Vsn),
|
Template = serialization_template(Vsn),
|
||||||
[ {source_hash, Hash}
|
[ {source_hash, Hash}
|
||||||
, {type_info, TypeInfo}
|
, {type_info, TypeInfo}
|
||||||
, {byte_code, ByteCode}
|
, {byte_code, ByteCode}
|
||||||
] = aeser_chain_objects:deserialize(Type, Vsn, Template, Binary),
|
] = gmser_chain_objects:deserialize(Type, Vsn, Template, Binary),
|
||||||
#{ source_hash => Hash
|
#{ source_hash => Hash
|
||||||
, type_info => TypeInfo
|
, type_info => TypeInfo
|
||||||
, byte_code => ByteCode
|
, byte_code => ByteCode
|
||||||
@ -68,7 +69,7 @@ deserialize(Binary) ->
|
|||||||
, {type_info, TypeInfo}
|
, {type_info, TypeInfo}
|
||||||
, {byte_code, ByteCode}
|
, {byte_code, ByteCode}
|
||||||
, {compiler_version, CompilerVersion}
|
, {compiler_version, CompilerVersion}
|
||||||
] = aeser_chain_objects:deserialize(Type, Vsn, Template, Binary),
|
] = gmser_chain_objects:deserialize(Type, Vsn, Template, Binary),
|
||||||
#{ source_hash => Hash
|
#{ source_hash => Hash
|
||||||
, type_info => TypeInfo
|
, type_info => TypeInfo
|
||||||
, byte_code => ByteCode
|
, byte_code => ByteCode
|
||||||
@ -83,7 +84,7 @@ deserialize(Binary) ->
|
|||||||
, {byte_code, ByteCode}
|
, {byte_code, ByteCode}
|
||||||
, {compiler_version, CompilerVersion}
|
, {compiler_version, CompilerVersion}
|
||||||
, {payable, Payable}
|
, {payable, Payable}
|
||||||
] = aeser_chain_objects:deserialize(Type, Vsn, Template, Binary),
|
] = gmser_chain_objects:deserialize(Type, Vsn, Template, Binary),
|
||||||
#{ source_hash => Hash
|
#{ source_hash => Hash
|
||||||
, type_info => TypeInfo
|
, type_info => TypeInfo
|
||||||
, byte_code => ByteCode
|
, byte_code => ByteCode
|
@ -1,17 +1,15 @@
|
|||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
|
%%% @copyright (C) 2025, QPQ AG
|
||||||
%%% @copyright (C) 2023, Aeternity Anstalt
|
%%% @copyright (C) 2023, Aeternity Anstalt
|
||||||
%%% @doc
|
%%% @doc
|
||||||
%%% Serialization of delegation signatures
|
%%% Serialization of delegation signatures
|
||||||
%%% @end
|
%%% @end
|
||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
-module(aeser_delegation).
|
-module(gmser_delegation).
|
||||||
|
|
||||||
-export([ aens_preclaim_sig/3
|
-export([ aens_preclaim_sig/3
|
||||||
, aens_name_sig/4
|
, aens_name_sig/4
|
||||||
, aens_sig/3
|
, aens_sig/3
|
||||||
|
|
||||||
, oracle_sig/3
|
|
||||||
, oracle_response_sig/3
|
|
||||||
]).
|
]).
|
||||||
|
|
||||||
%% Delegation signatures are prefixed with a unique tag, ensuring not to
|
%% Delegation signatures are prefixed with a unique tag, ensuring not to
|
||||||
@ -28,7 +26,7 @@
|
|||||||
|
|
||||||
-type sig_data() :: binary().
|
-type sig_data() :: binary().
|
||||||
|
|
||||||
-spec aens_preclaim_sig(binary(), aeser_id:id(), aeser_id:id()) -> sig_data().
|
-spec aens_preclaim_sig(binary(), gmser_id:id(), gmser_id:id()) -> sig_data().
|
||||||
aens_preclaim_sig(NetworkId, Account, Contract) ->
|
aens_preclaim_sig(NetworkId, Account, Contract) ->
|
||||||
assert_id(account, Account),
|
assert_id(account, Account),
|
||||||
assert_id(contract, Contract),
|
assert_id(contract, Contract),
|
||||||
@ -36,7 +34,7 @@ aens_preclaim_sig(NetworkId, Account, Contract) ->
|
|||||||
Fields = [{account, Account}, {contract, Contract}],
|
Fields = [{account, Account}, {contract, Contract}],
|
||||||
serialize(?TYPE_AENS_PRECLAIM, NetworkId, Template, Fields).
|
serialize(?TYPE_AENS_PRECLAIM, NetworkId, Template, Fields).
|
||||||
|
|
||||||
-spec aens_name_sig(binary(), aeser_id:id(), aeser_id:id(), aeser_id:id()) -> sig_data().
|
-spec aens_name_sig(binary(), gmser_id:id(), gmser_id:id(), gmser_id:id()) -> sig_data().
|
||||||
aens_name_sig(NetworkId, Account, Name, Contract) ->
|
aens_name_sig(NetworkId, Account, Name, Contract) ->
|
||||||
assert_id(account, Account),
|
assert_id(account, Account),
|
||||||
assert_id(name, Name),
|
assert_id(name, Name),
|
||||||
@ -45,7 +43,7 @@ aens_name_sig(NetworkId, Account, Name, Contract) ->
|
|||||||
Fields = [{account, Account}, {name, Name}, {contract, Contract}],
|
Fields = [{account, Account}, {name, Name}, {contract, Contract}],
|
||||||
serialize(?TYPE_AENS_NAME, NetworkId, Template, Fields).
|
serialize(?TYPE_AENS_NAME, NetworkId, Template, Fields).
|
||||||
|
|
||||||
-spec aens_sig(binary(), aeser_id:id(), aeser_id:id()) -> sig_data().
|
-spec aens_sig(binary(), gmser_id:id(), gmser_id:id()) -> sig_data().
|
||||||
aens_sig(NetworkId, Account, Contract) ->
|
aens_sig(NetworkId, Account, Contract) ->
|
||||||
assert_id(account, Account),
|
assert_id(account, Account),
|
||||||
assert_id(contract, Contract),
|
assert_id(contract, Contract),
|
||||||
@ -53,29 +51,14 @@ aens_sig(NetworkId, Account, Contract) ->
|
|||||||
Fields = [{account, Account}, {contract, Contract}],
|
Fields = [{account, Account}, {contract, Contract}],
|
||||||
serialize(?TYPE_AENS, NetworkId, Template, Fields).
|
serialize(?TYPE_AENS, NetworkId, Template, Fields).
|
||||||
|
|
||||||
-spec oracle_sig(binary(), aeser_id:id(), aeser_id:id()) -> sig_data().
|
|
||||||
oracle_sig(NetworkId, Account, Contract) ->
|
|
||||||
assert_id(account, Account),
|
|
||||||
assert_id(contract, Contract),
|
|
||||||
Template = [{account, id}, {contract, id}],
|
|
||||||
Fields = [{account, Account}, {contract, Contract}],
|
|
||||||
serialize(?TYPE_ORACLE, NetworkId, Template, Fields).
|
|
||||||
|
|
||||||
-spec oracle_response_sig(binary(), aeser_id:id(), aeser_id:id()) -> sig_data().
|
|
||||||
oracle_response_sig(NetworkId, QueryId, Contract) ->
|
|
||||||
assert_id(oracle, QueryId),
|
|
||||||
assert_id(contract, Contract),
|
|
||||||
Template = [{query, id}, {contract, id}],
|
|
||||||
Fields = [{query, QueryId}, {contract, Contract}],
|
|
||||||
serialize(?TYPE_ORACLE_RESPONSE, NetworkId, Template, Fields).
|
|
||||||
|
|
||||||
%% ------------------------------------------------------------------------
|
%% ------------------------------------------------------------------------
|
||||||
%% -- Internal functions
|
%% -- Internal functions
|
||||||
%% ------------------------------------------------------------------------
|
%% ------------------------------------------------------------------------
|
||||||
|
|
||||||
serialize(Type, NetworkId, Template, Fields) ->
|
serialize(Type, NetworkId, Template, Fields) ->
|
||||||
Data = aeserialization:serialize(Type, ?VSN, Template, Fields),
|
Data = gmserialization:serialize(Type, ?VSN, Template, Fields),
|
||||||
<<?DELEGATION_TAG:16, NetworkId/binary, Data/binary>>.
|
<<?DELEGATION_TAG:16, NetworkId/binary, Data/binary>>.
|
||||||
|
|
||||||
assert_id(Type, AeserId) ->
|
assert_id(Type, AeserId) ->
|
||||||
Type = aeser_id:specialize_type(AeserId).
|
Type = gmser_id:specialize_type(AeserId).
|
@ -1,12 +1,13 @@
|
|||||||
%%% -*- erlang-indent-level:4; indent-tabs-mode: nil -*-
|
%%% -*- erlang-indent-level:4; indent-tabs-mode: nil -*-
|
||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
|
%%% @copyright (C) 2025, QPQ AG
|
||||||
%%% @copyright (C) 2018, Aeternity Anstalt
|
%%% @copyright (C) 2018, Aeternity Anstalt
|
||||||
%%% @doc
|
%%% @doc
|
||||||
%%% ADT for identifiers
|
%%% ADT for identifiers
|
||||||
%%% @end
|
%%% @end
|
||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
|
|
||||||
-module(aeser_id).
|
-module(gmser_id).
|
||||||
|
|
||||||
-export([ create/2
|
-export([ create/2
|
||||||
, specialize/1
|
, specialize/1
|
||||||
@ -24,7 +25,7 @@
|
|||||||
, val
|
, val
|
||||||
}).
|
}).
|
||||||
|
|
||||||
-type tag() :: 'account' | 'oracle' | 'name'
|
-type tag() :: 'account' | 'name'
|
||||||
| 'commitment' | 'contract' | 'channel'
|
| 'commitment' | 'contract' | 'channel'
|
||||||
| 'associate_chain' | 'entry' .
|
| 'associate_chain' | 'entry' .
|
||||||
-type val() :: <<_:256>>.
|
-type val() :: <<_:256>>.
|
||||||
@ -40,7 +41,6 @@
|
|||||||
-define(SERIALIZED_SIZE, 33). %% ?TAG_SIZE + ?PUB_SIZE
|
-define(SERIALIZED_SIZE, 33). %% ?TAG_SIZE + ?PUB_SIZE
|
||||||
|
|
||||||
-define(IS_TAG(___TAG___), ___TAG___ =:= account;
|
-define(IS_TAG(___TAG___), ___TAG___ =:= account;
|
||||||
___TAG___ =:= oracle;
|
|
||||||
___TAG___ =:= name;
|
___TAG___ =:= name;
|
||||||
___TAG___ =:= commitment;
|
___TAG___ =:= commitment;
|
||||||
___TAG___ =:= contract;
|
___TAG___ =:= contract;
|
||||||
@ -100,7 +100,6 @@ decode(<<Tag:?TAG_SIZE/unit:8, Val:?PUB_SIZE/binary>>) ->
|
|||||||
encode_tag(account) -> 1;
|
encode_tag(account) -> 1;
|
||||||
encode_tag(name) -> 2;
|
encode_tag(name) -> 2;
|
||||||
encode_tag(commitment) -> 3;
|
encode_tag(commitment) -> 3;
|
||||||
encode_tag(oracle) -> 4;
|
|
||||||
encode_tag(contract) -> 5;
|
encode_tag(contract) -> 5;
|
||||||
encode_tag(channel) -> 6;
|
encode_tag(channel) -> 6;
|
||||||
encode_tag(associate_chain) -> 7;
|
encode_tag(associate_chain) -> 7;
|
||||||
@ -111,7 +110,6 @@ encode_tag(Other) -> error({illegal_id_tag_name, Other}).
|
|||||||
decode_tag(1) -> account;
|
decode_tag(1) -> account;
|
||||||
decode_tag(2) -> name;
|
decode_tag(2) -> name;
|
||||||
decode_tag(3) -> commitment;
|
decode_tag(3) -> commitment;
|
||||||
decode_tag(4) -> oracle;
|
|
||||||
decode_tag(5) -> contract;
|
decode_tag(5) -> contract;
|
||||||
decode_tag(6) -> channel;
|
decode_tag(6) -> channel;
|
||||||
decode_tag(7) -> associate_chain;
|
decode_tag(7) -> associate_chain;
|
@ -1,4 +1,5 @@
|
|||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
|
%%% @copyright (C) 2025, QPQ AG
|
||||||
%%% @copyright (C) 2017, Aeternity Anstalt
|
%%% @copyright (C) 2017, Aeternity Anstalt
|
||||||
%%% @doc
|
%%% @doc
|
||||||
%%% Implementation of the Recursive Length Prefix.
|
%%% Implementation of the Recursive Length Prefix.
|
||||||
@ -8,7 +9,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
|
|
||||||
-module(aeser_rlp).
|
-module(gmser_rlp).
|
||||||
-export([ decode/1
|
-export([ decode/1
|
||||||
, decode_one/1
|
, decode_one/1
|
||||||
, encode/1
|
, encode/1
|
@ -1,5 +1,5 @@
|
|||||||
{application, aeserialization,
|
{application, gmserialization,
|
||||||
[{description, "Serialization of data for Aeternity"},
|
[{description, "Serialization of data for the Gajumaru"},
|
||||||
{vsn, "0.1.0"},
|
{vsn, "0.1.0"},
|
||||||
{registered, []},
|
{registered, []},
|
||||||
{applications,
|
{applications,
|
@ -1,11 +1,12 @@
|
|||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
|
%%% @copyright (C) 2025, QPQ AG
|
||||||
%%% @copyright (C) 2018, Aeternity Anstalt
|
%%% @copyright (C) 2018, Aeternity Anstalt
|
||||||
%%% @doc
|
%%% @doc
|
||||||
%%% Functions for serializing generic objects to/from binary format.
|
%%% Functions for serializing generic objects to/from binary format.
|
||||||
%%% @end
|
%%% @end
|
||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
|
|
||||||
-module(aeserialization).
|
-module(gmserialization).
|
||||||
|
|
||||||
-export([ decode_fields/2
|
-export([ decode_fields/2
|
||||||
, deserialize/5
|
, deserialize/5
|
||||||
@ -35,9 +36,9 @@
|
|||||||
| binary()
|
| binary()
|
||||||
| boolean()
|
| boolean()
|
||||||
| [encodable_term()] %% Of any length
|
| [encodable_term()] %% Of any length
|
||||||
| #{atom() => encodable_term()}
|
| #{atom() => encodable_term()}
|
||||||
| tuple() %% Any arity, containing encodable_term().
|
| tuple() %% Any arity, containing encodable_term().
|
||||||
| aeser_id:id().
|
| gmser_id:id().
|
||||||
|
|
||||||
-type fields() :: [{field_name(), encodable_term()}].
|
-type fields() :: [{field_name(), encodable_term()}].
|
||||||
|
|
||||||
@ -49,13 +50,13 @@
|
|||||||
serialize(Tag, Vsn, Template, Fields) ->
|
serialize(Tag, Vsn, Template, Fields) ->
|
||||||
List = encode_fields([{tag, int}, {vsn, int}|Template],
|
List = encode_fields([{tag, int}, {vsn, int}|Template],
|
||||||
[{tag, Tag}, {vsn, Vsn}|Fields]),
|
[{tag, Tag}, {vsn, Vsn}|Fields]),
|
||||||
aeser_rlp:encode(List).
|
gmser_rlp:encode(List).
|
||||||
|
|
||||||
%% Type isn't strictly necessary, but will give a better error reason
|
%% Type isn't strictly necessary, but will give a better error reason
|
||||||
-spec deserialize(atom(), non_neg_integer(), non_neg_integer(),
|
-spec deserialize(atom(), non_neg_integer(), non_neg_integer(),
|
||||||
template(), binary()) -> fields().
|
template(), binary()) -> fields().
|
||||||
deserialize(Type, Tag, Vsn, Template0, Binary) ->
|
deserialize(Type, Tag, Vsn, Template0, Binary) ->
|
||||||
Decoded = aeser_rlp:decode(Binary),
|
Decoded = gmser_rlp:decode(Binary),
|
||||||
Template = [{tag, int}, {vsn, int}|Template0],
|
Template = [{tag, int}, {vsn, int}|Template0],
|
||||||
case decode_fields(Template, Decoded) of
|
case decode_fields(Template, Decoded) of
|
||||||
[{tag, Tag}, {vsn, Vsn}|Left] ->
|
[{tag, Tag}, {vsn, Vsn}|Left] ->
|
||||||
@ -68,7 +69,7 @@ deserialize(Type, Tag, Vsn, Template0, Binary) ->
|
|||||||
-spec deserialize_tag_and_vsn(binary()) ->
|
-spec deserialize_tag_and_vsn(binary()) ->
|
||||||
{non_neg_integer(), non_neg_integer(), fields()}.
|
{non_neg_integer(), non_neg_integer(), fields()}.
|
||||||
deserialize_tag_and_vsn(Binary) ->
|
deserialize_tag_and_vsn(Binary) ->
|
||||||
[TagBin, VsnBin|Fields] = aeser_rlp:decode(Binary),
|
[TagBin, VsnBin|Fields] = gmser_rlp:decode(Binary),
|
||||||
Template = [{tag, int}, {vsn, int}],
|
Template = [{tag, int}, {vsn, int}],
|
||||||
[{tag, Tag}, {vsn, Vsn}] = decode_fields(Template, [TagBin, VsnBin]),
|
[{tag, Tag}, {vsn, Vsn}] = decode_fields(Template, [TagBin, VsnBin]),
|
||||||
{Tag, Vsn, Fields}.
|
{Tag, Vsn, Fields}.
|
||||||
@ -118,7 +119,7 @@ encode_field(binary, X) when is_binary(X) -> X;
|
|||||||
encode_field(bool, true) -> <<1:8>>;
|
encode_field(bool, true) -> <<1:8>>;
|
||||||
encode_field(bool, false) -> <<0:8>>;
|
encode_field(bool, false) -> <<0:8>>;
|
||||||
encode_field(id, Val) ->
|
encode_field(id, Val) ->
|
||||||
try aeser_id:encode(Val)
|
try gmser_id:encode(Val)
|
||||||
catch _:_ -> error({illegal, id, Val})
|
catch _:_ -> error({illegal, id, Val})
|
||||||
end;
|
end;
|
||||||
encode_field(Type, Val) -> error({illegal, Type, Val}).
|
encode_field(Type, Val) -> error({illegal, Type, Val}).
|
||||||
@ -142,7 +143,7 @@ decode_field(binary, X) when is_binary(X) -> X;
|
|||||||
decode_field(bool, <<1:8>>) -> true;
|
decode_field(bool, <<1:8>>) -> true;
|
||||||
decode_field(bool, <<0:8>>) -> false;
|
decode_field(bool, <<0:8>>) -> false;
|
||||||
decode_field(id, Val) ->
|
decode_field(id, Val) ->
|
||||||
try aeser_id:decode(Val)
|
try gmser_id:decode(Val)
|
||||||
catch _:_ -> error({illegal, id, Val})
|
catch _:_ -> error({illegal, id, Val})
|
||||||
end;
|
end;
|
||||||
decode_field(Type, X) -> error({illegal, Type, X}).
|
decode_field(Type, X) -> error({illegal, Type, X}).
|
@ -1,67 +0,0 @@
|
|||||||
%%%-------------------------------------------------------------------
|
|
||||||
%%% @copyright (C) 2023, Aeternity Anstalt
|
|
||||||
%%%-------------------------------------------------------------------
|
|
||||||
|
|
||||||
-module(aeser_delegation_tests).
|
|
||||||
|
|
||||||
-include_lib("eunit/include/eunit.hrl").
|
|
||||||
|
|
||||||
-define(TEST_MODULE, aeser_delegation).
|
|
||||||
|
|
||||||
-define(ACCOUNT, aeser_id:create(account, <<1:256>>)).
|
|
||||||
-define(CONTRACT, aeser_id:create(contract, <<2:256>>)).
|
|
||||||
-define(NAME, aeser_id:create(name, <<3:256>>)).
|
|
||||||
-define(ORACLE, aeser_id:create(oracle, <<3:256>>)).
|
|
||||||
|
|
||||||
-define(NETWORK_ID, <<"my_fancy_network"/utf8>>).
|
|
||||||
|
|
||||||
encode_correct_test_() ->
|
|
||||||
[{"Encode preclaim sig",
|
|
||||||
fun() ->
|
|
||||||
aeser_delegation:aens_preclaim_sig(?NETWORK_ID, ?ACCOUNT, ?CONTRACT)
|
|
||||||
end},
|
|
||||||
{"Encode name sig",
|
|
||||||
fun() ->
|
|
||||||
aeser_delegation:aens_name_sig(?NETWORK_ID, ?ACCOUNT, ?NAME, ?CONTRACT)
|
|
||||||
end},
|
|
||||||
{"Encode aens wildcard sig",
|
|
||||||
fun() ->
|
|
||||||
aeser_delegation:aens_sig(?NETWORK_ID, ?ACCOUNT, ?CONTRACT)
|
|
||||||
end},
|
|
||||||
{"Encode oracle sig",
|
|
||||||
fun() ->
|
|
||||||
aeser_delegation:oracle_sig(?NETWORK_ID, ?ACCOUNT, ?CONTRACT)
|
|
||||||
end},
|
|
||||||
{"Encode oracle response sig",
|
|
||||||
fun() ->
|
|
||||||
aeser_delegation:oracle_response_sig(?NETWORK_ID, ?ORACLE, ?CONTRACT)
|
|
||||||
end}
|
|
||||||
].
|
|
||||||
|
|
||||||
encode_fail_test_() ->
|
|
||||||
[{"Bad encoding preclaim sig",
|
|
||||||
fun() ->
|
|
||||||
?assertError(_, aeser_delegation:aens_preclaim_sig(?NETWORK_ID, <<42:256>>, ?CONTRACT)),
|
|
||||||
?assertError(_, aeser_delegation:aens_preclaim_sig(?NETWORK_ID, ?CONTRACT, ?ACCOUNT))
|
|
||||||
end},
|
|
||||||
{"Bad encoding name sig",
|
|
||||||
fun() ->
|
|
||||||
?assertError(_, aeser_delegation:aens_name_sig(?NETWORK_ID, ?ACCOUNT, <<42:256>>, ?CONTRACT)),
|
|
||||||
?assertError(_, aeser_delegation:aens_name_sig(?NETWORK_ID, ?NAME, ?ACCOUNT, ?CONTRACT))
|
|
||||||
end},
|
|
||||||
{"Bad encoding aens wildcard sig",
|
|
||||||
fun() ->
|
|
||||||
?assertError(_, aeser_delegation:aens_sig(?NETWORK_ID, ?ACCOUNT, <<42:256>>)),
|
|
||||||
?assertError(_, aeser_delegation:aens_sig(?NETWORK_ID, ?CONTRACT, ?CONTRACT))
|
|
||||||
end},
|
|
||||||
{"Bad encoding oracle sig",
|
|
||||||
fun() ->
|
|
||||||
?assertError(_, aeser_delegation:oracle_sig(?NETWORK_ID, <<42:256>>, ?CONTRACT)),
|
|
||||||
?assertError(_, aeser_delegation:oracle_sig(?NETWORK_ID, ?ACCOUNT, ?ACCOUNT))
|
|
||||||
end},
|
|
||||||
{"Bad encoding oracle response sig",
|
|
||||||
fun() ->
|
|
||||||
?assertError(_, aeser_delegation:oracle_response_sig(?NETWORK_ID, <<42:256>>, ?CONTRACT)),
|
|
||||||
?assertError(_, aeser_delegation:oracle_response_sig(?NETWORK_ID, ?ORACLE, ?ORACLE))
|
|
||||||
end}
|
|
||||||
].
|
|
@ -1,12 +1,13 @@
|
|||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
|
%%% @copyright (C) 2025, QPQ AG
|
||||||
%%% @copyright (C) 2018, Aeternity Anstalt
|
%%% @copyright (C) 2018, Aeternity Anstalt
|
||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
|
|
||||||
-module(aeser_api_encoder_tests).
|
-module(gmser_api_encoder_tests).
|
||||||
|
|
||||||
-include_lib("eunit/include/eunit.hrl").
|
-include_lib("eunit/include/eunit.hrl").
|
||||||
|
|
||||||
-define(TEST_MODULE, aeser_api_encoder).
|
-define(TEST_MODULE, gmser_api_encoder).
|
||||||
-define(TYPES, [ {key_block_hash , 32}
|
-define(TYPES, [ {key_block_hash , 32}
|
||||||
, {micro_block_hash , 32}
|
, {micro_block_hash , 32}
|
||||||
, {block_tx_hash , 32}
|
, {block_tx_hash , 32}
|
||||||
@ -15,8 +16,6 @@
|
|||||||
, {contract_pubkey , 32}
|
, {contract_pubkey , 32}
|
||||||
, {transaction , not_applicable}
|
, {transaction , not_applicable}
|
||||||
, {tx_hash , 32}
|
, {tx_hash , 32}
|
||||||
, {oracle_pubkey , 32}
|
|
||||||
, {oracle_query_id , 32}
|
|
||||||
, {account_pubkey , 32}
|
, {account_pubkey , 32}
|
||||||
, {signature , 64}
|
, {signature , 64}
|
||||||
, {name , not_applicable}
|
, {name , not_applicable}
|
@ -1,11 +1,12 @@
|
|||||||
%%% -*- erlang-indent-level:4; indent-tabs-mode: nil -*-
|
%%% -*- erlang-indent-level:4; indent-tabs-mode: nil -*-
|
||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
|
%%% @copyright (C) 2025, QPQ AG
|
||||||
%%% @copyright (C) 2018, Aeternity Anstalt
|
%%% @copyright (C) 2018, Aeternity Anstalt
|
||||||
%%% @doc
|
%%% @doc
|
||||||
%%% EUnit tests for aeser_chain_objects
|
%%% EUnit tests for gmser_chain_objects
|
||||||
%%% @end
|
%%% @end
|
||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
-module(aeser_chain_objects_tests).
|
-module(gmser_chain_objects_tests).
|
||||||
|
|
||||||
-include_lib("eunit/include/eunit.hrl").
|
-include_lib("eunit/include/eunit.hrl").
|
||||||
|
|
||||||
@ -78,10 +79,10 @@ deserialize(Template, Bin) ->
|
|||||||
deserialize(Template, Bin, ?DEFAULT_TAG, ?DEFAULT_VERSION).
|
deserialize(Template, Bin, ?DEFAULT_TAG, ?DEFAULT_VERSION).
|
||||||
|
|
||||||
deserialize(Template, Bin, Tag, Vsn) ->
|
deserialize(Template, Bin, Tag, Vsn) ->
|
||||||
aeser_chain_objects:deserialize(Tag, Vsn, Template, Bin).
|
gmser_chain_objects:deserialize(Tag, Vsn, Template, Bin).
|
||||||
|
|
||||||
serialize(Template, Bin) ->
|
serialize(Template, Bin) ->
|
||||||
serialize(Template, Bin, ?DEFAULT_TAG, ?DEFAULT_VERSION).
|
serialize(Template, Bin, ?DEFAULT_TAG, ?DEFAULT_VERSION).
|
||||||
|
|
||||||
serialize(Template, Bin, Tag, Vsn) ->
|
serialize(Template, Bin, Tag, Vsn) ->
|
||||||
aeser_chain_objects:serialize(Tag, Vsn, Template, Bin).
|
gmser_chain_objects:serialize(Tag, Vsn, Template, Bin).
|
@ -1,7 +1,11 @@
|
|||||||
-module(aeser_contract_code_tests).
|
%%%-------------------------------------------------------------------
|
||||||
|
%%% @copyright (C) 2025, QPQ AG
|
||||||
|
%%%-------------------------------------------------------------------
|
||||||
|
|
||||||
|
-module(gmser_contract_code_tests).
|
||||||
|
|
||||||
-include_lib("eunit/include/eunit.hrl").
|
-include_lib("eunit/include/eunit.hrl").
|
||||||
-include("aeser_contract_code.hrl").
|
-include("gmser_contract_code.hrl").
|
||||||
|
|
||||||
-define(DUMMY_CODE_MAP_1,
|
-define(DUMMY_CODE_MAP_1,
|
||||||
#{ byte_code => <<"DUMMY CODE">>
|
#{ byte_code => <<"DUMMY CODE">>
|
||||||
@ -22,14 +26,14 @@
|
|||||||
, payable => true} ).
|
, payable => true} ).
|
||||||
|
|
||||||
vsn_1_test() ->
|
vsn_1_test() ->
|
||||||
aeser_contract_code:deserialize(
|
gmser_contract_code:deserialize(
|
||||||
aeser_contract_code:serialize(?DUMMY_CODE_MAP_1, ?SOPHIA_CONTRACT_VSN_1)).
|
gmser_contract_code:serialize(?DUMMY_CODE_MAP_1, ?SOPHIA_CONTRACT_VSN_1)).
|
||||||
|
|
||||||
vsn_2_test() ->
|
vsn_2_test() ->
|
||||||
aeser_contract_code:deserialize(
|
gmser_contract_code:deserialize(
|
||||||
aeser_contract_code:serialize(?DUMMY_CODE_MAP_2, ?SOPHIA_CONTRACT_VSN_2)).
|
gmser_contract_code:serialize(?DUMMY_CODE_MAP_2, ?SOPHIA_CONTRACT_VSN_2)).
|
||||||
|
|
||||||
vsn_3_test() ->
|
vsn_3_test() ->
|
||||||
aeser_contract_code:deserialize(
|
gmser_contract_code:deserialize(
|
||||||
aeser_contract_code:serialize(?DUMMY_CODE_MAP_3, ?SOPHIA_CONTRACT_VSN_3)).
|
gmser_contract_code:serialize(?DUMMY_CODE_MAP_3, ?SOPHIA_CONTRACT_VSN_3)).
|
||||||
|
|
49
test/gmser_delegation_tests.erl
Normal file
49
test/gmser_delegation_tests.erl
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
%%%-------------------------------------------------------------------
|
||||||
|
%%% @copyright (C) 2025, QPQ AG
|
||||||
|
%%% @copyright (C) 2023, Aeternity Anstalt
|
||||||
|
%%%-------------------------------------------------------------------
|
||||||
|
|
||||||
|
-module(gmser_delegation_tests).
|
||||||
|
|
||||||
|
-include_lib("eunit/include/eunit.hrl").
|
||||||
|
|
||||||
|
-define(TEST_MODULE, gmser_delegation).
|
||||||
|
|
||||||
|
-define(ACCOUNT, gmser_id:create(account, <<1:256>>)).
|
||||||
|
-define(CONTRACT, gmser_id:create(contract, <<2:256>>)).
|
||||||
|
-define(NAME, gmser_id:create(name, <<3:256>>)).
|
||||||
|
|
||||||
|
-define(NETWORK_ID, <<"my_fancy_network"/utf8>>).
|
||||||
|
|
||||||
|
encode_correct_test_() ->
|
||||||
|
[{"Encode preclaim sig",
|
||||||
|
fun() ->
|
||||||
|
gmser_delegation:aens_preclaim_sig(?NETWORK_ID, ?ACCOUNT, ?CONTRACT)
|
||||||
|
end},
|
||||||
|
{"Encode name sig",
|
||||||
|
fun() ->
|
||||||
|
gmser_delegation:aens_name_sig(?NETWORK_ID, ?ACCOUNT, ?NAME, ?CONTRACT)
|
||||||
|
end},
|
||||||
|
{"Encode aens wildcard sig",
|
||||||
|
fun() ->
|
||||||
|
gmser_delegation:aens_sig(?NETWORK_ID, ?ACCOUNT, ?CONTRACT)
|
||||||
|
end}
|
||||||
|
].
|
||||||
|
|
||||||
|
encode_fail_test_() ->
|
||||||
|
[{"Bad encoding preclaim sig",
|
||||||
|
fun() ->
|
||||||
|
?assertError(_, gmser_delegation:aens_preclaim_sig(?NETWORK_ID, <<42:256>>, ?CONTRACT)),
|
||||||
|
?assertError(_, gmser_delegation:aens_preclaim_sig(?NETWORK_ID, ?CONTRACT, ?ACCOUNT))
|
||||||
|
end},
|
||||||
|
{"Bad encoding name sig",
|
||||||
|
fun() ->
|
||||||
|
?assertError(_, gmser_delegation:aens_name_sig(?NETWORK_ID, ?ACCOUNT, <<42:256>>, ?CONTRACT)),
|
||||||
|
?assertError(_, gmser_delegation:aens_name_sig(?NETWORK_ID, ?NAME, ?ACCOUNT, ?CONTRACT))
|
||||||
|
end},
|
||||||
|
{"Bad encoding aens wildcard sig",
|
||||||
|
fun() ->
|
||||||
|
?assertError(_, gmser_delegation:aens_sig(?NETWORK_ID, ?ACCOUNT, <<42:256>>)),
|
||||||
|
?assertError(_, gmser_delegation:aens_sig(?NETWORK_ID, ?CONTRACT, ?CONTRACT))
|
||||||
|
end}
|
||||||
|
].
|
@ -1,10 +1,11 @@
|
|||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
|
%%% @copyright (C) 2025, QPQ AG
|
||||||
%%% @copyright (C) 2017, Aeternity Anstalt
|
%%% @copyright (C) 2017, Aeternity Anstalt
|
||||||
%%% @doc Tests for Recursive Length Prefix
|
%%% @doc Tests for Recursive Length Prefix
|
||||||
%%% @end
|
%%% @end
|
||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
|
|
||||||
-module(aeser_rlp_tests).
|
-module(gmser_rlp_tests).
|
||||||
|
|
||||||
-include_lib("eunit/include/eunit.hrl").
|
-include_lib("eunit/include/eunit.hrl").
|
||||||
|
|
||||||
@ -13,7 +14,7 @@
|
|||||||
-define(BYTE_ARRAY_OFFSET , 128).
|
-define(BYTE_ARRAY_OFFSET , 128).
|
||||||
-define(LIST_OFFSET , 192).
|
-define(LIST_OFFSET , 192).
|
||||||
|
|
||||||
-define(TEST_MODULE, aeser_rlp).
|
-define(TEST_MODULE, gmser_rlp).
|
||||||
|
|
||||||
rlp_one_byte_test() ->
|
rlp_one_byte_test() ->
|
||||||
B = <<42>>,
|
B = <<42>>,
|
Loading…
x
Reference in New Issue
Block a user