Add Address.is_payable(address)
This commit is contained in:
parent
f27d37d624
commit
e9505e240f
@ -504,7 +504,8 @@ global_env() ->
|
||||
IntScope = #scope{ funs = MkDefs([{"to_str", Fun1(Int, String)}]) },
|
||||
AddressScope = #scope{ funs = MkDefs([{"to_str", Fun1(Address, String)},
|
||||
{"is_oracle", Fun1(Address, Bool)},
|
||||
{"is_contract", Fun1(Address, Bool)}]) },
|
||||
{"is_contract", Fun1(Address, Bool)},
|
||||
{"is_payable", Fun1(Address, Bool)}]) },
|
||||
|
||||
#env{ scopes =
|
||||
#{ [] => TopScope
|
||||
|
@ -197,7 +197,7 @@ builtins() ->
|
||||
{"union", 2}, {"difference", 2}, {"none", none}, {"all", none}]},
|
||||
{["Bytes"], [{"to_int", 1}, {"to_str", 1}]},
|
||||
{["Int"], [{"to_str", 1}]},
|
||||
{["Address"], [{"to_str", 1}, {"is_oracle", 1}, {"is_contract", 1}]}
|
||||
{["Address"], [{"to_str", 1}, {"is_oracle", 1}, {"is_contract", 1}, {"is_payable", 1}]}
|
||||
],
|
||||
maps:from_list([ {NS ++ [Fun], {MkName(NS, Fun), Arity}}
|
||||
|| {NS, Funs} <- Scopes,
|
||||
|
@ -433,6 +433,9 @@ ast_body(?qid_app(["Address", "is_oracle"], [Addr], _, _), Icode) ->
|
||||
ast_body(?qid_app(["Address", "is_contract"], [Addr], _, _), Icode) ->
|
||||
prim_call(?PRIM_CALL_ADDR_IS_CONTRACT, #integer{value = 0},
|
||||
[ast_body(Addr, Icode)], [word], word);
|
||||
ast_body(?qid_app(["Address", "is_payable"], [Addr], _, _), Icode) ->
|
||||
prim_call(?PRIM_CALL_ADDR_IS_PAYABLE, #integer{value = 0},
|
||||
[ast_body(Addr, Icode)], [word], word);
|
||||
|
||||
ast_body(?qid_app(["Bytes", "to_int"], [Bytes], _, _), Icode) ->
|
||||
{typed, _, _, {bytes_t, _, N}} = Bytes,
|
||||
|
@ -109,6 +109,7 @@
|
||||
Op =:= 'ORACLE_CHECK_QUERY' orelse
|
||||
Op =:= 'IS_ORACLE' orelse
|
||||
Op =:= 'IS_CONTRACT' orelse
|
||||
Op =:= 'IS_PAYABLE' orelse
|
||||
Op =:= 'CREATOR' orelse
|
||||
false)).
|
||||
|
||||
@ -543,6 +544,8 @@ builtin_to_scode(Env, address_is_oracle, [_] = Args) ->
|
||||
call_to_scode(Env, aeb_fate_ops:is_oracle(?a, ?a), Args);
|
||||
builtin_to_scode(Env, address_is_contract, [_] = Args) ->
|
||||
call_to_scode(Env, aeb_fate_ops:is_contract(?a, ?a), Args);
|
||||
builtin_to_scode(Env, address_is_payable, [_] = Args) ->
|
||||
call_to_scode(Env, aeb_fate_ops:is_payable(?a, ?a), Args);
|
||||
builtin_to_scode(Env, aens_resolve, [_Name, _Key, _Type] = Args) ->
|
||||
call_to_scode(Env, aeb_fate_ops:aens_resolve(?a, ?a, ?a, ?a), Args);
|
||||
builtin_to_scode(Env, aens_preclaim, [_Sign, _Account, _Hash] = Args) ->
|
||||
@ -836,6 +839,7 @@ attributes(I) ->
|
||||
{'ORACLE_CHECK_QUERY', A, B, C, D, E} -> Impure(A, [B, C, D, E]);
|
||||
{'IS_ORACLE', A, B} -> Impure(A, [B]);
|
||||
{'IS_CONTRACT', A, B} -> Impure(A, [B]);
|
||||
{'IS_PAYABLE', A, B} -> Impure(A, [B]);
|
||||
{'CREATOR', A} -> Pure(A, []);
|
||||
{'ADDRESS', A} -> Pure(A, []);
|
||||
{'BALANCE', A} -> Impure(A, []);
|
||||
|
@ -31,3 +31,6 @@ contract AddrChain =
|
||||
|
||||
entrypoint c_creator() : address =
|
||||
Contract.creator
|
||||
|
||||
entrypoint is_payable(a : address) : bool =
|
||||
Address.is_payable(a)
|
||||
|
Loading…
x
Reference in New Issue
Block a user