WIP: Fixing silly display cases
This commit is contained in:
+60
-16
@@ -16,7 +16,8 @@
|
||||
refresh/0,
|
||||
nonce/1, spend/1, chain_id/0, grids/1,
|
||||
sign_mess/1, sign_binary/1, sign_tx/1, sign_call/3,
|
||||
deploy/1, prompt_call/3, list_calls/0, open_contract/1, show_call/2,
|
||||
deploy/1, prompt_call/3, list_calls/0,
|
||||
open_contract/1, open_contract/2, show_call/2, show_call/3,
|
||||
make_key/6, recover_key/1, mnemonic/1, rename_key/2, drop_key/1, list_keys/0,
|
||||
add_node/1, set_sole_node/1]).
|
||||
-export([tic/1, update_balance/2]).
|
||||
@@ -26,7 +27,6 @@
|
||||
-export([init/1, terminate/2, code_change/3,
|
||||
handle_call/3, handle_cast/2, handle_info/2]).
|
||||
-include("$zx_include/zx_logger.hrl").
|
||||
|
||||
-include("gd.hrl").
|
||||
|
||||
|
||||
@@ -232,23 +232,48 @@ list_calls() ->
|
||||
-spec open_contract(ConID) -> ok
|
||||
when ConID :: string().
|
||||
%% @doc
|
||||
%% @equiv open_contract(ConID, true).
|
||||
|
||||
open_contract(ConID) ->
|
||||
open_contract(ConID, true).
|
||||
|
||||
|
||||
-spec open_contract(ConID, DevmanToFront) -> ok
|
||||
when ConID :: string(),
|
||||
DevmanToFront :: boolean().
|
||||
%% @doc
|
||||
%% Ask the controller to tell the devman interface to open a deployed contract.
|
||||
%% The controller will start the devman if it isn't already on.
|
||||
|
||||
open_contract(ConID) ->
|
||||
gen_server:cast(?MODULE, {open_contract, ConID}).
|
||||
open_contract(ConID, DevmanToFront) when is_binary(ConID) ->
|
||||
gen_server:cast(?MODULE, {open_contract, ConID, DevmanToFront});
|
||||
open_contract(ConID, DevmanToFront) when is_list(ConID) ->
|
||||
open_contract(list_to_binary(ConID), DevmanToFront).
|
||||
|
||||
|
||||
-spec show_call(ConID, Info) -> ok
|
||||
when ConID :: string(),
|
||||
Info :: map().
|
||||
%% @doc
|
||||
%% @equiv show_call(ConID, Info, true).
|
||||
|
||||
show_call(ConID, Info) ->
|
||||
show_call(ConID, Info, true).
|
||||
|
||||
|
||||
-spec show_call(ConID, Info, DevmanToFront) -> ok
|
||||
when ConID :: string(),
|
||||
Info :: map(),
|
||||
DevmanToFront :: boolean().
|
||||
%% @doc
|
||||
%% Ask the controller to tell the devman interface to dislpay the result of a call
|
||||
%% to the indicated contract. Opens the contract in question if it isn't alread open.
|
||||
%% Starts the devman if it isn't already running.
|
||||
|
||||
show_call(ConID, Info) ->
|
||||
gen_server:cast(?MODULE, {show_call, ConID, Info}).
|
||||
show_call(ConID, Info, DevmanToFront) when is_binary(ConID) ->
|
||||
gen_server:cast(?MODULE, {show_call, ConID, Info, DevmanToFront});
|
||||
show_call(ConID, Info, DevmanToFront) when is_list(ConID) ->
|
||||
show_call(list_to_binary(ConID), Info, DevmanToFront).
|
||||
|
||||
|
||||
-spec make_key(Type, Size, Name, Seed, Encoding, Transform) -> ok
|
||||
@@ -521,11 +546,11 @@ handle_cast({rename_key, ID, NewName}, State) ->
|
||||
handle_cast({drop_key, ID}, State) ->
|
||||
NewState = do_drop_key(ID, State),
|
||||
{noreply, NewState};
|
||||
handle_cast({open_contract, ConID}, State) ->
|
||||
NewState = do_open_contract(ConID, State),
|
||||
handle_cast({open_contract, ConID, ToFront}, State) ->
|
||||
NewState = do_open_contract(ConID, ToFront, State),
|
||||
{noreply, NewState};
|
||||
handle_cast({show_call, ConID, Info}, State) ->
|
||||
NewState = do_show_call(ConID, Info, State),
|
||||
handle_cast({show_call, ConID, Info, ToFront}, State) ->
|
||||
NewState = do_show_call(ConID, Info, ToFront, State),
|
||||
{noreply, NewState};
|
||||
handle_cast({add_node, New}, State) ->
|
||||
NewState = do_add_node(New, State),
|
||||
@@ -594,11 +619,29 @@ terminate(Reason, _) ->
|
||||
|
||||
%%% GUI doers
|
||||
|
||||
-spec do_show_ui(Name, State) -> NewState
|
||||
when Name :: ui_name() | term(),
|
||||
State :: state(),
|
||||
NewState :: state().
|
||||
|
||||
do_show_ui(Name, State = #s{tasks = Tasks, prefs = Prefs}) ->
|
||||
do_show_ui(Name, State) ->
|
||||
do_show_ui(Name, true, State).
|
||||
|
||||
|
||||
-spec do_show_ui(Name, ToFront, State) -> NewState
|
||||
when Name :: ui_name() | term(),
|
||||
ToFront :: boolean(),
|
||||
State :: state(),
|
||||
NewState :: state().
|
||||
|
||||
do_show_ui(Name, ToFront, State = #s{tasks = Tasks, prefs = Prefs}) ->
|
||||
case lists:keyfind(Name, #ui.name, Tasks) of
|
||||
#ui{wx = Win} ->
|
||||
ok = Name:to_front(Win),
|
||||
ok =
|
||||
case ToFront of
|
||||
true -> Name:to_front(Win);
|
||||
false -> ok
|
||||
end,
|
||||
State;
|
||||
false ->
|
||||
TaskPrefs = maps:get(Name, Prefs, #{}),
|
||||
@@ -1019,14 +1062,15 @@ do_drop_key(ID, State = #s{wallet = W, wallets = Wallets, pass = Pass}) ->
|
||||
State#s{wallet = NewWallet}.
|
||||
|
||||
|
||||
do_open_contract(ConID, State) ->
|
||||
NewState = do_show_ui(gd_v_devman, State),
|
||||
do_open_contract(ConID, ToFront, State) ->
|
||||
NewState = do_show_ui(gd_v_devman, ToFront, State),
|
||||
ok = gd_v_devman:open_contract(ConID),
|
||||
NewState.
|
||||
|
||||
|
||||
do_show_call(ConID, Info, State) ->
|
||||
NewState = do_show_ui(gd_v_devman, State),
|
||||
do_show_call(ConID, Info, ToFront, State) ->
|
||||
NewState = do_show_ui(gd_v_devman, ToFront, State),
|
||||
ok = gd_v_devman:open_contract(ConID),
|
||||
ok = gd_v_devman:call_result(ConID, Info),
|
||||
NewState.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user