forked from Militereum/Militereum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetApprovalForAll.pas
110 lines (96 loc) · 2.71 KB
/
setApprovalForAll.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
unit setApprovalForAll;
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
TFrmSetApprovalForAll = class(TFrmBase)
lblTitle: TLabel;
lblTokenTitle: TLabel;
lblSpenderTitle: TLabel;
lblSpenderText: TLabel;
lblTokenText: TLabel;
lblAmountTitle: TLabel;
lblAmountText: TLabel;
Label1: TLabel;
Label2: TLabel;
procedure lblTokenTextClick(Sender: TObject);
procedure lblSpenderTextClick(Sender: TObject);
strict private
FToken: TAddress;
procedure SetToken(value: TAddress);
procedure SetSpender(value: TAddress);
public
property Token: TAddress write SetToken;
property Spender: TAddress write SetSpender;
end;
procedure show(const chain: TChain; const tx: transaction.ITransaction; const token, spender: TAddress; const callback: TProc<Boolean>; const log: TLog);
implementation
uses
// web3
web3.eth.erc721,
// project
cache,
common,
thread;
{$R *.fmx}
procedure show(const chain: TChain; const tx: transaction.ITransaction; const token, spender: TAddress; const callback: TProc<Boolean>; const log: TLog);
begin
const frmSetApprovalForAll = TFrmSetApprovalForAll.Create(chain, tx, callback, log);
frmSetApprovalForAll.Token := token;
frmSetApprovalForAll.Spender := spender;
frmSetApprovalForAll.Show;
end;
{ TFrmSetApprovalForAll }
procedure TFrmSetApprovalForAll.SetToken(value: TAddress);
begin
FToken := value;
web3.eth.erc721.create(TWeb3.Create(Chain), FToken).Name(procedure(name: string; err: IError)
begin
if Assigned(err) then
Self.Log(err)
else if name.IsEmpty then
lblTokenText.Text := string(value)
else
lblTokenText.Text := name;
end);
end;
procedure TFrmSetApprovalForAll.SetSpender(value: TAddress);
begin
lblSpenderText.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
lblSpenderText.Text := friendly;
end);
end);
end;
procedure TFrmSetApprovalForAll.lblTokenTextClick(Sender: TObject);
begin
common.Open(Self.Chain.Explorer + '/token/' + string(FToken));
end;
procedure TFrmSetApprovalForAll.lblSpenderTextClick(Sender: TObject);
begin
cache.fromName(lblSpenderText.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/' + lblSpenderText.Text);
end);
end;
end.