Compare commits

..

8 Commits

Author SHA1 Message Date
Sean Hinde 27bb4331aa Small tidy up 2021-11-02 09:36:45 +01:00
Sean Hinde 9b36c771c7 Update to use latest enacl with new API 2021-11-01 18:37:12 +01:00
Dimitar Ivanov 58e34ae7b5 Merge pull request #14 from aeternity/GH-2851-paying_for_tx
Add paying_for_tx to aeser_chain_objects
2021-03-10 15:49:31 +02:00
Dimitar Ivanov 87baccba42 Merge pull request #13 from aeternity/channel_set_delegates_tx
Describe channel_set_delegates_tx
2021-03-09 17:46:19 +02:00
Dimitar Ivanov 5e820bed55 Describe channel_set_delegates_tx 2021-03-07 12:28:27 +02:00
Hans Svensson 80ff8a49f4 Add paying_for_tx to aeser_chain_objects 2019-11-08 13:40:35 +01:00
Thomas Arts 47aaa8f543 Merge pull request #11 from aeternity/add-name_auction-chain-object
Name_auction serialization
2019-09-02 08:43:54 +02:00
Thomas Arts e1fe683f95 Name_auction serialization 2019-08-30 11:34:57 +02:00
5 changed files with 10 additions and 26 deletions
+1 -1
View File
@@ -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, "26180f4"}}}
, {enacl, {git, "https://github.com/aeternity/enacl.git", {ref, "793ddb5"}}}
]}.
-5
View File
@@ -32,7 +32,6 @@
| account_pubkey
| signature
| name
| subname
| commitment
| peer_pubkey
| state
@@ -196,7 +195,6 @@ type2enc(signature) -> ?BASE58;
type2enc(commitment) -> ?BASE58;
type2enc(peer_pubkey) -> ?BASE58;
type2enc(name) -> ?BASE58;
type2enc(subname) -> ?BASE64;
type2enc(state) -> ?BASE64;
type2enc(poi) -> ?BASE64;
type2enc(state_trees) -> ?BASE64;
@@ -225,7 +223,6 @@ type2pfx(signature) -> <<"sg">>;
type2pfx(commitment) -> <<"cm">>;
type2pfx(peer_pubkey) -> <<"pp">>;
type2pfx(name) -> <<"nm">>;
type2pfx(subname) -> <<"sn">>;
type2pfx(state) -> <<"st">>;
type2pfx(poi) -> <<"pi">>;
type2pfx(state_trees) -> <<"ss">>;
@@ -253,7 +250,6 @@ pfx2type(<<"sg">>) -> signature;
pfx2type(<<"cm">>) -> commitment;
pfx2type(<<"pp">>) -> peer_pubkey;
pfx2type(<<"nm">>) -> name;
pfx2type(<<"sn">>) -> subname;
pfx2type(<<"st">>) -> state;
pfx2type(<<"pi">>) -> poi;
pfx2type(<<"ss">>) -> state_trees;
@@ -281,7 +277,6 @@ byte_size_for_type(oracle_response) -> not_applicable;
byte_size_for_type(account_pubkey) -> 32;
byte_size_for_type(signature) -> 64;
byte_size_for_type(name) -> not_applicable;
byte_size_for_type(subname) -> not_applicable;
byte_size_for_type(commitment) -> 32;
byte_size_for_type(peer_pubkey) -> 32;
byte_size_for_type(state) -> 32;
+6 -4
View File
@@ -52,13 +52,13 @@ tag(name_preclaim_tx) -> 33;
tag(name_update_tx) -> 34;
tag(name_revoke_tx) -> 35;
tag(name_transfer_tx) -> 36;
tag(subname) -> 38;
tag(subname_tx) -> 39;
tag(name_auction) -> 37;
tag(contract) -> 40;
tag(contract_call) -> 41;
tag(contract_create_tx) -> 42;
tag(contract_call_tx) -> 43;
tag(channel_create_tx) -> 50;
tag(channel_set_delegates_tx) -> 501;
tag(channel_deposit_tx) -> 51;
tag(channel_withdraw_tx) -> 52;
tag(channel_force_progress_tx) -> 521;
@@ -90,6 +90,7 @@ tag(accounts_mtree) -> 626;
tag(compiler_sophia) -> 70;
tag(ga_attach_tx) -> 80;
tag(ga_meta_tx) -> 81;
tag(paying_for_tx) -> 82;
tag(key_block) -> 100;
tag(micro_block) -> 101;
tag(light_micro_block) -> 102;
@@ -111,13 +112,13 @@ rev_tag(33) -> name_preclaim_tx;
rev_tag(34) -> name_update_tx;
rev_tag(35) -> name_revoke_tx;
rev_tag(36) -> name_transfer_tx;
rev_tag(38) -> subname;
rev_tag(39) -> subname_tx;
rev_tag(37) -> name_auction;
rev_tag(40) -> contract;
rev_tag(41) -> contract_call;
rev_tag(42) -> contract_create_tx;
rev_tag(43) -> contract_call_tx;
rev_tag(50) -> channel_create_tx;
rev_tag(501) -> channel_set_delegates_tx;
rev_tag(51) -> channel_deposit_tx;
rev_tag(52) -> channel_withdraw_tx;
rev_tag(521) -> channel_force_progress_tx;
@@ -149,6 +150,7 @@ rev_tag(626) -> accounts_mtree;
rev_tag(70) -> compiler_sophia;
rev_tag(80) -> ga_attach_tx;
rev_tag(81) -> ga_meta_tx;
rev_tag(82) -> paying_for_tx;
rev_tag(100) -> key_block;
rev_tag(101) -> micro_block;
rev_tag(102) -> light_micro_block;
+1 -2
View File
@@ -23,8 +23,7 @@ serialize(CodeMap = #{ byte_code := ByteCode
SourceHash = case CodeMap of
#{ source_hash := SHash } -> SHash;
#{ contract_source := SrcStr } ->
{ok, SHash} = enacl:generichash(32, list_to_binary(SrcStr)),
SHash
enacl:generichash(32, list_to_binary(SrcStr))
end,
%% Compiler version
+2 -14
View File
@@ -24,7 +24,7 @@
, val
}).
-type tag() :: 'account' | 'oracle' | 'name' | 'subname'
-type tag() :: 'account' | 'oracle' | 'name'
| 'commitment' | 'contract' | 'channel'.
-type val() :: <<_:256>>.
-opaque(id() :: #id{}).
@@ -37,12 +37,10 @@
-define(PUB_SIZE, 32).
-define(TAG_SIZE, 1).
-define(SERIALIZED_SIZE, 33). %% ?TAG_SIZE + ?PUB_SIZE
-define(SUBNAME_SERIALIZED_SIZE, 65). %% ?TAG_SIZE + ?PUB_SIZE + ?PUB_SIZE
-define(IS_TAG(___TAG___), ___TAG___ =:= account;
___TAG___ =:= oracle;
___TAG___ =:= name;
___TAG___ =:= subname;
___TAG___ =:= commitment;
___TAG___ =:= contract;
___TAG___ =:= channel
@@ -84,33 +82,24 @@ is_id(_) -> false.
-spec encode(id()) -> binary().
encode(#id{tag = Tag, val = Val}) ->
Res = <<(encode_tag(Tag)):?TAG_SIZE/unit:8, Val/binary>>,
true = serialized_size(Tag) =:= byte_size(Res),
true = ?SERIALIZED_SIZE =:= byte_size(Res),
Res.
-spec decode(binary()) -> id().
decode(<<Tag:?TAG_SIZE/unit:8, Val:?PUB_SIZE/binary>>) ->
#id{ tag = decode_tag(Tag)
, val = Val};
decode(<<SubnameTag:?TAG_SIZE/unit:8, Val:(?PUB_SIZE+?PUB_SIZE)/binary>>) ->
#id{ tag = subname = decode_tag(SubnameTag)
, val = Val}.
%%%===================================================================
%%% Internal functions
%%%===================================================================
serialized_size(subname) -> ?SUBNAME_SERIALIZED_SIZE;
serialized_size(_) -> ?SERIALIZED_SIZE.
encode_tag(account) -> 1;
encode_tag(name) -> 2;
encode_tag(commitment) -> 3;
encode_tag(oracle) -> 4;
encode_tag(contract) -> 5;
encode_tag(channel) -> 6;
encode_tag(subname) -> 7;
encode_tag(Other) -> error({illegal_id_tag_name, Other}).
decode_tag(1) -> account;
@@ -119,5 +108,4 @@ decode_tag(3) -> commitment;
decode_tag(4) -> oracle;
decode_tag(5) -> contract;
decode_tag(6) -> channel;
decode_tag(7) -> subname;
decode_tag(X) -> error({illegal_id_tag, X}).