From 242700e0848ffdc1fa10fc411423068a0861020e Mon Sep 17 00:00:00 2001 From: Thomas Arts Date: Tue, 11 Jun 2019 14:27:49 +0200 Subject: [PATCH] Add creation of fate calldata --- src/{aeb_abi.erl => aeb_aevm_abi.erl} | 4 ++-- src/aeb_fate_abi.erl | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) rename src/{aeb_abi.erl => aeb_aevm_abi.erl} (99%) create mode 100644 src/aeb_fate_abi.erl diff --git a/src/aeb_abi.erl b/src/aeb_aevm_abi.erl similarity index 99% rename from src/aeb_abi.erl rename to src/aeb_aevm_abi.erl index a59a95c..15bbd6c 100644 --- a/src/aeb_abi.erl +++ b/src/aeb_aevm_abi.erl @@ -2,12 +2,12 @@ %%% @copyright (C) 2017, Aeternity Anstalt %%% @doc %%% Encode and decode data and function calls according to -%%% Sophia-AEVM-ABI. +%%% Sophia-AEVM-ABI %%% @end %%% Created : 25 Jan 2018 %%% %%%------------------------------------------------------------------- --module(aeb_abi). +-module(aeb_aevm_abi). -define(HASH_SIZE, 32). -export([ create_calldata/4 diff --git a/src/aeb_fate_abi.erl b/src/aeb_fate_abi.erl new file mode 100644 index 0000000..91f05b2 --- /dev/null +++ b/src/aeb_fate_abi.erl @@ -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))}))}. -- 2.30.2