diff --git a/chains/evm/chain.go b/chains/evm/chain.go index 18862e12..50d810a8 100644 --- a/chains/evm/chain.go +++ b/chains/evm/chain.go @@ -7,6 +7,7 @@ import ( "context" "fmt" "math/big" + "reflect" "github.com/rs/zerolog" "github.com/rs/zerolog/log" @@ -52,7 +53,7 @@ func NewEVMChain(listener EventListener, messageHandler MessageHandler, executor // PollEvents is the goroutine that polls blocks and searches Deposit events in them. // Events are then sent to eventsChan. func (c *EVMChain) PollEvents(ctx context.Context) { - if c.listener == nil { + if reflect.ValueOf(c.listener).IsNil() { return } @@ -61,7 +62,7 @@ func (c *EVMChain) PollEvents(ctx context.Context) { } func (c *EVMChain) ReceiveMessage(m *message.Message) (*proposal.Proposal, error) { - if c.messageHandler == nil { + if reflect.ValueOf(c.messageHandler).IsNil() { return nil, fmt.Errorf("message handler not configured") } @@ -69,7 +70,7 @@ func (c *EVMChain) ReceiveMessage(m *message.Message) (*proposal.Proposal, error } func (c *EVMChain) Write(props []*proposal.Proposal) error { - if c.executor == nil { + if reflect.ValueOf(c.executor).IsNil() { return fmt.Errorf("executor not configured") } diff --git a/chains/substrate/chain.go b/chains/substrate/chain.go index c0989a52..6b88c2e8 100644 --- a/chains/substrate/chain.go +++ b/chains/substrate/chain.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "math/big" + "reflect" "github.com/rs/zerolog" "github.com/rs/zerolog/log" @@ -47,7 +48,7 @@ func NewSubstrateChain(listener EventListener, messageHandler MessageHandler, ex // PollEvents is the goroutine that polls blocks and searches Deposit events in them. // Events are then sent to eventsChan. func (c *SubstrateChain) PollEvents(ctx context.Context) { - if c.listener == nil { + if reflect.ValueOf(c.listener).IsNil() { return } @@ -56,7 +57,7 @@ func (c *SubstrateChain) PollEvents(ctx context.Context) { } func (c *SubstrateChain) ReceiveMessage(m *message.Message) (*proposal.Proposal, error) { - if c.messageHandler == nil { + if reflect.ValueOf(c.messageHandler).IsNil() { return nil, fmt.Errorf("message handler not configured") } @@ -64,7 +65,7 @@ func (c *SubstrateChain) ReceiveMessage(m *message.Message) (*proposal.Proposal, } func (c *SubstrateChain) Write(props []*proposal.Proposal) error { - if c.executor == nil { + if reflect.ValueOf(c.executor).IsNil() { return fmt.Errorf("executor not configured") }