Fix network ID check

This commit is contained in:
Craig Everett 2024-11-13 13:52:57 +09:00
parent 1d65097c54
commit b2c18021f4
2 changed files with 27 additions and 11 deletions

View File

@ -516,6 +516,8 @@ do_refresh2(ChainID, State = #s{wallet = W = #wallet{poas = POAs}}) ->
ensure_hz_set(Node = #node{ip = IP, external = Port}) -> ensure_hz_set(Node = #node{ip = IP, external = Port}) ->
case hz:chain_nodes() of
[{IP, Port}] ->
case hz:status() of case hz:status() of
{ok, #{"network_id" := ChainID}} -> {ok, #{"network_id" := ChainID}} ->
ok = hz:network_id(ChainID), ok = hz:network_id(ChainID),
@ -526,6 +528,10 @@ ensure_hz_set(Node = #node{ip = IP, external = Port}) ->
ensure_hz_set(Node); ensure_hz_set(Node);
Error -> Error ->
Error Error
end;
_ ->
ok = hz:chain_nodes([{IP, Port}]),
ensure_hz_set(Node)
end. end.
@ -1088,10 +1094,16 @@ read(Path, Pass) ->
read2(Bin) -> read2(Bin) ->
case zx_lib:b_to_t(Bin) of case zx_lib:b_to_t(Bin) of
{ok, T} -> {ok, T}; {ok, T} -> read3(T);
error -> {error, badarg} error -> {error, badarg}
end. end.
read3(T) ->
case element(2, T) of
1 -> {ok, T};
_ -> {error, bad_wallet}
end.
persist(Prefs) -> persist(Prefs) ->
Path = prefs_path(), Path = prefs_path(),

View File

@ -80,6 +80,11 @@ init({Prefs, Manifest}) ->
end, end,
Buttons = lists:map(MakeButton, ButtonTemplates), 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, AddButton = fun(#w{wx = B}) -> wxSizer:add(ButtSz, B, zxw:flags(wide)) end,
Notebook = wxNotebook:new(Frame, ?wxID_ANY, [{style, ?wxBK_DEFAULT}]), 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 true -> IP
end, end,
Elements = indexify([Address | stringify_ports([E, I, R, C, M])]), Elements = indexify([Address | stringify_ports([E, I, R, C, M])]),
tell("Elements: ~p", [Elements]),
_ = wxListCtrl:insertItem(List, Index, ""), _ = wxListCtrl:insertItem(List, Index, ""),
AddText = fun({K, L}) -> wxListCtrl:setItem(List, Index, K, L) end, AddText = fun({K, L}) -> wxListCtrl:setItem(List, Index, K, L) end,
lists:foreach(AddText, Elements) lists:foreach(AddText, Elements)