Compare commits
7 Commits
master
..
c7fbe0cb41
| Author | SHA1 | Date | |
|---|---|---|---|
| c7fbe0cb41 | |||
| 4737323875 | |||
| 355f50c2be | |||
| dc4b05c938 | |||
| 2f43d50dcb | |||
| ef4ca0907c | |||
| 138fe0697d |
+2
-3
@@ -3,8 +3,7 @@
|
|||||||
{registered,[]},
|
{registered,[]},
|
||||||
{included_applications,[]},
|
{included_applications,[]},
|
||||||
{applications,[stdlib,kernel,sasl,ssl]},
|
{applications,[stdlib,kernel,sasl,ssl]},
|
||||||
{vsn,"0.9.0"},
|
{vsn,"0.5.4"},
|
||||||
{modules,[gajudesk,gd_con,gd_grids,gd_gui,gd_jt,gd_lib,
|
{modules,[gajudesk,gd_con,gd_grids,gd_gui,gd_jt,gd_key_master,
|
||||||
gd_m_spend,gd_m_wallet_importer,gd_sophia_editor,
|
|
||||||
gd_sup,gd_v,gd_v_devman,gd_v_netman,gd_v_wallman]},
|
gd_sup,gd_v,gd_v_devman,gd_v_netman,gd_v_wallman]},
|
||||||
{mod,{gajudesk,[]}}]}.
|
{mod,{gajudesk,[]}}]}.
|
||||||
|
|||||||
+6
-6
@@ -1,7 +1,7 @@
|
|||||||
%% Node, Chain and Net represent the physical network.
|
%% Node, Chain and Net represent the physical network.
|
||||||
|
|
||||||
-record(node,
|
-record(node,
|
||||||
{ip = "groot.testnet.gajumaru.io" :: string() | inet:ip_address(),
|
{ip = {161,97,102,143} :: string() | inet:ip_address(),
|
||||||
external = 3013 :: none | inet:port_number(), % 3013
|
external = 3013 :: none | inet:port_number(), % 3013
|
||||||
internal = none :: none | inet:port_number(), % 3113
|
internal = none :: none | inet:port_number(), % 3113
|
||||||
rosetta = none :: none | inet:port_number(), % 8080
|
rosetta = none :: none | inet:port_number(), % 8080
|
||||||
@@ -10,13 +10,13 @@
|
|||||||
|
|
||||||
|
|
||||||
-record(chain,
|
-record(chain,
|
||||||
{id = <<"groot.testnet">> :: binary(),
|
{id = <<"groot.devnet">> :: binary(),
|
||||||
coins = ["gaju"] :: [string()],
|
coins = ["gaju"] :: [string()],
|
||||||
nodes = [#node{}] :: [#node{}]}).
|
nodes = [#node{}] :: [#node{}]}).
|
||||||
|
|
||||||
|
|
||||||
-record(net,
|
-record(net,
|
||||||
{id = <<"testnet">> :: binary(),
|
{id = <<"devnet">> :: binary(),
|
||||||
chains = [#chain{}] :: [#chain{}]}).
|
chains = [#chain{}] :: [#chain{}]}).
|
||||||
|
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
-record(coin,
|
-record(coin,
|
||||||
{id = "gaju" :: string(),
|
{id = "gaju" :: string(),
|
||||||
mint = <<"groot.testnet">> :: binary(),
|
mint = <<"groot.devnet">> :: binary(),
|
||||||
acs = [#ac{}] :: [#ac{}]}).
|
acs = [#ac{}] :: [#ac{}]}).
|
||||||
|
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
-record(balance,
|
-record(balance,
|
||||||
{coin = "gaju" :: string(),
|
{coin = "gaju" :: string(),
|
||||||
total = 0 :: non_neg_integer(),
|
total = 0 :: non_neg_integer(),
|
||||||
dist = [{<<"groot.testnet">>, 0}] :: [{Chain :: binary(), non_neg_integer()}]}).
|
dist = [{<<"groot.devnet">>, 0}] :: [{Chain :: binary(), non_neg_integer()}]}).
|
||||||
|
|
||||||
|
|
||||||
-record(poa,
|
-record(poa,
|
||||||
@@ -81,7 +81,7 @@
|
|||||||
name = "" :: string(),
|
name = "" :: string(),
|
||||||
poas = [] :: [#poa{}],
|
poas = [] :: [#poa{}],
|
||||||
keys = [] :: [#key{}],
|
keys = [] :: [#key{}],
|
||||||
chain_id = <<"groot.testnet">> :: binary(),
|
chain_id = <<"groot.devnet">> :: binary(),
|
||||||
endpoint = #node{} :: #node{},
|
endpoint = #node{} :: #node{},
|
||||||
nets = [#net{}] :: [#net{}],
|
nets = [#net{}] :: [#net{}],
|
||||||
txs = #{} :: gajudesk:key_txs()}).
|
txs = #{} :: gajudesk:key_txs()}).
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
% Widgets
|
|
||||||
-record(w,
|
|
||||||
{name = none :: string() | atom() | {FunName :: binary(), call | dryr},
|
|
||||||
id = 0 :: integer(),
|
|
||||||
wx = none :: none | wx:wx_object()}).
|
|
||||||
+4096
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(gajudesk).
|
-module(gajudesk).
|
||||||
-vsn("0.9.0").
|
-vsn("0.5.4").
|
||||||
-behavior(application).
|
-behavior(application).
|
||||||
-author("Craig Everett <craigeverett@qpq.swiss>").
|
-author("Craig Everett <craigeverett@qpq.swiss>").
|
||||||
-copyright("QPQ AG <info@qpq.swiss>").
|
-copyright("QPQ AG <info@qpq.swiss>").
|
||||||
|
|||||||
+275
-529
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -37,7 +37,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(gd_grids).
|
-module(gd_grids).
|
||||||
-vsn("0.9.0").
|
-vsn("0.5.4").
|
||||||
-author("Craig Everett <craigeverett@qpq.swiss>").
|
-author("Craig Everett <craigeverett@qpq.swiss>").
|
||||||
-copyright("QPQ AG <info@qpq.swiss>").
|
-copyright("QPQ AG <info@qpq.swiss>").
|
||||||
-license("GPL-3.0-or-later").
|
-license("GPL-3.0-or-later").
|
||||||
@@ -59,7 +59,7 @@
|
|||||||
Reason :: bad_url.
|
Reason :: bad_url.
|
||||||
|
|
||||||
parse(URL) ->
|
parse(URL) ->
|
||||||
case uri_string:parse(string:trim(URL)) of
|
case uri_string:parse(URL) of
|
||||||
#{path := "/1/s/" ++ R, host := H, query := Q, scheme := "grids"} ->
|
#{path := "/1/s/" ++ R, host := H, query := Q, scheme := "grids"} ->
|
||||||
spend(R, chain, list_to_binary(H), Q);
|
spend(R, chain, list_to_binary(H), Q);
|
||||||
#{path := "/1/s/" ++ R, host := H, query := Q, scheme := "grid"} ->
|
#{path := "/1/s/" ++ R, host := H, query := Q, scheme := "grid"} ->
|
||||||
|
|||||||
+235
-143
@@ -3,7 +3,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(gd_gui).
|
-module(gd_gui).
|
||||||
-vsn("0.9.0").
|
-vsn("0.5.4").
|
||||||
-author("Craig Everett <craigeverett@qpq.swiss>").
|
-author("Craig Everett <craigeverett@qpq.swiss>").
|
||||||
-copyright("QPQ AG <info@qpq.swiss>").
|
-copyright("QPQ AG <info@qpq.swiss>").
|
||||||
-license("GPL-3.0-or-later").
|
-license("GPL-3.0-or-later").
|
||||||
@@ -17,9 +17,13 @@
|
|||||||
handle_call/3, handle_cast/2, handle_info/2, handle_event/2]).
|
handle_call/3, handle_cast/2, handle_info/2, handle_event/2]).
|
||||||
-include("$zx_include/zx_logger.hrl").
|
-include("$zx_include/zx_logger.hrl").
|
||||||
-include("gd.hrl").
|
-include("gd.hrl").
|
||||||
-include("gdl.hrl").
|
|
||||||
|
|
||||||
|
|
||||||
|
-record(w,
|
||||||
|
{name = none :: atom(),
|
||||||
|
id = 0 :: integer(),
|
||||||
|
wx = none :: none | wx:wx_object()}).
|
||||||
|
|
||||||
-record(h,
|
-record(h,
|
||||||
{win = none :: none | wx:wx_object(),
|
{win = none :: none | wx:wx_object(),
|
||||||
sz = none :: none | wx:wx_object()}).
|
sz = none :: none | wx:wx_object()}).
|
||||||
@@ -28,13 +32,13 @@
|
|||||||
{wx = none :: none | wx:wx_object(),
|
{wx = none :: none | wx:wx_object(),
|
||||||
frame = none :: none | wx:wx_object(),
|
frame = none :: none | wx:wx_object(),
|
||||||
sizer = none :: none | wx:wx_object(),
|
sizer = none :: none | wx:wx_object(),
|
||||||
lang = en_US :: en_US | ja_JP,
|
lang = en :: en | jp,
|
||||||
j = none :: none | fun(),
|
j = none :: none | fun(),
|
||||||
prefs = #{} :: #{atom() := term()},
|
prefs = #{} :: #{atom() := term()},
|
||||||
accounts = [] :: [gajudesk:poa()],
|
accounts = [] :: [gajudesk:poa()],
|
||||||
picker = none :: none | wx:wx_object(),
|
picker = none :: none | wx:wx_object(),
|
||||||
id = {#w{}, #w{}} :: labeled(),
|
id = {#w{}, #w{}} :: labeled(),
|
||||||
balance = #w{} :: #w{},
|
balance = {#w{}, #w{}} :: labeled(),
|
||||||
buttons = [] :: [widget()],
|
buttons = [] :: [widget()],
|
||||||
history = #h{} :: #h{}}).
|
history = #h{} :: #h{}}).
|
||||||
|
|
||||||
@@ -80,32 +84,26 @@ start_link(Accounts) ->
|
|||||||
|
|
||||||
init(Prefs) ->
|
init(Prefs) ->
|
||||||
ok = log(info, "GUI starting..."),
|
ok = log(info, "GUI starting..."),
|
||||||
Lang = maps:get(lang, Prefs, en_US),
|
Lang = maps:get(lang, Prefs, en_us),
|
||||||
Trans = gd_jt:read_translations(?MODULE),
|
Trans = gd_jt:read_translations(?MODULE),
|
||||||
J = gd_jt:j(Lang, Trans),
|
J = gd_jt:j(Lang, Trans),
|
||||||
|
|
||||||
AppName = J("GajuDesk"),
|
|
||||||
VSN = proplists:get_value(vsn, ?MODULE:module_info(attributes)),
|
|
||||||
Wx = wx:new(),
|
Wx = wx:new(),
|
||||||
Frame = wxFrame:new(Wx, ?wxID_ANY, AppName ++ " v" ++ VSN),
|
Frame = wxFrame:new(Wx, ?wxID_ANY, J("GajuDesk")),
|
||||||
Panel = wxWindow:new(Frame, ?wxID_ANY),
|
|
||||||
TopSz = wxBoxSizer:new(?wxVERTICAL),
|
|
||||||
_ = wxBoxSizer:add(TopSz, Panel, zxw:flags(wide)),
|
|
||||||
MainSz = wxBoxSizer:new(?wxVERTICAL),
|
MainSz = wxBoxSizer:new(?wxVERTICAL),
|
||||||
Picker = wxListBox:new(Panel, ?wxID_ANY, [{style, ?wxLC_SINGLE_SEL}]),
|
Picker = wxListBox:new(Frame, ?wxID_ANY, [{style, ?wxLC_SINGLE_SEL}]),
|
||||||
|
|
||||||
WallB = wxButton:new(Panel, ?wxID_ANY, [{label, "[none]"}, {style, ?wxBORDER_NONE}]),
|
WallB = wxButton:new(Frame, ?wxID_ANY, [{label, "[none]"}, {style, ?wxBORDER_NONE}]),
|
||||||
WallW = #w{name = wallet, id = wxButton:getId(WallB), wx = WallB},
|
WallW = #w{name = wallet, id = wxButton:getId(WallB), wx = WallB},
|
||||||
ChainB = wxButton:new(Panel, ?wxID_ANY, [{label, "[ChainID]"}, {style, ?wxBORDER_NONE}]),
|
ChainB = wxButton:new(Frame, ?wxID_ANY, [{label, "[ChainID]"}, {style, ?wxBORDER_NONE}]),
|
||||||
_ = wxButton:disable(ChainB),
|
|
||||||
ChainW = #w{name = chain, id = wxButton:getId(ChainB), wx = ChainB},
|
ChainW = #w{name = chain, id = wxButton:getId(ChainB), wx = ChainB},
|
||||||
NodeB = wxButton:new(Panel, ?wxID_ANY, [{label, "[Node]"}, {style, ?wxBORDER_NONE}]),
|
NodeB = wxButton:new(Frame, ?wxID_ANY, [{label, "[Node]"}, {style, ?wxBORDER_NONE}]),
|
||||||
NodeW = #w{name = node, id = wxButton:getId(NodeB), wx = NodeB},
|
NodeW = #w{name = node, id = wxButton:getId(NodeB), wx = NodeB},
|
||||||
DevB = wxButton:new(Panel, ?wxID_ANY, [{label, "𝑓 () →"}]),
|
DevB = wxButton:new(Frame, ?wxID_ANY, [{label, "𝑓 () →"}]),
|
||||||
DevW = #w{name = dev, id = wxButton:getId(DevB), wx = DevB},
|
DevW = #w{name = dev, id = wxButton:getId(DevB), wx = DevB},
|
||||||
|
|
||||||
ID_L = wxStaticText:new(Panel, ?wxID_ANY, J("Account ID: ")),
|
ID_L = wxStaticText:new(Frame, ?wxID_ANY, J("Account ID: ")),
|
||||||
ID_T = wxStaticText:new(Panel, ?wxID_ANY, ""),
|
ID_T = wxStaticText:new(Frame, ?wxID_ANY, ""),
|
||||||
ID_W =
|
ID_W =
|
||||||
{#w{id = wxStaticText:getId(ID_L), wx = ID_L},
|
{#w{id = wxStaticText:getId(ID_L), wx = ID_L},
|
||||||
#w{id = wxStaticText:getId(ID_T), wx = ID_T}},
|
#w{id = wxStaticText:getId(ID_T), wx = ID_T}},
|
||||||
@@ -113,9 +111,13 @@ init(Prefs) ->
|
|||||||
_ = wxSizer:add(ID_Sz, ID_L, zxw:flags(base)),
|
_ = wxSizer:add(ID_Sz, ID_L, zxw:flags(base)),
|
||||||
_ = wxSizer:add(ID_Sz, ID_T, zxw:flags(wide)),
|
_ = wxSizer:add(ID_Sz, ID_T, zxw:flags(wide)),
|
||||||
|
|
||||||
BalanceT = wxStaticText:new(Panel, ?wxID_ANY, hz_format:amount(0)),
|
BalanceL = wxStaticText:new(Frame, ?wxID_ANY, "木"),
|
||||||
Balance = #w{id = wxStaticText:getId(BalanceT), wx = BalanceT},
|
BalanceT = wxStaticText:new(Frame, ?wxID_ANY, price_to_string(0)),
|
||||||
|
Balance =
|
||||||
|
{#w{id = wxStaticText:getId(BalanceL), wx = BalanceL},
|
||||||
|
#w{id = wxStaticText:getId(BalanceT), wx = BalanceT}},
|
||||||
BalanceSz = wxBoxSizer:new(?wxHORIZONTAL),
|
BalanceSz = wxBoxSizer:new(?wxHORIZONTAL),
|
||||||
|
_ = wxSizer:add(BalanceSz, BalanceL, zxw:flags(base)),
|
||||||
_ = wxSizer:add(BalanceSz, BalanceT, zxw:flags(wide)),
|
_ = wxSizer:add(BalanceSz, BalanceT, zxw:flags(wide)),
|
||||||
|
|
||||||
NumbersSz = wxBoxSizer:new(?wxVERTICAL),
|
NumbersSz = wxBoxSizer:new(?wxVERTICAL),
|
||||||
@@ -129,7 +131,7 @@ init(Prefs) ->
|
|||||||
{rename, J("Rename")},
|
{rename, J("Rename")},
|
||||||
{drop_key, J("Delete")},
|
{drop_key, J("Delete")},
|
||||||
{send, J("Send Money")},
|
{send, J("Send Money")},
|
||||||
% {recv, J("Receive Money")},
|
{recv, J("Receive Money")},
|
||||||
{grids, J("GRIDS URL")},
|
{grids, J("GRIDS URL")},
|
||||||
{copy, J("Copy")},
|
{copy, J("Copy")},
|
||||||
{www, J("WWW")},
|
{www, J("WWW")},
|
||||||
@@ -137,17 +139,11 @@ init(Prefs) ->
|
|||||||
|
|
||||||
MakeButton =
|
MakeButton =
|
||||||
fun({Name, Label}) ->
|
fun({Name, Label}) ->
|
||||||
B = wxButton:new(Panel, ?wxID_ANY, [{label, Label}]),
|
B = wxButton:new(Frame, ?wxID_ANY, [{label, Label}]),
|
||||||
#w{name = Name, id = wxButton:getId(B), wx = B}
|
#w{name = Name, id = wxButton:getId(B), wx = B}
|
||||||
end,
|
end,
|
||||||
|
|
||||||
Buttons = [WallW, ChainW, NodeW, DevW | lists:map(MakeButton, ButtonTemplates)],
|
Buttons = [WallW, ChainW, NodeW, DevW | lists:map(MakeButton, ButtonTemplates)],
|
||||||
Disable =
|
|
||||||
fun(Button) ->
|
|
||||||
#w{wx = W} = lists:keyfind(Button, #w.name, Buttons),
|
|
||||||
wxButton:disable(W)
|
|
||||||
end,
|
|
||||||
ok = lists:foreach(Disable, key_buttons()),
|
|
||||||
|
|
||||||
ChainSz = wxBoxSizer:new(?wxHORIZONTAL),
|
ChainSz = wxBoxSizer:new(?wxHORIZONTAL),
|
||||||
AccountSz = wxBoxSizer:new(?wxHORIZONTAL),
|
AccountSz = wxBoxSizer:new(?wxHORIZONTAL),
|
||||||
@@ -177,18 +173,18 @@ init(Prefs) ->
|
|||||||
_ = wxSizer:add(AccountSz, DropBn, zxw:flags(wide)),
|
_ = wxSizer:add(AccountSz, DropBn, zxw:flags(wide)),
|
||||||
|
|
||||||
#w{wx = SendBn} = lists:keyfind(send, #w.name, Buttons),
|
#w{wx = SendBn} = lists:keyfind(send, #w.name, Buttons),
|
||||||
% #w{wx = RecvBn} = lists:keyfind(recv, #w.name, Buttons),
|
#w{wx = RecvBn} = lists:keyfind(recv, #w.name, Buttons),
|
||||||
#w{wx = GridsBn} = lists:keyfind(grids, #w.name, Buttons),
|
#w{wx = GridsBn} = lists:keyfind(grids, #w.name, Buttons),
|
||||||
_ = wxSizer:add(ActionsSz, SendBn, zxw:flags(wide)),
|
_ = wxSizer:add(ActionsSz, SendBn, zxw:flags(wide)),
|
||||||
% _ = wxSizer:add(ActionsSz, RecvBn, zxw:flags(wide)),
|
_ = wxSizer:add(ActionsSz, RecvBn, zxw:flags(wide)),
|
||||||
_ = wxSizer:add(ActionsSz, GridsBn, zxw:flags(wide)),
|
_ = wxSizer:add(ActionsSz, GridsBn, zxw:flags(wide)),
|
||||||
|
|
||||||
#w{wx = Refresh} = lists:keyfind(refresh, #w.name, Buttons),
|
#w{wx = Refresh} = lists:keyfind(refresh, #w.name, Buttons),
|
||||||
|
|
||||||
% HistoryWin = wxScrolledWindow:new(Panel),
|
HistoryWin = wxScrolledWindow:new(Frame),
|
||||||
% HistorySz = wxBoxSizer:new(?wxVERTICAL),
|
HistorySz = wxBoxSizer:new(?wxVERTICAL),
|
||||||
% ok = wxScrolledWindow:setSizerAndFit(HistoryWin, HistorySz),
|
ok = wxScrolledWindow:setSizerAndFit(HistoryWin, HistorySz),
|
||||||
% ok = wxScrolledWindow:setScrollRate(HistoryWin, 5, 5),
|
ok = wxScrolledWindow:setScrollRate(HistoryWin, 5, 5),
|
||||||
|
|
||||||
_ = wxSizer:add(MainSz, ChainSz, zxw:flags(base)),
|
_ = wxSizer:add(MainSz, ChainSz, zxw:flags(base)),
|
||||||
_ = wxSizer:add(MainSz, AccountSz, zxw:flags(base)),
|
_ = wxSizer:add(MainSz, AccountSz, zxw:flags(base)),
|
||||||
@@ -196,9 +192,8 @@ init(Prefs) ->
|
|||||||
_ = wxSizer:add(MainSz, DetailsSz, zxw:flags(base)),
|
_ = wxSizer:add(MainSz, DetailsSz, zxw:flags(base)),
|
||||||
_ = wxSizer:add(MainSz, ActionsSz, zxw:flags(base)),
|
_ = wxSizer:add(MainSz, ActionsSz, zxw:flags(base)),
|
||||||
_ = wxSizer:add(MainSz, Refresh, zxw:flags(base)),
|
_ = wxSizer:add(MainSz, Refresh, zxw:flags(base)),
|
||||||
% _ = wxSizer:add(MainSz, HistoryWin, zxw:flags(wide)),
|
_ = wxSizer:add(MainSz, HistoryWin, zxw:flags(wide)),
|
||||||
ok = wxWindow:setSizer(Panel, MainSz),
|
ok = wxFrame:setSizer(Frame, MainSz),
|
||||||
ok = wxFrame:setSizer(Frame, TopSz),
|
|
||||||
ok = wxSizer:layout(MainSz),
|
ok = wxSizer:layout(MainSz),
|
||||||
|
|
||||||
ok = gd_v:safe_size(Frame, Prefs),
|
ok = gd_v:safe_size(Frame, Prefs),
|
||||||
@@ -212,8 +207,8 @@ init(Prefs) ->
|
|||||||
picker = Picker,
|
picker = Picker,
|
||||||
id = ID_W,
|
id = ID_W,
|
||||||
balance = Balance,
|
balance = Balance,
|
||||||
buttons = Buttons},
|
buttons = Buttons,
|
||||||
% history = #h{win = HistoryWin, sz = HistorySz}},
|
history = #h{win = HistoryWin, sz = HistorySz}},
|
||||||
{Frame, State}.
|
{Frame, State}.
|
||||||
|
|
||||||
|
|
||||||
@@ -298,7 +293,7 @@ handle_event(#wx{event = #wxCommand{type = command_button_clicked},
|
|||||||
#w{name = mnemonic} -> show_mnemonic(State);
|
#w{name = mnemonic} -> show_mnemonic(State);
|
||||||
#w{name = rename} -> rename_key(State);
|
#w{name = rename} -> rename_key(State);
|
||||||
#w{name = drop_key} -> drop_key(State);
|
#w{name = drop_key} -> drop_key(State);
|
||||||
#w{name = copy} -> copy_pk(State);
|
#w{name = copy} -> copy(State);
|
||||||
#w{name = www} -> www(State);
|
#w{name = www} -> www(State);
|
||||||
#w{name = send} -> spend(State);
|
#w{name = send} -> spend(State);
|
||||||
#w{name = grids} -> grids_dialogue(State);
|
#w{name = grids} -> grids_dialogue(State);
|
||||||
@@ -333,7 +328,6 @@ handle_event(Event, State) ->
|
|||||||
|
|
||||||
|
|
||||||
handle_troubling(#s{frame = Frame}, Info) ->
|
handle_troubling(#s{frame = Frame}, Info) ->
|
||||||
ok = wxFrame:raise(Frame),
|
|
||||||
zxw:show_message(Frame, Info).
|
zxw:show_message(Frame, Info).
|
||||||
|
|
||||||
|
|
||||||
@@ -358,7 +352,6 @@ refresh(State) ->
|
|||||||
|
|
||||||
wallman(State) ->
|
wallman(State) ->
|
||||||
ok = gd_con:show_ui(gd_v_wallman),
|
ok = gd_con:show_ui(gd_v_wallman),
|
||||||
ok = gd_v_wallman:to_front(),
|
|
||||||
State.
|
State.
|
||||||
|
|
||||||
|
|
||||||
@@ -588,7 +581,7 @@ show_mnemonic(Selected, State = #s{frame = Frame, j = J, accounts = Accounts}) -
|
|||||||
ok =
|
ok =
|
||||||
case wxDialog:showModal(Dialog) of
|
case wxDialog:showModal(Dialog) of
|
||||||
?wxID_CANCEL -> ok;
|
?wxID_CANCEL -> ok;
|
||||||
?wxID_OK -> gd_lib:copy_to_clipboard(Mnemonic)
|
?wxID_OK -> copy_to_clipboard(Mnemonic)
|
||||||
end,
|
end,
|
||||||
ok = wxDialog:destroy(Dialog),
|
ok = wxDialog:destroy(Dialog),
|
||||||
State.
|
State.
|
||||||
@@ -604,15 +597,33 @@ rename_key(State = #s{picker = Picker}) ->
|
|||||||
|
|
||||||
rename_key(Selected, State = #s{frame = Frame, j = J, accounts = Accounts}) ->
|
rename_key(Selected, State = #s{frame = Frame, j = J, accounts = Accounts}) ->
|
||||||
#poa{id = ID, name = Name} = lists:nth(Selected, Accounts),
|
#poa{id = ID, name = Name} = lists:nth(Selected, Accounts),
|
||||||
Title = J("Rename Key"),
|
Dialog = wxDialog:new(Frame, ?wxID_ANY, J("New Key")),
|
||||||
Label = J("New Name"),
|
Sizer = wxBoxSizer:new(?wxVERTICAL),
|
||||||
Options = [{label, Label}, {init, Name}, selected, empty],
|
NameSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, J("Name (Optional)")}]),
|
||||||
|
NameTx = wxTextCtrl:new(Dialog, ?wxID_ANY),
|
||||||
|
ok = wxTextCtrl:setValue(NameTx, Name),
|
||||||
|
_ = wxStaticBoxSizer:add(NameSz, NameTx, zxw:flags(base)),
|
||||||
|
ButtSz = wxBoxSizer:new(?wxHORIZONTAL),
|
||||||
|
Affirm = wxButton:new(Dialog, ?wxID_OK),
|
||||||
|
Cancel = wxButton:new(Dialog, ?wxID_CANCEL),
|
||||||
|
_ = wxBoxSizer:add(ButtSz, Affirm, zxw:flags(wide)),
|
||||||
|
_ = wxBoxSizer:add(ButtSz, Cancel, zxw:flags(wide)),
|
||||||
|
_ = wxBoxSizer:add(Sizer, NameSz, zxw:flags(base)),
|
||||||
|
_ = wxBoxSizer:add(Sizer, ButtSz, zxw:flags(wide)),
|
||||||
|
ok = wxDialog:setSizer(Dialog, Sizer),
|
||||||
|
ok = wxBoxSizer:layout(Sizer),
|
||||||
|
ok = wxDialog:setSize(Dialog, {500, 130}),
|
||||||
|
ok = wxDialog:center(Dialog),
|
||||||
|
ok = wxStyledTextCtrl:setFocus(NameTx),
|
||||||
ok =
|
ok =
|
||||||
case zxw_modal_text:show(Frame, Title, Options) of
|
case wxDialog:showModal(Dialog) of
|
||||||
{ok, ""} -> gd_con:rename_key(ID, binary_to_list(ID));
|
?wxID_OK ->
|
||||||
{ok, NewName} -> gd_con:rename_key(ID, NewName);
|
NewName = wxTextCtrl:getValue(NameTx),
|
||||||
cancel -> ok
|
gd_con:rename_key(ID, NewName);
|
||||||
|
?wxID_CANCEL ->
|
||||||
|
ok
|
||||||
end,
|
end,
|
||||||
|
ok = wxDialog:destroy(Dialog),
|
||||||
State.
|
State.
|
||||||
|
|
||||||
|
|
||||||
@@ -656,33 +667,38 @@ drop_key(Selected, State = #s{frame = Frame, j = J, accounts = Accounts, prefs =
|
|||||||
State#s{prefs = NewPrefs}.
|
State#s{prefs = NewPrefs}.
|
||||||
|
|
||||||
|
|
||||||
copy_pk(State = #s{id = {_, #w{wx = ID_T}}}) ->
|
copy(State = #s{id = {_, #w{wx = ID_T}}}) ->
|
||||||
String = wxStaticText:getLabel(ID_T),
|
String = wxStaticText:getLabel(ID_T),
|
||||||
ok = gd_lib:copy_to_clipboard(String),
|
ok = copy_to_clipboard(String),
|
||||||
State.
|
State.
|
||||||
|
|
||||||
|
copy_to_clipboard(String) ->
|
||||||
www(State = #s{id = {_, #w{wx = ID_T}}, j = J}) ->
|
CB = wxClipboard:get(),
|
||||||
case wxStaticText:getLabel(ID_T) of
|
case wxClipboard:open(CB) of
|
||||||
"" ->
|
true ->
|
||||||
ok = handle_troubling(State, J("No key selected.")),
|
Text = wxTextDataObject:new([{text, String}]),
|
||||||
State;
|
case wxClipboard:setData(CB, Text) of
|
||||||
ID ->
|
true ->
|
||||||
ok = www2(State, ID),
|
R = wxClipboard:flush(CB),
|
||||||
State
|
log(info, "String copied to system clipboard. Flushed: ~p", [R]);
|
||||||
|
false ->
|
||||||
|
log(info, "Failed to copy to clipboard")
|
||||||
|
end,
|
||||||
|
ok = wxClipboard:close(CB);
|
||||||
|
false ->
|
||||||
|
log(info, "Failed to acquire the clipboard.")
|
||||||
end.
|
end.
|
||||||
|
|
||||||
www2(State = #s{j = J}, AccountID) ->
|
|
||||||
case gd_con:network() of
|
www(State = #s{id = {_, #w{wx = ID_T}}}) ->
|
||||||
{ok, ChainID} ->
|
String = wxStaticText:getLabel(ID_T),
|
||||||
URL = unicode:characters_to_list(["https://", ChainID, ".gajumaru.io/account/", AccountID]),
|
URL = unicode:characters_to_list(["https://aescan.io/accounts/", String]),
|
||||||
|
ok =
|
||||||
case wx_misc:launchDefaultBrowser(URL) of
|
case wx_misc:launchDefaultBrowser(URL) of
|
||||||
true -> log(info, "Opened in browser: ~ts", [URL]);
|
true -> log(info, "Opened in browser: ~ts", [URL]);
|
||||||
false -> log(info, "Failed to open browser: ~ts", [URL])
|
false -> log(info, "Failed to open browser: ~ts", [URL])
|
||||||
end;
|
end,
|
||||||
none ->
|
State.
|
||||||
handle_troubling(State, J("No chain assigned."))
|
|
||||||
end.
|
|
||||||
|
|
||||||
|
|
||||||
spend(State = #s{accounts = []}) ->
|
spend(State = #s{accounts = []}) ->
|
||||||
@@ -705,29 +721,129 @@ spend(Selected, State = #s{accounts = Accounts}) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
spend2(#poa{id = ID, name = Name}, Nonce, Height, State = #s{frame = Frame, j = J}) ->
|
spend2(#poa{id = ID, name = Name}, Nonce, Height, State = #s{frame = Frame, j = J}) ->
|
||||||
|
Dialog = wxDialog:new(Frame, ?wxID_ANY, J("Transfer"), [{size, {500, 400}}]),
|
||||||
|
Sizer = wxBoxSizer:new(?wxVERTICAL),
|
||||||
|
|
||||||
Account = [Name, " (", ID, ")"],
|
Account = [Name, " (", ID, ")"],
|
||||||
Args = {Account, J},
|
FromTx = wxStaticText:new(Dialog, ?wxID_ANY, Account),
|
||||||
|
FromSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, J("From")}]),
|
||||||
|
_ = wxStaticBoxSizer:add(FromSz, FromTx, zxw:flags(wide)),
|
||||||
|
|
||||||
|
ToTx = wxTextCtrl:new(Dialog, ?wxID_ANY),
|
||||||
|
ToSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, J("To")}]),
|
||||||
|
_ = wxStaticBoxSizer:add(ToSz, ToTx, zxw:flags(wide)),
|
||||||
|
|
||||||
|
AmtTx = wxTextCtrl:new(Dialog, ?wxID_ANY),
|
||||||
|
AmtSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, J("Amount")}]),
|
||||||
|
_ = wxStaticBoxSizer:add(AmtSz, AmtTx, zxw:flags(wide)),
|
||||||
|
|
||||||
|
DataTx = wxTextCtrl:new(Dialog, ?wxID_ANY, [{style, ?wxTE_MULTILINE}]),
|
||||||
|
DataSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, J("Message (optional)")}]),
|
||||||
|
_ = wxStaticBoxSizer:add(DataSz, DataTx, zxw:flags(wide)),
|
||||||
|
|
||||||
|
Style = [{style, ?wxSL_HORIZONTAL bor ?wxSL_LABELS}],
|
||||||
|
|
||||||
|
TTL_Sl = wxSlider:new(Dialog, ?wxID_ANY, 100, 10, 1000, Style),
|
||||||
|
TTL_Sz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, J("TTL")}]),
|
||||||
|
_ = wxStaticBoxSizer:add(TTL_Sz, TTL_Sl, zxw:flags(wide)),
|
||||||
|
|
||||||
|
Min = hz:min_gas_price(),
|
||||||
|
Max = Min * 2,
|
||||||
|
GasSl = wxSlider:new(Dialog, ?wxID_ANY, Min, Min, Max, Style),
|
||||||
|
GasSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, J("Gas Price")}]),
|
||||||
|
_ = wxStaticBoxSizer:add(GasSz, GasSl, zxw:flags(wide)),
|
||||||
|
|
||||||
|
ButtSz = wxBoxSizer:new(?wxHORIZONTAL),
|
||||||
|
Affirm = wxButton:new(Dialog, ?wxID_OK),
|
||||||
|
Cancel = wxButton:new(Dialog, ?wxID_CANCEL),
|
||||||
|
_ = wxBoxSizer:add(ButtSz, Affirm, zxw:flags(wide)),
|
||||||
|
_ = wxBoxSizer:add(ButtSz, Cancel, zxw:flags(wide)),
|
||||||
|
|
||||||
|
_ = wxBoxSizer:add(Sizer, FromSz, zxw:flags(base)),
|
||||||
|
_ = wxBoxSizer:add(Sizer, ToSz, zxw:flags(base)),
|
||||||
|
_ = wxBoxSizer:add(Sizer, AmtSz, zxw:flags(base)),
|
||||||
|
_ = wxBoxSizer:add(Sizer, DataSz, zxw:flags(wide)),
|
||||||
|
_ = wxBoxSizer:add(Sizer, TTL_Sz, zxw:flags(wide)),
|
||||||
|
_ = wxBoxSizer:add(Sizer, GasSz, zxw:flags(base)),
|
||||||
|
_ = wxBoxSizer:add(Sizer, ButtSz, zxw:flags(base)),
|
||||||
|
ok = wxDialog:setSizer(Dialog, Sizer),
|
||||||
|
ok = wxBoxSizer:layout(Sizer),
|
||||||
|
ok = wxFrame:setSize(Dialog, {500, 450}),
|
||||||
|
ok = wxFrame:center(Dialog),
|
||||||
ok =
|
ok =
|
||||||
case gd_m_spend:show(Frame, Args) of
|
case wxDialog:showModal(Dialog) of
|
||||||
{ok, Partial = #spend_tx{ttl = TTL}} ->
|
?wxID_OK ->
|
||||||
TX =
|
TX =
|
||||||
Partial#spend_tx{sender_id = ID,
|
#spend_tx{sender_id = ID,
|
||||||
|
recipient_id = wxTextCtrl:getValue(ToTx),
|
||||||
|
amount = wxTextCtrl:getValue(AmtTx),
|
||||||
|
gas_price = wxSlider:getValue(GasSl),
|
||||||
gas = 20000,
|
gas = 20000,
|
||||||
ttl = Height + TTL,
|
ttl = Height + wxSlider:getValue(TTL_Sl),
|
||||||
nonce = Nonce},
|
nonce = Nonce,
|
||||||
gd_con:spend(TX);
|
payload = wxTextCtrl:getValue(DataTx)},
|
||||||
cancel ->
|
clean_spend(TX);
|
||||||
|
?wxID_CANCEL ->
|
||||||
ok
|
ok
|
||||||
end,
|
end,
|
||||||
|
ok = wxDialog:destroy(Dialog),
|
||||||
State.
|
State.
|
||||||
|
|
||||||
|
clean_spend(#spend_tx{recipient_id = ""}) ->
|
||||||
|
ok;
|
||||||
|
clean_spend( TX = #spend_tx{amount = S}) when is_list(S) ->
|
||||||
|
case string_to_price(S) of
|
||||||
|
{ok, Amount} -> clean_spend(TX#spend_tx{amount = Amount});
|
||||||
|
{error, _} -> ok
|
||||||
|
end;
|
||||||
|
clean_spend(TX = #spend_tx{gas_price = S}) when is_list(S) ->
|
||||||
|
case is_int(S) of
|
||||||
|
true -> clean_spend(TX#spend_tx{gas_price = list_to_integer(S)});
|
||||||
|
false -> ok
|
||||||
|
end;
|
||||||
|
clean_spend(TX = #spend_tx{gas = S}) when is_list(S) ->
|
||||||
|
case is_int(S) of
|
||||||
|
true -> clean_spend(TX#spend_tx{gas = list_to_integer(S)});
|
||||||
|
false -> ok
|
||||||
|
end;
|
||||||
|
clean_spend(TX = #spend_tx{payload = S}) when is_list(S) ->
|
||||||
|
clean_spend(TX#spend_tx{payload = list_to_binary(S)});
|
||||||
|
clean_spend(TX) ->
|
||||||
|
gd_con:spend(TX).
|
||||||
|
|
||||||
|
|
||||||
|
is_int(S) ->
|
||||||
|
lists:all(fun(C) -> $0 =< C andalso C =< $9 end, S).
|
||||||
|
|
||||||
|
|
||||||
grids_dialogue(State = #s{frame = Frame, j = J}) ->
|
grids_dialogue(State = #s{frame = Frame, j = J}) ->
|
||||||
Title = J("GRIDS URL"),
|
Dialog = wxDialog:new(Frame, ?wxID_ANY, J("GRIDS URL")),
|
||||||
|
Sizer = wxBoxSizer:new(?wxVERTICAL),
|
||||||
|
Label = J("GRIDS URL"),
|
||||||
|
URL_Sz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, J(Label)}]),
|
||||||
|
URL_Tx = wxTextCtrl:new(Dialog, ?wxID_ANY),
|
||||||
|
_ = wxStaticBoxSizer:add(URL_Sz, URL_Tx, zxw:flags(wide)),
|
||||||
|
ButtSz = wxBoxSizer:new(?wxHORIZONTAL),
|
||||||
|
Affirm = wxButton:new(Dialog, ?wxID_OK),
|
||||||
|
Cancel = wxButton:new(Dialog, ?wxID_CANCEL),
|
||||||
|
_ = wxBoxSizer:add(ButtSz, Affirm, zxw:flags(wide)),
|
||||||
|
_ = wxBoxSizer:add(ButtSz, Cancel, zxw:flags(wide)),
|
||||||
|
_ = wxBoxSizer:add(Sizer, URL_Sz, zxw:flags(base)),
|
||||||
|
_ = wxBoxSizer:add(Sizer, ButtSz, zxw:flags(wide)),
|
||||||
|
ok = wxDialog:setSizer(Dialog, Sizer),
|
||||||
|
ok = wxBoxSizer:layout(Sizer),
|
||||||
|
ok = wxDialog:setSize(Dialog, {500, 130}),
|
||||||
|
ok = wxDialog:center(Dialog),
|
||||||
|
ok = wxStyledTextCtrl:setFocus(URL_Tx),
|
||||||
ok =
|
ok =
|
||||||
case zxw_modal_text:show(Frame, Title) of
|
case wxDialog:showModal(Dialog) of
|
||||||
{ok, String} -> gd_con:grids(String);
|
?wxID_OK ->
|
||||||
cancel -> ok
|
case wxTextCtrl:getValue(URL_Tx) of
|
||||||
|
"" -> ok;
|
||||||
|
String -> gd_con:grids(String)
|
||||||
|
end;
|
||||||
|
?wxID_CANCEL ->
|
||||||
|
ok
|
||||||
end,
|
end,
|
||||||
State.
|
State.
|
||||||
|
|
||||||
@@ -740,13 +856,13 @@ handle_button(Name, State) ->
|
|||||||
|
|
||||||
do_selection(Selected,
|
do_selection(Selected,
|
||||||
State = #s{prefs = Prefs, accounts = Accounts,
|
State = #s{prefs = Prefs, accounts = Accounts,
|
||||||
balance = #w{wx = B}, id = {_, #w{wx = I}}})
|
balance = {_, #w{wx = B}}, id = {_, #w{wx = I}}})
|
||||||
when Selected < length(Accounts) ->
|
when Selected < length(Accounts) ->
|
||||||
OneBasedIndex = Selected + 1,
|
OneBasedIndex = Selected + 1,
|
||||||
#poa{id = ID, balances = Balances} = lists:nth(OneBasedIndex, Accounts),
|
#poa{id = ID, balances = Balances} = lists:nth(OneBasedIndex, Accounts),
|
||||||
[#balance{total = Pucks}] = Balances,
|
[#balance{total = Pucks}] = Balances,
|
||||||
ok = wxStaticText:setLabel(I, ID),
|
ok = wxStaticText:setLabel(I, ID),
|
||||||
ok = wxStaticText:setLabel(B, hz_format:amount(Pucks)),
|
ok = wxStaticText:setLabel(B, price_to_string(Pucks)),
|
||||||
ok = gd_con:selected(OneBasedIndex),
|
ok = gd_con:selected(OneBasedIndex),
|
||||||
NewPrefs = maps:put(selected, Selected, Prefs),
|
NewPrefs = maps:put(selected, Selected, Prefs),
|
||||||
State#s{prefs = NewPrefs};
|
State#s{prefs = NewPrefs};
|
||||||
@@ -773,7 +889,7 @@ do_show(Accounts, State = #s{sizer = Sizer, prefs = Prefs, picker = Picker}) ->
|
|||||||
ok = wxSizer:layout(Sizer),
|
ok = wxSizer:layout(Sizer),
|
||||||
NewState.
|
NewState.
|
||||||
|
|
||||||
clear_account(State = #s{balance = #w{wx = B}, id = {_, #w{wx = I}}}) ->
|
clear_account(State = #s{balance = {_, #w{wx = B}}, id = {_, #w{wx = I}}}) ->
|
||||||
ok = wxStaticText:setLabel(I, ""),
|
ok = wxStaticText:setLabel(I, ""),
|
||||||
ok = wxStaticText:setLabel(B, ""),
|
ok = wxStaticText:setLabel(B, ""),
|
||||||
State.
|
State.
|
||||||
@@ -781,28 +897,12 @@ clear_account(State = #s{balance = #w{wx = B}, id = {_, #w{wx = I}}}) ->
|
|||||||
|
|
||||||
do_wallet(none, #s{buttons = Buttons}) ->
|
do_wallet(none, #s{buttons = Buttons}) ->
|
||||||
#w{wx = WalletB} = lists:keyfind(wallet, #w.name, Buttons),
|
#w{wx = WalletB} = lists:keyfind(wallet, #w.name, Buttons),
|
||||||
Disable =
|
|
||||||
fun(Button) ->
|
|
||||||
#w{wx = W} = lists:keyfind(Button, #w.name, Buttons),
|
|
||||||
wxButton:disable(W)
|
|
||||||
end,
|
|
||||||
ok = lists:foreach(Disable, key_buttons()),
|
|
||||||
ok = wxButton:setLabel(WalletB, "[no wallet]");
|
ok = wxButton:setLabel(WalletB, "[no wallet]");
|
||||||
do_wallet(Name, #s{buttons = Buttons}) ->
|
do_wallet(Name, #s{buttons = Buttons}) ->
|
||||||
#w{wx = WalletB} = lists:keyfind(wallet, #w.name, Buttons),
|
#w{wx = WalletB} = lists:keyfind(wallet, #w.name, Buttons),
|
||||||
Enable =
|
|
||||||
fun(Button) ->
|
|
||||||
#w{wx = W} = lists:keyfind(Button, #w.name, Buttons),
|
|
||||||
wxButton:enable(W)
|
|
||||||
end,
|
|
||||||
ok = lists:foreach(Enable, key_buttons()),
|
|
||||||
ok = wxButton:setLabel(WalletB, Name).
|
ok = wxButton:setLabel(WalletB, Name).
|
||||||
|
|
||||||
|
|
||||||
key_buttons() ->
|
|
||||||
[make_key, recover, mnemonic, rename, drop_key].
|
|
||||||
|
|
||||||
|
|
||||||
do_chain(none, none, #s{buttons = Buttons}) ->
|
do_chain(none, none, #s{buttons = Buttons}) ->
|
||||||
#w{wx = ChainB} = lists:keyfind(chain, #w.name, Buttons),
|
#w{wx = ChainB} = lists:keyfind(chain, #w.name, Buttons),
|
||||||
#w{wx = NodeB} = lists:keyfind(node, #w.name, Buttons),
|
#w{wx = NodeB} = lists:keyfind(node, #w.name, Buttons),
|
||||||
@@ -918,48 +1018,6 @@ do_grids_mess_sig2(Request = #{"grids" := 1,
|
|||||||
?wxID_CANCEL -> ok
|
?wxID_CANCEL -> ok
|
||||||
end,
|
end,
|
||||||
wxDialog:destroy(Dialog);
|
wxDialog:destroy(Dialog);
|
||||||
do_grids_mess_sig2(Request = #{"grids" := 1,
|
|
||||||
"type" := "binary",
|
|
||||||
"url" := URL,
|
|
||||||
"public_id" := ID,
|
|
||||||
"payload" := Base64},
|
|
||||||
#s{frame = Frame, j = J}) ->
|
|
||||||
Dialog = wxDialog:new(Frame, ?wxID_ANY, J("Binary Data Signature Request")),
|
|
||||||
Sizer = wxBoxSizer:new(?wxVERTICAL),
|
|
||||||
Instruction =
|
|
||||||
J("The server at the URL below is requesting you sign the following binary data."),
|
|
||||||
InstTx = wxStaticText:new(Dialog, ?wxID_ANY, Instruction),
|
|
||||||
AcctSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, J("Signature Account")}]),
|
|
||||||
AcctTx = wxStaticText:new(Dialog, ?wxID_ANY, ID),
|
|
||||||
_ = wxStaticBoxSizer:add(AcctSz, AcctTx, zxw:flags(wide)),
|
|
||||||
URL_Label = J("Originating URL"),
|
|
||||||
URL_Sz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, URL_Label}]),
|
|
||||||
URL_Tx = wxStaticText:new(Dialog, ?wxID_ANY, URL),
|
|
||||||
_ = wxStaticBoxSizer:add(URL_Sz, URL_Tx, zxw:flags(wide)),
|
|
||||||
MessSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, J("Base-64 Data")}]),
|
|
||||||
MessStyle = ?wxTE_MULTILINE bor ?wxTE_READONLY,
|
|
||||||
MessTx = wxTextCtrl:new(Dialog, ?wxID_ANY, [{value, Base64}, {style, MessStyle}]),
|
|
||||||
_ = wxStaticBoxSizer:add(MessSz, MessTx, zxw:flags(wide)),
|
|
||||||
ButtSz = wxBoxSizer:new(?wxHORIZONTAL),
|
|
||||||
Affirm = wxButton:new(Dialog, ?wxID_OK),
|
|
||||||
Cancel = wxButton:new(Dialog, ?wxID_CANCEL),
|
|
||||||
_ = wxBoxSizer:add(ButtSz, Affirm, zxw:flags(wide)),
|
|
||||||
_ = wxBoxSizer:add(ButtSz, Cancel, zxw:flags(wide)),
|
|
||||||
_ = wxBoxSizer:add(Sizer, InstTx, zxw:flags(wide)),
|
|
||||||
_ = wxBoxSizer:add(Sizer, AcctSz, zxw:flags(wide)),
|
|
||||||
_ = wxBoxSizer:add(Sizer, URL_Sz, zxw:flags(wide)),
|
|
||||||
_ = wxBoxSizer:add(Sizer, MessSz, zxw:flags(wide)),
|
|
||||||
_ = wxBoxSizer:add(Sizer, ButtSz, zxw:flags(base)),
|
|
||||||
ok = wxDialog:setSizer(Dialog, Sizer),
|
|
||||||
ok = wxDialog:setSize(Dialog, {500, 500}),
|
|
||||||
ok = wxBoxSizer:layout(Sizer),
|
|
||||||
ok = wxFrame:center(Dialog),
|
|
||||||
ok =
|
|
||||||
case wxDialog:showModal(Dialog) of
|
|
||||||
?wxID_OK -> gd_con:sign_binary(Request);
|
|
||||||
?wxID_CANCEL -> ok
|
|
||||||
end,
|
|
||||||
wxDialog:destroy(Dialog);
|
|
||||||
do_grids_mess_sig2(Request = #{"grids" := 1,
|
do_grids_mess_sig2(Request = #{"grids" := 1,
|
||||||
"type" := "tx",
|
"type" := "tx",
|
||||||
"url" := URL,
|
"url" := URL,
|
||||||
@@ -1018,3 +1076,37 @@ do_grids_mess_sig2(Request = #{"grids" := 1,
|
|||||||
wxDialog:destroy(Dialog);
|
wxDialog:destroy(Dialog);
|
||||||
do_grids_mess_sig2(BadRequest, _) ->
|
do_grids_mess_sig2(BadRequest, _) ->
|
||||||
tell("Bad request: ~tp", [BadRequest]).
|
tell("Bad request: ~tp", [BadRequest]).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%%% Helpers
|
||||||
|
|
||||||
|
|
||||||
|
price_to_string(Pucks) ->
|
||||||
|
Gaju = 1_000_000_000_000_000_000,
|
||||||
|
H = integer_to_list(Pucks div Gaju),
|
||||||
|
R = Pucks rem Gaju,
|
||||||
|
case string:strip(lists:flatten(io_lib:format("~18..0w", [R])), right, $0) of
|
||||||
|
[] -> H;
|
||||||
|
T -> string:join([H, T], ".")
|
||||||
|
end.
|
||||||
|
|
||||||
|
string_to_price(String) ->
|
||||||
|
case string:split(String, ".") of
|
||||||
|
[H] -> join_price(H, "0");
|
||||||
|
[H, T] -> join_price(H, T);
|
||||||
|
_ -> {error, bad_price}
|
||||||
|
end.
|
||||||
|
|
||||||
|
join_price(H, T) ->
|
||||||
|
try
|
||||||
|
Parts = [H, string:pad(T, 18, trailing, $0)],
|
||||||
|
Price = list_to_integer(unicode:characters_to_list(Parts)),
|
||||||
|
case Price < 0 of
|
||||||
|
false -> {ok, Price};
|
||||||
|
true -> {error, negative_price}
|
||||||
|
end
|
||||||
|
catch
|
||||||
|
error:R -> {error, R}
|
||||||
|
end.
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@
|
|||||||
%%% translation library is retained).
|
%%% translation library is retained).
|
||||||
|
|
||||||
-module(gd_jt).
|
-module(gd_jt).
|
||||||
-vsn("0.9.0").
|
-vsn("0.5.4").
|
||||||
-export([read_translations/1, j/2, oneshot_j/2]).
|
-export([read_translations/1, j/2, oneshot_j/2]).
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
-104
@@ -1,104 +0,0 @@
|
|||||||
%%% @doc
|
|
||||||
%%% GajuDesk Helper Functions
|
|
||||||
%%% @end
|
|
||||||
|
|
||||||
-module(gd_lib).
|
|
||||||
-vsn("0.9.0").
|
|
||||||
|
|
||||||
-include_lib("wx/include/wx.hrl").
|
|
||||||
-export([is_int/1,
|
|
||||||
mono_text/2, mono_text/3, mono_text/4,
|
|
||||||
button/2, button/3,
|
|
||||||
copy_to_clipboard/1]).
|
|
||||||
|
|
||||||
-include("$zx_include/zx_logger.hrl").
|
|
||||||
-include("gd.hrl").
|
|
||||||
-include("gdl.hrl").
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-spec is_int(string()) -> boolean().
|
|
||||||
%% @doc
|
|
||||||
%% A simple boolean check over whether every character in a string is part of an integer value
|
|
||||||
%% without the trashy `try .. catch' way.
|
|
||||||
|
|
||||||
is_int(S) ->
|
|
||||||
lists:all(fun(C) -> $0 =< C andalso C =< $9 end, S).
|
|
||||||
|
|
||||||
|
|
||||||
-spec mono_text(Parent, Name) -> StaticText
|
|
||||||
when Parent :: wxWindow:wxWindow(),
|
|
||||||
Name :: term(),
|
|
||||||
StaticText :: #wx{}.
|
|
||||||
%% @doc
|
|
||||||
%% Creates a blank monospace font static text field.
|
|
||||||
%% @equiv mono_text(Parent, Name, "").
|
|
||||||
|
|
||||||
mono_text(Parent, Name) ->
|
|
||||||
mono_text(Parent, Name, "").
|
|
||||||
|
|
||||||
|
|
||||||
-spec mono_text(Parent, Name, Value) -> StaticText
|
|
||||||
when Parent :: wxWindow:wxWindow(),
|
|
||||||
Name :: term(),
|
|
||||||
Value :: string(),
|
|
||||||
StaticText :: #w{}.
|
|
||||||
%% @doc
|
|
||||||
%% Creats a monospace font static text field with the given value.
|
|
||||||
%% This exists so that I don't have to remember the difference between how to create a styled
|
|
||||||
%% wxStaticText vs wxTextCtrl (which has to do it in a weird way because it has a much richer
|
|
||||||
%% notion of text styling).
|
|
||||||
|
|
||||||
mono_text(Parent, Name, Value) ->
|
|
||||||
mono_text(Parent, Name, Value, []).
|
|
||||||
|
|
||||||
mono_text(Parent, Name, Value, Options) ->
|
|
||||||
Text = wxTextCtrl:new(Parent, ?wxID_ANY, [{value, Value} | Options]),
|
|
||||||
Font = wxFont:new(10, ?wxFONTFAMILY_TELETYPE, ?wxFONTSTYLE_NORMAL, ?wxFONTWEIGHT_NORMAL),
|
|
||||||
ok =
|
|
||||||
case wxTextCtrl:setFont(Text, Font) of
|
|
||||||
true -> ok;
|
|
||||||
false -> tell(info, "wxStaticText ~p is already monospace.", [Text])
|
|
||||||
end,
|
|
||||||
#w{name = Name, id = wxTextCtrl:getId(Text), wx = Text}.
|
|
||||||
|
|
||||||
|
|
||||||
-spec button(Parent, Label) -> Button
|
|
||||||
when Parent :: wxWindow:wxWindow(),
|
|
||||||
Label :: string(),
|
|
||||||
Button :: #w{}.
|
|
||||||
|
|
||||||
button(Parent, Label) ->
|
|
||||||
button(Parent, Label, Label).
|
|
||||||
|
|
||||||
|
|
||||||
-spec button(Parent, Name, Label) -> Button
|
|
||||||
when Parent :: wxWindow:wxWindow(),
|
|
||||||
Name :: term(),
|
|
||||||
Label :: string(),
|
|
||||||
Button :: #wx{}.
|
|
||||||
|
|
||||||
button(Parent, Name, Label) ->
|
|
||||||
Button = wxButton:new(Parent, ?wxID_ANY, [{label, Label}]),
|
|
||||||
#w{name = Name, id = wxButton:getId(Button), wx = Button}.
|
|
||||||
|
|
||||||
|
|
||||||
-spec copy_to_clipboard(String) -> ok
|
|
||||||
when String :: unicode:charlist().
|
|
||||||
|
|
||||||
copy_to_clipboard(String) ->
|
|
||||||
CB = wxClipboard:get(),
|
|
||||||
case wxClipboard:open(CB) of
|
|
||||||
true ->
|
|
||||||
Text = wxTextDataObject:new([{text, String}]),
|
|
||||||
case wxClipboard:setData(CB, Text) of
|
|
||||||
true ->
|
|
||||||
R = wxClipboard:flush(CB),
|
|
||||||
log(info, "String copied to system clipboard. Flushed: ~p", [R]);
|
|
||||||
false ->
|
|
||||||
log(info, "Failed to copy to clipboard")
|
|
||||||
end,
|
|
||||||
ok = wxClipboard:close(CB);
|
|
||||||
false ->
|
|
||||||
log(info, "Failed to acquire the clipboard.")
|
|
||||||
end.
|
|
||||||
@@ -1,284 +0,0 @@
|
|||||||
%%% @doc
|
|
||||||
%%% A live modal for creating a SpendTX
|
|
||||||
%%% @end
|
|
||||||
|
|
||||||
-module(gd_m_spend).
|
|
||||||
-vsn("0.9.0").
|
|
||||||
-author("Craig Everett <zxq9@zxq9.com>").
|
|
||||||
-copyright("Craig Everett <zxq9@zxq9.com>").
|
|
||||||
-license("GPL-3.0-or-later").
|
|
||||||
|
|
||||||
%-behavior(zxw_modal).
|
|
||||||
|
|
||||||
-export([show/2]).
|
|
||||||
-export([init/1, handle_info/2, handle_event/2]).
|
|
||||||
|
|
||||||
-include_lib("wx/include/wx.hrl").
|
|
||||||
-include("$zx_include/zx_logger.hrl").
|
|
||||||
-include("gd.hrl").
|
|
||||||
|
|
||||||
-record(s,
|
|
||||||
{frame = none :: none | wx:wx_object(),
|
|
||||||
parent = none :: none | wx:wx_object(),
|
|
||||||
caller = none :: none | pid(),
|
|
||||||
j = j() :: fun(),
|
|
||||||
to_tx = none :: none | wx:wx_object(),
|
|
||||||
amount_tx = none :: none | wx:wx_object(),
|
|
||||||
payload_tx = none :: none | wx:wx_object(),
|
|
||||||
ttl_sl = none :: none | wx:wx_object(),
|
|
||||||
gas_sl = none :: none | wx:wx_object(),
|
|
||||||
affirm = none :: none | wx:wx_object(),
|
|
||||||
cancel = none :: none | wx:wx_object()}).
|
|
||||||
|
|
||||||
j() ->
|
|
||||||
fun(X) -> X end.
|
|
||||||
|
|
||||||
|
|
||||||
%%% Interface
|
|
||||||
|
|
||||||
-spec show(Parent, Args) -> {ok, #spend_tx{}} | cancel
|
|
||||||
when Parent :: wxFrame:wxFrame(),
|
|
||||||
Args :: {Account :: iolist(),
|
|
||||||
Nonce :: pos_integer(),
|
|
||||||
Height :: pos_integer(),
|
|
||||||
J :: fun()}.
|
|
||||||
|
|
||||||
show(Parent, Args) ->
|
|
||||||
zxw_modal:show(Parent, ?MODULE, Args).
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%% Init
|
|
||||||
|
|
||||||
init({Parent, Caller, {Account, J}}) ->
|
|
||||||
Frame = wxFrame:new(Parent, ?wxID_ANY, J("Transfer Gajus")),
|
|
||||||
Panel = wxWindow:new(Frame, ?wxID_ANY),
|
|
||||||
TopSz = wxBoxSizer:new(?wxVERTICAL),
|
|
||||||
_ = wxBoxSizer:add(TopSz, Panel, zxw:flags(wide)),
|
|
||||||
MainSz = wxBoxSizer:new(?wxVERTICAL),
|
|
||||||
|
|
||||||
FromTx = wxStaticText:new(Panel, ?wxID_ANY, Account),
|
|
||||||
FromSz = wxStaticBoxSizer:new(?wxVERTICAL, Panel, [{label, J("From")}]),
|
|
||||||
_ = wxStaticBoxSizer:add(FromSz, FromTx, zxw:flags({wide, 5})),
|
|
||||||
ToTx = wxTextCtrl:new(Panel, ?wxID_ANY),
|
|
||||||
ToSz = wxStaticBoxSizer:new(?wxVERTICAL, Panel, [{label, J("To")}]),
|
|
||||||
_ = wxStaticBoxSizer:add(ToSz, ToTx, zxw:flags({wide, 5})),
|
|
||||||
AmtTx = wxTextCtrl:new(Panel, ?wxID_ANY),
|
|
||||||
AmtSz = wxStaticBoxSizer:new(?wxVERTICAL, Panel, [{label, J("Amount")}]),
|
|
||||||
AmtInSz = wxBoxSizer:new(?wxHORIZONTAL),
|
|
||||||
_ = wxStaticBoxSizer:add(AmtInSz, AmtTx, zxw:flags({wide, 5})),
|
|
||||||
_ = wxStaticBoxSizer:add(AmtSz, AmtInSz, zxw:flags({wide, 5})),
|
|
||||||
PayloadTx = wxTextCtrl:new(Panel, ?wxID_ANY, [{style, ?wxTE_MULTILINE}]),
|
|
||||||
PayloadSz = wxStaticBoxSizer:new(?wxVERTICAL, Panel, [{label, J("Message")}]),
|
|
||||||
_ = wxStaticBoxSizer:add(PayloadSz, PayloadTx, zxw:flags({wide, 5})),
|
|
||||||
Style = [{style, ?wxSL_HORIZONTAL bor ?wxSL_LABELS}],
|
|
||||||
TTL_Sl = wxSlider:new(Panel, ?wxID_ANY, 100, 10, 1000, Style),
|
|
||||||
TTL_Sz = wxStaticBoxSizer:new(?wxVERTICAL, Panel, [{label, J("TTL")}]),
|
|
||||||
_ = wxStaticBoxSizer:add(TTL_Sz, TTL_Sl, zxw:flags({wide, 5})),
|
|
||||||
Min = hz:min_gas_price(),
|
|
||||||
Max = Min * 2,
|
|
||||||
GasSl = wxSlider:new(Panel, ?wxID_ANY, Min, Min, Max, Style),
|
|
||||||
GasSz = wxStaticBoxSizer:new(?wxVERTICAL, Panel, [{label, J("Gas Price")}]),
|
|
||||||
_ = wxStaticBoxSizer:add(GasSz, GasSl, zxw:flags({wide, 5})),
|
|
||||||
ButtSz = wxBoxSizer:new(?wxHORIZONTAL),
|
|
||||||
Affirm = wxButton:new(Panel, ?wxID_ANY, [{label, J("OK")}]),
|
|
||||||
Cancel = wxButton:new(Panel, ?wxID_ANY, [{label, J("Cancel")}]),
|
|
||||||
_ = wxBoxSizer:add(ButtSz, Affirm, zxw:flags({wide, 5})),
|
|
||||||
_ = wxBoxSizer:add(ButtSz, Cancel, zxw:flags({wide, 5})),
|
|
||||||
_ = wxBoxSizer:add(MainSz, FromSz, zxw:flags({base, 5})),
|
|
||||||
_ = wxBoxSizer:add(MainSz, ToSz, zxw:flags({base, 5})),
|
|
||||||
_ = wxBoxSizer:add(MainSz, AmtSz, zxw:flags({base, 5})),
|
|
||||||
_ = wxBoxSizer:add(MainSz, PayloadSz, zxw:flags({wide, 5})),
|
|
||||||
_ = wxBoxSizer:add(MainSz, TTL_Sz, zxw:flags({base, 5})),
|
|
||||||
_ = wxBoxSizer:add(MainSz, GasSz, zxw:flags({base, 5})),
|
|
||||||
_ = wxBoxSizer:add(MainSz, ButtSz, zxw:flags({base, 5})),
|
|
||||||
HandleKey = key_handler(ToTx, AmtTx, PayloadTx, TTL_Sl, GasSl, Affirm, Cancel),
|
|
||||||
ok = wxFrame:connect(Frame, key_down, [{callback, HandleKey}]),
|
|
||||||
ok = wxTextCtrl:connect(ToTx, key_down, [{callback, HandleKey}]),
|
|
||||||
ok = wxTextCtrl:connect(AmtTx, key_down, [{callback, HandleKey}]),
|
|
||||||
ok = wxTextCtrl:connect(PayloadTx, key_down, [{callback, HandleKey}]),
|
|
||||||
ok = wxTextCtrl:connect(TTL_Sl, key_down, [{callback, HandleKey}]),
|
|
||||||
ok = wxTextCtrl:connect(GasSl, key_down, [{callback, HandleKey}]),
|
|
||||||
ok = wxTextCtrl:connect(Affirm, key_down, [{callback, HandleKey}]),
|
|
||||||
ok = wxTextCtrl:connect(Cancel, key_down, [{callback, HandleKey}]),
|
|
||||||
ok = wxFrame:connect(Frame, command_button_clicked),
|
|
||||||
ok = wxFrame:connect(Frame, close_window),
|
|
||||||
ok = wxFrame:setSize(Frame, {500, 650}),
|
|
||||||
ok = wxFrame:center(Frame),
|
|
||||||
ok = wxWindow:setSizer(Panel, MainSz),
|
|
||||||
ok = wxFrame:setSizer(Frame, TopSz),
|
|
||||||
ok = wxBoxSizer:layout(MainSz),
|
|
||||||
ok = wxFrame:centerOnParent(Frame),
|
|
||||||
true = wxFrame:show(Frame),
|
|
||||||
self() ! {focus, to_tx},
|
|
||||||
State =
|
|
||||||
#s{frame = Frame, parent = Parent, caller = Caller,
|
|
||||||
to_tx = ToTx, amount_tx = AmtTx, payload_tx = PayloadTx,
|
|
||||||
ttl_sl = TTL_Sl, gas_sl = GasSl,
|
|
||||||
affirm = Affirm, cancel = Cancel},
|
|
||||||
{Frame, State}.
|
|
||||||
|
|
||||||
|
|
||||||
key_handler(ToTx, AmtTx, PayloadTx, TTL_Sl, GasSl, Affirm, Cancel) ->
|
|
||||||
Me = self(),
|
|
||||||
ToID = wxTextCtrl:getId(ToTx),
|
|
||||||
AmtID = wxTextCtrl:getId(AmtTx),
|
|
||||||
PL_ID = wxTextCtrl:getId(PayloadTx),
|
|
||||||
TTL_ID = wxSlider:getId(TTL_Sl),
|
|
||||||
GasID = wxSlider:getId(GasSl),
|
|
||||||
AffirmID = wxButton:getId(Affirm),
|
|
||||||
CancelID = wxButton:getId(Cancel),
|
|
||||||
fun(#wx{id = ID, event = #wxKey{type = key_down, keyCode = Code}}, KeyPress) ->
|
|
||||||
case {Code, wxKeyEvent:shiftDown(KeyPress)} of
|
|
||||||
{9, false} ->
|
|
||||||
case ID of
|
|
||||||
ToID -> Me ! {focus, amount_tx};
|
|
||||||
AmtID -> Me ! {focus, payload_tx};
|
|
||||||
PL_ID -> Me ! {focus, ttl_sl};
|
|
||||||
TTL_ID -> Me ! {focus, gas_sl};
|
|
||||||
GasID -> Me ! {focus, affirm};
|
|
||||||
AffirmID -> Me ! {focus, cancel};
|
|
||||||
CancelID -> Me ! {focus, to_tx};
|
|
||||||
_ -> wxEvent:skip(KeyPress)
|
|
||||||
end;
|
|
||||||
{9, true} ->
|
|
||||||
case ID of
|
|
||||||
ToID -> Me ! {focus, cancel};
|
|
||||||
AmtID -> Me ! {focus, to_tx};
|
|
||||||
PL_ID -> Me ! {focus, amount_tx};
|
|
||||||
TTL_ID -> Me ! {focus, payload_tx};
|
|
||||||
GasID -> Me ! {focus, ttl_sl};
|
|
||||||
AffirmID -> Me ! {focus, gas_sl};
|
|
||||||
CancelID -> Me ! {focus, affirm};
|
|
||||||
_ -> wxEvent:skip(KeyPress)
|
|
||||||
end;
|
|
||||||
{13, _} ->
|
|
||||||
case ID of
|
|
||||||
ToID -> Me ! {tab, to_tx};
|
|
||||||
AmtID -> Me ! {tab, amount_tx};
|
|
||||||
PL_ID -> Me ! {tab, payload_tx};
|
|
||||||
TTL_ID -> Me ! {tab, ttl_sl};
|
|
||||||
GasID -> Me ! {tab, gas_sl};
|
|
||||||
AffirmID -> Me ! {enter, affirm};
|
|
||||||
CancelID -> Me ! {enter, cancel};
|
|
||||||
_ -> wxEvent:skip(KeyPress)
|
|
||||||
end;
|
|
||||||
{27, _} ->
|
|
||||||
Me ! esc;
|
|
||||||
{_, _} ->
|
|
||||||
wxEvent:skip(KeyPress)
|
|
||||||
end
|
|
||||||
end.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
handle_info({focus, Element}, State) ->
|
|
||||||
ok = focus(Element, State),
|
|
||||||
{noreply, State};
|
|
||||||
handle_info({enter, affirm}, State) ->
|
|
||||||
check(State);
|
|
||||||
handle_info({enter, cancel}, State) ->
|
|
||||||
cancel(State);
|
|
||||||
handle_info(esc, State) ->
|
|
||||||
ok = cancel(State),
|
|
||||||
{noreply, State};
|
|
||||||
handle_info(Message, State) ->
|
|
||||||
ok = log(warning, "Message: ~p~nState: ~p~n", [Message, State]),
|
|
||||||
{noreply, State}.
|
|
||||||
|
|
||||||
|
|
||||||
handle_event(#wx{event = #wxCommand{type = command_button_clicked}, id = ID},
|
|
||||||
State = #s{affirm = Affirm, cancel = Cancel}) ->
|
|
||||||
AffirmID = wxButton:getId(Affirm),
|
|
||||||
CancelID = wxButton:getId(Cancel),
|
|
||||||
NewState =
|
|
||||||
case ID of
|
|
||||||
AffirmID -> check(State);
|
|
||||||
CancelID -> cancel(State)
|
|
||||||
end,
|
|
||||||
{noreply, NewState};
|
|
||||||
handle_event(#wx{event = #wxClose{}}, State) ->
|
|
||||||
NewState = cancel(State),
|
|
||||||
{noreply, NewState};
|
|
||||||
handle_event(Event, State) ->
|
|
||||||
ok = log(warning, "Unexpected event ~tp State: ~tp~n", [Event, State]),
|
|
||||||
{noreply, State}.
|
|
||||||
|
|
||||||
|
|
||||||
%%% Doers
|
|
||||||
|
|
||||||
focus(to_tx, #s{to_tx = ToTX}) -> wxTextCtrl:setFocus(ToTX);
|
|
||||||
focus(amount_tx, #s{amount_tx = AmountTX}) -> wxTextCtrl:setFocus(AmountTX);
|
|
||||||
focus(payload_tx, #s{payload_tx = PayloadTX}) -> wxTextCtrl:setFocus(PayloadTX);
|
|
||||||
focus(ttl_sl, #s{ttl_sl = TTL_SL}) -> wxSlider:setFocus(TTL_SL);
|
|
||||||
focus(gas_sl, #s{gas_sl = GasSL}) -> wxSlider:setFocus(GasSL);
|
|
||||||
focus(affirm, #s{affirm = Affirm}) -> wxButton:setFocus(Affirm);
|
|
||||||
focus(cancel, #s{cancel = Cancel}) -> wxButton:setFocus(Cancel).
|
|
||||||
|
|
||||||
|
|
||||||
cancel(#s{frame = Frame, caller = Caller}) ->
|
|
||||||
ok = wxFrame:destroy(Frame),
|
|
||||||
zxw_modal:done(Caller, cancel).
|
|
||||||
|
|
||||||
|
|
||||||
check(State =#s{frame = Frame, caller = Caller, j = J,
|
|
||||||
to_tx = ToTx, amount_tx = AmountTx, payload_tx = PayloadTx,
|
|
||||||
ttl_sl = TTL_Sl, gas_sl = GasSl}) ->
|
|
||||||
DirtyTX =
|
|
||||||
[{recipient_id, wxTextCtrl:getValue(ToTx)},
|
|
||||||
{amount, wxTextCtrl:getValue(AmountTx)},
|
|
||||||
{gas_price, wxSlider:getValue(GasSl)},
|
|
||||||
{ttl, wxSlider:getValue(TTL_Sl)},
|
|
||||||
{payload, wxTextCtrl:getValue(PayloadTx)}],
|
|
||||||
ok =
|
|
||||||
case clean_spend(DirtyTX, #spend_tx{}, J, []) of
|
|
||||||
{ok, CleanTX} ->
|
|
||||||
ok = wxFrame:destroy(Frame),
|
|
||||||
zxw_modal:done(Caller, {ok, CleanTX});
|
|
||||||
{error, Errors} ->
|
|
||||||
DerpyDerpDerp = form_message(Errors, J),
|
|
||||||
ok = zxw:show_message(Frame, DerpyDerpDerp),
|
|
||||||
State
|
|
||||||
end.
|
|
||||||
|
|
||||||
|
|
||||||
% TODO: There should be some suggestive logic around gas prices, both based on how large
|
|
||||||
% the payload and TTL are, but also the ingoing current common gas rate. This will require
|
|
||||||
% a "gas station" sort of analysis app to query, though.
|
|
||||||
clean_spend([{recipient_id, ""} | Rest], TX, J, Errors) ->
|
|
||||||
NewErrors = [{recipient_id, J("Recipient field is empty.")} | Errors],
|
|
||||||
clean_spend(Rest, TX, J, NewErrors);
|
|
||||||
clean_spend([{recipient_id, Recipient} | Rest], TX, J, Errors) ->
|
|
||||||
clean_spend(Rest, TX#spend_tx{recipient_id = list_to_binary(Recipient)}, J, Errors);
|
|
||||||
clean_spend([{amount, ""} | Rest], TX, J, Errors) ->
|
|
||||||
clean_spend(Rest, TX#spend_tx{amount = 0}, J, Errors);
|
|
||||||
clean_spend([{amount, S} | Rest], TX, J, Errors) ->
|
|
||||||
{NewTX, NewErrors} =
|
|
||||||
case hz_format:read(S) of
|
|
||||||
{ok, Amount} ->
|
|
||||||
{TX#spend_tx{amount = Amount}, Errors};
|
|
||||||
error ->
|
|
||||||
Derp = J("Amount field is not properly formatted."),
|
|
||||||
{TX, [{amount, Derp} | Errors]}
|
|
||||||
end,
|
|
||||||
clean_spend(Rest, NewTX, J, NewErrors);
|
|
||||||
clean_spend([{gas_price, GasPrice} | Rest], TX, J, Errors) ->
|
|
||||||
clean_spend(Rest, TX#spend_tx{gas_price = GasPrice}, J, Errors);
|
|
||||||
clean_spend([{ttl, TTL} | Rest], TX, J, Errors) ->
|
|
||||||
clean_spend(Rest, TX#spend_tx{ttl = TTL}, J, Errors);
|
|
||||||
clean_spend([{payload, S} | Rest], TX, J, Errors) ->
|
|
||||||
clean_spend(Rest, TX#spend_tx{payload = list_to_binary(S)}, J, Errors);
|
|
||||||
clean_spend([], TX, _, []) ->
|
|
||||||
{ok, TX};
|
|
||||||
clean_spend([], _, _, Errors) ->
|
|
||||||
{error, Errors}.
|
|
||||||
|
|
||||||
|
|
||||||
form_message(Errors, J) ->
|
|
||||||
Header = J("The following errors were encountered:"),
|
|
||||||
unicode:characters_to_list([Header, "\n", assemble(Errors)]).
|
|
||||||
|
|
||||||
% TODO: Highlight the fields since we know them.
|
|
||||||
assemble([{_, M} | T]) -> [M, "\n" | assemble(T)];
|
|
||||||
assemble([]) -> [].
|
|
||||||
|
|
||||||
@@ -1,184 +0,0 @@
|
|||||||
%%% @doc
|
|
||||||
%%% A live modal for importing a wallet.
|
|
||||||
%%%
|
|
||||||
%%% Interprets [ENTER] as an "OK" button click and [ESC] as a "Cancel" button click.
|
|
||||||
%%% @end
|
|
||||||
|
|
||||||
-module(gd_m_wallet_importer).
|
|
||||||
-vsn("0.9.0").
|
|
||||||
-author("Craig Everett <zxq9@zxq9.com>").
|
|
||||||
-copyright("Craig Everett <zxq9@zxq9.com>").
|
|
||||||
-license("GPL-3.0-or-later").
|
|
||||||
|
|
||||||
-behavior(zxw_modal).
|
|
||||||
|
|
||||||
-export([show/6]).
|
|
||||||
-export([init/1, handle_info/2, handle_event/2]).
|
|
||||||
|
|
||||||
-include_lib("wx/include/wx.hrl").
|
|
||||||
-include("$zx_include/zx_logger.hrl").
|
|
||||||
|
|
||||||
-record(s,
|
|
||||||
{frame = none :: none | wx:wx_object(),
|
|
||||||
parent = none :: none | wx:wx_object(),
|
|
||||||
caller = none :: none | pid(),
|
|
||||||
name_tx = none :: none | wx:wx_object(),
|
|
||||||
pass_tx = none :: none | wx:wx_object(),
|
|
||||||
ok = none :: none | wx:wx_object(),
|
|
||||||
cancel = none :: none | wx:wx_object()}).
|
|
||||||
|
|
||||||
|
|
||||||
%%% Interface
|
|
||||||
|
|
||||||
-spec show(Parent, Title, NameLabel, PassLabel, OK_L, Cancel_L) -> {ok, Name, Pass} | cancel
|
|
||||||
when Parent :: wxFrame:wxFrame(),
|
|
||||||
Title :: string(),
|
|
||||||
NameLabel :: string(),
|
|
||||||
PassLabel :: string(),
|
|
||||||
OK_L :: string(),
|
|
||||||
Cancel_L :: string(),
|
|
||||||
Name :: string(),
|
|
||||||
Pass :: string() | none.
|
|
||||||
|
|
||||||
show(Parent, Title, NameLabel, PassLabel, OK_L, Cancel_L) ->
|
|
||||||
zxw_modal:show(Parent, ?MODULE, {Title, NameLabel, PassLabel, OK_L, Cancel_L}).
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%% Init
|
|
||||||
|
|
||||||
init({Parent, Caller, {Title, NameLabel, PassLabel, OK_L, Cancel_L}}) ->
|
|
||||||
Frame = wxFrame:new(Parent, ?wxID_ANY, Title),
|
|
||||||
Panel = wxWindow:new(Frame, ?wxID_ANY),
|
|
||||||
TopSz = wxBoxSizer:new(?wxVERTICAL),
|
|
||||||
_ = wxBoxSizer:add(TopSz, Panel, zxw:flags(wide)),
|
|
||||||
MainSz = wxBoxSizer:new(?wxVERTICAL),
|
|
||||||
NameSz = wxStaticBoxSizer:new(?wxVERTICAL, Panel, [{label, NameLabel}]),
|
|
||||||
NameTx = wxTextCtrl:new(Panel, ?wxID_ANY, [{style, ?wxTE_PROCESS_TAB}]),
|
|
||||||
_ = wxSizer:add(NameSz, NameTx, zxw:flags({wide, 5})),
|
|
||||||
PassSz = wxStaticBoxSizer:new(?wxVERTICAL, Panel, [{label, PassLabel}]),
|
|
||||||
PassTx = wxTextCtrl:new(Panel, ?wxID_ANY, [{style, ?wxTE_PROCESS_TAB bor ?wxTE_PASSWORD}]),
|
|
||||||
_ = wxSizer:add(PassSz, PassTx, zxw:flags({wide, 5})),
|
|
||||||
OK = wxButton:new(Panel, ?wxID_ANY, [{label, OK_L}]),
|
|
||||||
Cancel = wxButton:new(Panel, ?wxID_ANY, [{label, Cancel_L}]),
|
|
||||||
ButtSz = wxBoxSizer:new(?wxHORIZONTAL),
|
|
||||||
_ = wxBoxSizer:add(ButtSz, OK, zxw:flags({wide, 5})),
|
|
||||||
_ = wxBoxSizer:add(ButtSz, Cancel, zxw:flags({wide, 5})),
|
|
||||||
_ = wxBoxSizer:add(MainSz, NameSz, zxw:flags({wide, 5})),
|
|
||||||
_ = wxBoxSizer:add(MainSz, PassSz, zxw:flags({wide, 5})),
|
|
||||||
_ = wxBoxSizer:add(MainSz, ButtSz, zxw:flags({wide, 5})),
|
|
||||||
HandleKey = key_handler(NameTx, PassTx, OK, Cancel),
|
|
||||||
ok = wxFrame:connect(Frame, key_down, [{callback, HandleKey}]),
|
|
||||||
ok = wxTextCtrl:connect(NameTx, key_down, [{callback, HandleKey}]),
|
|
||||||
ok = wxTextCtrl:connect(PassTx, key_down, [{callback, HandleKey}]),
|
|
||||||
ok = wxTextCtrl:connect(OK, key_down, [{callback, HandleKey}]),
|
|
||||||
ok = wxTextCtrl:connect(Cancel, key_down, [{callback, HandleKey}]),
|
|
||||||
ok = wxFrame:connect(Frame, command_button_clicked),
|
|
||||||
ok = wxFrame:connect(Frame, close_window),
|
|
||||||
ok = wxFrame:setSize(Frame, {500, 220}),
|
|
||||||
ok = wxWindow:setSizer(Panel, MainSz),
|
|
||||||
ok = wxFrame:setSizer(Frame, TopSz),
|
|
||||||
ok = wxBoxSizer:layout(MainSz),
|
|
||||||
ok = wxFrame:centerOnParent(Frame),
|
|
||||||
ok = wxTextCtrl:setFocus(NameTx),
|
|
||||||
true = wxFrame:show(Frame),
|
|
||||||
State =
|
|
||||||
#s{frame = Frame, parent = Parent, caller = Caller,
|
|
||||||
name_tx = NameTx, pass_tx = PassTx,
|
|
||||||
ok = OK, cancel = Cancel},
|
|
||||||
{Frame, State}.
|
|
||||||
|
|
||||||
|
|
||||||
key_handler(NameTx, PassTx, OK, Cancel) ->
|
|
||||||
Me = self(),
|
|
||||||
NameID = wxTextCtrl:getId(NameTx),
|
|
||||||
PassID = wxTextCtrl:getId(PassTx),
|
|
||||||
OK_ID = wxButton:getId(OK),
|
|
||||||
CancelID = wxButton:getId(Cancel),
|
|
||||||
fun(#wx{id = ID, event = #wxKey{type = key_down, keyCode = Code}}, KeyPress) ->
|
|
||||||
case Code of
|
|
||||||
9 ->
|
|
||||||
case ID of
|
|
||||||
NameID -> Me ! {tab, name};
|
|
||||||
PassID -> Me ! {tab, pass};
|
|
||||||
OK_ID -> Me ! {tab, ok};
|
|
||||||
CancelID -> Me ! {tab, cancel};
|
|
||||||
_ -> wxEvent:skip(KeyPress)
|
|
||||||
end;
|
|
||||||
13 ->
|
|
||||||
case ID of
|
|
||||||
NameID -> Me ! {enter, name};
|
|
||||||
PassID -> Me ! {enter, pass};
|
|
||||||
_ -> wxEvent:skip(KeyPress)
|
|
||||||
end;
|
|
||||||
27 ->
|
|
||||||
Me ! esc;
|
|
||||||
_ ->
|
|
||||||
wxEvent:skip(KeyPress)
|
|
||||||
end
|
|
||||||
end.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
handle_info({tab, Element}, State) ->
|
|
||||||
ok = tab_traverse(Element, State),
|
|
||||||
{noreply, State};
|
|
||||||
handle_info({enter, name}, State = #s{pass_tx = PassTx}) ->
|
|
||||||
ok = wxTextCtrl:setFocus(PassTx),
|
|
||||||
{noreply, State};
|
|
||||||
handle_info({enter, pass}, State) ->
|
|
||||||
done(State);
|
|
||||||
handle_info(esc, State) ->
|
|
||||||
ok = cancel(State),
|
|
||||||
{noreply, State};
|
|
||||||
handle_info(Message, State) ->
|
|
||||||
ok = log(warning, "Message: ~p~nState: ~p~n", [Message, State]),
|
|
||||||
{noreply, State}.
|
|
||||||
|
|
||||||
|
|
||||||
handle_event(#wx{event = #wxCommand{type = command_button_clicked}, id = ID},
|
|
||||||
State = #s{ok = OK, cancel = Cancel}) ->
|
|
||||||
OK_ID = wxButton:getId(OK),
|
|
||||||
CancelID = wxButton:getId(Cancel),
|
|
||||||
case ID of
|
|
||||||
OK_ID -> done(State);
|
|
||||||
CancelID -> cancel(State)
|
|
||||||
end;
|
|
||||||
handle_event(#wx{event = #wxClose{}}, State) ->
|
|
||||||
NewState = cancel(State),
|
|
||||||
{noreply, NewState};
|
|
||||||
handle_event(Event, State) ->
|
|
||||||
ok = log(warning, "Unexpected event ~tp State: ~tp~n", [Event, State]),
|
|
||||||
{noreply, State}.
|
|
||||||
|
|
||||||
|
|
||||||
%%% Doers
|
|
||||||
|
|
||||||
tab_traverse(name, #s{pass_tx = PassTx}) ->
|
|
||||||
wxTextCtrl:setFocus(PassTx);
|
|
||||||
tab_traverse(pass, #s{ok = OK}) ->
|
|
||||||
wxButton:setFocus(OK);
|
|
||||||
tab_traverse(ok, #s{cancel = Cancel}) ->
|
|
||||||
wxButton:setFocus(Cancel);
|
|
||||||
tab_traverse(cancel, #s{name_tx = NameTx}) ->
|
|
||||||
wxTextCtrl:setFocus(NameTx).
|
|
||||||
|
|
||||||
|
|
||||||
cancel(#s{frame = Frame, caller = Caller}) ->
|
|
||||||
ok = wxFrame:destroy(Frame),
|
|
||||||
zxw_modal:done(Caller, cancel).
|
|
||||||
|
|
||||||
|
|
||||||
done(#s{frame = Frame, caller = Caller, name_tx = NameTx, pass_tx = PassTx}) ->
|
|
||||||
Result =
|
|
||||||
case wxTextCtrl:getValue(NameTx) of
|
|
||||||
"" ->
|
|
||||||
cancel;
|
|
||||||
Name ->
|
|
||||||
case wxTextCtrl:getValue(PassTx) of
|
|
||||||
"" -> {ok, Name, none};
|
|
||||||
Pass -> {ok, Name, Pass}
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
ok = wxFrame:destroy(Frame),
|
|
||||||
zxw_modal:done(Caller, Result).
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
-module(gd_sophia_editor).
|
-module(gd_sophia_editor).
|
||||||
-vsn("0.9.0").
|
-export([new/1, update/2,
|
||||||
-export([new/1, update/1, update/2,
|
|
||||||
get_text/1, set_text/2]).
|
get_text/1, set_text/2]).
|
||||||
|
|
||||||
-include("$zx_include/zx_logger.hrl").
|
-include("$zx_include/zx_logger.hrl").
|
||||||
@@ -26,7 +25,6 @@
|
|||||||
-define(H, 255). % High
|
-define(H, 255). % High
|
||||||
-define(M, 192). % Medium
|
-define(M, 192). % Medium
|
||||||
-define(L, 128). % Low
|
-define(L, 128). % Low
|
||||||
-define(D, 64). % Deep-Low
|
|
||||||
-define(X, 32). % X-Low
|
-define(X, 32). % X-Low
|
||||||
-define(Z, 0). % Zilch
|
-define(Z, 0). % Zilch
|
||||||
|
|
||||||
@@ -47,9 +45,8 @@
|
|||||||
-define(brown, {?L, ?L, ?Z}).
|
-define(brown, {?L, ?L, ?Z}).
|
||||||
-define(magenta, {?L, ?Z, ?L}).
|
-define(magenta, {?L, ?Z, ?L}).
|
||||||
-define(cyan, {?Z, ?L, ?L}).
|
-define(cyan, {?Z, ?L, ?L}).
|
||||||
-define(grey, {?L, ?L, ?L}).
|
|
||||||
-define(dark_grey, {?D, ?D, ?D}).
|
|
||||||
-define(not_black, {?X, ?X, ?X}).
|
-define(not_black, {?X, ?X, ?X}).
|
||||||
|
-define(grey, {?L, ?L, ?L}).
|
||||||
-define(white, {?M, ?M, ?M}).
|
-define(white, {?M, ?M, ?M}).
|
||||||
|
|
||||||
styles() ->
|
styles() ->
|
||||||
@@ -69,9 +66,6 @@ palette(light) ->
|
|||||||
?STRING => ?red,
|
?STRING => ?red,
|
||||||
?NUMBER => ?magenta,
|
?NUMBER => ?magenta,
|
||||||
?OPERATOR => ?brown,
|
?OPERATOR => ?brown,
|
||||||
sel_back => ?grey,
|
|
||||||
line_num => ?brown,
|
|
||||||
cursor => ?black,
|
|
||||||
bg => ?high_white};
|
bg => ?high_white};
|
||||||
palette(dark) ->
|
palette(dark) ->
|
||||||
#{?DEFAULT => ?white,
|
#{?DEFAULT => ?white,
|
||||||
@@ -81,9 +75,6 @@ palette(dark) ->
|
|||||||
?STRING => ?light_red,
|
?STRING => ?light_red,
|
||||||
?NUMBER => ?light_magenta,
|
?NUMBER => ?light_magenta,
|
||||||
?OPERATOR => ?yellow,
|
?OPERATOR => ?yellow,
|
||||||
sel_back => ?dark_grey,
|
|
||||||
line_num => ?yellow,
|
|
||||||
cursor => ?white,
|
|
||||||
bg => ?not_black}.
|
bg => ?not_black}.
|
||||||
|
|
||||||
color_mode() ->
|
color_mode() ->
|
||||||
@@ -105,8 +96,6 @@ new(Parent) ->
|
|||||||
[{face, "Monospace"}]),
|
[{face, "Monospace"}]),
|
||||||
SetMonospace = fun(Style) -> wxStyledTextCtrl:styleSetFont(STC, Style, Mono) end,
|
SetMonospace = fun(Style) -> wxStyledTextCtrl:styleSetFont(STC, Style, Mono) end,
|
||||||
ok = lists:foreach(SetMonospace, styles()),
|
ok = lists:foreach(SetMonospace, styles()),
|
||||||
ok = wxStyledTextCtrl:setMarginType(STC, 0, ?wxSTC_MARGIN_NUMBER),
|
|
||||||
ok = wxStyledTextCtrl:setMarginWidth(STC, 0, 40),
|
|
||||||
ok = wxStyledTextCtrl:styleSetFont(STC, ?wxSTC_STYLE_DEFAULT, Mono),
|
ok = wxStyledTextCtrl:styleSetFont(STC, ?wxSTC_STYLE_DEFAULT, Mono),
|
||||||
ok = set_colors(STC),
|
ok = set_colors(STC),
|
||||||
STC.
|
STC.
|
||||||
@@ -122,25 +111,18 @@ set_text(STC, Text) ->
|
|||||||
|
|
||||||
set_colors(STC) ->
|
set_colors(STC) ->
|
||||||
ok = wxStyledTextCtrl:styleClearAll(STC),
|
ok = wxStyledTextCtrl:styleClearAll(STC),
|
||||||
Palette = palette(color_mode()),
|
Palette = #{bg := BGC} = palette(color_mode()),
|
||||||
#{bg := BGC, cursor := CC, line_num := LNC, sel_back := SFB} = Palette,
|
|
||||||
Colorize =
|
Colorize =
|
||||||
fun(Style) ->
|
fun(Style) ->
|
||||||
Color = maps:get(Style, Palette),
|
Color = maps:get(Style, Palette),
|
||||||
ok = wxStyledTextCtrl:styleSetForeground(STC, Style, Color),
|
ok = wxStyledTextCtrl:styleSetForeground(STC, Style, Color),
|
||||||
ok = wxStyledTextCtrl:styleSetBackground(STC, Style, BGC)
|
ok = wxStyledTextCtrl:styleSetBackground(STC, Style, BGC)
|
||||||
end,
|
end,
|
||||||
ok = wxStyledTextCtrl:setCaretForeground(STC, CC),
|
|
||||||
ok = wxStyledTextCtrl:setSelBackground(STC, true, SFB),
|
|
||||||
ok = wxStyledTextCtrl:styleSetForeground(STC, ?wxSTC_STYLE_LINENUMBER, LNC),
|
|
||||||
ok = wxStyledTextCtrl:styleSetBackground(STC, ?wxSTC_STYLE_DEFAULT, BGC),
|
ok = wxStyledTextCtrl:styleSetBackground(STC, ?wxSTC_STYLE_DEFAULT, BGC),
|
||||||
lists:foreach(Colorize, styles()).
|
lists:foreach(Colorize, styles()).
|
||||||
|
|
||||||
|
|
||||||
update(_Event, STC) ->
|
update(_Event, STC) ->
|
||||||
update(STC).
|
|
||||||
|
|
||||||
update(STC) ->
|
|
||||||
Text = wxStyledTextCtrl:getText(STC),
|
Text = wxStyledTextCtrl:getText(STC),
|
||||||
case so_scan:scan(Text) of
|
case so_scan:scan(Text) of
|
||||||
{ok, Tokens} ->
|
{ok, Tokens} ->
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(gd_sup).
|
-module(gd_sup).
|
||||||
-vsn("0.9.0").
|
-vsn("0.5.4").
|
||||||
-behaviour(supervisor).
|
-behaviour(supervisor).
|
||||||
-author("Craig Everett <craigeverett@qpq.swiss>").
|
-author("Craig Everett <craigeverett@qpq.swiss>").
|
||||||
-copyright("QPQ AG <info@qpq.swiss>").
|
-copyright("QPQ AG <info@qpq.swiss>").
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
-module(gd_v).
|
-module(gd_v).
|
||||||
-vsn("0.9.0").
|
-vsn("0.5.4").
|
||||||
-author("Craig Everett <craigeverett@qpq.swiss>").
|
-author("Craig Everett <craigeverett@qpq.swiss>").
|
||||||
-copyright("QPQ AG <info@qpq.swiss>").
|
-copyright("QPQ AG <info@qpq.swiss>").
|
||||||
-license("GPL-3.0-or-later").
|
-license("GPL-3.0-or-later").
|
||||||
|
|||||||
@@ -1,591 +0,0 @@
|
|||||||
-module(gd_v_call).
|
|
||||||
-vsn("0.9.0").
|
|
||||||
-author("Craig Everett <craigeverett@qpq.swiss>").
|
|
||||||
-copyright("QPQ AG <info@qpq.swiss>").
|
|
||||||
-license("GPL-3.0-or-later").
|
|
||||||
|
|
||||||
-behavior(wx_object).
|
|
||||||
%-behavior(gd_v).
|
|
||||||
-include_lib("wx/include/wx.hrl").
|
|
||||||
-export([to_front/1, tx_hash/1, tx_data/1, tx_info/1]).
|
|
||||||
-export([start_link/1]).
|
|
||||||
-export([init/1, terminate/2, code_change/3,
|
|
||||||
handle_call/3, handle_cast/2, handle_info/2, handle_event/2]).
|
|
||||||
-include("$zx_include/zx_logger.hrl").
|
|
||||||
-include("gd.hrl").
|
|
||||||
-include("gdl.hrl").
|
|
||||||
|
|
||||||
|
|
||||||
% State
|
|
||||||
-record(s,
|
|
||||||
{wx = none :: none | wx:wx_object(),
|
|
||||||
frame = none :: none | wx:wx_object(),
|
|
||||||
lang = en :: en | jp,
|
|
||||||
j = none :: none | fun(),
|
|
||||||
prefs = #{} :: map(),
|
|
||||||
con_id = <<"">> :: binary(),
|
|
||||||
fundef = none :: none | fun_def(),
|
|
||||||
funret = none :: none | term(), % FIXME
|
|
||||||
build = none :: none | map(),
|
|
||||||
args = [] :: [#w{}],
|
|
||||||
kp = #w{} :: #w{},
|
|
||||||
params = [] :: [param()],
|
|
||||||
return = #w{} :: #w{}, % wxTextCtrl, single-line
|
|
||||||
copy = #w{} :: #w{},
|
|
||||||
status = none :: status(),
|
|
||||||
action = #w{} :: #w{},
|
|
||||||
tx_data = none :: none | map(),
|
|
||||||
tx_info = none :: none | map(),
|
|
||||||
hash = #w{} :: #w{}, % wxTextCtrl, single-line
|
|
||||||
info = #w{} :: #w{}}). % wxTextCtrl, multi-line
|
|
||||||
|
|
||||||
|
|
||||||
-type fun_name() :: string().
|
|
||||||
-type fun_ilk() :: call | dryr | init.
|
|
||||||
-type fun_def() :: {fun_name(), fun_ilk()}.
|
|
||||||
-type param() :: {Label :: string(), Check :: fun(), #w{}}.
|
|
||||||
-type status() :: none
|
|
||||||
| submitted
|
|
||||||
| rejected
|
|
||||||
| included.
|
|
||||||
|
|
||||||
|
|
||||||
%%% Interface
|
|
||||||
|
|
||||||
-spec to_front(Win) -> ok
|
|
||||||
when Win :: wx:wx_object().
|
|
||||||
|
|
||||||
to_front(Win) ->
|
|
||||||
wx_object:cast(Win, to_front).
|
|
||||||
|
|
||||||
|
|
||||||
-spec tx_hash(Win) -> Result
|
|
||||||
when Win :: pid() | wx:wx_object(),
|
|
||||||
Result :: none | string().
|
|
||||||
|
|
||||||
tx_hash(Win) ->
|
|
||||||
wx_object:call(Win, tx_hash).
|
|
||||||
|
|
||||||
|
|
||||||
-spec tx_data(Win) -> Result
|
|
||||||
when Win :: pid() | wx:wx_object(),
|
|
||||||
Result :: none | map().
|
|
||||||
|
|
||||||
tx_data(Win) ->
|
|
||||||
wx_object:call(Win, tx_data).
|
|
||||||
|
|
||||||
|
|
||||||
-spec tx_info(Win) -> Result
|
|
||||||
when Win :: pid() | wx:wx_object(),
|
|
||||||
Result :: none | map().
|
|
||||||
|
|
||||||
tx_info(Win) ->
|
|
||||||
wx_object:call(Win, tx_info).
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%%% Startup Functions
|
|
||||||
|
|
||||||
start_link(Args) ->
|
|
||||||
wx_object:start_link(?MODULE, Args, []).
|
|
||||||
|
|
||||||
|
|
||||||
init({Prefs, FunDef = {FunName, FunIlk}, ConID, Build, Selected, Keys}) ->
|
|
||||||
Lang = maps:get(lang, Prefs, en),
|
|
||||||
Trans = gd_jt:read_translations(?MODULE),
|
|
||||||
J = gd_jt:j(Lang, Trans),
|
|
||||||
{aaci, ConName, FunSpecs, _} = maps:get(aaci, Build),
|
|
||||||
FunSpec = {FunArgs, FunReturn} = maps:get(FunName, FunSpecs),
|
|
||||||
{CallTypeLabel, ActionLabel} =
|
|
||||||
case FunIlk of
|
|
||||||
call -> {J("Contract Call"), J("Submit Call")};
|
|
||||||
dryr -> {J("Dry Run"), J("Submit Dry Run")};
|
|
||||||
init -> {J("Deploy"), J("Deploy")}
|
|
||||||
end,
|
|
||||||
Arity = integer_to_list(length(FunArgs)),
|
|
||||||
Title = [CallTypeLabel, ": ", ConName, ".", FunName, "/", Arity],
|
|
||||||
Wx = wx:new(),
|
|
||||||
Frame = wxFrame:new(Wx, ?wxID_ANY, Title),
|
|
||||||
MainSz = wxBoxSizer:new(?wxVERTICAL),
|
|
||||||
|
|
||||||
KeySz = wxStaticBoxSizer:new(?wxVERTICAL, Frame, [{label, J("Signature Key")}]),
|
|
||||||
KeyBox = wxStaticBoxSizer:getStaticBox(KeySz),
|
|
||||||
KeyPicker = wxChoice:new(KeyBox, ?wxID_ANY, [{choices, Keys}]),
|
|
||||||
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, Return, Copy, HasArgs} = call_arg_sizer(Frame, J, FunIlk, FunSpec),
|
|
||||||
{ParamSz, Params} = call_param_sizer(Frame, J),
|
|
||||||
|
|
||||||
Action = #w{wx = ActionBn} = gd_lib:button(Frame, ActionLabel),
|
|
||||||
|
|
||||||
TX_Sz = wxStaticBoxSizer:new(?wxVERTICAL, Frame, [{label, J("Transaction Info")}]),
|
|
||||||
TX_Sz_Box = wxStaticBoxSizer:getStaticBox(TX_Sz),
|
|
||||||
Single = [{style, ?wxTE_READONLY}],
|
|
||||||
Multi = [{style, ?wxTE_MULTILINE bor ?wxTE_READONLY}],
|
|
||||||
TX_Hash = #w{wx = HashT} = gd_lib:mono_text(TX_Sz_Box, tx_hash, "", Single),
|
|
||||||
TX_Info = #w{wx = InfoT} = gd_lib:mono_text(TX_Sz_Box, tx_info, "", Multi),
|
|
||||||
|
|
||||||
_ = wxStaticBoxSizer:add(TX_Sz, HashT, zxw:flags({base, 5})),
|
|
||||||
_ = wxStaticBoxSizer:add(TX_Sz, InfoT, zxw:flags({wide, 5})),
|
|
||||||
|
|
||||||
ArgSzArgs =
|
|
||||||
case HasArgs of
|
|
||||||
true -> [{proportion, 2}, {flag, ?wxEXPAND bor ?wxALL}, {border, 5}];
|
|
||||||
false -> zxw:flags({base, 5})
|
|
||||||
end,
|
|
||||||
_ = wxSizer:add(MainSz, ArgSz, ArgSzArgs),
|
|
||||||
_ = wxSizer:add(MainSz, KeySz, zxw:flags({base, 5})),
|
|
||||||
_ = wxSizer:add(MainSz, ParamSz, zxw:flags({base, 5})),
|
|
||||||
_ = wxSizer:add(MainSz, ActionBn, zxw:flags({base, 5})),
|
|
||||||
_ = wxSizer:add(MainSz, TX_Sz, [{proportion, 1}, {flag, ?wxEXPAND bor ?wxALL}, {border, 5}]),
|
|
||||||
|
|
||||||
_ = wxFrame:setSizer(Frame, MainSz),
|
|
||||||
_ = wxFrame:setSize(Frame, {900, 900}),
|
|
||||||
_ = wxSizer:layout(MainSz),
|
|
||||||
ok = wxFrame:connect(Frame, close_window),
|
|
||||||
ok = wxFrame:connect(Frame, command_button_clicked),
|
|
||||||
true = wxFrame:show(Frame),
|
|
||||||
State =
|
|
||||||
#s{wx = Wx, frame = Frame, j = J, prefs = Prefs,
|
|
||||||
fundef = FunDef, funret = FunReturn, con_id = ConID, build = Build,
|
|
||||||
args = Args, kp = KP, params = Params,
|
|
||||||
return = Return, copy = Copy,
|
|
||||||
action = Action, status = none,
|
|
||||||
hash = TX_Hash, info = TX_Info},
|
|
||||||
{Frame, State}.
|
|
||||||
|
|
||||||
|
|
||||||
call_arg_sizer(Frame, J, FunIlk, {CallArgs, ReturnType}) ->
|
|
||||||
SpecSz = wxStaticBoxSizer:new(?wxVERTICAL, Frame, [{label, J("Function Spec")}]),
|
|
||||||
SpecBox = wxStaticBoxSizer:getStaticBox(SpecSz),
|
|
||||||
{CallSz, CallControls, HasArgs} = call_sizer(SpecBox, J, CallArgs),
|
|
||||||
{ReturnSz, Return, Copy} = return_sizer(SpecBox, J, FunIlk, ReturnType),
|
|
||||||
_ = wxStaticBoxSizer:add(SpecSz, CallSz, zxw:flags({wide, 5})),
|
|
||||||
_ = wxStaticBoxSizer:add(SpecSz, ReturnSz, zxw:flags({base, 5})),
|
|
||||||
{SpecSz, CallControls, Return, Copy, HasArgs}.
|
|
||||||
|
|
||||||
call_sizer(Parent, J, []) ->
|
|
||||||
CallSz = wxStaticBoxSizer:new(?wxVERTICAL, Parent, [{label, J("Call Args")}]),
|
|
||||||
CallBox = wxStaticBoxSizer:getStaticBox(CallSz),
|
|
||||||
Args = wxStaticText:new(CallBox, ?wxID_ANY, ["[", J("No Args"), "]"]),
|
|
||||||
_ = wxStaticBoxSizer:add(CallSz, Args, zxw:flags({wide, 5})),
|
|
||||||
{CallSz, [], false};
|
|
||||||
call_sizer(Parent, J, CallArgs) ->
|
|
||||||
CallSz = wxStaticBoxSizer:new(?wxVERTICAL, Parent, [{label, J("Call Args")}]),
|
|
||||||
CallBox = wxStaticBoxSizer:getStaticBox(CallSz),
|
|
||||||
ScrollWin = wxScrolledWindow:new(CallBox),
|
|
||||||
ScrollSz = wxBoxSizer:new(?wxVERTICAL),
|
|
||||||
ok = wxScrolledWindow:setSizerAndFit(ScrollWin, ScrollSz),
|
|
||||||
ok = wxScrolledWindow:setScrollRate(ScrollWin, 5, 5),
|
|
||||||
GridSz = wxFlexGridSizer:new(2, [{gap, {4, 4}}]),
|
|
||||||
ok = wxFlexGridSizer:setFlexibleDirection(GridSz, ?wxHORIZONTAL),
|
|
||||||
ok = wxFlexGridSizer:addGrowableCol(GridSz, 1),
|
|
||||||
_ = wxStaticBoxSizer:add(ScrollSz, GridSz, zxw:flags(wide)),
|
|
||||||
_ = wxStaticBoxSizer:add(CallSz, ScrollWin, zxw:flags(wide)),
|
|
||||||
AddArg =
|
|
||||||
fun({Name, Type}) ->
|
|
||||||
L = wxStaticText:new(ScrollWin, ?wxID_ANY, [Name, " : ", textify(Type)]),
|
|
||||||
C = #w{wx = T} = gd_lib:mono_text(ScrollWin, Name),
|
|
||||||
_ = wxFlexGridSizer:add(GridSz, L, zxw:flags({base, 5})),
|
|
||||||
_ = wxFlexGridSizer:add(GridSz, T, zxw:flags({wide, 5})),
|
|
||||||
C
|
|
||||||
end,
|
|
||||||
Controls = lists:map(AddArg, CallArgs),
|
|
||||||
{CallSz, Controls, true}.
|
|
||||||
|
|
||||||
return_sizer(Parent, J, FunIlk, ReturnType) ->
|
|
||||||
IlkLabel =
|
|
||||||
case FunIlk =:= init of
|
|
||||||
false -> textify(ReturnType);
|
|
||||||
true -> J("Contract Address")
|
|
||||||
end,
|
|
||||||
ReturnSz = wxStaticBoxSizer:new(?wxVERTICAL, Parent, [{label, J("Return Type")}]),
|
|
||||||
ReturnSzBox = wxStaticBoxSizer:getStaticBox(ReturnSz),
|
|
||||||
ReturnLabel = wxStaticText:new(ReturnSzBox, ?wxID_ANY, IlkLabel),
|
|
||||||
Single = [{style, ?wxTE_READONLY}],
|
|
||||||
Return = #w{wx = ReturnTx} = gd_lib:mono_text(ReturnSzBox, return, "", Single),
|
|
||||||
Copy = #w{wx = CopyB} = gd_lib:button(ReturnSzBox, J("Copy")),
|
|
||||||
_ = wxButton:disable(CopyB),
|
|
||||||
_ = wxStaticBoxSizer:add(ReturnSz, ReturnLabel, zxw:flags({wide, 5})),
|
|
||||||
_ = wxStaticBoxSizer:add(ReturnSz, ReturnTx, zxw:flags({wide, 5})),
|
|
||||||
_ = wxStaticBoxSizer:add(ReturnSz, CopyB, zxw:flags({wide, 5})),
|
|
||||||
{ReturnSz, Return, Copy}.
|
|
||||||
|
|
||||||
|
|
||||||
call_param_sizer(Frame, J) ->
|
|
||||||
{ok, Height} = hz:top_height(),
|
|
||||||
DefTTL = Height + 10000,
|
|
||||||
DefGasP = hz:min_gas_price(),
|
|
||||||
DefGas = 5000000,
|
|
||||||
DefAmount = 0,
|
|
||||||
ParamSz = wxStaticBoxSizer:new(?wxVERTICAL, Frame, [{label, J("TX Parameters")}]),
|
|
||||||
ParamBox = wxStaticBoxSizer:getStaticBox(ParamSz),
|
|
||||||
GridSz = wxFlexGridSizer:new(2, 4, 4),
|
|
||||||
ok = wxFlexGridSizer:setFlexibleDirection(GridSz, ?wxHORIZONTAL),
|
|
||||||
ok = wxFlexGridSizer:addGrowableCol(GridSz, 1),
|
|
||||||
Amount_L = wxStaticText:new(ParamBox, ?wxID_ANY, J("Amount")),
|
|
||||||
Amount_T = wxTextCtrl:new(ParamBox, ?wxID_ANY),
|
|
||||||
ok = wxTextCtrl:setValue(Amount_T, integer_to_list(DefAmount)),
|
|
||||||
Gas_L = wxStaticText:new(ParamBox, ?wxID_ANY, J("Gas")),
|
|
||||||
Gas_T = wxTextCtrl:new(ParamBox, ?wxID_ANY),
|
|
||||||
ok = wxTextCtrl:setValue(Gas_T, integer_to_list(DefGas)),
|
|
||||||
GasP_L = wxStaticText:new(ParamBox, ?wxID_ANY, J("Gas Price")),
|
|
||||||
GasP_T = wxTextCtrl:new(ParamBox, ?wxID_ANY),
|
|
||||||
ok = wxTextCtrl:setValue(GasP_T, integer_to_list(DefGasP)),
|
|
||||||
TTL_L = wxStaticText:new(ParamBox, ?wxID_ANY, "TTL"),
|
|
||||||
TTL_T = wxTextCtrl:new(ParamBox, ?wxID_ANY),
|
|
||||||
ok = wxTextCtrl:setValue(TTL_T, integer_to_list(DefTTL)),
|
|
||||||
_ = wxFlexGridSizer:add(GridSz, Amount_L, zxw:flags({base, 5})),
|
|
||||||
_ = wxFlexGridSizer:add(GridSz, Amount_T, zxw:flags({wide, 5})),
|
|
||||||
_ = wxFlexGridSizer:add(GridSz, Gas_L, zxw:flags({base, 5})),
|
|
||||||
_ = wxFlexGridSizer:add(GridSz, Gas_T, zxw:flags({wide, 5})),
|
|
||||||
_ = wxFlexGridSizer:add(GridSz, GasP_L, zxw:flags({base, 5})),
|
|
||||||
_ = wxFlexGridSizer:add(GridSz, GasP_T, zxw:flags({wide, 5})),
|
|
||||||
_ = wxFlexGridSizer:add(GridSz, TTL_L, zxw:flags({base, 5})),
|
|
||||||
_ = wxFlexGridSizer:add(GridSz, TTL_T, zxw:flags({wide, 5})),
|
|
||||||
_ = wxSizer:add(ParamSz, GridSz, zxw:flags(wide)),
|
|
||||||
Params =
|
|
||||||
[{J("TX Amount"), fun gte_0/1, Amount_T} ,
|
|
||||||
{J("Gas") , fun gt_0/1, Gas_T},
|
|
||||||
{J("Gas Price"), fun gt_0/1, GasP_T},
|
|
||||||
{ "TTL", fun gte_0/1, TTL_T}],
|
|
||||||
{ParamSz, Params}.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%%% Spine
|
|
||||||
|
|
||||||
handle_call(tx_hash, _, State) ->
|
|
||||||
TXHash = do_tx_hash(State),
|
|
||||||
{reply, TXHash, State};
|
|
||||||
handle_call(tx_data, _, State = #s{tx_data = TXData}) ->
|
|
||||||
{reply, TXData, State};
|
|
||||||
handle_call(tx_info, _, State = #s{tx_info = TXInfo}) ->
|
|
||||||
{reply, TXInfo, State};
|
|
||||||
handle_call(Unexpected, From, State) ->
|
|
||||||
ok = log(warning, "Unexpected call from ~tp: ~tp~n", [From, Unexpected]),
|
|
||||||
{noreply, State}.
|
|
||||||
|
|
||||||
|
|
||||||
handle_cast(Unexpected, State) ->
|
|
||||||
ok = log(warning, "Unexpected cast: ~tp~n", [Unexpected]),
|
|
||||||
{noreply, State}.
|
|
||||||
|
|
||||||
|
|
||||||
handle_info(retire, State) ->
|
|
||||||
ok = retire(State),
|
|
||||||
{noreply, State};
|
|
||||||
handle_info(Unexpected, State) ->
|
|
||||||
ok = log(warning, "Unexpected info: ~tp~n", [Unexpected]),
|
|
||||||
{noreply, State}.
|
|
||||||
|
|
||||||
|
|
||||||
handle_event(#wx{event = #wxCommand{type = command_button_clicked}, id = ID},
|
|
||||||
State = #s{action = #w{id = ID}, status = none}) ->
|
|
||||||
NewState = prep_call(State),
|
|
||||||
{noreply, NewState};
|
|
||||||
handle_event(#wx{event = #wxCommand{type = command_button_clicked}, id = ID},
|
|
||||||
State = #s{action = #w{id = ID}}) ->
|
|
||||||
NewState = check_tx(State),
|
|
||||||
{noreply, NewState};
|
|
||||||
handle_event(#wx{event = #wxCommand{type = command_button_clicked}, id = ID},
|
|
||||||
State = #s{copy = #w{id = ID}}) ->
|
|
||||||
ok = copy(State),
|
|
||||||
{noreply, State};
|
|
||||||
handle_event(#wx{event = #wxClose{}}, State) ->
|
|
||||||
ok = retire(State),
|
|
||||||
{noreply, State};
|
|
||||||
handle_event(Event, State) ->
|
|
||||||
ok = tell(info, "Unexpected event ~tp State: ~tp~n", [Event, State]),
|
|
||||||
{noreply, State}.
|
|
||||||
|
|
||||||
|
|
||||||
code_change(_, State, _) ->
|
|
||||||
{ok, State}.
|
|
||||||
|
|
||||||
|
|
||||||
retire(#s{frame = Frame}) ->
|
|
||||||
wxWindow:destroy(Frame).
|
|
||||||
|
|
||||||
|
|
||||||
terminate(wx_deleted, _) ->
|
|
||||||
wx:destroy();
|
|
||||||
terminate(Reason, State) ->
|
|
||||||
ok = log(info, "Reason: ~tp, State: ~tp", [Reason, State]),
|
|
||||||
wx:destroy().
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%%% Handlers
|
|
||||||
|
|
||||||
handle_troubling(State = #s{frame = Frame}, Info) ->
|
|
||||||
ok = wxFrame:raise(Frame),
|
|
||||||
ok = zxw:show_message(Frame, Info),
|
|
||||||
State.
|
|
||||||
|
|
||||||
|
|
||||||
do_tx_hash(#s{tx_data = #{"tx_hash" := TXHash}}) ->
|
|
||||||
TXHash;
|
|
||||||
do_tx_hash(#s{tx_data = none}) ->
|
|
||||||
none.
|
|
||||||
|
|
||||||
|
|
||||||
prep_call(State) ->
|
|
||||||
case gd_con:chain_id() of
|
|
||||||
{ok, ChainID} -> prep_call2(State, ChainID);
|
|
||||||
Error -> handle_troubling(State, Error)
|
|
||||||
end.
|
|
||||||
|
|
||||||
prep_call2(State, ChainID) ->
|
|
||||||
case params(State) of
|
|
||||||
{ok, Params} -> prep_call3(State, ChainID, Params);
|
|
||||||
Error -> handle_troubling(State, Error)
|
|
||||||
end.
|
|
||||||
|
|
||||||
prep_call3(State, ChainID, Params) ->
|
|
||||||
case args(State) of
|
|
||||||
{ok, Args} -> prep_call4(State, ChainID, Params, {sophia, Args});
|
|
||||||
Error -> handle_troubling(State, Error)
|
|
||||||
end.
|
|
||||||
|
|
||||||
prep_call4(State = #s{fundef = {"init", init}, build = Build}, ChainID, Params, Args) ->
|
|
||||||
{CallerID, Nonce, Gas, GP, Amount, TTL} = Params,
|
|
||||||
case hz:contract_create_built(CallerID, Nonce, Gas, GP, Amount, TTL, Build, Args) of
|
|
||||||
{ok, CreateTX} -> deploy(State, ChainID, CallerID, CreateTX);
|
|
||||||
Error -> handle_troubling(State, Error)
|
|
||||||
end;
|
|
||||||
prep_call4(State = #s{fundef = {Name, Ilk}, con_id = ConID, build = Build}, ChainID, Params, Args) ->
|
|
||||||
{CallerID, Nonce, Gas, GP, Amount, TTL} = Params,
|
|
||||||
AACI = maps:get(aaci, Build),
|
|
||||||
case hz:contract_call(CallerID, Nonce, Gas, GP, Amount, TTL, AACI, ConID, Name, Args) of
|
|
||||||
{ok, UnsignedTX} ->
|
|
||||||
case Ilk of
|
|
||||||
call -> do_call(State, ChainID, CallerID, UnsignedTX);
|
|
||||||
dryr -> do_dry_run(State, ConID, UnsignedTX)
|
|
||||||
end;
|
|
||||||
Error ->
|
|
||||||
handle_troubling(State, Error)
|
|
||||||
end.
|
|
||||||
|
|
||||||
params(State = #s{kp = #w{wx = KeyPicker}}) ->
|
|
||||||
ID = wxChoice:getString(KeyPicker, wxChoice:getSelection(KeyPicker)),
|
|
||||||
PK = unicode:characters_to_binary(ID),
|
|
||||||
case hz:next_nonce(PK) of
|
|
||||||
{ok, Nonce} -> params2(State, PK, Nonce);
|
|
||||||
Error -> handle_troubling(State, Error)
|
|
||||||
end.
|
|
||||||
|
|
||||||
params2(#s{params = Params}, PK, Nonce) ->
|
|
||||||
case lists:foldl(fun extract/2, {ok, []}, Params) of
|
|
||||||
{ok, [TTL, GP, Gas, Amount]} -> {ok, {PK, Nonce, Gas, GP, Amount, TTL}};
|
|
||||||
Error -> Error
|
|
||||||
end.
|
|
||||||
|
|
||||||
extract({Name, Check, Widget}, {Status, Out}) ->
|
|
||||||
case Check(wxTextCtrl:getValue(Widget)) of
|
|
||||||
{ok, Value} -> {Status, [Value | Out]};
|
|
||||||
Error -> {error, [{Name, Error}, Out]}
|
|
||||||
end.
|
|
||||||
|
|
||||||
|
|
||||||
% TODO: Put some basic checking in here, like for blank strings, at least.
|
|
||||||
% It should be possible to perform type/parse checks over this since we have
|
|
||||||
% access to the AACI. But not today.
|
|
||||||
args(#s{args = ArgFields}) ->
|
|
||||||
Values = [wxTextCtrl:getValue(W) || #w{wx = W} <- ArgFields],
|
|
||||||
{ok, Values}.
|
|
||||||
|
|
||||||
|
|
||||||
deploy(State, ChainID, CallerID, CreateTX) ->
|
|
||||||
case gd_con:sign_call(ChainID, CallerID, CreateTX) of
|
|
||||||
{ok, SignedTX} -> deploy2(State, SignedTX);
|
|
||||||
Error -> handle_troubling(State, Error)
|
|
||||||
end.
|
|
||||||
|
|
||||||
deploy2(State = #s{j = J, hash = #w{wx = HashT}, action = #w{wx = ActionB}}, SignedTX) ->
|
|
||||||
case hz:post_tx(SignedTX) of
|
|
||||||
{ok, Data = #{"tx_hash" := TXHash}} ->
|
|
||||||
_ = wxButton:disable(ActionB),
|
|
||||||
ok = wxButton:setLabel(ActionB, J("Check Transaction Status")),
|
|
||||||
ok = log(info, "Submitted transaction ~s", [TXHash]),
|
|
||||||
ok = wxTextCtrl:setValue(HashT, unicode:characters_to_list(TXHash)),
|
|
||||||
check_tx(State#s{tx_data = Data, status = submitted});
|
|
||||||
{ok, #{"reason" := Reason}} ->
|
|
||||||
handle_troubling(State, {error, Reason});
|
|
||||||
Error ->
|
|
||||||
handle_troubling(State, Error)
|
|
||||||
end.
|
|
||||||
|
|
||||||
|
|
||||||
do_call(State, ChainID, CallerID, UnsignedTX) ->
|
|
||||||
case gd_con:sign_call(ChainID, CallerID, UnsignedTX) of
|
|
||||||
{ok, SignedTX} -> do_call2(State, SignedTX);
|
|
||||||
Error -> handle_troubling(State, Error)
|
|
||||||
end.
|
|
||||||
|
|
||||||
do_call2(State = #s{action = #w{wx = ActionB}}, SignedTX) ->
|
|
||||||
_ = wxButton:disable(ActionB),
|
|
||||||
case hz:post_tx(SignedTX) of
|
|
||||||
{ok, #{"reason" := Reason}} -> handle_troubling(State#s{status = rejected}, Reason);
|
|
||||||
{ok, Data} -> check_tx(State#s{tx_data = Data, status = submitted});
|
|
||||||
Error -> handle_troubling(State, Error)
|
|
||||||
end.
|
|
||||||
|
|
||||||
|
|
||||||
do_dry_run(State = #s{action = #w{wx = ActionB}}, ConID, TX) ->
|
|
||||||
_ = wxButton:disable(ActionB),
|
|
||||||
case hz:dry_run(TX) of
|
|
||||||
{ok, Result} -> dry_run2(State#s{tx_info = Result});
|
|
||||||
Other -> handle_troubling(State, {error, ConID, Other})
|
|
||||||
end.
|
|
||||||
|
|
||||||
|
|
||||||
dry_run2(State = #s{funret = ReturnType,
|
|
||||||
return = #w{wx = ReturnT},
|
|
||||||
copy = #w{wx = CopyB},
|
|
||||||
tx_data = TXData,
|
|
||||||
tx_info = TXInfo,
|
|
||||||
hash = #w{wx = HashT},
|
|
||||||
info = #w{wx = InfoT}}) ->
|
|
||||||
ReturnV =
|
|
||||||
case TXInfo of
|
|
||||||
#{"results" :=
|
|
||||||
[#{"call_obj" :=
|
|
||||||
#{"return_type" := "revert",
|
|
||||||
"return_value" := ReturnCB},
|
|
||||||
"result" := "ok","type" := "contract_call"}]} ->
|
|
||||||
io_lib:format("Revert: ~ts", [hz:decode_bytearray(ReturnCB, sophia)]);
|
|
||||||
#{"results" :=
|
|
||||||
[#{"call_obj" :=
|
|
||||||
#{"return_type" := "ok",
|
|
||||||
"return_value" := ReturnCB},
|
|
||||||
"result" := "ok","type" := "contract_call"}]} ->
|
|
||||||
hz:decode_bytearray(ReturnCB, {sophia, ReturnType});
|
|
||||||
Other ->
|
|
||||||
io_lib:format("???: ~tp", [Other])
|
|
||||||
end,
|
|
||||||
_ = wxButton:enable(CopyB),
|
|
||||||
FormattedHash = io_lib:format("~tp", [TXData]),
|
|
||||||
FormattedInfo = io_lib:format("~tp", [TXInfo]),
|
|
||||||
ok = wxTextCtrl:setValue(ReturnT, ReturnV),
|
|
||||||
ok = wxTextCtrl:setValue(HashT, FormattedHash),
|
|
||||||
ok = wxTextCtrl:setValue(InfoT, FormattedInfo),
|
|
||||||
State.
|
|
||||||
|
|
||||||
|
|
||||||
check_tx(State = #s{j = J,
|
|
||||||
fundef = {_, init},
|
|
||||||
tx_data = #{"tx_hash" := TXHash},
|
|
||||||
tx_info = none,
|
|
||||||
status = submitted,
|
|
||||||
action = #w{wx = ActionB},
|
|
||||||
info = #w{wx = InfoT}}) ->
|
|
||||||
case hz:tx_info(TXHash) of
|
|
||||||
{ok, Info = #{"call_info" := #{"return_type" := "ok", "contract_id" := ConID}}} ->
|
|
||||||
ok = tell(info, "Contract deployed: ~p", [Info]),
|
|
||||||
_ = wxButton:disable(ActionB),
|
|
||||||
ok = gd_con:open_contract(ConID),
|
|
||||||
self() ! retire,
|
|
||||||
State;
|
|
||||||
{error, "Tx not mined"} ->
|
|
||||||
ok = wxTextCtrl:setValue(InfoT, J("[Transaction not yet mined.]")),
|
|
||||||
ok = wxButton:setLabel(ActionB, J("Check Deployment Status")),
|
|
||||||
_ = wxButton:enable(ActionB),
|
|
||||||
State;
|
|
||||||
Other ->
|
|
||||||
FormattedJunk = io_lib:format("~tp", [Other]),
|
|
||||||
ok = wxTextCtrl:setValue(InfoT, FormattedJunk),
|
|
||||||
ok = wxButton:setLabel(ActionB, J("Check Depoyment Status")),
|
|
||||||
_ = wxButton:enable(ActionB),
|
|
||||||
State
|
|
||||||
end;
|
|
||||||
check_tx(State = #s{j = J,
|
|
||||||
funret = ReturnType,
|
|
||||||
tx_data = #{"tx_hash" := TXHash},
|
|
||||||
tx_info = none,
|
|
||||||
status = submitted,
|
|
||||||
return = #w{wx = ReturnT},
|
|
||||||
copy = #w{wx = CopyB},
|
|
||||||
action = #w{wx = ActionB},
|
|
||||||
info = #w{wx = InfoT}}) ->
|
|
||||||
case hz:tx_info(TXHash) of
|
|
||||||
{ok, Info = #{"call_info" := #{"return_type" := "ok",
|
|
||||||
"return_value" := ReturnCB}}} ->
|
|
||||||
FormattedInfo = io_lib:format("~tp", [Info]),
|
|
||||||
_ = wxButton:enable(CopyB),
|
|
||||||
_ = wxButton:disable(ActionB),
|
|
||||||
ReturnV = hz:decode_bytearray(ReturnCB, {sophia, ReturnType}),
|
|
||||||
ok = wxTextCtrl:setValue(ReturnT, ReturnV),
|
|
||||||
ok = wxTextCtrl:setValue(InfoT, FormattedInfo),
|
|
||||||
State#s{status = included, tx_info = Info};
|
|
||||||
{ok, Reason = #{"call_info" := #{"return_type" := "revert", "return_value" := ReturnCB}}} ->
|
|
||||||
_ = wxButton:enable(CopyB),
|
|
||||||
_ = wxButton:disable(ActionB),
|
|
||||||
ReturnV = io_lib:format("Revert: ~ts", [hz:decode_bytearray(ReturnCB, sophia)]),
|
|
||||||
ok = wxTextCtrl:setValue(ReturnT, ReturnV),
|
|
||||||
FormattedInfo = io_lib:format("~tp", [Reason]),
|
|
||||||
ok = wxTextCtrl:setValue(InfoT, FormattedInfo),
|
|
||||||
State#s{status = rejected, tx_info = Reason};
|
|
||||||
{error, "Tx not mined"} ->
|
|
||||||
ok = wxTextCtrl:setValue(InfoT, J("[Transaction not yet mined.]")),
|
|
||||||
ok = wxButton:setLabel(ActionB, J("Check Transaction Status")),
|
|
||||||
_ = wxButton:enable(ActionB),
|
|
||||||
State;
|
|
||||||
Error ->
|
|
||||||
handle_troubling(State, Error)
|
|
||||||
end;
|
|
||||||
check_tx(State = #s{tx_data = TXData,
|
|
||||||
action = #w{wx = ActionB}}) ->
|
|
||||||
_ = wxButton:disable(ActionB),
|
|
||||||
tell(info, "TXData: ~p", [TXData]),
|
|
||||||
ok = tell("Nothing to check"),
|
|
||||||
State.
|
|
||||||
|
|
||||||
|
|
||||||
copy(#s{tx_info = none}) ->
|
|
||||||
ok;
|
|
||||||
copy(#s{return = #w{wx = ReturnT}}) ->
|
|
||||||
Output = wxTextCtrl:getValue(ReturnT),
|
|
||||||
gd_lib:copy_to_clipboard(Output).
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
textify({integer, _, _}) -> "int";
|
|
||||||
textify({boolean, _, _}) -> "bool";
|
|
||||||
textify({{bytes, [I]}, _, _}) -> io_lib:format("bytes(~w)", [I]);
|
|
||||||
textify({{bytes, any}, _, _}) -> "bytes()";
|
|
||||||
textify({T, _, _}) when is_atom(T) -> atom_to_list(T);
|
|
||||||
textify({T, _, _}) when is_list(T) -> T;
|
|
||||||
textify({T, _, _}) -> io_lib:format("~tp", [T]).
|
|
||||||
|
|
||||||
|
|
||||||
gt_0(S) ->
|
|
||||||
C = "Must be an integer greater than 0",
|
|
||||||
R =
|
|
||||||
try
|
|
||||||
{ok, list_to_integer(S)}
|
|
||||||
catch
|
|
||||||
error:badarg -> {error, {S, C}}
|
|
||||||
end,
|
|
||||||
case R of
|
|
||||||
{ok, N} when N > 0 -> {ok, N};
|
|
||||||
{ok, N} when N =< 0 -> {error, {S, C}};
|
|
||||||
Error -> Error
|
|
||||||
end.
|
|
||||||
|
|
||||||
gte_0(S) ->
|
|
||||||
C = "Must be a non-negative integer.",
|
|
||||||
R =
|
|
||||||
try
|
|
||||||
{ok, list_to_integer(S)}
|
|
||||||
catch
|
|
||||||
error:badarg -> {error, {S, C}}
|
|
||||||
end,
|
|
||||||
case R of
|
|
||||||
{ok, N} when N >= 0 -> {ok, N};
|
|
||||||
{ok, N} when N < 0 -> {error, {S, C}};
|
|
||||||
Error -> Error
|
|
||||||
end.
|
|
||||||
+629
-151
File diff suppressed because it is too large
Load Diff
+7
-3
@@ -1,5 +1,5 @@
|
|||||||
-module(gd_v_netman).
|
-module(gd_v_netman).
|
||||||
-vsn("0.9.0").
|
-vsn("0.5.4").
|
||||||
-author("Craig Everett <zxq9@zxq9.com>").
|
-author("Craig Everett <zxq9@zxq9.com>").
|
||||||
-copyright("QPQ AG <info@qpq.swiss>").
|
-copyright("QPQ AG <info@qpq.swiss>").
|
||||||
-license("GPL-3.0-or-later").
|
-license("GPL-3.0-or-later").
|
||||||
@@ -14,9 +14,13 @@
|
|||||||
handle_call/3, handle_cast/2, handle_info/2, handle_event/2]).
|
handle_call/3, handle_cast/2, handle_info/2, handle_event/2]).
|
||||||
-include("$zx_include/zx_logger.hrl").
|
-include("$zx_include/zx_logger.hrl").
|
||||||
-include("gd.hrl").
|
-include("gd.hrl").
|
||||||
-include("gdl.hrl").
|
|
||||||
|
|
||||||
|
|
||||||
|
-record(w,
|
||||||
|
{name = none :: atom(),
|
||||||
|
id = 0 :: integer(),
|
||||||
|
wx = none :: none | wx:wx_object()}).
|
||||||
|
|
||||||
-record(s,
|
-record(s,
|
||||||
{wx = none :: none | wx:wx_object(),
|
{wx = none :: none | wx:wx_object(),
|
||||||
frame = none :: none | wx:wx_object(),
|
frame = none :: none | wx:wx_object(),
|
||||||
@@ -56,7 +60,7 @@ start_link(Args) ->
|
|||||||
|
|
||||||
|
|
||||||
init({Prefs, Manifest}) ->
|
init({Prefs, Manifest}) ->
|
||||||
Lang = maps:get(lang, Prefs, en),
|
Lang = maps:get(lang, Prefs, en_us),
|
||||||
Trans = gd_jt:read_translations(?MODULE),
|
Trans = gd_jt:read_translations(?MODULE),
|
||||||
J = gd_jt:j(Lang, Trans),
|
J = gd_jt:j(Lang, Trans),
|
||||||
Wx = wx:new(),
|
Wx = wx:new(),
|
||||||
|
|||||||
+105
-227
@@ -1,19 +1,5 @@
|
|||||||
%%% @doc
|
|
||||||
%%% The GajuDesk Wallet Manager
|
|
||||||
%%%
|
|
||||||
%%% This is an interface for managing multiple wallets.
|
|
||||||
%%% A wallet is defined as a collection of accounts/keys.
|
|
||||||
%%%
|
|
||||||
%%% NOTE:
|
|
||||||
%%% Any call to `gd_con:show_ui(gd_v_wallman)' must be followed by a call to
|
|
||||||
%%% either `gd_v_wallman:to_front()' or `gd_v_wallman:first_run()' or else
|
|
||||||
%%% this UI process will just sit in the background (invisible) until told to
|
|
||||||
%%% do something.
|
|
||||||
%%% @end
|
|
||||||
|
|
||||||
|
|
||||||
-module(gd_v_wallman).
|
-module(gd_v_wallman).
|
||||||
-vsn("0.9.0").
|
-vsn("0.5.4").
|
||||||
-author("Craig Everett <zxq9@zxq9.com>").
|
-author("Craig Everett <zxq9@zxq9.com>").
|
||||||
-copyright("QPQ AG <info@qpq.swiss>").
|
-copyright("QPQ AG <info@qpq.swiss>").
|
||||||
-license("GPL-3.0-or-later").
|
-license("GPL-3.0-or-later").
|
||||||
@@ -21,16 +7,20 @@
|
|||||||
-behavior(wx_object).
|
-behavior(wx_object).
|
||||||
%-behavior(gd_v).
|
%-behavior(gd_v).
|
||||||
-include_lib("wx/include/wx.hrl").
|
-include_lib("wx/include/wx.hrl").
|
||||||
-export([to_front/0, to_front/1, first_run/0, trouble/1]).
|
-export([to_front/1]).
|
||||||
-export([show/2]).
|
-export([show/2]).
|
||||||
-export([start_link/1]).
|
-export([start_link/1]).
|
||||||
-export([init/1, terminate/2, code_change/3,
|
-export([init/1, terminate/2, code_change/3,
|
||||||
handle_call/3, handle_cast/2, handle_info/2, handle_event/2]).
|
handle_call/3, handle_cast/2, handle_info/2, handle_event/2]).
|
||||||
-include("$zx_include/zx_logger.hrl").
|
-include("$zx_include/zx_logger.hrl").
|
||||||
-include("gd.hrl").
|
-include("gd.hrl").
|
||||||
-include("gdl.hrl").
|
|
||||||
|
|
||||||
|
|
||||||
|
-record(w,
|
||||||
|
{name = none :: atom(),
|
||||||
|
id = 0 :: integer(),
|
||||||
|
wx = none :: none | wx:wx_object()}).
|
||||||
|
|
||||||
-record(s,
|
-record(s,
|
||||||
{wx = none :: none | wx:wx_object(),
|
{wx = none :: none | wx:wx_object(),
|
||||||
frame = none :: none | wx:wx_object(),
|
frame = none :: none | wx:wx_object(),
|
||||||
@@ -39,18 +29,11 @@
|
|||||||
prefs = #{} :: map(),
|
prefs = #{} :: map(),
|
||||||
wallets = [] :: [#wr{}],
|
wallets = [] :: [#wr{}],
|
||||||
picker = none :: none | wx:wx_object(),
|
picker = none :: none | wx:wx_object(),
|
||||||
buttons = [] :: [#w{}],
|
buttons = [] :: [#w{}]}).
|
||||||
wiz = none :: none | {wx:wx_object(), Buttons :: [#w{}]}}).
|
|
||||||
|
|
||||||
|
|
||||||
%%% Interface
|
%%% Interface
|
||||||
|
|
||||||
-spec to_front() -> ok.
|
|
||||||
|
|
||||||
to_front() ->
|
|
||||||
wx_object:cast(?MODULE, to_front).
|
|
||||||
|
|
||||||
|
|
||||||
-spec to_front(Win) -> ok
|
-spec to_front(Win) -> ok
|
||||||
when Win :: wx:wx_object().
|
when Win :: wx:wx_object().
|
||||||
|
|
||||||
@@ -58,19 +41,6 @@ to_front(Win) ->
|
|||||||
wx_object:cast(Win, to_front).
|
wx_object:cast(Win, to_front).
|
||||||
|
|
||||||
|
|
||||||
-spec first_run() -> ok.
|
|
||||||
|
|
||||||
first_run() ->
|
|
||||||
wx_object:cast(?MODULE, first_run).
|
|
||||||
|
|
||||||
|
|
||||||
-spec trouble(Info) -> ok
|
|
||||||
when Info :: term().
|
|
||||||
|
|
||||||
trouble(Info) ->
|
|
||||||
wx_object:cast(?MODULE, {trouble, Info}).
|
|
||||||
|
|
||||||
|
|
||||||
-spec show(Win, Manifest) -> ok
|
-spec show(Win, Manifest) -> ok
|
||||||
when Win :: wx:xw_object(),
|
when Win :: wx:xw_object(),
|
||||||
Manifest :: [#wr{}].
|
Manifest :: [#wr{}].
|
||||||
@@ -86,7 +56,7 @@ start_link(Args) ->
|
|||||||
|
|
||||||
|
|
||||||
init({Prefs, Manifest}) ->
|
init({Prefs, Manifest}) ->
|
||||||
Lang = maps:get(lang, Prefs, en),
|
Lang = maps:get(lang, Prefs, en_us),
|
||||||
Trans = gd_jt:read_translations(?MODULE),
|
Trans = gd_jt:read_translations(?MODULE),
|
||||||
J = gd_jt:j(Lang, Trans),
|
J = gd_jt:j(Lang, Trans),
|
||||||
Wx = wx:new(),
|
Wx = wx:new(),
|
||||||
@@ -119,24 +89,11 @@ init({Prefs, Manifest}) ->
|
|||||||
ok = wxFrame:setSizer(Frame, MainSz),
|
ok = wxFrame:setSizer(Frame, MainSz),
|
||||||
ok = wxSizer:layout(MainSz),
|
ok = wxSizer:layout(MainSz),
|
||||||
|
|
||||||
NewPrefs =
|
ok = gd_v:safe_size(Frame, Prefs),
|
||||||
case maps:is_key(geometry, Prefs) of
|
|
||||||
true ->
|
|
||||||
Prefs;
|
|
||||||
false ->
|
|
||||||
Display = wxDisplay:new(),
|
|
||||||
{_, _, W, H} = wxDisplay:getGeometry(Display),
|
|
||||||
ok = wxDisplay:destroy(Display),
|
|
||||||
WW = 500,
|
|
||||||
WH = 350,
|
|
||||||
X = (W div 2) - (WW div 2),
|
|
||||||
Y = (H div 2) - (WH div 2),
|
|
||||||
Prefs#{geometry => {X, Y, WW, WH}}
|
|
||||||
end,
|
|
||||||
ok = gd_v:safe_size(Frame, NewPrefs),
|
|
||||||
|
|
||||||
ok = wxFrame:connect(Frame, command_button_clicked),
|
ok = wxFrame:connect(Frame, command_button_clicked),
|
||||||
ok = wxFrame:connect(Frame, close_window),
|
ok = wxFrame:connect(Frame, close_window),
|
||||||
|
true = wxFrame:show(Frame),
|
||||||
ok = wxListBox:connect(Picker, command_listbox_doubleclicked),
|
ok = wxListBox:connect(Picker, command_listbox_doubleclicked),
|
||||||
State = #s{wx = Wx, frame = Frame, lang = Lang, j = J, prefs = Prefs,
|
State = #s{wx = Wx, frame = Frame, lang = Lang, j = J, prefs = Prefs,
|
||||||
wallets = Manifest,
|
wallets = Manifest,
|
||||||
@@ -146,23 +103,16 @@ init({Prefs, Manifest}) ->
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%%% wx_object
|
%%% wx_object
|
||||||
|
|
||||||
handle_call(Unexpected, From, State) ->
|
handle_call(Unexpected, From, State) ->
|
||||||
ok = log(warning, "Unexpected call from ~tp: ~tp~n", [From, Unexpected]),
|
ok = log(warning, "Unexpected call from ~tp: ~tp~n", [From, Unexpected]),
|
||||||
{noreply, State}.
|
{noreply, State}.
|
||||||
|
|
||||||
|
|
||||||
handle_cast(to_front, State = #s{frame = Frame}) ->
|
handle_cast(to_front, State = #s{frame = Frame}) ->
|
||||||
ok = ensure_shown(Frame),
|
|
||||||
ok = wxFrame:raise(Frame),
|
ok = wxFrame:raise(Frame),
|
||||||
{noreply, State};
|
{noreply, State};
|
||||||
handle_cast(first_run, State) ->
|
|
||||||
NewState = do_first_run(State),
|
|
||||||
{noreply, NewState};
|
|
||||||
handle_cast({trouble, Info}, State) ->
|
|
||||||
ok = handle_troubling(State, Info),
|
|
||||||
{noreply, State};
|
|
||||||
handle_cast({show, Manifest}, State) ->
|
handle_cast({show, Manifest}, State) ->
|
||||||
NewState = do_show(Manifest, State),
|
NewState = do_show(Manifest, State),
|
||||||
{noreply, NewState};
|
{noreply, NewState};
|
||||||
@@ -178,7 +128,7 @@ handle_info(Unexpected, State) ->
|
|||||||
|
|
||||||
handle_event(#wx{event = #wxCommand{type = command_button_clicked},
|
handle_event(#wx{event = #wxCommand{type = command_button_clicked},
|
||||||
id = ID},
|
id = ID},
|
||||||
State = #s{buttons = Buttons, wiz = none}) ->
|
State = #s{buttons = Buttons}) ->
|
||||||
NewState =
|
NewState =
|
||||||
case lists:keyfind(ID, #w.id, Buttons) of
|
case lists:keyfind(ID, #w.id, Buttons) of
|
||||||
#w{name = open} -> do_open(State);
|
#w{name = open} -> do_open(State);
|
||||||
@@ -191,34 +141,17 @@ handle_event(#wx{event = #wxCommand{type = command_button_clicked},
|
|||||||
{noreply, NewState};
|
{noreply, NewState};
|
||||||
handle_event(#wx{event = #wxCommand{type = command_listbox_doubleclicked,
|
handle_event(#wx{event = #wxCommand{type = command_listbox_doubleclicked,
|
||||||
commandInt = Selected}},
|
commandInt = Selected}},
|
||||||
State = #s{wiz = none}) ->
|
State) ->
|
||||||
ok = do_open2(Selected + 1, State),
|
NewState = do_open2(Selected + 1, State),
|
||||||
{noreply, State};
|
{noreply, NewState};
|
||||||
handle_event(#wx{event = #wxClose{}}, State = #s{wiz = none}) ->
|
handle_event(#wx{event = #wxClose{}}, State) ->
|
||||||
ok = do_close(State),
|
ok = do_close(State),
|
||||||
{noreply, State};
|
{noreply, State};
|
||||||
handle_event(#wx{event = #wxCommand{type = command_button_clicked},
|
|
||||||
id = ID},
|
|
||||||
State = #s{wiz = {_, WizButtons}}) ->
|
|
||||||
NewState =
|
|
||||||
case lists:keyfind(ID, #w.id, WizButtons) of
|
|
||||||
#w{name = noob} -> wiz_noob_assist(State);
|
|
||||||
#w{name = l33t} -> close_wiz(State);
|
|
||||||
false -> State
|
|
||||||
end,
|
|
||||||
{noreply, NewState};
|
|
||||||
handle_event(#wx{event = #wxClose{}}, State = #s{wiz = {_, _}}) ->
|
|
||||||
NewState = close_wiz(State),
|
|
||||||
{noreply, NewState};
|
|
||||||
handle_event(Event, State) ->
|
handle_event(Event, State) ->
|
||||||
ok = tell(info, "Unexpected event ~tp State: ~tp~n", [Event, State]),
|
ok = tell(info, "Unexpected event ~tp State: ~tp~n", [Event, State]),
|
||||||
{noreply, State}.
|
{noreply, State}.
|
||||||
|
|
||||||
|
|
||||||
handle_troubling(#s{frame = Frame}, Info) ->
|
|
||||||
zxw:show_message(Frame, Info).
|
|
||||||
|
|
||||||
|
|
||||||
code_change(_, State, _) ->
|
code_change(_, State, _) ->
|
||||||
{ok, State}.
|
{ok, State}.
|
||||||
|
|
||||||
@@ -239,26 +172,6 @@ do_show(Manifest, State = #s{picker = Picker}) ->
|
|||||||
State#s{wallets = Manifest}.
|
State#s{wallets = Manifest}.
|
||||||
|
|
||||||
|
|
||||||
do_first_run(State = #s{frame = Frame, wallets = Manifest}) ->
|
|
||||||
Count = length(Manifest),
|
|
||||||
if
|
|
||||||
Count =:= 0 ->
|
|
||||||
do_wiz(State);
|
|
||||||
Count =:= 1 ->
|
|
||||||
do_open(State);
|
|
||||||
Count > 1 ->
|
|
||||||
true = wxFrame:show(Frame),
|
|
||||||
wxFrame:raise(Frame),
|
|
||||||
State
|
|
||||||
end.
|
|
||||||
|
|
||||||
|
|
||||||
close_wiz(State = #s{frame = Frame, wiz = {Wiz, _}}) ->
|
|
||||||
ok = wxWindow:destroy(Wiz),
|
|
||||||
true = wxFrame:show(Frame),
|
|
||||||
State#s{wiz = none}.
|
|
||||||
|
|
||||||
|
|
||||||
do_close(#s{frame = Frame, prefs = Prefs}) ->
|
do_close(#s{frame = Frame, prefs = Prefs}) ->
|
||||||
Geometry =
|
Geometry =
|
||||||
case wxTopLevelWindow:isMaximized(Frame) of
|
case wxTopLevelWindow:isMaximized(Frame) of
|
||||||
@@ -281,26 +194,10 @@ handle_button(Name, State) ->
|
|||||||
|
|
||||||
do_open(State = #s{wallets = []}) ->
|
do_open(State = #s{wallets = []}) ->
|
||||||
State;
|
State;
|
||||||
do_open(State = #s{wallets = [#wr{pass = true, path = Path}]}) ->
|
|
||||||
ok = do_open3(Path, State),
|
|
||||||
State;
|
|
||||||
do_open(State = #s{wallets = [#wr{pass = false, path = Path}], frame = Frame}) ->
|
|
||||||
ok =
|
|
||||||
case gd_con:open_wallet(Path, none) of
|
|
||||||
ok ->
|
|
||||||
do_close(State);
|
|
||||||
Error ->
|
|
||||||
ok = ensure_shown(Frame),
|
|
||||||
trouble(Error)
|
|
||||||
end,
|
|
||||||
State;
|
|
||||||
do_open(State = #s{picker = Picker}) ->
|
do_open(State = #s{picker = Picker}) ->
|
||||||
case wxListBox:getSelection(Picker) of
|
case wxListBox:getSelection(Picker) of
|
||||||
-1 ->
|
-1 -> State;
|
||||||
State;
|
Selected -> do_open2(Selected + 1, State)
|
||||||
Selected ->
|
|
||||||
ok = do_open2(Selected + 1, State),
|
|
||||||
State
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
do_open2(Selected, State = #s{wallets = Wallets}) ->
|
do_open2(Selected, State = #s{wallets = Wallets}) ->
|
||||||
@@ -309,74 +206,43 @@ do_open2(Selected, State = #s{wallets = Wallets}) ->
|
|||||||
do_open3(Path, State);
|
do_open3(Path, State);
|
||||||
#wr{pass = false, path = Path} ->
|
#wr{pass = false, path = Path} ->
|
||||||
ok = gd_con:open_wallet(Path, none),
|
ok = gd_con:open_wallet(Path, none),
|
||||||
do_close(State)
|
|
||||||
end.
|
|
||||||
|
|
||||||
do_open3(Path, State = #s{frame = Frame, j = J}) ->
|
|
||||||
Title = J("Passphrase"),
|
|
||||||
case zxw_modal_text:show(Frame, Title, [{password, true}]) of
|
|
||||||
{ok, Phrase} ->
|
|
||||||
case gd_con:open_wallet(Path, Phrase) of
|
|
||||||
ok -> do_close(State);
|
|
||||||
Error -> trouble(Error)
|
|
||||||
end;
|
|
||||||
cancel ->
|
|
||||||
ok
|
|
||||||
end.
|
|
||||||
|
|
||||||
|
|
||||||
do_wiz(State = #s{wx = WX, lang = Lang, wiz = none}) ->
|
|
||||||
Trans = gd_jt:read_translations(?MODULE),
|
|
||||||
J = gd_jt:j(Lang, Trans),
|
|
||||||
|
|
||||||
Wiz = wxFrame:new(WX, ?wxID_ANY, J("Initializing Wallet")),
|
|
||||||
MainSz = wxBoxSizer:new(?wxVERTICAL),
|
|
||||||
|
|
||||||
ButtonTemplates =
|
|
||||||
[{noob, J("I'm new!\nCreate a new account for me.")},
|
|
||||||
{l33t, J("Open the wallet manager.")}],
|
|
||||||
|
|
||||||
MakeButton =
|
|
||||||
fun({Name, Label}) ->
|
|
||||||
B = wxButton:new(Wiz, ?wxID_ANY, [{label, Label}]),
|
|
||||||
#w{name = Name, id = wxButton:getId(B), wx = B}
|
|
||||||
end,
|
|
||||||
|
|
||||||
Buttons = lists:map(MakeButton, ButtonTemplates),
|
|
||||||
|
|
||||||
Add = fun(#w{wx = Button}) -> wxBoxSizer:add(MainSz, Button, zxw:flags(wide)) end,
|
|
||||||
ok = lists:foreach(Add, Buttons),
|
|
||||||
|
|
||||||
ok = wxFrame:setSizer(Wiz, MainSz),
|
|
||||||
ok = wxSizer:layout(MainSz),
|
|
||||||
|
|
||||||
ok = wxFrame:connect(Wiz, command_button_clicked),
|
|
||||||
ok = wxFrame:connect(Wiz, close_window),
|
|
||||||
ok = wxFrame:setSize(Wiz, {300, 300}),
|
|
||||||
ok = wxFrame:center(Wiz),
|
|
||||||
true = wxFrame:show(Wiz),
|
|
||||||
State#s{wiz = {Wiz, Buttons}}.
|
|
||||||
|
|
||||||
|
|
||||||
wiz_noob_assist(State = #s{j = J, wiz = {Wiz, _}}) ->
|
|
||||||
DefaultDir = zx_lib:path(var, "otpr", "gajudesk"),
|
|
||||||
Name = default_name(),
|
|
||||||
Path = filename:join(DefaultDir, Name),
|
|
||||||
case do_new2(Path, J, Wiz) of
|
|
||||||
ok ->
|
|
||||||
Label = J("Account 1"),
|
|
||||||
ok = gd_con:make_key({eddsa, ed25519}, 256, Label, <<>>, none, {sha3, 256}),
|
|
||||||
ok = do_close(State),
|
ok = do_close(State),
|
||||||
State;
|
|
||||||
abort ->
|
|
||||||
State
|
State
|
||||||
end.
|
end.
|
||||||
|
|
||||||
default_name() ->
|
do_open3(Path, State = #s{frame = Frame, j = J}) ->
|
||||||
{{YY, MM, DD}, {Hr, Mn, Sc}} = calendar:local_time(),
|
Label = J("Password"),
|
||||||
Form = "~4.10.0B-~2.10.0B-~2.10.0B_~2.10.0B-~2.10.0B-~2.10.0B",
|
Dialog = wxDialog:new(Frame, ?wxID_ANY, Label),
|
||||||
Name = io_lib:format(Form, [YY, MM, DD, Hr, Mn, Sc]),
|
Sizer = wxBoxSizer:new(?wxVERTICAL),
|
||||||
unicode:characters_to_list(Name ++ ".gaju").
|
PassSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, Label}]),
|
||||||
|
PassTx = wxTextCtrl:new(Dialog, ?wxID_ANY, [{style, ?wxTE_PASSWORD}]),
|
||||||
|
_ = wxStaticBoxSizer:add(PassSz, PassTx, zxw:flags(wide)),
|
||||||
|
ButtSz = wxBoxSizer:new(?wxHORIZONTAL),
|
||||||
|
Affirm = wxButton:new(Dialog, ?wxID_OK),
|
||||||
|
_ = wxBoxSizer:add(ButtSz, Affirm, zxw:flags(wide)),
|
||||||
|
_ = wxBoxSizer:add(Sizer, PassSz, zxw:flags(base)),
|
||||||
|
_ = wxBoxSizer:add(Sizer, ButtSz, zxw:flags(wide)),
|
||||||
|
ok = wxDialog:setSizer(Dialog, Sizer),
|
||||||
|
ok = wxBoxSizer:layout(Sizer),
|
||||||
|
ok = wxDialog:setSize(Dialog, {500, 130}),
|
||||||
|
ok = wxFrame:center(Dialog),
|
||||||
|
ok = wxStyledTextCtrl:setFocus(PassTx),
|
||||||
|
case wxDialog:showModal(Dialog) of
|
||||||
|
?wxID_OK ->
|
||||||
|
case wxTextCtrl:getValue(PassTx) of
|
||||||
|
"" ->
|
||||||
|
ok = wxDialog:destroy(Dialog),
|
||||||
|
State;
|
||||||
|
Phrase ->
|
||||||
|
ok = wxDialog:destroy(Dialog),
|
||||||
|
ok = gd_con:open_wallet(Path, Phrase),
|
||||||
|
ok = do_close(State),
|
||||||
|
State
|
||||||
|
end;
|
||||||
|
?wxID_CANCEL ->
|
||||||
|
ok = wxDialog:destroy(Dialog),
|
||||||
|
State
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
do_new(State = #s{frame = Frame, j = J, prefs = Prefs}) ->
|
do_new(State = #s{frame = Frame, j = J, prefs = Prefs}) ->
|
||||||
@@ -384,9 +250,8 @@ do_new(State = #s{frame = Frame, j = J, prefs = Prefs}) ->
|
|||||||
Options =
|
Options =
|
||||||
[{message, J("Save Location")},
|
[{message, J("Save Location")},
|
||||||
{defaultDir, DefaultDir},
|
{defaultDir, DefaultDir},
|
||||||
{defaultFile, default_name()},
|
{defaultFile, "default.gaju"},
|
||||||
{wildCard, "*.gaju"},
|
{wildCard, "*.gaju"},
|
||||||
{sz, {300, 270}},
|
|
||||||
{style, ?wxFD_SAVE bor ?wxFD_OVERWRITE_PROMPT}],
|
{style, ?wxFD_SAVE bor ?wxFD_OVERWRITE_PROMPT}],
|
||||||
Dialog = wxFileDialog:new(Frame, Options),
|
Dialog = wxFileDialog:new(Frame, Options),
|
||||||
case wxFileDialog:showModal(Dialog) of
|
case wxFileDialog:showModal(Dialog) of
|
||||||
@@ -398,9 +263,7 @@ do_new(State = #s{frame = Frame, j = J, prefs = Prefs}) ->
|
|||||||
case do_new2(Path, J, Frame) of
|
case do_new2(Path, J, Frame) of
|
||||||
ok ->
|
ok ->
|
||||||
NewPrefs = maps:put(dir, Dir, Prefs),
|
NewPrefs = maps:put(dir, Dir, Prefs),
|
||||||
NewState = State#s{prefs = NewPrefs},
|
do_close(State#s{prefs = NewPrefs});
|
||||||
ok = do_close(NewState),
|
|
||||||
NewState;
|
|
||||||
abort ->
|
abort ->
|
||||||
State
|
State
|
||||||
end;
|
end;
|
||||||
@@ -412,8 +275,7 @@ do_new(State = #s{frame = Frame, j = J, prefs = Prefs}) ->
|
|||||||
do_new2(Path, J, Frame) ->
|
do_new2(Path, J, Frame) ->
|
||||||
Dialog = wxDialog:new(Frame, ?wxID_ANY, J("New Wallet"), [{size, {400, 250}}]),
|
Dialog = wxDialog:new(Frame, ?wxID_ANY, J("New Wallet"), [{size, {400, 250}}]),
|
||||||
Sizer = wxBoxSizer:new(?wxVERTICAL),
|
Sizer = wxBoxSizer:new(?wxVERTICAL),
|
||||||
NetworkOptions = [J("Mainnet"), J("Testnet")],
|
|
||||||
Network = wxRadioBox:new(Dialog, ?wxID_ANY, J("Network"), {0, 0}, {50, 50}, NetworkOptions),
|
|
||||||
NameSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, J("Name")}]),
|
NameSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, J("Name")}]),
|
||||||
NameTx = wxTextCtrl:new(Dialog, ?wxID_ANY),
|
NameTx = wxTextCtrl:new(Dialog, ?wxID_ANY),
|
||||||
_ = wxSizer:add(NameSz, NameTx, zxw:flags(wide)),
|
_ = wxSizer:add(NameSz, NameTx, zxw:flags(wide)),
|
||||||
@@ -432,14 +294,12 @@ do_new2(Path, J, Frame) ->
|
|||||||
_ = wxBoxSizer:add(ButtSz, Affirm, zxw:flags(wide)),
|
_ = wxBoxSizer:add(ButtSz, Affirm, zxw:flags(wide)),
|
||||||
_ = wxBoxSizer:add(ButtSz, Cancel, zxw:flags(wide)),
|
_ = wxBoxSizer:add(ButtSz, Cancel, zxw:flags(wide)),
|
||||||
|
|
||||||
_ = wxBoxSizer:add(Sizer, Network, zxw:flags(base)),
|
|
||||||
_ = wxSizer:add(Sizer, NameSz, zxw:flags(base)),
|
_ = wxSizer:add(Sizer, NameSz, zxw:flags(base)),
|
||||||
_ = wxSizer:add(Sizer, PassSz, zxw:flags(base)),
|
_ = wxSizer:add(Sizer, PassSz, zxw:flags(base)),
|
||||||
_ = wxSizer:add(Sizer, PassConSz, zxw:flags(base)),
|
_ = wxSizer:add(Sizer, PassConSz, zxw:flags(base)),
|
||||||
_ = wxSizer:add(Sizer, ButtSz, zxw:flags(wide)),
|
_ = wxSizer:add(Sizer, ButtSz, zxw:flags(wide)),
|
||||||
|
|
||||||
ok = wxDialog:setSizer(Dialog, Sizer),
|
ok = wxDialog:setSizer(Dialog, Sizer),
|
||||||
ok = wxDialog:setSize(Dialog, {300, 270}),
|
|
||||||
ok = wxBoxSizer:layout(Sizer),
|
ok = wxBoxSizer:layout(Sizer),
|
||||||
ok = wxDialog:center(Dialog),
|
ok = wxDialog:center(Dialog),
|
||||||
ok = wxStyledTextCtrl:setFocus(NameTx),
|
ok = wxStyledTextCtrl:setFocus(NameTx),
|
||||||
@@ -447,12 +307,6 @@ do_new2(Path, J, Frame) ->
|
|||||||
Result =
|
Result =
|
||||||
case wxDialog:showModal(Dialog) of
|
case wxDialog:showModal(Dialog) of
|
||||||
?wxID_OK ->
|
?wxID_OK ->
|
||||||
Net =
|
|
||||||
case wxRadioBox:getSelection(Network) of
|
|
||||||
0 -> mainnet;
|
|
||||||
1 -> testnet;
|
|
||||||
_ -> mainnet
|
|
||||||
end,
|
|
||||||
Name =
|
Name =
|
||||||
case wxTextCtrl:getValue(NameTx) of
|
case wxTextCtrl:getValue(NameTx) of
|
||||||
"" -> Path;
|
"" -> Path;
|
||||||
@@ -464,17 +318,17 @@ do_new2(Path, J, Frame) ->
|
|||||||
{P, P} -> P;
|
{P, P} -> P;
|
||||||
{_, _} -> bad
|
{_, _} -> bad
|
||||||
end,
|
end,
|
||||||
do_new3(Net, Name, Path, Pass);
|
do_new3(Name, Path, Pass);
|
||||||
?wxID_CANCEL ->
|
?wxID_CANCEL ->
|
||||||
abort
|
abort
|
||||||
end,
|
end,
|
||||||
ok = wxDialog:destroy(Dialog),
|
ok = wxDialog:destroy(Dialog),
|
||||||
Result.
|
Result.
|
||||||
|
|
||||||
do_new3(_, _, _, bad) ->
|
do_new3(_, _, bad) ->
|
||||||
abort;
|
abort;
|
||||||
do_new3(Net, Name, Path, Pass) ->
|
do_new3(Name, Path, Pass) ->
|
||||||
gd_con:new_wallet(Net, Name, Path, Pass).
|
gd_con:new_wallet(Name, Path, Pass).
|
||||||
|
|
||||||
|
|
||||||
do_import(State = #s{frame = Frame, j = J, prefs = Prefs}) ->
|
do_import(State = #s{frame = Frame, j = J, prefs = Prefs}) ->
|
||||||
@@ -493,9 +347,7 @@ do_import(State = #s{frame = Frame, j = J, prefs = Prefs}) ->
|
|||||||
case do_import2(Dir, File, J, Frame) of
|
case do_import2(Dir, File, J, Frame) of
|
||||||
ok ->
|
ok ->
|
||||||
NewPrefs = maps:put(dir, Dir, Prefs),
|
NewPrefs = maps:put(dir, Dir, Prefs),
|
||||||
NewState = State#s{prefs = NewPrefs},
|
do_close(State#s{prefs = NewPrefs});
|
||||||
ok = do_close(NewState),
|
|
||||||
NewState;
|
|
||||||
abort ->
|
abort ->
|
||||||
State
|
State
|
||||||
end;
|
end;
|
||||||
@@ -508,15 +360,51 @@ do_import2(_, "", _, _) ->
|
|||||||
abort;
|
abort;
|
||||||
do_import2(Dir, File, J, Frame) ->
|
do_import2(Dir, File, J, Frame) ->
|
||||||
Path = filename:join(Dir, File),
|
Path = filename:join(Dir, File),
|
||||||
Title = J("Import Wallet"),
|
Dialog = wxDialog:new(Frame, ?wxID_ANY, J("Import Wallet")),
|
||||||
NameL = J("Wallet Name"),
|
Sizer = wxBoxSizer:new(?wxVERTICAL),
|
||||||
PassL = J("Passphrase (leave blank if none)"),
|
|
||||||
OK_L = J("OK"),
|
NameSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, J("Name")}]),
|
||||||
CancelL = J("Cancel"),
|
NameTx = wxTextCtrl:new(Dialog, ?wxID_ANY),
|
||||||
case gd_m_wallet_importer:show(Frame, Title, NameL, PassL, OK_L, CancelL) of
|
_ = wxSizer:add(NameSz, NameTx, zxw:flags(wide)),
|
||||||
{ok, Name, Pass} -> gd_con:import_wallet(Name, Path, Pass);
|
PassSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, J("Passphrase")}]),
|
||||||
cancel -> abort
|
PassTx = wxTextCtrl:new(Dialog, ?wxID_ANY),
|
||||||
end.
|
_ = wxSizer:add(PassSz, PassTx, zxw:flags(wide)),
|
||||||
|
|
||||||
|
ButtSz = wxBoxSizer:new(?wxHORIZONTAL),
|
||||||
|
Affirm = wxButton:new(Dialog, ?wxID_OK),
|
||||||
|
Cancel = wxButton:new(Dialog, ?wxID_CANCEL),
|
||||||
|
_ = wxBoxSizer:add(ButtSz, Affirm, zxw:flags(wide)),
|
||||||
|
_ = wxBoxSizer:add(ButtSz, Cancel, zxw:flags(wide)),
|
||||||
|
|
||||||
|
_ = wxSizer:add(Sizer, NameSz, zxw:flags(base)),
|
||||||
|
_ = wxSizer:add(Sizer, PassSz, zxw:flags(base)),
|
||||||
|
_ = wxSizer:add(Sizer, ButtSz, zxw:flags(wide)),
|
||||||
|
|
||||||
|
ok = wxDialog:setSizer(Dialog, Sizer),
|
||||||
|
ok = wxBoxSizer:layout(Sizer),
|
||||||
|
ok = wxFrame:setSize(Dialog, {500, 200}),
|
||||||
|
ok = wxFrame:center(Dialog),
|
||||||
|
ok = wxStyledTextCtrl:setFocus(NameTx),
|
||||||
|
|
||||||
|
Result =
|
||||||
|
case wxDialog:showModal(Dialog) of
|
||||||
|
?wxID_OK ->
|
||||||
|
Name =
|
||||||
|
case wxTextCtrl:getValue(NameTx) of
|
||||||
|
"" -> Path;
|
||||||
|
N -> N
|
||||||
|
end,
|
||||||
|
Pass =
|
||||||
|
case wxTextCtrl:getValue(PassTx) of
|
||||||
|
"" -> none;
|
||||||
|
P -> P
|
||||||
|
end,
|
||||||
|
gd_con:import_wallet(Name, Path, Pass);
|
||||||
|
?wxID_CANCEL ->
|
||||||
|
abort
|
||||||
|
end,
|
||||||
|
ok = wxDialog:destroy(Dialog),
|
||||||
|
Result.
|
||||||
|
|
||||||
|
|
||||||
do_drop(State = #s{picker = Picker}) ->
|
do_drop(State = #s{picker = Picker}) ->
|
||||||
@@ -561,13 +449,3 @@ do_drop(Selected, State = #s{j = J, frame = Frame, wallets = Wallets}) ->
|
|||||||
ok
|
ok
|
||||||
end,
|
end,
|
||||||
State.
|
State.
|
||||||
|
|
||||||
|
|
||||||
ensure_shown(Frame) ->
|
|
||||||
case wxWindow:isShown(Frame) of
|
|
||||||
true ->
|
|
||||||
ok;
|
|
||||||
false ->
|
|
||||||
true = wxFrame:show(Frame),
|
|
||||||
ok
|
|
||||||
end.
|
|
||||||
|
|||||||
@@ -2,19 +2,19 @@
|
|||||||
{type,gui}.
|
{type,gui}.
|
||||||
{modules,[]}.
|
{modules,[]}.
|
||||||
{prefix,"gd"}.
|
{prefix,"gd"}.
|
||||||
{author,"Craig Everett"}.
|
|
||||||
{desc,"A desktop client for the Gajumaru network of blockchain networks"}.
|
{desc,"A desktop client for the Gajumaru network of blockchain networks"}.
|
||||||
{package_id,{"otpr","gajudesk",{0,9,0}}}.
|
{author,"Craig Everett"}.
|
||||||
{deps,[{"otpr","hakuzaru",{0,9,1}},
|
{package_id,{"otpr","gajudesk",{0,5,4}}}.
|
||||||
{"otpr","zxwidgets",{1,1,0}},
|
{deps,[{"otpr","base58",{0,1,1}},
|
||||||
{"otpr","eblake2",{1,0,1}},
|
{"otpr","hakuzaru",{0,6,0}},
|
||||||
{"otpr","base58",{0,1,1}},
|
|
||||||
{"otpr","gmserialization",{0,1,3}},
|
{"otpr","gmserialization",{0,1,3}},
|
||||||
{"otpr","sophia",{9,0,0}},
|
{"otpr","sophia",{9,0,0}},
|
||||||
{"otpr","gmbytecode",{3,4,1}},
|
{"otpr","gmbytecode",{3,4,1}},
|
||||||
{"otpr","lom",{1,0,0}},
|
{"otpr","lom",{1,0,0}},
|
||||||
{"otpr","zj",{1,1,0}},
|
{"otpr","zj",{1,1,0}},
|
||||||
{"otpr","ec_utils",{1,0,0}}]}.
|
{"otpr","eblake2",{1,0,0}},
|
||||||
|
{"otpr","ec_utils",{1,0,0}},
|
||||||
|
{"otpr","zxwidgets",{1,0,1}}]}.
|
||||||
{key_name,none}.
|
{key_name,none}.
|
||||||
{a_email,"craigeverett@qpq.swiss"}.
|
{a_email,"craigeverett@qpq.swiss"}.
|
||||||
{c_email,"info@qpq.swiss"}.
|
{c_email,"info@qpq.swiss"}.
|
||||||
|
|||||||
Reference in New Issue
Block a user