Remove old type references, update naming, add license notices (#43)
Gajumaru Serialization Tests / tests (push) Successful in -4m21s
Gajumaru Serialization Tests / tests (push) Successful in -4m21s
Removed the oracle type references and updated the dependency list to point to git.qpq.swiss. Reviewed-on: #43 Co-authored-by: Craig Everett <zxq9@zxq9.com> Co-committed-by: Craig Everett <zxq9@zxq9.com>
This commit was merged in pull request #43.
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
%%%-------------------------------------------------------------------
|
||||
%%% @copyright (C) 2025, QPQ AG
|
||||
%%% @copyright (C) 2023, Aeternity Anstalt
|
||||
%%% @doc
|
||||
%%% Serialization of delegation signatures
|
||||
%%% @end
|
||||
%%%-------------------------------------------------------------------
|
||||
-module(gmser_delegation).
|
||||
|
||||
-export([ aens_preclaim_sig/3
|
||||
, aens_name_sig/4
|
||||
, aens_sig/3
|
||||
]).
|
||||
|
||||
%% Delegation signatures are prefixed with a unique tag, ensuring not to
|
||||
%% collide with serialized transactions.
|
||||
-define(DELEGATION_TAG, 16#1a01).
|
||||
|
||||
-define(TYPE_AENS, 1).
|
||||
-define(TYPE_AENS_NAME, 2).
|
||||
-define(TYPE_AENS_PRECLAIM, 3).
|
||||
-define(TYPE_ORACLE, 4).
|
||||
-define(TYPE_ORACLE_RESPONSE, 5).
|
||||
|
||||
-define(VSN, 1).
|
||||
|
||||
-type sig_data() :: binary().
|
||||
|
||||
-spec aens_preclaim_sig(binary(), gmser_id:id(), gmser_id:id()) -> sig_data().
|
||||
aens_preclaim_sig(NetworkId, Account, Contract) ->
|
||||
assert_id(account, Account),
|
||||
assert_id(contract, Contract),
|
||||
Template = [{account, id}, {contract, id}],
|
||||
Fields = [{account, Account}, {contract, Contract}],
|
||||
serialize(?TYPE_AENS_PRECLAIM, NetworkId, Template, Fields).
|
||||
|
||||
-spec aens_name_sig(binary(), gmser_id:id(), gmser_id:id(), gmser_id:id()) -> sig_data().
|
||||
aens_name_sig(NetworkId, Account, Name, Contract) ->
|
||||
assert_id(account, Account),
|
||||
assert_id(name, Name),
|
||||
assert_id(contract, Contract),
|
||||
Template = [{account, id}, {name, id}, {contract, id}],
|
||||
Fields = [{account, Account}, {name, Name}, {contract, Contract}],
|
||||
serialize(?TYPE_AENS_NAME, NetworkId, Template, Fields).
|
||||
|
||||
-spec aens_sig(binary(), gmser_id:id(), gmser_id:id()) -> sig_data().
|
||||
aens_sig(NetworkId, Account, Contract) ->
|
||||
assert_id(account, Account),
|
||||
assert_id(contract, Contract),
|
||||
Template = [{account, id}, {contract, id}],
|
||||
Fields = [{account, Account}, {contract, Contract}],
|
||||
serialize(?TYPE_AENS, NetworkId, Template, Fields).
|
||||
|
||||
|
||||
%% ------------------------------------------------------------------------
|
||||
%% -- Internal functions
|
||||
%% ------------------------------------------------------------------------
|
||||
|
||||
serialize(Type, NetworkId, Template, Fields) ->
|
||||
Data = gmserialization:serialize(Type, ?VSN, Template, Fields),
|
||||
<<?DELEGATION_TAG:16, NetworkId/binary, Data/binary>>.
|
||||
|
||||
assert_id(Type, AeserId) ->
|
||||
Type = gmser_id:specialize_type(AeserId).
|
||||
Reference in New Issue
Block a user