forked from Militereum/Militereum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnoDexPair.pas
85 lines (72 loc) · 2.01 KB
/
noDexPair.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
unit noDexPair;
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
TFrmNoDexPair = class(TFrmBase)
lblTitle: TLabel;
lblTokenText: TLabel;
lblFooter: TLabel;
procedure lblTokenTextClick(Sender: TObject);
strict private
procedure SetAction(value: TTokenAction);
procedure SetToken(value: TAddress);
public
property Action: TTokenAction write SetAction;
property Token: TAddress write SetToken;
end;
procedure show(const action: TTokenAction; const chain: TChain; const tx: transaction.ITransaction; const token: TAddress; const callback: TProc<Boolean>; const log: TLog);
implementation
uses
// project
cache,
common,
thread;
{$R *.fmx}
procedure show(const action: TTokenAction; const chain: TChain; const tx: transaction.ITransaction; const token: TAddress; const callback: TProc<Boolean>; const log: TLog);
begin
const frmNoDexPair = TFrmNoDexPair.Create(chain, tx, callback, log);
frmNoDexPair.Action := action;
frmNoDexPair.Token := token;
frmNoDexPair.Show;
end;
{ TFrmNoDexPair }
procedure TFrmNoDexPair.SetAction(value: TTokenAction);
begin
lblTitle.Text := System.SysUtils.Format(lblTitle.Text, [ActionText[value]]);
end;
procedure TFrmNoDexPair.SetToken(value: TAddress);
begin
lblTokenText.Text := string(value);
cache.getFriendlyName(Self.Chain, value, procedure(friendly: string; err: IError)
begin
if Assigned(err) then Self.Log(err) else thread.synchronize(procedure
begin
lblTokenText.Text := friendly;
end);
end);
end;
procedure TFrmNoDexPair.lblTokenTextClick(Sender: TObject);
begin
cache.fromName(lblTokenText.Text, procedure(address: TAddress; err: IError)
begin
if not Assigned(err) then
common.Open(Self.Chain.Explorer + '/token/' + string(address))
else
common.Open(Self.Chain.Explorer + '/token/' + lblTokenText.Text);
end);
end;
end.