diff --git a/CHANGELOG.md b/CHANGELOG.md index 69ee66e..f8b8f58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `Chain.bytecode_hash` - Minor support for variadic functions - `void` type that represents an empty type +- `Call.fee` builtin ### Changed - Contract interfaces must be now invocated by `contract interface` keywords - `main` keyword to indicate the main contract in case there are child contracts around diff --git a/rebar.config b/rebar.config index 966c8b4..df4a71c 100644 --- a/rebar.config +++ b/rebar.config @@ -2,7 +2,7 @@ {erl_opts, [debug_info]}. -{deps, [ {aebytecode, {git, "https://github.com/aeternity/aebytecode.git", {ref,"951db9f"}}} +{deps, [ {aebytecode, {git, "https://github.com/aeternity/aebytecode.git", {ref,"05dfd7f"}}} , {getopt, "1.0.1"} , {eblake2, "1.0.0"} , {jsx, {git, "https://github.com/talentdeficit/jsx.git", diff --git a/rebar.lock b/rebar.lock index 477ca9f..8df56f7 100644 --- a/rebar.lock +++ b/rebar.lock @@ -1,7 +1,7 @@ {"1.1.0", [{<<"aebytecode">>, {git,"https://github.com/aeternity/aebytecode.git", - {ref,"951db9f38412a1f798987403d24c512d82fec8c7"}}, + {ref,"05dfd7ffc7fb1e07ecc0b1e516da571f56d7dc8f"}}, 0}, {<<"aeserialization">>, {git,"https://github.com/aeternity/aeserialization.git", diff --git a/src/aeso_ast_infer_types.erl b/src/aeso_ast_infer_types.erl index bd52d1b..bc049cf 100644 --- a/src/aeso_ast_infer_types.erl +++ b/src/aeso_ast_infer_types.erl @@ -561,6 +561,7 @@ global_env() -> {"caller", Address}, {"value", Int}, {"gas_price", Int}, + {"fee", Int}, {"gas_left", Fun([], Int)}]) }, diff --git a/src/aeso_ast_to_fcode.erl b/src/aeso_ast_to_fcode.erl index 835d4d0..8083b53 100644 --- a/src/aeso_ast_to_fcode.erl +++ b/src/aeso_ast_to_fcode.erl @@ -246,7 +246,7 @@ builtins() -> {"timestamp", none}, {"block_height", none}, {"difficulty", none}, {"gas_limit", none}, {"bytecode_hash", 1}, {"create", variable}, {"clone", variable}]}, {["Contract"], [{"address", none}, {"balance", none}, {"creator", none}]}, - {["Call"], [{"origin", none}, {"caller", none}, {"value", none}, {"gas_price", none}, + {["Call"], [{"origin", none}, {"caller", none}, {"value", none}, {"gas_price", none}, {"fee", none}, {"gas_left", 0}]}, {["Oracle"], [{"register", 4}, {"expiry", 1}, {"query_fee", 1}, {"query", 5}, {"get_question", 2}, {"respond", 4}, {"extend", 3}, {"get_answer", 2}, diff --git a/src/aeso_fcode_to_fate.erl b/src/aeso_fcode_to_fate.erl index e93da66..879af6d 100644 --- a/src/aeso_fcode_to_fate.erl +++ b/src/aeso_fcode_to_fate.erl @@ -527,6 +527,8 @@ builtin_to_scode(_Env, call_value, []) -> [aeb_fate_ops:call_value(?a)]; builtin_to_scode(_Env, call_gas_price, []) -> [aeb_fate_ops:gasprice(?a)]; +builtin_to_scode(_Env, call_fee, []) -> + [aeb_fate_ops:fee(?a)]; builtin_to_scode(_Env, call_gas_left, []) -> [aeb_fate_ops:gas(?a)]; builtin_to_scode(Env, oracle_register, [_Sign,_Account,_QFee,_TTL,_QType,_RType] = Args) -> @@ -925,6 +927,7 @@ attributes(I) -> {'ORIGIN', A} -> Pure(A, []); {'CALLER', A} -> Pure(A, []); {'GASPRICE', A} -> Pure(A, []); + {'FEE', A} -> Pure(A, []); {'BLOCKHASH', A, B} -> Pure(A, [B]); {'BENEFICIARY', A} -> Pure(A, []); {'TIMESTAMP', A} -> Pure(A, []); diff --git a/test/contracts/environment.aes b/test/contracts/environment.aes index a05f5bf..7c02e6b 100644 --- a/test/contracts/environment.aes +++ b/test/contracts/environment.aes @@ -44,6 +44,9 @@ contract Environment = // Gas price entrypoint call_gas_price() : int = Call.gas_price + // Fee + entrypoint call_fee() : int = Call.fee + // -- Information about the chain --- // Account balances