-
Notifications
You must be signed in to change notification settings - Fork 0
/
08_EventSubscriberDemo.ts
86 lines (72 loc) · 2.48 KB
/
08_EventSubscriberDemo.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
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
import { SuiClient, getFullnodeUrl } from '@mysten/sui.js/client';
import {SuiEvent} from "@mysten/sui.js/src/types/events";
const client = new SuiClient({
url: getFullnodeUrl('testnet'),
});
const pythFilterMainnet = {
MoveEventType: "0x80d7de9c4a56194087e0ba0bf59492aa8e6a5ee881606226930827085ddf2332::suifrens::SuiFrenMinted2"
};
const listenToEvents = async () => {
const devNftSub = await client.subscribeEvent({
filter: pythFilterMainnet,
onMessage(event : SuiEvent) {
console.log("Event Happened! = ", event);
},
});
};
//listenToEvents();
const listenToEvents2 = async ()=> {
const unsubscribe = await client.subscribeEvent({
filter: {
Sender: '0x02a212de6a9dfa3a69e22387acfbafbb1a9e591bd9d636e7895dcfc8de05f331',
},
onMessage(event) {
// handle subscription notification message here. This function is called once per subscription message.
console.log("events 2")
},
});
}
listenToEvents2();
//
// const packageFiltering = provider.subscribeEvent({
// filter: {
// Package: "0xee496a0cc04d06a345982ba6697c90c619020de9e274408c7819f787ff66e1a1"
// },
// onMessage(event: SuiEvent) {
// console.log("Suifrens Event Happened! = ", event);
// },
// }).then(SubscriptionId => {
// console.log("Subscriber subscribed. Listening to ", connOptions.fullnode,
// " \nSubscriptionId = ", SubscriptionId);
// });
//
// const moveModuleFiltering = provider.subscribeEvent({
// filter: {
// MoveModule:
// { package: "0x00b53b0f4174108627fbee72e2498b58d6a2714cded53fac537034c220d26302",
// module: "pyth"
// }
// },
// onMessage(event: SuiEvent) {
// console.log("pyth Event Happened! = ", event);
// },
// }).then(SubscriptionId => {
// console.log("Subscriber subscribed. Listening to ", connOptions.fullnode,
// " \nSubscriptionId = ", SubscriptionId);
// });
//
//
// const moveEventFieldFiltering = provider.subscribeEvent({
// filter: {
// MoveEventField:
// { path: "/transactionModule",
// value: "capy_labs"
// }
// },
// onMessage(event: SuiEvent) {
// console.log("moveEventFieldFiltering Event Happened! = ", event);
// },
// }).then(SubscriptionId => {
// console.log("Subscriber subscribed. Listening to ", connOptions.fullnode,
// " \nSubscriptionId = ", SubscriptionId);
// });