-
Notifications
You must be signed in to change notification settings - Fork 532
/
interface.go
74 lines (64 loc) · 2.99 KB
/
interface.go
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
package plugin
import (
"context"
v1 "github.com/ignite/cli/v29/ignite/services/plugin/grpc/v1"
)
// Flag type aliases.
const (
FlagTypeString = v1.Flag_TYPE_FLAG_STRING_UNSPECIFIED
FlagTypeInt = v1.Flag_TYPE_FLAG_INT
FlagTypeUint = v1.Flag_TYPE_FLAG_UINT
FlagTypeInt64 = v1.Flag_TYPE_FLAG_INT64
FlagTypeUint64 = v1.Flag_TYPE_FLAG_UINT64
FlagTypeBool = v1.Flag_TYPE_FLAG_BOOL
FlagTypeStringSlice = v1.Flag_TYPE_FLAG_STRING_SLICE
)
// Type aliases for the current plugin version.
type (
Command = v1.Command
ChainInfo = v1.ChainInfo
ExecutedCommand = v1.ExecutedCommand
ExecutedHook = v1.ExecutedHook
Flag = v1.Flag
FlagType = v1.Flag_Type
Hook = v1.Hook
Manifest = v1.Manifest
)
// Interface defines the interface that all Ignite App must implement.
//
//go:generate mockery --srcpkg . --name Interface --structname PluginInterface --filename interface.go --with-expecter
type Interface interface {
// Manifest declares the app's Command(s) and Hook(s).
Manifest(context.Context) (*Manifest, error)
// Execute will be invoked by ignite when an app Command is executed.
// It is global for all commands declared in Manifest, if you have declared
// multiple commands, use cmd.Path to distinguish them.
// The clientAPI argument can be used by plugins to get chain app analysis info.
Execute(context.Context, *ExecutedCommand, ClientAPI) error
// ExecuteHookPre is invoked by ignite when a command specified by the Hook
// path is invoked.
// It is global for all hooks declared in Manifest, if you have declared
// multiple hooks, use hook.Name to distinguish them.
// The clientAPI argument can be used by plugins to get chain app analysis info.
ExecuteHookPre(context.Context, *ExecutedHook, ClientAPI) error
// ExecuteHookPost is invoked by ignite when a command specified by the hook
// path is invoked.
// It is global for all hooks declared in Manifest, if you have declared
// multiple hooks, use hook.Name to distinguish them.
// The clientAPI argument can be used by plugins to get chain app analysis info.
ExecuteHookPost(context.Context, *ExecutedHook, ClientAPI) error
// ExecuteHookCleanUp is invoked by ignite when a command specified by the
// hook path is invoked. Unlike ExecuteHookPost, it is invoked regardless of
// execution status of the command and hooks.
// It is global for all hooks declared in Manifest, if you have declared
// multiple hooks, use hook.Name to distinguish them.
// The clientAPI argument can be used by plugins to get chain app analysis info.
ExecuteHookCleanUp(context.Context, *ExecutedHook, ClientAPI) error
}
// ClientAPI defines the interface for plugins to get chain app code analysis info.
//
//go:generate mockery --srcpkg . --name ClientAPI --structname PluginClientAPI --filename client_api.go --with-expecter
type ClientAPI interface {
// GetChainInfo returns basic info for the configured blockchain app.
GetChainInfo(context.Context) (*ChainInfo, error)
}