Don't return unexported types
This commit is contained in:
parent
e1236b4072
commit
4a98b7942f
@ -159,7 +159,7 @@ func SetupTusdRepo(vulcanizeLogID *int64, wantedEvents, wantedMethods []string)
|
||||
|
||||
func SetupTusdContract(wantedEvents, wantedMethods []string) *contract.Contract {
|
||||
p := mocks.NewParser(constants.TusdAbiString)
|
||||
err := p.Parse()
|
||||
err := p.Parse(constants.TusdContractAddress)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
return contract.Contract{
|
||||
@ -205,7 +205,7 @@ func SetupENSRepo(vulcanizeLogID *int64, wantedEvents, wantedMethods []string) (
|
||||
|
||||
func SetupENSContract(wantedEvents, wantedMethods []string) *contract.Contract {
|
||||
p := mocks.NewParser(constants.ENSAbiString)
|
||||
err := p.Parse()
|
||||
err := p.Parse(constants.EnsContractAddress)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
return contract.Contract{
|
||||
@ -223,7 +223,7 @@ func SetupENSContract(wantedEvents, wantedMethods []string) *contract.Contract {
|
||||
|
||||
func SetupMarketPlaceContract(wantedEvents, wantedMethods []string) *contract.Contract {
|
||||
p := mocks.NewParser(constants.MarketPlaceAbiString)
|
||||
err := p.Parse()
|
||||
err := p.Parse(constants.MarketPlaceContractAddress)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
return contract.Contract{
|
||||
@ -241,7 +241,7 @@ func SetupMarketPlaceContract(wantedEvents, wantedMethods []string) *contract.Co
|
||||
|
||||
func SetupMolochContract(wantedEvents, wantedMethods []string) *contract.Contract {
|
||||
p := mocks.NewParser(constants.MolochAbiString)
|
||||
err := p.Parse()
|
||||
err := p.Parse(constants.MolochContractAddress)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
return contract.Contract{
|
||||
|
@ -18,7 +18,7 @@ package mocks
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/pkg/contract_watcher/shared/parser"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/contract_watcher/shared/types"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/eth"
|
||||
)
|
||||
@ -26,29 +26,32 @@ import (
|
||||
// Mock parser
|
||||
// Is given ABI string instead of address
|
||||
// Performs all other functions of the real parser
|
||||
type parser struct {
|
||||
type mockParser struct {
|
||||
abi string
|
||||
parsedAbi abi.ABI
|
||||
}
|
||||
|
||||
func NewParser(abi string) *parser {
|
||||
|
||||
return &parser{
|
||||
func NewParser(abi string) parser.Parser {
|
||||
return &mockParser{
|
||||
abi: abi,
|
||||
}
|
||||
}
|
||||
|
||||
func (p *parser) Abi() string {
|
||||
func (p *mockParser) Abi() string {
|
||||
return p.abi
|
||||
}
|
||||
|
||||
func (p *parser) ParsedAbi() abi.ABI {
|
||||
func (p *mockParser) ParsedAbi() abi.ABI {
|
||||
return p.parsedAbi
|
||||
}
|
||||
|
||||
func (p *mockParser) ParseAbiStr(abiStr string) error {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
// Retrieves and parses the abi string
|
||||
// for the given contract address
|
||||
func (p *parser) Parse() error {
|
||||
func (p *mockParser) Parse(contractAddr string) error {
|
||||
var err error
|
||||
p.parsedAbi, err = eth.ParseAbi(p.abi)
|
||||
|
||||
@ -58,7 +61,7 @@ func (p *parser) Parse() error {
|
||||
// Returns only specified methods, if they meet the criteria
|
||||
// Returns as array with methods in same order they were specified
|
||||
// Nil wanted array => no events are returned
|
||||
func (p *parser) GetSelectMethods(wanted []string) []types.Method {
|
||||
func (p *mockParser) GetSelectMethods(wanted []string) []types.Method {
|
||||
wLen := len(wanted)
|
||||
if wLen == 0 {
|
||||
return nil
|
||||
@ -78,7 +81,7 @@ func (p *parser) GetSelectMethods(wanted []string) []types.Method {
|
||||
// Returns wanted methods
|
||||
// Empty wanted array => all methods are returned
|
||||
// Nil wanted array => no methods are returned
|
||||
func (p *parser) GetMethods(wanted []string) []types.Method {
|
||||
func (p *mockParser) GetMethods(wanted []string) []types.Method {
|
||||
if wanted == nil {
|
||||
return nil
|
||||
}
|
||||
@ -95,7 +98,7 @@ func (p *parser) GetMethods(wanted []string) []types.Method {
|
||||
|
||||
// Returns wanted events as map of types.Events
|
||||
// If no events are specified, all events are returned
|
||||
func (p *parser) GetEvents(wanted []string) map[string]types.Event {
|
||||
func (p *mockParser) GetEvents(wanted []string) map[string]types.Event {
|
||||
events := map[string]types.Event{}
|
||||
|
||||
for _, e := range p.parsedAbi.Events {
|
||||
|
@ -40,7 +40,7 @@ var _ = Describe("Parser", func() {
|
||||
Describe("Mock Parse", func() {
|
||||
It("Uses parses given abi string", func() {
|
||||
mp := mocks.NewParser(constants.DaiAbiString)
|
||||
err = mp.Parse()
|
||||
err = mp.Parse(constants.DaiContractAddress)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
parsedAbi := mp.ParsedAbi()
|
||||
|
@ -42,7 +42,7 @@ type builder struct {
|
||||
}
|
||||
|
||||
// Requires populated plugin config
|
||||
func NewPluginBuilder(gc config.Plugin) *builder {
|
||||
func NewPluginBuilder(gc config.Plugin) PluginBuilder {
|
||||
return &builder{
|
||||
GenConfig: gc,
|
||||
tmpVenDirs: make([]string, 0),
|
||||
|
@ -36,7 +36,7 @@ type generator struct {
|
||||
}
|
||||
|
||||
// Creates a new generator from a plugin and database config
|
||||
func NewGenerator(gc config.Plugin, dbc config.Database) (*generator, error) {
|
||||
func NewGenerator(gc config.Plugin, dbc config.Database) (Generator, error) {
|
||||
if len(gc.Transformers) < 1 {
|
||||
return nil, errors.New("plugin generator is not configured with any transformers")
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ type manager struct {
|
||||
}
|
||||
|
||||
// Manager requires both filled in generator and database configs
|
||||
func NewMigrationManager(gc config.Plugin, dbc config.Database) *manager {
|
||||
func NewMigrationManager(gc config.Plugin, dbc config.Database) MigrationManager {
|
||||
return &manager{
|
||||
GenConfig: gc,
|
||||
DBConfig: dbc,
|
||||
|
@ -37,7 +37,7 @@ type writer struct {
|
||||
}
|
||||
|
||||
// Requires populated plugin config
|
||||
func NewPluginWriter(gc config.Plugin) *writer {
|
||||
func NewPluginWriter(gc config.Plugin) PluginWriter {
|
||||
return &writer{
|
||||
GenConfig: gc,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user