Dekajigger the kajiggerlicious SpendTX

This commit is contained in:
2025-12-23 15:59:48 +09:00
parent d9acde1b83
commit 638c88f900
3 changed files with 152 additions and 153 deletions
+13 -23
View File
@@ -38,7 +38,7 @@
accounts = [] :: [gajudesk:poa()],
picker = none :: none | wx:wx_object(),
id = {#w{}, #w{}} :: labeled(),
balance = {#w{}, #w{}} :: labeled(),
balance = #w{} :: #w{},
buttons = [] :: [widget()],
history = #h{} :: #h{}}).
@@ -117,13 +117,9 @@ init(Prefs) ->
_ = wxSizer:add(ID_Sz, ID_L, zxw:flags(base)),
_ = wxSizer:add(ID_Sz, ID_T, zxw:flags(wide)),
BalanceL = wxStaticText:new(Panel, ?wxID_ANY, ""),
BalanceT = wxStaticText:new(Panel, ?wxID_ANY, price_to_string(0)),
Balance =
{#w{id = wxStaticText:getId(BalanceL), wx = BalanceL},
#w{id = wxStaticText:getId(BalanceT), wx = BalanceT}},
BalanceT = wxStaticText:new(Panel, ?wxID_ANY, hz_format:amount(0)),
Balance = #w{id = wxStaticText:getId(BalanceT), wx = BalanceT},
BalanceSz = wxBoxSizer:new(?wxHORIZONTAL),
_ = wxSizer:add(BalanceSz, BalanceL, zxw:flags(base)),
_ = wxSizer:add(BalanceSz, BalanceT, zxw:flags(wide)),
NumbersSz = wxBoxSizer:new(?wxVERTICAL),
@@ -729,22 +725,16 @@ spend(Selected, State = #s{accounts = Accounts}) ->
end.
spend2(#poa{id = ID, name = Name}, Nonce, Height, State = #s{frame = Frame, j = J}) ->
Title = J("Transfer Gajus"),
Account = [Name, " (", ID, ")"],
Args = {Account, Nonce, Height},
Labels = {J("From"), J("To"), J("Amount"), J("Message (optional)"), J("TTL"), J("Gas Price")},
Args = {Account, J},
ok =
case gd_m_spend:show(Frame, Title, Args, Labels) of
{ok, RecipientID, Amount, GasPrice, TTL, Payload} ->
case gd_m_spend:show(Frame, Args) of
{ok, Partial = #spend_tx{ttl = TTL}} ->
TX =
#spend_tx{sender_id = ID,
recipient_id = RecipientID,
amount = Amount,
gas_price = GasPrice,
gas = 20000,
ttl = Height + TTL,
nonce = Nonce,
payload = Payload},
Partial#spend_tx{sender_id = ID,
gas = 20000,
ttl = Height + TTL,
nonce = Nonce},
gd_con:spend(TX);
cancel ->
ok
@@ -770,13 +760,13 @@ handle_button(Name, State) ->
do_selection(Selected,
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) ->
OneBasedIndex = Selected + 1,
#poa{id = ID, balances = Balances} = lists:nth(OneBasedIndex, Accounts),
[#balance{total = Pucks}] = Balances,
ok = wxStaticText:setLabel(I, ID),
ok = wxStaticText:setLabel(B, price_to_string(Pucks)),
ok = wxStaticText:setLabel(B, hz_format:amount(Pucks)),
ok = gd_con:selected(OneBasedIndex),
NewPrefs = maps:put(selected, Selected, Prefs),
State#s{prefs = NewPrefs};
@@ -803,7 +793,7 @@ do_show(Accounts, State = #s{sizer = Sizer, prefs = Prefs, picker = Picker}) ->
ok = wxSizer:layout(Sizer),
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(B, ""),
State.