Type the payee address before releasing payments in the Web3 page
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4645c5a97d
commit
2d3302a2f7
7 files changed
+108
-13
No files matched your search
@@ -16,6 +16,9 @@ namespace Decentralized
|
||||
private enum Page { Home, Bank, Poinbase, Web3 }
|
||||
|
||||
private static Page _page = Page.Home;
|
||||
private sealed class PendingPay { public string Address, Summary; public int Total; public Action Execute; }
|
||||
private static PendingPay _pay;
|
||||
private static string _addr = "";
|
||||
private static string _amount = "";
|
||||
private static string _message;
|
||||
|
||||
@@ -30,7 +33,7 @@ namespace Decentralized
|
||||
{
|
||||
var page = p;
|
||||
string name = L.T("tab." + p.ToString().ToLowerInvariant());
|
||||
b.AddButton(page == _page ? $"[{name}]" : name, () => { _page = page; _message = null; Open(); });
|
||||
b.AddButton(page == _page ? $"[{name}]" : name, () => { _page = page; _message = null; _pay = null; Open(); });
|
||||
}
|
||||
b.End();
|
||||
b.AddSeparator();
|
||||
@@ -48,7 +51,7 @@ namespace Decentralized
|
||||
b.Show();
|
||||
}
|
||||
|
||||
private static void Go(Page p) { _page = p; _message = null; Open(); }
|
||||
private static void Go(Page p) { _page = p; _message = null; _pay = null; Open(); }
|
||||
|
||||
private static void Entry(CustomUIBuilder b, string icon, string name, string line1, string line2, Page target)
|
||||
{
|
||||
@@ -235,6 +238,7 @@ namespace Decentralized
|
||||
private static void Web3Page(CustomUIBuilder b)
|
||||
{
|
||||
var w = Session.Data.Hot;
|
||||
if (_pay != null) { PayPage(b); return; }
|
||||
{
|
||||
if (_web3Tab == Web3Tab.Mixer && !Unlock.MixerUnlocked) _web3Tab = Web3Tab.Trade;
|
||||
if (_web3Tab == Web3Tab.Black && !Unlock.BlackUnlocked) _web3Tab = Web3Tab.Trade;
|
||||
@@ -244,7 +248,7 @@ namespace Decentralized
|
||||
if ((t == Web3Tab.Mixer && !Unlock.MixerUnlocked) || (t == Web3Tab.Black && !Unlock.BlackUnlocked)) continue;
|
||||
var tab = t;
|
||||
string name = L.T("web3.sub." + t.ToString().ToLowerInvariant());
|
||||
b.AddButton(tab == _web3Tab ? $"[{name}]" : name, () => { _web3Tab = tab; _message = null; Open(); });
|
||||
b.AddButton(tab == _web3Tab ? $"[{name}]" : name, () => { _web3Tab = tab; _message = null; _pay = null; Open(); });
|
||||
}
|
||||
b.End();
|
||||
if (_web3Tab == Web3Tab.Mining) { ReportPage(b); return; }
|
||||
@@ -306,7 +310,7 @@ namespace Decentralized
|
||||
if (t == BlackTab.Desk && !desk) continue;
|
||||
var tab = t;
|
||||
string name = L.T("black.sub." + t.ToString().ToLowerInvariant());
|
||||
b.AddButton(tab == _blackTab ? $"[{name}]" : name, () => { _blackTab = tab; _message = null; Open(); });
|
||||
b.AddButton(tab == _blackTab ? $"[{name}]" : name, () => { _blackTab = tab; _message = null; _pay = null; Open(); });
|
||||
}
|
||||
b.End();
|
||||
if (d.Black.Closed(day)) { b.AddLabel(L.T("black.rugged", d.Black.ClosedUntil - day + 1)); return; }
|
||||
@@ -340,7 +344,7 @@ namespace Decentralized
|
||||
GoodHead(c, g, L.T("black.stock", offer.Qty));
|
||||
c.AddLabel(L.T("black.price", offer.Price));
|
||||
c.AddFlexibleSpace();
|
||||
c.AddButton(L.T("black.buy"), () => BuyOffer(offer));
|
||||
c.AddButton(L.T("black.buy"), () => BeginPay(d.Address("platform"), ItemName(offer.Item), offer.Price, () => BuyOffer(offer)));
|
||||
});
|
||||
}
|
||||
else MerchantShelf(b, d);
|
||||
@@ -362,7 +366,7 @@ namespace Decentralized
|
||||
}
|
||||
b.End();
|
||||
b.AddLabel(L.T("mixer.balance", _payAsset, Fmt.Num(d.Hot.Avail(_payAsset))) + " " + L.T("black.sell.rating", d.Black.Rating) + " " + L.T("black.sell.slots", d.Black.ActiveListings, Tuning.BmMaxListings));
|
||||
b.AddButton(L.T("black.sell.all"), ListAll);
|
||||
b.AddButton(L.T("black.sell.all"), () => BeginPay(d.Address("platform"), L.T("black.sell.all") + L.T("pay.listfee"), BlackDelivery.Sellable().Sum(it => BlackMarket.ListFee(BlackMarket.ListPriceOf(BlackDelivery.RefValue(it), _sellMult))), ListAll));
|
||||
b.AddSeparator();
|
||||
var items = BlackDelivery.Sellable();
|
||||
if (items.Count == 0) { b.AddLabel(L.T("black.sell.none")); return; }
|
||||
@@ -380,7 +384,7 @@ namespace Decentralized
|
||||
GoodHead(c, g, "");
|
||||
c.AddLabel(L.T("black.price", g.Price));
|
||||
c.AddFlexibleSpace();
|
||||
c.AddButton(L.T("black.sell.list"), () => ListItem(it));
|
||||
c.AddButton(L.T("black.sell.list"), () => BeginPay(d.Address("platform"), ItemName(g.Item) + L.T("pay.listfee"), BlackMarket.ListFee(g.Price), () => ListItem(it)));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -461,7 +465,7 @@ namespace Decentralized
|
||||
c.AddLabel(L.T("black.price", BlackMarket.Pay(BlackMarket.OrderTotal(listing.Price, count), _mode)) + (count > 1 ? " ×" + count : ""));
|
||||
c.AddFlexibleSpace();
|
||||
bool ok = _mode == PayMode.Escrow || seller.Advance;
|
||||
c.AddButton(ok ? L.T("black.order") : L.T("black.noadvance"), () => { if (ok) PlaceOrder(listing, count); });
|
||||
c.AddButton(ok ? L.T("black.order") : L.T("black.noadvance"), () => { if (ok) BeginPay(seller.Name, ItemName(listing.Item) + (count > 1 ? " ×" + count : ""), BlackMarket.Pay(BlackMarket.OrderTotal(listing.Price, count), _mode), () => PlaceOrder(listing, count)); });
|
||||
});
|
||||
}
|
||||
|
||||
@@ -496,6 +500,35 @@ namespace Decentralized
|
||||
|
||||
private static string ItemName(string id) => BlackDelivery.ItemName(id);
|
||||
|
||||
private static void BeginPay(string address, string summary, int total, Action execute)
|
||||
{
|
||||
_pay = new PendingPay { Address = address, Summary = summary, Total = total, Execute = execute };
|
||||
_addr = "";
|
||||
_message = null;
|
||||
Open();
|
||||
}
|
||||
|
||||
/// <summary>付款确认:手输收款地址才放款,输错不付。</summary>
|
||||
private static void PayPage(CustomUIBuilder b)
|
||||
{
|
||||
var p = _pay;
|
||||
b.AddHeader(L.T("black.pay.confirm"));
|
||||
b.AddLabel(L.T("black.pay.item", p.Summary, p.Total));
|
||||
b.AddLabel(L.T("black.pay.to", p.Address));
|
||||
b.BeginPanel(RightW, -1f, TextAnchor.MiddleCenter, 0f, 0f);
|
||||
b.AddInput(L.T("black.pay.input"), _addr, s => _addr = s, "addr", s => _addr = s);
|
||||
b.End();
|
||||
b.BeginRow();
|
||||
b.AddButton(L.T("black.pay.go"), () =>
|
||||
{
|
||||
if (!string.Equals((_addr ?? "").Trim(), p.Address, StringComparison.OrdinalIgnoreCase)) { _message = L.T("black.pay.bad"); Open(); return; }
|
||||
_pay = null;
|
||||
p.Execute();
|
||||
});
|
||||
b.AddButton(L.T("black.pay.cancel"), () => { _pay = null; _message = null; Open(); });
|
||||
b.End();
|
||||
}
|
||||
|
||||
private static void BuyOffer(BmOffer o)
|
||||
{
|
||||
var d = Session.Data;
|
||||
@@ -579,7 +612,7 @@ namespace Decentralized
|
||||
r.End();
|
||||
r.AddLabel(_deskIn ? L.T("mixer.balance", _deskAsset, Fmt.Num(w.Avail(_deskAsset))) : L.T("mixer.balance", Assets.Ponero, Fmt.Num(w.Avail(Assets.Ponero))));
|
||||
AmountRow(r);
|
||||
r.AddButton(L.T("black.desk.go"), DeskSwap);
|
||||
r.AddButton(L.T("black.desk.go"), () => { if (!ReadAmount(out double dv)) return; BeginPay(d.Address("desk"), L.T("pay.swap", Fmt.Num(dv), _deskIn ? _deskAsset : Assets.Ponero), (int)Math.Round(dv * Session.Price(_deskIn ? _deskAsset : Assets.Ponero)), DeskSwap); });
|
||||
});
|
||||
}
|
||||
|
||||
@@ -648,7 +681,7 @@ namespace Decentralized
|
||||
double rate = Mixer.RoundRate(v * Session.Price(_mixAsset));
|
||||
r.AddLabel(L.T("mixer.preview", Fmt.Num(v * Math.Pow(1 - Tuning.MixerFee, _mixRounds)), _mixAsset, (int)Math.Round((1 - Math.Pow(1 - rate, _mixRounds)) * 100), day + _mixRounds));
|
||||
}
|
||||
r.AddButton(L.T("mixer.go"), MixDeposit);
|
||||
r.AddButton(L.T("mixer.go"), () => { if (!ReadAmount(out double mv)) return; BeginPay(d.Address("mixer"), L.T("pay.mix", Fmt.Num(mv), _mixAsset), (int)Math.Round(mv * Session.Price(_mixAsset)), MixDeposit); });
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user