This commit is contained in:
2026-04-28 14:15:28 +09:00
parent fadc252fb2
commit 24ce75f520
3 changed files with 34 additions and 68 deletions
+18 -24
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,
prompt_call/3,
deploy/1, prompt_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]).
@@ -158,7 +158,7 @@ spend(TX) ->
when ID :: binary().
chain_id() ->
gen_server:cast(?MODULE, {chain_id, ID}).
gen_server:cast(?MODULE, chain_id).
-spec grids(string()) -> ok.
@@ -192,28 +192,18 @@ sign_tx(Request) ->
when ChainID :: binary(),
PubKey :: gajudesk:id(),
TX :: binary(),
Result :: {ok, SignedTX :: binary()},
Result :: {ok, SignedTX :: binary()}
| {error, Reason :: term()}.
sign_call(ChainID, PubKey, TX) ->
gen_server:call(?MODULE, {sign_call, ChainID, PubKey, TX}).
-spec deploy(Build, Params, InitArgs) -> Result
when Build :: map(),
Params :: {PK :: gajudesk:id(),
Nonce :: non_neg_integer(),
TTL :: pos_integer(),
GasP :: pos_integer(),
Gas :: pos_integer(),
Amount :: pos_integer()},
InitArgs :: [Arg :: string()],
Result :: {ok, TX_Hash :: gajudesk:id()}
| {error, Reason},
Reason :: term(). % FIXME
-spec deploy(Build) -> ok
when Build :: map().
deploy(Build, Params, InitArgs) ->
gen_server:cast(?MODULE, {deploy, Build, Params, InitArgs}).
deploy(Build) ->
gen_server:cast(?MODULE, {deploy, Build}).
-spec prompt_call(FunDef, ConID, Build) -> ok
@@ -406,9 +396,9 @@ handle_call(list_keys, _, State) ->
handle_call({nonce, ID}, _, State) ->
Response = do_nonce(ID),
{reply, Response, State};
handle_call({chain_id, State) ->
handle_call(chain_id, _, State) ->
Response = do_chain_id(State),
{reply, Response, NewState};
{reply, Response, State};
handle_call({sign_call, ChainID, PubKey, TX}, _, State) ->
Response = do_sign_call(State, ChainID, PubKey, TX),
{reply, Response, State};
@@ -479,10 +469,10 @@ handle_cast({sign_binary, Request}, State) ->
handle_cast({sign_tx, Request}, State) ->
ok = do_sign_tx(Request, State),
{noreply, State};
handle_cast({deploy, Build, Params, InitArgs}, State) ->
ok = do_deploy(Build, Params, InitArgs, State),
handle_cast({deploy, Build}, State) ->
ok = do_deploy(Build, State),
{noreply, State};
handle_cast({prompt_call, FunDef, ConID, Build}) ->
handle_cast({prompt_call, FunDef, ConID, Build}, State) ->
NewState = do_prompt_call(FunDef, ConID, Build, State),
{noreply, NewState};
handle_cast({make_key, Name, Seed, Encoding, Transform}, State) ->
@@ -594,7 +584,7 @@ task_data(gd_v_devman, #s{}) ->
%%% Network operations
% NOTE: This is temporary. As GD becomes more chain aware this will move.
do_chain_id(#s{wallet = #wallet{chain_id = ChainID}) ->
do_chain_id(#s{wallet = #wallet{chain_id = ChainID}}) ->
{ok, ChainID};
do_chain_id(_) ->
{error, no_chain}.
@@ -862,6 +852,10 @@ do_network(#s{wallet = #wallet{chain_id = ChainID}}) ->
{ok, ChainID}.
do_deploy(Build, State) ->
do_prompt_call({"init", init}, none, Build, State).
do_prompt_call(FunDef, ConID, Build, State = #s{tasks = Tasks, prefs = Prefs}) ->
Name = {ConID, FunDef},
case do_list_keys(State) of
@@ -872,7 +866,7 @@ do_prompt_call(FunDef, ConID, Build, State = #s{tasks = Tasks, prefs = Prefs}) -
State;
false ->
CallPrefs = maps:get(gd_v_call, Prefs, #{}),
Win = gd_v_call:start_link({CallPrefs, FunDef, ConID, Build, Selected, Keys}),
Win = gd_v_call:start_link({CallPrefs, FunDef, ConID, Build, Selected, KeyIDs}),
PID = wx_object:get_pid(Win),
Mon = monitor(process, PID),
UI = #ui{name = Name, pid = PID, wx = Win, mon = Mon},