Make Contract Calls Great Again

This commit is contained in:
2026-05-06 12:46:26 +09:00
parent 8b390f8d82
commit b071467faa
3 changed files with 110 additions and 59 deletions
+42 -2
View File
@@ -16,7 +16,7 @@
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,
deploy/1, prompt_call/3, list_calls/0, open_contract/1, show_call/2,
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]).
@@ -210,7 +210,7 @@ deploy(Build) ->
when FunDef :: {FunName, FunType},
FunName :: string(),
FunType :: call | dryr | init,
ConID :: none | binary(),
ConID :: none | string(),
Build :: map(). % Fixme
prompt_call(FunDef, ConID, Build) ->
@@ -229,6 +229,28 @@ list_calls() ->
gen_server:call(?MODULE, list_calls).
-spec open_contract(ConID) -> ok
when ConID :: string().
%% @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}).
-spec show_call(ConID, Info) -> ok
when ConID :: string(),
Info :: map().
%% @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}).
-spec make_key(Type, Size, Name, Seed, Encoding, Transform) -> ok
when Type :: {eddsa, ed25519},
Size :: 256,
@@ -499,6 +521,12 @@ 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),
{noreply, NewState};
handle_cast({show_call, ConID, Info}, State) ->
NewState = do_show_call(ConID, Info, State),
{noreply, NewState};
handle_cast({add_node, New}, State) ->
NewState = do_add_node(New, State),
{noreply, NewState};
@@ -991,6 +1019,18 @@ 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),
ok = gd_v_devman:open_contract(ConID),
NewState.
do_show_call(ConID, Info, State) ->
NewState = do_show_ui(gd_v_devman, State),
ok = gd_v_devman:call_result(ConID, Info),
NewState.
do_open_wallet(Path, Phrase, State = #s{timer = Timer}) ->
Pass = pass(Phrase),
case read(Path, Pass) of