Repository: cosmos/relayer
Pull request #862 (2022-07-21 20:35:27)

Move cosmos provider into relayer/chains/cosmos
Consolidate both `cosmos` packages, processor and provider, into the one in `relayer/chains/cosmos`.


Patch:
diff --git a/cmd/chains.go b/cmd/chains.go
index c69ae70..07d537d 100644
--- a/cmd/chains.go
+++ b/cmd/chains.go
@@ -12,7 +12,7 @@ import (
 	"strings"
 
 	"github.com/cosmos/relayer/v2/relayer"
-	"github.com/cosmos/relayer/v2/relayer/provider/cosmos"
+	"github.com/cosmos/relayer/v2/relayer/chains/cosmos"
 	"github.com/spf13/cobra"
 	registry "github.com/strangelove-ventures/lens/client/chain_registry"
 	"go.uber.org/zap"
diff --git a/cmd/config.go b/cmd/config.go
index c6d1f17..4c5ca0d 100644
--- a/cmd/config.go
+++ b/cmd/config.go
@@ -30,8 +30,8 @@ import (
 	"time"
 
 	"github.com/cosmos/relayer/v2/relayer"
+	"github.com/cosmos/relayer/v2/relayer/chains/cosmos"
 	"github.com/cosmos/relayer/v2/relayer/provider"
-	"github.com/cosmos/relayer/v2/relayer/provider/cosmos"
 	"github.com/spf13/cobra"
 	"go.uber.org/zap"
 	"gopkg.in/yaml.v3"
diff --git a/relayer/chains/cosmos/cosmos_chain_processor.go b/relayer/chains/cosmos/cosmos_chain_processor.go
index d28fe28..e4cd3fc 100644
--- a/relayer/chains/cosmos/cosmos_chain_processor.go
+++ b/relayer/chains/cosmos/cosmos_chain_processor.go
@@ -12,7 +12,6 @@ import (
 	chantypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types"
 	"github.com/cosmos/relayer/v2/relayer/processor"
 	"github.com/cosmos/relayer/v2/relayer/provider"
-	"github.com/cosmos/relayer/v2/relayer/provider/cosmos"
 	ctypes "github.com/tendermint/tendermint/rpc/core/types"
 	"go.uber.org/zap"
 	"golang.org/x/sync/errgroup"
@@ -21,7 +20,7 @@ import (
 type CosmosChainProcessor struct {
 	log *zap.Logger
 
-	chainProvider *cosmos.CosmosProvider
+	chainProvider *CosmosProvider
 
 	pathProcessors processor.PathProcessors
 
@@ -47,7 +46,7 @@ type CosmosChainProcessor struct {
 	channelConnections map[string]string
 }
 
-func NewCosmosChainProcessor(log *zap.Logger, provider *cosmos.CosmosProvider) *CosmosChainProcessor {
+func NewCosmosChainProcessor(log *zap.Logger, provider *CosmosProvider) *CosmosChainProcessor {
 	return &CosmosChainProcessor{
 		log:                  log.With(zap.String("chain_name", provider.ChainName()), zap.String("chain_id", provider.ChainId())),
 		chainProvider:        provider,
@@ -290,7 +289,7 @@ func (ccp *CosmosChainProcessor) queryCycle(ctx context.Context, persistence *qu
 
 	ppChanged := false
 
-	var latestHeader cosmos.CosmosIBCHeader
+	var latestHeader CosmosIBCHeader
 
 	newLatestQueriedBlock := persistence.latestQueriedBlock
 
@@ -317,7 +316,7 @@ func (ccp *CosmosChainProcessor) queryCycle(ctx context.Context, persistence *qu
 			break
 		}
 
-		latestHeader = ibcHeader.(cosmos.CosmosIBCHeader)
+		latestHeader = ibcHeader.(CosmosIBCHeader)
 
 		heightUint64 := uint64(i)
 
diff --git a/relayer/provider/cosmos/log.go b/relayer/chains/cosmos/log.go
similarity index 100%
rename from relayer/provider/cosmos/log.go
rename to relayer/chains/cosmos/log.go
diff --git a/relayer/provider/cosmos/msg.go b/relayer/chains/cosmos/msg.go
similarity index 100%
rename from relayer/provider/cosmos/msg.go
rename to relayer/chains/cosmos/msg.go
diff --git a/relayer/provider/cosmos/provider.go b/relayer/chains/cosmos/provider.go
similarity index 100%
rename from relayer/provider/cosmos/provider.go
rename to relayer/chains/cosmos/provider.go
diff --git a/relayer/provider/cosmos/query.go b/relayer/chains/cosmos/query.go
similarity index 100%
rename from relayer/provider/cosmos/query.go
rename to relayer/chains/cosmos/query.go
diff --git a/relayer/provider/cosmos/relayer_packets.go b/relayer/chains/cosmos/relayer_packets.go
similarity index 100%
rename from relayer/provider/cosmos/relayer_packets.go
rename to relayer/chains/cosmos/relayer_packets.go
diff --git a/relayer/provider/cosmos/tx.go b/relayer/chains/cosmos/tx.go
similarity index 100%
rename from relayer/provider/cosmos/tx.go
rename to relayer/chains/cosmos/tx.go
diff --git a/relayer/chains/mock/mock_chain_processor.go b/relayer/chains/mock/mock_chain_processor.go
index 7c94b2a..5ed3214 100644
--- a/relayer/chains/mock/mock_chain_processor.go
+++ b/relayer/chains/mock/mock_chain_processor.go
@@ -4,9 +4,9 @@ import (
 	"context"
 	"time"
 
+	"github.com/cosmos/relayer/v2/relayer/chains/cosmos"
 	"github.com/cosmos/relayer/v2/relayer/processor"
 	"github.com/cosmos/relayer/v2/relayer/provider"
-	"github.com/cosmos/relayer/v2/relayer/provider/cosmos"
 
 	chantypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types"
 	"go.uber.org/zap"
diff --git a/relayer/log-chain.go b/relayer/log-chain.go
index b296c3e..7994e77 100644
--- a/relayer/log-chain.go
+++ b/relayer/log-chain.go
@@ -3,8 +3,8 @@ package relayer
 import (
 	"fmt"
 
+	"github.com/cosmos/relayer/v2/relayer/chains/cosmos"
 	"github.com/cosmos/relayer/v2/relayer/provider"
-	"github.com/cosmos/relayer/v2/relayer/provider/cosmos"
 	"go.uber.org/zap"
 
 	conntypes "github.com/cosmos/ibc-go/v3/modules/core/03-connection/types"
diff --git a/relayer/strategies.go b/relayer/strategies.go
index eb7ca25..c10e2fd 100644
--- a/relayer/strategies.go
+++ b/relayer/strategies.go
@@ -10,10 +10,9 @@ import (
 
 	"github.com/avast/retry-go/v4"
 	"github.com/cosmos/ibc-go/v3/modules/core/04-channel/types"
-	cosmosprocessor "github.com/cosmos/relayer/v2/relayer/chains/cosmos"
+	"github.com/cosmos/relayer/v2/relayer/chains/cosmos"
 	"github.com/cosmos/relayer/v2/relayer/processor"
 	"github.com/cosmos/relayer/v2/relayer/provider"
-	cosmosprovider "github.com/cosmos/relayer/v2/relayer/provider/cosmos"
 	"go.uber.org/zap"
 )
 
@@ -88,8 +87,8 @@ type pathChain struct {
 func (chain pathChain) chainProcessor(log *zap.Logger) processor.ChainProcessor {
 	// Handle new ChainProcessor implementations as cases here
 	switch p := chain.provider.(type) {
-	case *cosmosprovider.CosmosProvider:
-		return cosmosprocessor.NewCosmosChainProcessor(log, p)
+	case *cosmos.CosmosProvider:
+		return cosmos.NewCosmosChainProcessor(log, p)
 	default:
 		panic(fmt.Errorf("unsupported chain provider type: %T", chain.provider))
 	}


Test patch:
diff --git a/_test/test_chains.go b/_test/test_chains.go
index b42951f..37c8231 100644
--- a/_test/test_chains.go
+++ b/_test/test_chains.go
@@ -9,8 +9,8 @@ import (
 
 	"github.com/cosmos/cosmos-sdk/server"
 	"github.com/cosmos/relayer/v2/relayer"
+	"github.com/cosmos/relayer/v2/relayer/chains/cosmos"
 	"github.com/cosmos/relayer/v2/relayer/provider"
-	"github.com/cosmos/relayer/v2/relayer/provider/cosmos"
 	dc "github.com/ory/dockertest/v3/docker"
 	"github.com/stretchr/testify/require"
 	"go.uber.org/zap/zaptest"
diff --git a/cmd/chains_test.go b/cmd/chains_test.go
index b49df31..0a1b695 100644
--- a/cmd/chains_test.go
+++ b/cmd/chains_test.go
@@ -9,7 +9,7 @@ import (
 
 	"github.com/cosmos/relayer/v2/cmd"
 	"github.com/cosmos/relayer/v2/internal/relayertest"
-	"github.com/cosmos/relayer/v2/relayer/provider/cosmos"
+	"github.com/cosmos/relayer/v2/relayer/chains/cosmos"
 	"github.com/stretchr/testify/require"
 )
 
diff --git a/cmd/keys_test.go b/cmd/keys_test.go
index e241656..63de620 100644
--- a/cmd/keys_test.go
+++ b/cmd/keys_test.go
@@ -7,7 +7,7 @@ import (
 	"github.com/cosmos/cosmos-sdk/crypto/keyring"
 	"github.com/cosmos/relayer/v2/cmd"
 	"github.com/cosmos/relayer/v2/internal/relayertest"
-	"github.com/cosmos/relayer/v2/relayer/provider/cosmos"
+	"github.com/cosmos/relayer/v2/relayer/chains/cosmos"
 	"github.com/stretchr/testify/require"
 )
 
diff --git a/ibctest/relayer.go b/ibctest/relayer.go
index 16620b6..b11dc12 100644
--- a/ibctest/relayer.go
+++ b/ibctest/relayer.go
@@ -10,7 +10,7 @@ import (
 	"github.com/cosmos/cosmos-sdk/crypto/keyring"
 	"github.com/cosmos/relayer/v2/cmd"
 	"github.com/cosmos/relayer/v2/internal/relayertest"
-	"github.com/cosmos/relayer/v2/relayer/provider/cosmos"
+	"github.com/cosmos/relayer/v2/relayer/chains/cosmos"
 	"github.com/strangelove-ventures/ibctest/ibc"
 	"go.uber.org/zap"
 	"go.uber.org/zap/zaptest"