WIP: Monkeypatch to make simple args callable for now

This commit is contained in:
Craig Everett 2025-03-11 23:00:06 +09:00
parent dc4b05c938
commit 355f50c2be

View File

@ -416,12 +416,11 @@ call_params([{L, C} | T], A) ->
clicked4(State,
#c{id = ConID, build = #{aci := ACI}, funs = {_, Funs}},
{Name, Type},
{PK, Nonce, TTL, GasP, Gas, Amount}) ->
{PK, Nonce, TTL, GasP, Gas, Amt}) ->
AACI = hz:prepare_aaci(ACI),
#f{args = ArgFields} = lists:keyfind(Name, #f.name, Funs),
#f{args = ArgFields} = maps:get(Name, Funs),
Args = lists:map(fun get_arg/1, ArgFields),
FunName = binary_to_list(Name),
case hz:contract_call(PK, Nonce, Gas, GasP, Amount, TTL, AACI, ConID, FunName, Args) of
case hz:contract_call(PK, Nonce, Gas, GasP, Amt, TTL, AACI, ConID, Name, Args) of
{ok, UnsignedTX} ->
case Type of
call -> do_call(State, ConID, PK, UnsignedTX);
@ -594,12 +593,13 @@ deploy2(State, Source) ->
case compile(Source) of
% Options = sophia_options(),
% case so_compiler:from_string(Source, Options) of
% TODO: Make hz accept either the aaci or the aci, preferring the aaci if present
{ok, Build} ->
{ACI, Neutered} = maps:take(aci, Build),
ACI = maps:get(aci, Build),
RawAACI = {aaci, ContractName, Funs, NS} = hz:prepare_aaci(ACI),
{InitSpec, Callable} = maps:take("init", Funs),
AACI = setelement(3, RawAACI, Callable),
Complete = maps:put(aaci, AACI, Neutered),
Complete = maps:put(aaci, AACI, Build),
ok = tell(info, "Deploying Contract: ~p", [ContractName]),
deploy3(State, InitSpec, Complete, NS);
Other ->
@ -656,7 +656,7 @@ deploy4(State = #s{frame = Frame, j = J}, InitSpec, Build, NS, Selected, Keys) -
?wxID_OK ->
ID = wxChoice:getString(KeyPicker, wxChoice:getSelection(KeyPicker)),
PK = unicode:characters_to_binary(ID),
InitArgs = lists:map(fun get_arg/1, ArgFields),
IArgs = lists:map(fun get_arg/1, ArgFields),
Controls =
[{"TTL", TTL_Tx},
{"Gas Price", GasP_Tx},
@ -666,7 +666,7 @@ deploy4(State = #s{frame = Frame, j = J}, InitSpec, Build, NS, Selected, Keys) -
{ok, [TTL, GasP, Gas, Amount]} ->
{ok, Nonce} = hz:next_nonce(PK),
DeployParams = {PK, Nonce, TTL, GasP, Gas, Amount},
{ok, DeployParams, InitArgs};
{ok, DeployParams, IArgs};
E ->
E
end;
@ -1089,9 +1089,9 @@ load3(State = #s{tabs = TopBook, cons = {Consbook, Pages}, buttons = Buttons, j
{Out, IFaces, Build, NewButtons} =
case compile(Source) of
{ok, Output} ->
{ACI, Neutered} = maps:take(aci, Output),
ACI = maps:get(aci, Output),
AACI = {aaci, ContractName, Funs, NS} = hz:prepare_aaci(ACI),
Complete = maps:put(aaci, AACI, Neutered),
Complete = maps:put(aaci, AACI, Output),
ok = tell(info, "Loading Contract: ~p", [ContractName]),
Callable = maps:remove("init", Funs),
tell(info, "Callable: ~p", [Callable]),