forked from Militereum/Militereum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrevoke.pas
116 lines (100 loc) · 2.48 KB
/
revoke.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
109
110
111
112
113
114
115
116
unit revoke;
interface
uses
// Delphi
System.Classes,
System.SysUtils,
System.UITypes,
// FireMonkey
FMX.Controls,
FMX.Controls.Presentation,
FMX.Forms,
FMX.Objects,
FMX.StdCtrls,
FMX.Types,
// web3
web3;
type
TFrmRevoke = class(TForm)
btnYes: TButton;
btnNo: TButton;
imgMilitereum: TImage;
lblTitle: TLabel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
imgRevokeCash: TImage;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure btnYesClick(Sender: TObject);
procedure btnNoClick(Sender: TObject);
private
FChain : TChain;
FCallback: TProc<Boolean>;
protected
procedure DoShow; override;
procedure SetToken(const value: TAddress);
procedure SetSpender(const value: TAddress);
public
property Chain : TChain write FChain;
property Token : TAddress write SetToken;
property Spender : TAddress write SetSpender;
property Callback: TProc<Boolean> write FCallback;
end;
procedure show(
const chain : TChain;
const token : TAddress;
const spender : TAddress;
const callback: TProc<Boolean>);
implementation
{$R *.fmx}
uses
// web3
web3.eth.types,
// project
base,
cache,
thread;
procedure show(const chain: TChain; const token: TAddress; const spender: TAddress; const callback: TProc<Boolean>);
begin
const frmRevoke = TFrmRevoke.Create(Application);
frmRevoke.Chain := chain;
frmRevoke.Token := token;
frmRevoke.Spender := spender;
frmRevoke.Callback := callback;
frmRevoke.Show;
end;
{ TFrmRevoke }
procedure TFrmRevoke.SetToken(const value: TAddress);
begin
cache.getSymbol(Self.FChain, value, procedure(symbol: string; err: IError)
begin
if symbol <> '' then thread.synchronize(procedure
begin
lblTitle.Text := Format('Your %s are at risk', [symbol]);
end);
end);
end;
procedure TFrmRevoke.SetSpender(const value: TAddress);
begin
Label1.Text := Format(Label1.Text, [value.Abbreviated]);
end;
procedure TFrmRevoke.btnNoClick(Sender: TObject);
begin
if Assigned(Self.FCallback) then Self.FCallback(False);
Self.Close;
end;
procedure TFrmRevoke.btnYesClick(Sender: TObject);
begin
if Assigned(Self.FCallback) then Self.FCallback(True);
Self.Close;
end;
procedure TFrmRevoke.DoShow;
begin
centerOnDisplayUnderMouseCursor(Self);
inherited DoShow;
end;
procedure TFrmRevoke.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := TCloseAction.caFree;
end;
end.