WIP: Monkeypatch to make simple args callable for now
This commit is contained in:
parent
dc4b05c938
commit
355f50c2be
@ -416,12 +416,11 @@ call_params([{L, C} | T], A) ->
|
|||||||
clicked4(State,
|
clicked4(State,
|
||||||
#c{id = ConID, build = #{aci := ACI}, funs = {_, Funs}},
|
#c{id = ConID, build = #{aci := ACI}, funs = {_, Funs}},
|
||||||
{Name, Type},
|
{Name, Type},
|
||||||
{PK, Nonce, TTL, GasP, Gas, Amount}) ->
|
{PK, Nonce, TTL, GasP, Gas, Amt}) ->
|
||||||
AACI = hz:prepare_aaci(ACI),
|
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),
|
Args = lists:map(fun get_arg/1, ArgFields),
|
||||||
FunName = binary_to_list(Name),
|
case hz:contract_call(PK, Nonce, Gas, GasP, Amt, TTL, AACI, ConID, Name, Args) of
|
||||||
case hz:contract_call(PK, Nonce, Gas, GasP, Amount, TTL, AACI, ConID, FunName, Args) of
|
|
||||||
{ok, UnsignedTX} ->
|
{ok, UnsignedTX} ->
|
||||||
case Type of
|
case Type of
|
||||||
call -> do_call(State, ConID, PK, UnsignedTX);
|
call -> do_call(State, ConID, PK, UnsignedTX);
|
||||||
@ -594,12 +593,13 @@ deploy2(State, Source) ->
|
|||||||
case compile(Source) of
|
case compile(Source) of
|
||||||
% Options = sophia_options(),
|
% Options = sophia_options(),
|
||||||
% case so_compiler:from_string(Source, Options) of
|
% 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} ->
|
{ok, Build} ->
|
||||||
{ACI, Neutered} = maps:take(aci, Build),
|
ACI = maps:get(aci, Build),
|
||||||
RawAACI = {aaci, ContractName, Funs, NS} = hz:prepare_aaci(ACI),
|
RawAACI = {aaci, ContractName, Funs, NS} = hz:prepare_aaci(ACI),
|
||||||
{InitSpec, Callable} = maps:take("init", Funs),
|
{InitSpec, Callable} = maps:take("init", Funs),
|
||||||
AACI = setelement(3, RawAACI, Callable),
|
AACI = setelement(3, RawAACI, Callable),
|
||||||
Complete = maps:put(aaci, AACI, Neutered),
|
Complete = maps:put(aaci, AACI, Build),
|
||||||
ok = tell(info, "Deploying Contract: ~p", [ContractName]),
|
ok = tell(info, "Deploying Contract: ~p", [ContractName]),
|
||||||
deploy3(State, InitSpec, Complete, NS);
|
deploy3(State, InitSpec, Complete, NS);
|
||||||
Other ->
|
Other ->
|
||||||
@ -656,7 +656,7 @@ deploy4(State = #s{frame = Frame, j = J}, InitSpec, Build, NS, Selected, Keys) -
|
|||||||
?wxID_OK ->
|
?wxID_OK ->
|
||||||
ID = wxChoice:getString(KeyPicker, wxChoice:getSelection(KeyPicker)),
|
ID = wxChoice:getString(KeyPicker, wxChoice:getSelection(KeyPicker)),
|
||||||
PK = unicode:characters_to_binary(ID),
|
PK = unicode:characters_to_binary(ID),
|
||||||
InitArgs = lists:map(fun get_arg/1, ArgFields),
|
IArgs = lists:map(fun get_arg/1, ArgFields),
|
||||||
Controls =
|
Controls =
|
||||||
[{"TTL", TTL_Tx},
|
[{"TTL", TTL_Tx},
|
||||||
{"Gas Price", GasP_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, [TTL, GasP, Gas, Amount]} ->
|
||||||
{ok, Nonce} = hz:next_nonce(PK),
|
{ok, Nonce} = hz:next_nonce(PK),
|
||||||
DeployParams = {PK, Nonce, TTL, GasP, Gas, Amount},
|
DeployParams = {PK, Nonce, TTL, GasP, Gas, Amount},
|
||||||
{ok, DeployParams, InitArgs};
|
{ok, DeployParams, IArgs};
|
||||||
E ->
|
E ->
|
||||||
E
|
E
|
||||||
end;
|
end;
|
||||||
@ -1089,9 +1089,9 @@ load3(State = #s{tabs = TopBook, cons = {Consbook, Pages}, buttons = Buttons, j
|
|||||||
{Out, IFaces, Build, NewButtons} =
|
{Out, IFaces, Build, NewButtons} =
|
||||||
case compile(Source) of
|
case compile(Source) of
|
||||||
{ok, Output} ->
|
{ok, Output} ->
|
||||||
{ACI, Neutered} = maps:take(aci, Output),
|
ACI = maps:get(aci, Output),
|
||||||
AACI = {aaci, ContractName, Funs, NS} = hz:prepare_aaci(ACI),
|
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]),
|
ok = tell(info, "Loading Contract: ~p", [ContractName]),
|
||||||
Callable = maps:remove("init", Funs),
|
Callable = maps:remove("init", Funs),
|
||||||
tell(info, "Callable: ~p", [Callable]),
|
tell(info, "Callable: ~p", [Callable]),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user