From a4db8d9a95c9d11790b355d5c94b5858b4f3508f Mon Sep 17 00:00:00 2001 From: Craig Everett Date: Tue, 7 Apr 2026 18:40:17 +0900 Subject: [PATCH] WIP --- src/gd_lib.erl | 2 +- src/gd_v_call.erl | 27 +++++++++++++++++---------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/gd_lib.erl b/src/gd_lib.erl index fffd704..f4ef441 100644 --- a/src/gd_lib.erl +++ b/src/gd_lib.erl @@ -54,7 +54,7 @@ mono_text(Parent, Name, Value) -> ok = case wxStaticText:setFont(Text, Font) of true -> ok; - false -> log(info, "wxStaticText ~p is already monospace.", [Text) + false -> tell(info, "wxStaticText ~p is already monospace.", [Text) end, #w{name = Name, id = wxStaticText:getId(Text), wx = Text}. diff --git a/src/gd_v_call.erl b/src/gd_v_call.erl index 53b273f..401e114 100644 --- a/src/gd_v_call.erl +++ b/src/gd_v_call.erl @@ -28,6 +28,7 @@ build = none :: none | map(), args = [] :: [#w{}], kp = #w{} :: #w{}, + params = [] :: [param()], ttl = #w{} :: #w{}, gasprice = #w{} :: #w{}, gas = #w{} :: #w{}, @@ -43,6 +44,7 @@ -type fun_name() :: string(). -type fun_type() :: call | dryr | init. -type fun_def() :: {fun_name(), fun_type()}. +-type param() :: {Label :: string(), Check :: fun(), #w{}}. %%% Interface @@ -247,7 +249,7 @@ handle_troubling(State = #s{frame = Frame}, Info) -> State. -engage(State = #s{j = J}) -> +engage(State) -> case gd_con:chain_id() of {ok, ChainID} -> engage(State, ChainID); Error -> handle_troubling(State, Error) @@ -285,23 +287,28 @@ params(State = #s{kp = #w{wx = KeyPicker}}) -> Error -> handle_troubling(State, Error) end. -params2(State, PK, Nonce) -> - Params = extract(State), params2(#s{ttl = #w{wx = TTL_T}, gasprice = #w{wx = GasPriceT}, gas = #w{wx = GasT}, amount = #w{wx = AmountT}}, PK, Nonce) -> - TTL = wxTextCtrl:getValue(TTL_T), - GasPrice = wxTextCtrl:getValue(GasPriceT), + ToExtract = + [{ttl, fun gte_0/1, TTL_T}, + {gasprice, fun gt_0/1, GasPriceT}, + {gas, fun gt_0/1, GasT}, + {amount, fun gt_0/1, AmountT}], + case lists:foldl(fun extract/2, {ok, []}, ToCheck) of + {ok, [TTL, GasPrice, Gas, Amount]} -> + {error, Out} -> + end. -extract(State) -> extract(State, {none, none, none, none}). +extract({Name, Check, Widget}, {Status, Out}) -> + case Check(wxTextCtrl:getValue(Widget)) of + {ok, Value} -> {Status, [Value | Out]}; + Error -> {error, [{Name, Error}, Out]} + end. -extract(State = #s{ttl = W}, {none, none, none, none}) -> -extract(State = #s{gasprice = W}, {TTL, none, none, none}) -> -extract(State = #s{gas = W}, {TTL, GP, none, none}) -> -extract(State = #s{amount = W}, {TTL, GP, Gas, none}) -> args(#s{args = ArgFields}) ->