From 355f50c2bed6dae94c48526aba772957d8ec844c Mon Sep 17 00:00:00 2001 From: Craig Everett Date: Tue, 11 Mar 2025 23:00:06 +0900 Subject: [PATCH] WIP: Monkeypatch to make simple args callable for now --- src/gd_v_devman.erl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/gd_v_devman.erl b/src/gd_v_devman.erl index 3ea351a..4459516 100644 --- a/src/gd_v_devman.erl +++ b/src/gd_v_devman.erl @@ -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]),