Make Contract Calls Great Again #35
+16
-9
@@ -76,10 +76,12 @@ set_manifest(Entries) ->
|
|||||||
|
|
||||||
|
|
||||||
-spec open_contract(Address) -> ok
|
-spec open_contract(Address) -> ok
|
||||||
when Address :: string().
|
when Address :: binary() | string().
|
||||||
|
|
||||||
open_contract(Address) ->
|
open_contract(Address) when is_binary(Address) ->
|
||||||
wx_object:cast(?MODULE, {open_contract, Address}).
|
wx_object:cast(?MODULE, {open_contract, Address});
|
||||||
|
open_contract(Address) when is_list(Address) ->
|
||||||
|
open_contract(list_to_binary(Address)).
|
||||||
|
|
||||||
|
|
||||||
-spec write_console(ConID, Message) -> ok
|
-spec write_console(ConID, Message) -> ok
|
||||||
@@ -562,8 +564,8 @@ open_hash(State = #s{frame = Frame, j = J}) ->
|
|||||||
Title = J("Retrieve Contract Source"),
|
Title = J("Retrieve Contract Source"),
|
||||||
Label = J("Address Hash"),
|
Label = J("Address Hash"),
|
||||||
case zxw_modal_text:show(Frame, Title, [{label, Label}]) of
|
case zxw_modal_text:show(Frame, Title, [{label, Label}]) of
|
||||||
{ok, Address = "ct_" ++ _} -> open_hash2(State, Address);
|
{ok, Address = "ct_" ++ _} -> open_hash2(State, list_to_binary(Address));
|
||||||
{ok, Address = "th_" ++ _} -> get_contract_from_tx(State, Address);
|
{ok, Address = "th_" ++ _} -> get_contract_from_tx(State, list_to_binary(Address));
|
||||||
{ok, Turd} -> handle_troubling(State, {bad_address, Turd});
|
{ok, Turd} -> handle_troubling(State, {bad_address, Turd});
|
||||||
cancel -> State
|
cancel -> State
|
||||||
end.
|
end.
|
||||||
@@ -581,7 +583,11 @@ get_contract_from_tx(State, Address) ->
|
|||||||
|
|
||||||
open_hash2(State, Address) ->
|
open_hash2(State, Address) ->
|
||||||
case hz:contract_source(Address) of
|
case hz:contract_source(Address) of
|
||||||
|
{project, [{Name, Source}]} ->
|
||||||
|
ok = tell("Retrieved ~p from ~p", [Name, Address]),
|
||||||
|
open_hash3(State, Address, Source);
|
||||||
{ok, Source} ->
|
{ok, Source} ->
|
||||||
|
ok = tell("Retrieved uncompressed source of ~p", [Address]),
|
||||||
open_hash3(State, Address, Source);
|
open_hash3(State, Address, Source);
|
||||||
Error ->
|
Error ->
|
||||||
handle_troubling(State, Error)
|
handle_troubling(State, Error)
|
||||||
@@ -590,9 +596,7 @@ open_hash2(State, Address) ->
|
|||||||
open_hash3(State, Address, Source) ->
|
open_hash3(State, Address, Source) ->
|
||||||
% TODO: Compile on load and verify the deployed hash for validity.
|
% TODO: Compile on load and verify the deployed hash for validity.
|
||||||
case compile(Source) of
|
case compile(Source) of
|
||||||
{ok, Build} ->
|
{ok, _Build} ->
|
||||||
{aaci, _, FunDefs, _} = maps:get(aaci, Build),
|
|
||||||
ok = tell(info, "Compilation Succeeded!~n~tp~n~n~tp", [Build, FunDefs]),
|
|
||||||
add_code_page(State, {hash, Address}, Source);
|
add_code_page(State, {hash, Address}, Source);
|
||||||
Other ->
|
Other ->
|
||||||
ok = tell(info, "Compilation Failed!~n~tp", [Other]),
|
ok = tell(info, "Compilation Failed!~n~tp", [Other]),
|
||||||
@@ -743,7 +747,11 @@ load2(State, Address) when is_list(Address) ->
|
|||||||
|
|
||||||
load3(State, Address) ->
|
load3(State, Address) ->
|
||||||
case hz:contract_source(Address) of
|
case hz:contract_source(Address) of
|
||||||
|
{project, [{Name, Source}]} ->
|
||||||
|
ok = tell("Retrieved ~p from ~p", [Name, Address]),
|
||||||
|
load4(State, Address, Source);
|
||||||
{ok, Source} ->
|
{ok, Source} ->
|
||||||
|
ok = tell("Retrieved uncompressed source of ~p", [Address]),
|
||||||
load4(State, Address, Source);
|
load4(State, Address, Source);
|
||||||
Error ->
|
Error ->
|
||||||
handle_troubling(State, Error)
|
handle_troubling(State, Error)
|
||||||
@@ -777,7 +785,6 @@ load4(State = #s{tabs = TopBook, cons = {Consbook, Pages}, buttons = Buttons, j
|
|||||||
{ok, Output} ->
|
{ok, Output} ->
|
||||||
{aaci, _, Funs, _} = maps:get(aaci, Output),
|
{aaci, _, Funs, _} = maps:get(aaci, Output),
|
||||||
Callable = maps:remove("init", Funs),
|
Callable = maps:remove("init", Funs),
|
||||||
tell(info, "Callable: ~p", [Callable]),
|
|
||||||
{NB, IFs} = fun_interfaces(ScrollWin, FunSz, Buttons, Callable, J),
|
{NB, IFs} = fun_interfaces(ScrollWin, FunSz, Buttons, Callable, J),
|
||||||
O = io_lib:format("Compilation Succeeded!~n~tp~n~nDone!~n", [Output]),
|
O = io_lib:format("Compilation Succeeded!~n~tp~n~nDone!~n", [Output]),
|
||||||
{O, IFs, Output, NB};
|
{O, IFs, Output, NB};
|
||||||
|
|||||||
Reference in New Issue
Block a user