forked from Militereum/Militereum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphisher.pas
112 lines (95 loc) · 2.68 KB
/
phisher.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
unit phisher;
interface
uses
// Delphi
System.Classes,
System.SysUtils,
// FireMonkey
FMX.Controls,
FMX.Controls.Presentation,
FMX.Objects,
FMX.StdCtrls,
FMX.Types,
// web3
web3,
web3.eth.contract,
// project
base,
transaction;
type
TMobyMask = class(TCustomContract)
public
constructor Create; reintroduce;
procedure IsPhisher(const address: TAddress; const callback: TProc<Boolean, IError>);
end;
type
TFrmPhisher = class(TFrmBase)
lblTitle: TLabel;
lblAddressText: TLabel;
lblFooter: TLabel;
procedure lblAddressTextClick(Sender: TObject);
strict private
procedure SetAddress(value: TAddress);
public
property Address: TAddress write SetAddress;
end;
procedure isPhisher(const address: TAddress; const callback: TProc<Boolean, IError>);
procedure show(const chain: TChain; const tx: transaction.ITransaction; const address: TAddress; const callback: TProc<Boolean>; const log: TLog);
implementation
uses
// web3
web3.eth,
// project
cache,
common,
thread;
{$R *.fmx}
// https://github.com/Montoya/mobymask-snap#readme
procedure isPhisher(const address: TAddress; const callback: TProc<Boolean, IError>);
begin
const MM = TMobyMask.Create;
try
MM.IsPhisher(address, callback);
finally
MM.Free;
end;
end;
procedure show(const chain: TChain; const tx: transaction.ITransaction; const address: TAddress; const callback: TProc<Boolean>; const log: TLog);
begin
const frmPhisher = TFrmPhisher.Create(chain, tx, callback, log);
frmPhisher.Address := address;
frmPhisher.Show;
end;
{ TMobyMask }
constructor TMobyMask.Create;
begin
inherited Create(TWeb3.Create(common.Ethereum), '0xB06E6DB9288324738f04fCAAc910f5A60102C1F8');
end;
// mobyMaskContract.isPhisher('eip155:1:${transaction.to}')
procedure TMobyMask.IsPhisher(const address: TAddress; const callback: TProc<Boolean, IError>);
begin
web3.eth.call(Self.Client, Self.Contract, 'isPhisher(string)', ['eip155:1:' + string(address).ToLower], callback);
end;
{ TFrmPhisher }
procedure TFrmPhisher.SetAddress(value: TAddress);
begin
lblAddressText.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
lblAddressText.Text := friendly;
end);
end);
end;
procedure TFrmPhisher.lblAddressTextClick(Sender: TObject);
begin
cache.fromName(lblAddressText.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/' + lblAddressText.Text);
end);
end;
end.