From b2c18021f41e841a18c37b383a11f0990b5dd9ac Mon Sep 17 00:00:00 2001 From: Craig Everett Date: Wed, 13 Nov 2024 13:52:57 +0900 Subject: [PATCH] Fix network ID check --- src/gmc_con.erl | 32 ++++++++++++++++++++++---------- src/gmc_v_netman.erl | 6 +++++- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/gmc_con.erl b/src/gmc_con.erl index 5e82258..17e0540 100644 --- a/src/gmc_con.erl +++ b/src/gmc_con.erl @@ -516,16 +516,22 @@ do_refresh2(ChainID, State = #s{wallet = W = #wallet{poas = POAs}}) -> ensure_hz_set(Node = #node{ip = IP, external = Port}) -> - case hz:status() of - {ok, #{"network_id" := ChainID}} -> - ok = hz:network_id(ChainID), - ok = gmc_gui:chain(ChainID, Node), - {ok, list_to_binary(ChainID)}; - {error, no_nodes} -> + case hz:chain_nodes() of + [{IP, Port}] -> + case hz:status() of + {ok, #{"network_id" := ChainID}} -> + ok = hz:network_id(ChainID), + ok = gmc_gui:chain(ChainID, Node), + {ok, list_to_binary(ChainID)}; + {error, no_nodes} -> + ok = hz:chain_nodes([{IP, Port}]), + ensure_hz_set(Node); + Error -> + Error + end; + _ -> ok = hz:chain_nodes([{IP, Port}]), - ensure_hz_set(Node); - Error -> - Error + ensure_hz_set(Node) end. @@ -1088,10 +1094,16 @@ read(Path, Pass) -> read2(Bin) -> case zx_lib:b_to_t(Bin) of - {ok, T} -> {ok, T}; + {ok, T} -> read3(T); error -> {error, badarg} end. +read3(T) -> + case element(2, T) of + 1 -> {ok, T}; + _ -> {error, bad_wallet} + end. + persist(Prefs) -> Path = prefs_path(), diff --git a/src/gmc_v_netman.erl b/src/gmc_v_netman.erl index 88f7d45..c2260bf 100644 --- a/src/gmc_v_netman.erl +++ b/src/gmc_v_netman.erl @@ -80,6 +80,11 @@ init({Prefs, Manifest}) -> end, Buttons = lists:map(MakeButton, ButtonTemplates), + + % FIXME + Disable = fun(#w{wx = B}) -> wxButton:disable(B) end, + ok = lists:foreach(Disable, Buttons), + AddButton = fun(#w{wx = B}) -> wxSizer:add(ButtSz, B, zxw:flags(wide)) end, Notebook = wxNotebook:new(Frame, ?wxID_ANY, [{style, ?wxBK_DEFAULT}]), @@ -147,7 +152,6 @@ draw_chain_panels(Page, J, [#chain{id = ID, coins = Coins, nodes = Nodes} | Rest true -> IP end, Elements = indexify([Address | stringify_ports([E, I, R, C, M])]), - tell("Elements: ~p", [Elements]), _ = wxListCtrl:insertItem(List, Index, ""), AddText = fun({K, L}) -> wxListCtrl:setItem(List, Index, K, L) end, lists:foreach(AddText, Elements)