Add creation of fate calldata #167

Merged
zxq9 merged 1 commits from PT-166602172-calldat-for-fate into master 2019-06-11 21:58:41 +09:00
2 changed files with 25 additions and 2 deletions

View File

@ -2,12 +2,12 @@
%%% @copyright (C) 2017, Aeternity Anstalt %%% @copyright (C) 2017, Aeternity Anstalt
%%% @doc %%% @doc
%%% Encode and decode data and function calls according to %%% Encode and decode data and function calls according to
%%% Sophia-AEVM-ABI. %%% Sophia-AEVM-ABI
%%% @end %%% @end
%%% Created : 25 Jan 2018 %%% Created : 25 Jan 2018
%%% %%%
%%%------------------------------------------------------------------- %%%-------------------------------------------------------------------
-module(aeb_abi). -module(aeb_aevm_abi).
-define(HASH_SIZE, 32). -define(HASH_SIZE, 32).
-export([ create_calldata/4 -export([ create_calldata/4

23
src/aeb_fate_abi.erl Normal file
View File

@ -0,0 +1,23 @@
%%%-------------------------------------------------------------------
%%% @copyright (C) 2019, Aeternity Anstalt
%%% @doc
%%% Encode and decode data and function calls according to
%%% Sophia-FATE-ABI
%%% @end
%%% Created : 11 Jun 2019
%%%
%%%-------------------------------------------------------------------
-module(aeb_fate_abi).
-export([ create_calldata/2 ]).
%%%===================================================================
%%% API
%%%===================================================================
-spec create_calldata(list(), [term()]) -> {ok, binary()}.
create_calldata(FunName, Args) ->
FunctionId = aeb_fate_code:symbol_identifier(list_to_binary(FunName)),
{ok, aeb_fate_encoding:serialize(
aeb_fate_data:make_tuple({FunctionId,
aeb_fate_data:make_tuple(list_to_tuple(Args))}))}.