1
+ import { Block , SignedTransaction } from "@fleet-sdk/common" ;
2
+ import { BlockchainSnapshot } from "../../src/blockchain/blockchain_monitor.ts" ;
1
3
import { Plugin , PluginDescriptor } from "../../src/plugins/mod.ts" ;
2
4
import { z } from "zod/mod.ts" ;
3
5
4
6
export const _TEMPLATE_PLUGIN_ID = "_template_plugin" ;
5
7
6
8
interface _TemplatePluginConfig {
7
- tokenId : string ;
8
- exitAtPage : number ;
9
+ configValue : string ;
10
+ otherConfigValue : number ;
9
11
}
10
12
11
13
export class _TemplatePlugin extends Plugin < _TemplatePluginConfig > {
@@ -15,21 +17,67 @@ export class _TemplatePlugin extends Plugin<_TemplatePluginConfig> {
15
17
name : "Template Plugin" ,
16
18
// Description of your plugins functionality and anything else users should be aware of
17
19
description :
18
- "This is an example plugin showcasing how to create & implement ergomatic plugins. " ,
20
+ "Template for developers to get started creating their own plugins" ,
19
21
// Version of your plugin
20
22
version : "0.1.0" ,
21
23
} ;
22
24
}
23
25
24
26
onStart ( ) : Promise < void > {
27
+ this . logger . info ( `started with configuration: ${ this . config } ` ) ;
28
+
29
+ return Promise . resolve ( ) ;
30
+ }
31
+
32
+ onStop ( ) : Promise < void > {
33
+ this . logger . info ( "Plugin shutting down, performing cleanup!" ) ;
34
+
35
+ return Promise . resolve ( ) ;
36
+ }
37
+
38
+ onNewBlock (
39
+ block : Block ,
40
+ snapshot : Readonly < BlockchainSnapshot > ,
41
+ ) : Promise < void > {
42
+ this . logger . info ( `block: ${ block } , snapshot: ${ snapshot } ` ) ;
43
+
44
+ return Promise . resolve ( ) ;
45
+ }
46
+
47
+ onMempoolTx (
48
+ tx : SignedTransaction ,
49
+ snapshot : Readonly < BlockchainSnapshot > ,
50
+ ) : Promise < void > {
51
+ this . logger . info ( `mempool tx: ${ tx } , snapshot: ${ snapshot } ` ) ;
52
+
53
+ return Promise . resolve ( ) ;
54
+ }
55
+
56
+ onIncludedTx (
57
+ tx : SignedTransaction ,
58
+ snapshot : Readonly < BlockchainSnapshot > ,
59
+ ) : Promise < void > {
60
+ this . logger . info ( `tx included in block: ${ tx } , snapshot: ${ snapshot } ` ) ;
61
+
62
+ return Promise . resolve ( ) ;
63
+ }
64
+
65
+ onMempoolTxDrop (
66
+ tx : SignedTransaction ,
67
+ snapshot : Readonly < BlockchainSnapshot > ,
68
+ ) : Promise < void > {
69
+ this . logger . warning (
70
+ `tx dropped from mempool without being included in block: ${ tx } , snapshot: ${ snapshot } ` ,
71
+ ) ;
72
+
25
73
return Promise . resolve ( ) ;
26
74
}
27
75
28
76
// deno-lint-ignore no-explicit-any
29
77
configSchema ( ) : z . ZodObject < any > | undefined {
30
78
return z . object ( {
31
- tokenId : z . string ( ) ,
32
- exitAtPage : z . number ( ) ,
79
+ configValue : z . string ( ) ,
80
+ otherConfigValue : z . number ( ) ,
33
81
} ) ;
34
82
}
35
83
}
0 commit comments