Skip to content

Commit

Permalink
small improvement on errors and fix on plugin deps
Browse files Browse the repository at this point in the history
  • Loading branch information
bizk committed Sep 19, 2023
1 parent 293c7f4 commit 68d54f8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 1,951 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rosetta-cli-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ jobs:
- name: Checkout back to rosetta
uses: actions/checkout@v3
- name: Build Rosetta
run: go mod tidy && make rosetta && make plugin && ./rosetta --blockchain "cosmos" --network "cosmos" --tendermint "tcp://localhost:26657" --addr "localhost:8080" --grpc "localhost:9090 &"
run: go mod tidy && make rosetta && make plugin && ./rosetta --blockchain "cosmos" --network "cosmos" --tendermint "tcp://localhost:26657" --addr "localhost:8080" --grpc "localhost:9090"
- name: Rosetta-cli test
run: make rosetta-cli
11 changes: 5 additions & 6 deletions plugins.go
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@
package rosetta

import (
"errors"
"fmt"
"os"
"plugin"

crgerrs "github.com/cosmos/rosetta/lib/errors"

codectypes "github.com/cosmos/cosmos-sdk/codec/types"
)

func LoadPlugin(ir codectypes.InterfaceRegistry, pluginLocation string) (err error) {
pluginPathMain := fmt.Sprintf("./plugins/%s/main.so", pluginLocation)

if _, err := os.Stat(pluginPathMain); os.IsExist(err) {
return crgerrs.WrapError(crgerrs.ErrPlugin, fmt.Sprintf("Plugin file '%s' does not exist %s", pluginPathMain, err.Error()))
return errors.New(fmt.Sprintf("Plugin file '%s' does not exist %s", pluginPathMain, err.Error()))

Check failure on line 16 in plugins.go

View workflow job for this annotation

GitHub Actions / golangci-lint

errorf: should replace errors.New(fmt.Sprintf(...)) with fmt.Errorf(...) (revive)
}

// load module
plug, err := plugin.Open(pluginPathMain)
if err != nil {
return crgerrs.WrapError(crgerrs.ErrPlugin, fmt.Sprintf("There was an error while opening plugin on %s - %s", pluginPathMain, err.Error()))
return errors.New(fmt.Sprintf("There was an error while opening plugin on %s - %s", pluginPathMain, err.Error()))

Check failure on line 22 in plugins.go

View workflow job for this annotation

GitHub Actions / golangci-lint

errorf: should replace errors.New(fmt.Sprintf(...)) with fmt.Errorf(...) (revive)
}

initZone, err := plug.Lookup("InitZone")
if err != nil {
return crgerrs.WrapError(crgerrs.ErrPlugin, fmt.Sprintf("There was an error while initializing the zone %s", err.Error()))
return errors.New(fmt.Sprintf("There was an error while initializing the zone %s", err.Error()))

Check failure on line 27 in plugins.go

View workflow job for this annotation

GitHub Actions / golangci-lint

errorf: should replace errors.New(fmt.Sprintf(...)) with fmt.Errorf(...) (revive)
}
initZone.(func())()

registerInterfaces, err := plug.Lookup("RegisterInterfaces")
if err != nil {
return crgerrs.WrapError(crgerrs.ErrPlugin, fmt.Sprintf("There was an error while registering interfaces %s", err.Error()))
return errors.New(fmt.Sprintf("There was an error while registering interfaces %s", err.Error()))

Check failure on line 33 in plugins.go

View workflow job for this annotation

GitHub Actions / golangci-lint

errorf: should replace errors.New(fmt.Sprintf(...)) with fmt.Errorf(...) (revive)
}

registerInterfaces.(func(codectypes.InterfaceRegistry))(ir)
Expand Down
195 changes: 0 additions & 195 deletions plugins/cosmos-hub/go.mod

This file was deleted.

Loading

0 comments on commit 68d54f8

Please sign in to comment.