-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathscanNFT.ts
41 lines (33 loc) · 1.18 KB
/
scanNFT.ts
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
import { getFullnodeUrl, SuiClient } from "@mysten/sui/client";
import { SuiSecBlocklist, Action } from "suisecblocklist";
const client = new SuiClient({
url: getFullnodeUrl("mainnet"),
});
const blocklist = new SuiSecBlocklist();
blocklist.fetchObjectlist();
// setInterval(() => blocklist.fetchObjectlist(), 1000 * 60 * 5);
const address =
"0x465a02228c92dd41cce21ec5085d9942cfe006742ee2f9911cf5ced9a02c0d6f";
const own_objects = await client.getOwnedObjects({ owner: address });
let object_ids: string[] = [];
for (const object of own_objects.data) {
const object_id = object.data?.objectId;
object_ids.push(object_id);
}
const objects_info = await client.multiGetObjects({
ids: object_ids,
options: { showType: true },
});
for (const object_info of objects_info) {
const obj_info = object_info.data;
const object_id = obj_info.objectId;
const object_type = obj_info.type;
if (object_type?.startsWith("0x2::coin::Coin")) continue;
const action = await blocklist.scanObject(object_type);
if (action === Action.BLOCK) {
// block the object, do something
console.log("BLOCK", object_id, object_type);
} else {
console.log("NORMAL", object_id, object_type);
}
}