Updated plugin loader, mod, and sum to reflect changes made in utils v0.0.21.

This commit is contained in:
philip-morlier 2022-12-08 11:40:22 -08:00
parent 1805f477ae
commit c0530b8313
3 changed files with 12 additions and 13 deletions

2
go.mod
View File

@ -51,7 +51,7 @@ require (
github.com/naoina/go-stringutil v0.1.0 // indirect
github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416
github.com/olekukonko/tablewriter v0.0.5
github.com/openrelayxyz/plugeth-utils v0.0.20
github.com/openrelayxyz/plugeth-utils v0.0.21
github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7
github.com/prometheus/tsdb v0.7.1
github.com/rjeczalik/notify v0.9.1

4
go.sum
View File

@ -329,8 +329,8 @@ github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9k
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE=
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/openrelayxyz/plugeth-utils v0.0.20 h1:AAlGepQnWcYXIDzLT3HNh/cWayJ2MKbSb8Xd0ygFE7A=
github.com/openrelayxyz/plugeth-utils v0.0.20/go.mod h1:pyxp3NYW0VCJuwClSAuxNIiOdfjn7+h+PZKUVDmQ1qo=
github.com/openrelayxyz/plugeth-utils v0.0.21 h1:NFFdjLcvOB4WmsQ+yFzrkxpZhf4vpFUHuRhIY7VW9DQ=
github.com/openrelayxyz/plugeth-utils v0.0.21/go.mod h1:pyxp3NYW0VCJuwClSAuxNIiOdfjn7+h+PZKUVDmQ1qo=
github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/opentracing/opentracing-go v1.0.3-0.20180606204148-bd9c31933947/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU=

View File

@ -1,8 +1,6 @@
package plugins
import (
"github.com/openrelayxyz/plugeth-utils/core"
"flag"
"fmt"
"io/ioutil"
@ -10,13 +8,14 @@ import (
"plugin"
"reflect"
"strings"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/log"
"github.com/openrelayxyz/plugeth-utils/core"
"github.com/urfave/cli/v2"
)
type Subcommand func(*cli.Context, []string) error
type Subcommand func(core.Context, []string) error
type pluginDetails struct {
p *plugin.Plugin
@ -93,9 +92,9 @@ func NewPluginLoader(target string) (*PluginLoader, error) {
}
sb, err := plug.Lookup("Subcommands")
if err == nil {
subcommands, ok := sb.(*map[string]func(*cli.Context, []string) error)
subcommands, ok := sb.(*map[string]func(core.Context, []string) error)
if !ok {
log.Warn("Could not cast plugin.Subcommands to `map[string]func(*cli.Context, []string) error`", "file", fpath, "type", reflect.TypeOf(sb))
log.Warn("Could not cast plugin.Subcommands to `map[string]func(core.Context, []string) error`", "file", fpath, "type", reflect.TypeOf(sb))
} else {
for k, v := range *subcommands {
if _, ok := pl.Subcommands[k]; ok {
@ -110,7 +109,7 @@ func NewPluginLoader(target string) (*PluginLoader, error) {
return pl, nil
}
func Initialize(target string, ctx *cli.Context) (err error) {
func Initialize(target string, ctx core.Context) (err error) {
DefaultPluginLoader, err = NewPluginLoader(target)
if err != nil {
return err
@ -119,13 +118,13 @@ func Initialize(target string, ctx *cli.Context) (err error) {
return nil
}
func (pl *PluginLoader) Initialize(ctx *cli.Context) {
func (pl *PluginLoader) Initialize(ctx core.Context) {
fns := pl.Lookup("Initialize", func(i interface{}) bool {
_, ok := i.(func(*cli.Context, core.PluginLoader, core.Logger))
_, ok := i.(func(core.Context, core.PluginLoader, core.Logger))
return ok
})
for _, fni := range fns {
if fn, ok := fni.(func(*cli.Context, core.PluginLoader, core.Logger)); ok {
if fn, ok := fni.(func(core.Context, core.PluginLoader, core.Logger)); ok {
fn(ctx, pl, log.Root())
}
}