Less hacky handling of Chain.event
This commit is contained in:
parent
236ef6eb89
commit
b5b0d30fc4
@ -193,10 +193,10 @@ bind_state(Env) ->
|
||||
Env1 = bind_funs([{"state", State},
|
||||
{"put", {fun_t, Ann, [], [State], Unit}}], Env),
|
||||
|
||||
%% A bit of a hack: we bind Chain.event with the local event type.
|
||||
Env2 = force_bind_fun("event", {fun_t, Ann, [], [Event], Unit},
|
||||
Env1#env{ namespace = ["Chain"] }),
|
||||
Env2#env{ namespace = Env1#env.namespace }.
|
||||
%% We bind Chain.event in a local 'Chain' namespace.
|
||||
pop_scope(
|
||||
bind_fun("event", {fun_t, Ann, [], [Event], Unit},
|
||||
push_scope(namespace, {con, Ann, "Chain"}, Env1))).
|
||||
|
||||
-spec bind_field(name(), field_info(), env()) -> env().
|
||||
bind_field(X, Info, Env = #env{ fields = Fields }) ->
|
||||
|
@ -140,7 +140,7 @@ ast_type(T, Icode) ->
|
||||
ast_body(?qid_app(["Chain","spend"], [To, Amount], _, _), Icode) ->
|
||||
prim_call(?PRIM_CALL_SPEND, ast_body(Amount, Icode), [ast_body(To, Icode)], [word], {tuple, []});
|
||||
|
||||
ast_body(?qid_app(["Chain","event"], [Event], _, _), Icode) ->
|
||||
ast_body(?qid_app([Con, "Chain", "event"], [Event], _, _), Icode = #{ contract_name := Con }) ->
|
||||
aeso_builtins:check_event_type(Icode),
|
||||
builtin_call({event, maps:get(event_type, Icode)}, [ast_body(Event, Icode)]);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user