forked from Militereum/Militereum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlimit.pas
105 lines (90 loc) · 2.8 KB
/
limit.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
unit limit;
interface
uses
// Delphi
System.Classes,
System.SysUtils,
// FireMonkey
FMX.Controls,
FMX.Controls.Presentation,
FMX.Objects,
FMX.StdCtrls,
FMX.Types,
// web3
web3,
// project
base,
transaction;
type
TFrmLimit = class(TFrmBase)
lblTitle: TLabel;
lblAssetTitle: TLabel;
lblRecipientTitle: TLabel;
lblRecipientText: TLabel;
lblAssetText: TLabel;
lblAmountTitle: TLabel;
lblAmountText: TLabel;
procedure lblRecipientTextClick(Sender: TObject);
strict private
procedure SetSymbol(const value: string);
procedure SetRecipient(value: TAddress);
procedure SetAmount(value: Double);
public
constructor Create(const chain: TChain; const tx: transaction.ITransaction; const callback: TProc<Boolean>; const log: TLog); override;
property Symbol: string write SetSymbol;
property Recipient: TAddress write SetRecipient;
property Amount: Double write SetAmount;
end;
procedure show(const chain: TChain; const tx: transaction.ITransaction; const symbol: string; const recipient: TAddress; const amount: Double; const callback: TProc<Boolean>; const log: TLog);
implementation
uses
// project
cache,
common,
thread;
{$R *.fmx}
procedure show(const chain: TChain; const tx: transaction.ITransaction; const symbol: string; const recipient: TAddress; const amount: Double; const callback: TProc<Boolean>; const log: TLog);
begin
const frmLimit = TFrmLimit.Create(chain, tx, callback, log);
frmLimit.Symbol := symbol;
frmLimit.Recipient := recipient;
frmLimit.Amount := amount;
frmLimit.Show;
end;
{ TFrmLimit }
constructor TFrmLimit.Create(const chain: TChain; const tx: transaction.ITransaction; const callback: TProc<Boolean>; const log: TLog);
begin
inherited Create(chain, tx, callback, log);
lblTitle.Text := System.SysUtils.Format(lblTitle.Text, [common.LIMIT]);
end;
procedure TFrmLimit.SetSymbol(const value: string);
begin
lblAssetText.Text := value;
end;
procedure TFrmLimit.SetRecipient(value: TAddress);
begin
lblRecipientText.Text := string(value);
if not common.Demo then
cache.getFriendlyName(Self.Chain, value, procedure(friendly: string; err: IError)
begin
if Assigned(err) then Self.Log(err) else thread.synchronize(procedure
begin
lblRecipientText.Text := friendly;
end);
end);
end;
procedure TFrmLimit.SetAmount(value: Double);
begin
lblAmountText.Text := System.SysUtils.Format('$ %.2f', [value]);
end;
procedure TFrmLimit.lblRecipientTextClick(Sender: TObject);
begin
cache.fromName(lblRecipientText.Text, procedure(address: TAddress; err: IError)
begin
if not Assigned(err) then
common.Open(Self.Chain.Explorer + '/address/' + string(address))
else
common.Open(Self.Chain.Explorer + '/address/' + lblRecipientText.Text);
end);
end;
end.