-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
44 lines (38 loc) · 1.29 KB
/
index.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
import {FastifyInstance} from "fastify";
import {HyperionPlugin} from "../../hyperion-plugin";
export default class SamplePlugin extends HyperionPlugin {
internalPluginName = 'sample-plugin-name';
indexerPlugin = true;
apiPlugin = true;
hasApiRoutes = true;
constructor() {
super();
this.registerStreamHandlers();
}
registerStreamHandlers() {
this.streamHandlers.push({
event: 'trace',
handler: async streamEvent => {
const headers = streamEvent.properties.headers;
if (headers) {
if (headers.event === 'trace' && headers.account === 'eosio.evm' && headers.name === 'raw') {
if (streamEvent.content) {
const content = JSON.parse(streamEvent.content.toString());
this.processStreamData(headers, content);
}
}
}
}
});
}
processStreamData(headers: any, content: any) {
console.log(headers);
console.log(content);
}
initOnce() {
console.log('This method is called only once in the indexer master process');
super.initOnce();
}
addRoutes(server: FastifyInstance): void {
}
}