Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"time"

"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -23,6 +24,7 @@ import (
"google.golang.org/grpc/credentials/insecure"

"github.com/CoreumFoundation/coreum-tools/pkg/parallel"
coreumapp "github.com/CoreumFoundation/coreum/v4/app"
"github.com/CoreumFoundation/coreum/v4/pkg/client"
coreumconfig "github.com/CoreumFoundation/coreum/v4/pkg/config"
"github.com/CoreumFoundation/coreum/v4/pkg/config/constant"
Expand Down Expand Up @@ -147,9 +149,20 @@ func addClient(cfg cfg, log *zap.Logger, clientCtx client.Context) client.Contex
)
}

encodingConfig := coreumconfig.NewEncodingConfig(coreumapp.ModuleBasics)

pc, ok := encodingConfig.Codec.(codec.GRPCCodecProvider)
if !ok {
panic("failed to cast codec to codec.GRPCCodecProvider")
}

// tls grpc
if nodeURL.Scheme == "https" {
grpcClient, err := grpc.Dial(nodeURL.Host, grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})))
grpcClient, err := grpc.Dial(
nodeURL.Host,
grpc.WithDefaultCallOptions(grpc.ForceCodec(pc.GRPCCodec())),
grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})),
)
if err != nil {
panic(err)
}
Expand All @@ -163,7 +176,11 @@ func addClient(cfg cfg, log *zap.Logger, clientCtx client.Context) client.Contex
if host == "" {
host = cfg.node
}
grpcClient, err := grpc.Dial(host, grpc.WithTransportCredentials(insecure.NewCredentials()))
grpcClient, err := grpc.Dial(
host,
grpc.WithDefaultCallOptions(grpc.ForceCodec(pc.GRPCCodec())),
grpc.WithTransportCredentials(insecure.NewCredentials()),
)
if err != nil {
log.Fatal(
"Unable to create cosmos grpc client",
Expand Down
15 changes: 14 additions & 1 deletion integration-tests/transfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"time"

"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
sdk "github.com/cosmos/cosmos-sdk/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
Expand All @@ -23,6 +24,7 @@ import (
"google.golang.org/grpc/credentials/insecure"

"github.com/CoreumFoundation/coreum-tools/pkg/must"
coreumapp "github.com/CoreumFoundation/coreum/v4/app"
"github.com/CoreumFoundation/coreum/v4/pkg/client"
coreumconfig "github.com/CoreumFoundation/coreum/v4/pkg/config"
"github.com/CoreumFoundation/coreum/v4/pkg/config/constant"
Expand Down Expand Up @@ -54,7 +56,18 @@ func init() {
WithChainID(string(cfg.network.ChainID())).
WithBroadcastMode(flags.BroadcastSync)

grpcClient, err := grpc.Dial(cfg.coredAddress, grpc.WithTransportCredentials(insecure.NewCredentials()))
encodingConfig := coreumconfig.NewEncodingConfig(coreumapp.ModuleBasics)

pc, ok := encodingConfig.Codec.(codec.GRPCCodecProvider)
if !ok {
panic("failed to cast codec to codec.GRPCCodecProvider")
}

grpcClient, err := grpc.Dial(
cfg.coredAddress,
grpc.WithDefaultCallOptions(grpc.ForceCodec(pc.GRPCCodec())),
grpc.WithTransportCredentials(insecure.NewCredentials()),
)
must.OK(err)
cfg.clientCtx = cfg.clientCtx.WithGRPCClient(grpcClient)
}
Expand Down