This commit is contained in:
2026-04-29 12:55:26 +09:00
parent 0a671e7c9c
commit d1ee4c6a24
4 changed files with 24 additions and 17 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
% Widgets
-record(w,
{name = none :: atom() | {FunName :: binary(), call | dryr},
{name = none :: string() | atom() | {FunName :: binary(), call | dryr},
id = 0 :: integer(),
wx = none :: none | wx:wx_object()}).
+3 -2
View File
@@ -158,7 +158,7 @@ spend(TX) ->
when ID :: binary().
chain_id() ->
gen_server:cast(?MODULE, chain_id).
gen_server:call(?MODULE, chain_id).
-spec grids(string()) -> ok.
@@ -866,7 +866,8 @@ 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, KeyIDs}),
Args = {CallPrefs, FunDef, ConID, Build, Selected, KeyIDs},
Win = gd_v_call:start_link(Args),
PID = wx_object:get_pid(Win),
Mon = monitor(process, PID),
UI = #ui{name = Name, pid = PID, wx = Win, mon = Mon},
+18 -12
View File
@@ -71,7 +71,7 @@ start_link(Args) ->
wx_object:start_link({local, ?MODULE}, ?MODULE, Args, []).
init({Prefs, {FunName, FunType}, ConID, Build, Selected, Keys}) ->
init({Prefs, FunDef = {FunName, FunType}, ConID, Build, Selected, Keys}) ->
Lang = maps:get(lang, Prefs, en),
Trans = gd_jt:read_translations(?MODULE),
J = gd_jt:j(Lang, Trans),
@@ -91,7 +91,9 @@ init({Prefs, {FunName, FunType}, ConID, Build, Selected, Keys}) ->
KeySz = wxStaticBoxSizer:new(?wxVERTICAL, Frame, [{label, J("Signature Key")}]),
KeyPicker = wxChoice:new(Frame, ?wxID_ANY, [{choices, Keys}]),
ok = wxChoice:setSelection(KeyPicker, Selected),
KP = #w{name = key_picker, id = wxChoice:getId(KeyPicker), wx = KeyPicker},
ZeroBasedSelected = Selected - 1,
ok = wxChoice:setSelection(KeyPicker, ZeroBasedSelected),
_ = wxStaticBoxSizer:add(KeySz, KeyPicker, zxw:flags(wide)),
{ArgSz, Args, Dimensions} = call_arg_sizer(Frame, J, FunSpec),
@@ -105,7 +107,7 @@ init({Prefs, {FunName, FunType}, ConID, Build, Selected, Keys}) ->
TX_Hash = #w{wx = HashT} = gd_lib:mono_text(TX_Sz_Box, tx_hash),
TX_Info = #w{wx = InfoT} = gd_lib:mono_text(TX_Sz_Box, tx_hash),
Line = wxStaticLine:new(TX_Sz_Box, [{style, ?wxLI_HORIZONTAL}]),
Out = #w{wx = OutTxt} = gd_lib:mono_text(TX_Sz_Box, out),
Out = #w{wx = OutTxt} = gd_lib:mono_text(TX_Sz_Box, out),
Copy = #w{wx = CopyBn} = gd_lib:button(TX_Sz_Box, J("Copy")),
_ = wxStaticBoxSizer:add(TX_Sz, DataT, zxw:flags({base, 5})),
@@ -128,12 +130,12 @@ init({Prefs, {FunName, FunType}, ConID, Build, Selected, Keys}) ->
ok = wxFrame:connect(Frame, command_button_clicked),
true = wxFrame:show(Frame),
State =
#s{wx = Wx, frame = Frame, j = J, prefs = Prefs,
con_id = ConID, build = Build,
args = Args, kp = KeyPicker, params = Params,
#s{wx = Wx, frame = Frame, j = J, prefs = Prefs,
fundef = FunDef, con_id = ConID, build = Build,
args = Args, kp = KP, params = Params,
action = Action,
tx_data = TX_Data, tx_hash = TX_Hash, tx_info = TX_Info,
out = Out, copy = Copy},
out = Out, copy = Copy},
{Frame, State}.
@@ -149,7 +151,7 @@ call_sizer(Frame, J, []) ->
CallSz = wxStaticBoxSizer:new(?wxVERTICAL, Frame, [{label, J("Call Args")}]),
Args = wxStaticText:new(Frame, ?wxID_ANY, ["[", J("No Args"), "]"]),
_ = wxStaticBoxSizer:add(CallSz, Args, zxw:flags({wide, 5})),
{CallSz, [], {500, 500}};
{CallSz, [], {500, 700}};
call_sizer(Frame, J, CallArgs) ->
ScrollWin = wxScrolledWindow:new(Frame),
ScrollSz = wxBoxSizer:new(?wxVERTICAL),
@@ -167,7 +169,7 @@ call_sizer(Frame, J, CallArgs) ->
C = wxTextCtrl:new(ScrollWin, ?wxID_ANY),
_ = wxFlexGridSizer:add(GridSz, L, zxw:flags({base, 5})),
_ = wxFlexGridSizer:add(GridSz, C, zxw:flags({wide, 5})),
{Name, C}
#w{name = Name, id = wxTextCtrl:getId(C), wx = C}
end,
Controls = lists:map(AddArg, CallArgs),
{CallSz, Controls, {500, 900}}.
@@ -215,7 +217,7 @@ call_param_sizer(Frame, J) ->
[{ "TTL", fun gte_0/1, TTL_T},
{J("Gas Price"), fun gt_0/1, GasP_T},
{J("Gas") , fun gt_0/1, Gas_T},
{J("TX Amount"), fun gt_0/1, Amount_T}],
{J("TX Amount"), fun gte_0/1, Amount_T}],
{ParamSz, Params}.
@@ -272,18 +274,21 @@ engage(State) ->
end.
engage2(State, ChainID) ->
tell(info, "ChainID: ~p", [ChainID]),
case params(State) of
{ok, Params} -> engage3(State, ChainID, Params);
Error -> handle_troubling(State, Error)
end.
engage3(State, ChainID, Params) ->
tell(info, "Params: ~p", [Params]),
case args(State) of
{ok, Args} -> engage4(State, ChainID, Params, {sophia, Args});
Error -> handle_troubling(State, Error)
end.
engage4(State = #s{fundef = {"init", init}, build = Build}, ChainID, Params, Args) ->
tell(info, "Args: ~p", [Args]),
{CallerID, Nonce, TTL, GP, Gas, Amount} = Params,
case hz:contract_create_built(CallerID, Nonce, Gas, GP, Amount, TTL, Build, Args) of
{ok, CreateTX} -> deploy(State, ChainID, CallerID, CreateTX);
@@ -332,7 +337,7 @@ args(#s{args = ArgFields}) ->
deploy(State, ChainID, CallerID, CreateTX) ->
case gd_con:sign_tx(ChainID, CallerID, CreateTX) of
case gd_con:sign_call(ChainID, CallerID, CreateTX) of
{ok, SignedTX} -> deploy2(State, SignedTX);
Error -> handle_troubling(State, Error)
end.
@@ -378,7 +383,8 @@ check_tx(State = #s{tx_data = #{"tx_hash" := TXHash} = TXData, tx_info = none})
Error ->
handle_troubling(State, Error)
end;
check_tx(State) ->
check_tx(State = #s{tx_data = TXData}) ->
tell(info, "TXData: ~p", [TXData]),
ok = tell("Nothing to check"),
State.
+2 -2
View File
@@ -798,8 +798,8 @@ load3(State = #s{tabs = TopBook, cons = {Consbook, Pages}, buttons = Buttons, j
_ = wxSizer:add(ConsSz, ConsTx, zxw:flags(wide)),
_ = wxSizer:add(ProgSz, CodeSz, [{proportion, 3}, {flag, ?wxEXPAND}]),
_ = wxSizer:add(ProgSz, ScrollWin, [{proportion, 1}, {flag, ?wxEXPAND}]),
_ = wxSizer:add(PageSz, ProgSz, [{proportion, 3}, {flag, ?wxEXPAND}]),
_ = wxSizer:add(PageSz, ConsSz, [{proportion, 1}, {flag, ?wxEXPAND}]),
_ = wxSizer:add(PageSz, ProgSz, [{proportion, 3}, {flag, ?wxEXPAND}]),
_ = wxSizer:add(PageSz, ConsSz, [{proportion, 1}, {flag, ?wxEXPAND}]),
{Out, IFaces, Build, NewButtons} =
case compile(Source) of
{ok, Output} ->