WIP
This commit is contained in:
+18
-12
@@ -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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user