forked from Militereum/Militereum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhoneypot.pas
108 lines (94 loc) · 2.59 KB
/
honeypot.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
106
107
108
unit honeypot;
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
TFrmHoneypot = class(TFrmBase)
lblHeader: TLabel;
lblTokenTitle: TLabel;
lblRecipientTitle: TLabel;
lblRecipientText: TLabel;
lblTokenText: TLabel;
lblFooter: TLabel;
procedure lblTokenTextClick(Sender: TObject);
procedure lblRecipientTextClick(Sender: TObject);
strict private
FToken: TAddress;
procedure SetToken(value: TAddress);
procedure SetRecipient(value: TAddress);
public
property Token: TAddress write SetToken;
property Recipient: TAddress write SetRecipient;
end;
procedure show(const chain: TChain; const tx: transaction.ITransaction; const token, recipient: TAddress; const callback: TProc<Boolean>; const log: TLog);
implementation
uses
// web3
web3.utils,
// project
cache,
common,
thread;
{$R *.fmx}
procedure show(const chain: TChain; const tx: transaction.ITransaction; const token, recipient: TAddress; const callback: TProc<Boolean>; const log: TLog);
begin
const frmHoneypot = TFrmHoneypot.Create(chain, tx, callback, log);
frmHoneypot.Token := token;
frmHoneypot.Recipient := recipient;
frmHoneypot.Show;
end;
{ TFrmHoneypot }
procedure TFrmHoneypot.SetToken(value: TAddress);
begin
FToken := value;
if common.Demo then
lblTokenText.Text := string(value)
else
cache.getSymbol(Self.Chain, FToken, procedure(symbol: string; err: IError)
begin
if Assigned(err) then Self.Log(err) else thread.synchronize(procedure
begin
lblTokenText.Text := symbol;
end);
end);
end;
procedure TFrmHoneypot.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 TFrmHoneypot.lblTokenTextClick(Sender: TObject);
begin
common.Open(Self.Chain.Explorer + '/token/' + string(FToken));
end;
procedure TFrmHoneypot.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.