forked from Militereum/Militereum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpausable.pas
96 lines (82 loc) · 2.39 KB
/
pausable.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
unit pausable;
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
TFrmPausable = class(TFrmBase)
lblTitle: TLabel;
lblToken: TLabel;
lblFooter: TLabel;
procedure lblTokenClick(Sender: TObject);
strict private
procedure SetAction(value: TTokenAction);
procedure SetContract(value: TAddress);
procedure SetIsERC20(value: Boolean);
public
property Action: TTokenAction write SetAction;
property Contract: TAddress write SetContract;
property IsERC20: Boolean write SetIsERC20;
end;
procedure show(const action: TTokenAction; const chain: TChain; const tx: transaction.ITransaction; const contract: TAddress; const isERC20: Boolean; 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 contract: TAddress; const isERC20: Boolean; const callback: TProc<Boolean>; const log: TLog);
begin
const frmPausable = TFrmPausable.Create(chain, tx, callback, log);
frmPausable.Action := action;
frmPausable.Contract := contract;
frmPausable.IsERC20 := isERC20;
frmPausable.Show;
end;
{ TFrmPausable }
procedure TFrmPausable.SetAction(value: TTokenAction);
begin
lblTitle.Text := System.SysUtils.Format(lblTitle.Text, [ActionText[value], '%s']);
end;
procedure TFrmPausable.SetContract(value: TAddress);
begin
lblToken.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
lblToken.Text := friendly;
end);
end);
end;
procedure TFrmPausable.SetIsERC20(value: Boolean);
begin
lblTitle.Text := System.SysUtils.Format(lblTitle.Text, [(function: string
begin
if value then Result := 'token' else Result := 'contract'
end)()]);
end;
procedure TFrmPausable.lblTokenClick(Sender: TObject);
begin
cache.fromName(lblToken.Text, procedure(address: TAddress; err: IError)
begin
if Assigned(err) then
common.Open(Self.Chain.Explorer + '/address/' + lblToken.Text)
else
common.Open(Self.Chain.Explorer + '/address/' + string(address));
end);
end;
end.