diff --git a/app/gitopia.go b/app/gitopia.go index 76f8735..4c35b56 100644 --- a/app/gitopia.go +++ b/app/gitopia.go @@ -3,6 +3,7 @@ package app import ( "context" + "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/authz" "github.com/gitopia/git-server/logger" @@ -11,6 +12,8 @@ import ( "github.com/ignite/cli/ignite/pkg/cosmosclient" "github.com/pkg/errors" "github.com/spf13/viper" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" ) const ( @@ -38,12 +41,21 @@ func NewGitopiaClient(ctx context.Context, account string) (GitopiaClient, error cosmosclient.WithKeyringBackend(cosmosaccount.KeyringTest), cosmosclient.WithHome(viper.GetString("keyring_dir")), cosmosclient.WithAddressPrefix(GITOPIA_ACC_ADDRESS_PREFIX), + cosmosclient.WithGasPrices(viper.GetString("gas_prices")), ) if err != nil { return GitopiaClient{}, errors.Wrap(err, "error creating cosmos client") } - queryClient := types.NewQueryClient(client.Context().GRPCClient) + grpcConn, err := grpc.Dial(viper.GetString("gitopia_grpc_url"), + grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithDefaultCallOptions(grpc.ForceCodec(codec.NewProtoCodec(nil).GRPCCodec())), + ) + if err != nil { + return GitopiaClient{}, errors.Wrap(err, "error creating grpc client") + } + + queryClient := types.NewQueryClient(grpcConn) return GitopiaClient{ accountName: account, diff --git a/config_dev.toml b/config_dev.toml index e21162a..dc11504 100644 --- a/config_dev.toml +++ b/config_dev.toml @@ -4,4 +4,5 @@ git_dir = "/var/repos" attachment_dir = "/var/attachments" tm_addr = "http://grpc.gitopia.dev:26657" key_name = "git-server" -keyring_dir = "/home/ubuntu/git-server" \ No newline at end of file +keyring_dir = "/home/ubuntu/git-server" +gas_prices = "0.001utlore" diff --git a/config_local.toml b/config_local.toml index a0c1c0f..7d25f2c 100644 --- a/config_local.toml +++ b/config_local.toml @@ -4,4 +4,5 @@ git_dir = "/var/repos" attachment_dir = "/var/attachments" tm_addr = "http://localhost:26657" key_name = "git-server" -keyring_dir = "" \ No newline at end of file +keyring_dir = "" +gas_prices = "" diff --git a/config_prod.toml b/config_prod.toml index 4c03b57..b99be2a 100644 --- a/config_prod.toml +++ b/config_prod.toml @@ -4,4 +4,5 @@ git_dir = "/var/repos" attachment_dir = "/var/attachments" tm_addr = "http://grpc.gitopia.com:26657" key_name = "git-server" -keyring_dir = "/home/ubuntu/git-server" \ No newline at end of file +keyring_dir = "/home/ubuntu/git-server" +gas_prices = "0.001ulore" diff --git a/handler.go b/handler.go index d346f7c..05926ac 100644 --- a/handler.go +++ b/handler.go @@ -15,6 +15,7 @@ import ( "strings" "time" + "github.com/cosmos/cosmos-sdk/codec" "github.com/gitopia/git-server/utils" "github.com/gitopia/gitopia/x/gitopia/types" "github.com/spf13/viper" @@ -119,6 +120,7 @@ func getAttachmentHandler(w http.ResponseWriter, r *http.Request) { grpcUrl := viper.GetString("gitopia_grpc_url") grpcConn, err := grpc.Dial(grpcUrl, grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithDefaultCallOptions(grpc.ForceCodec(codec.NewProtoCodec(nil).GRPCCodec())), ) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) diff --git a/handler/forkRepository.go b/handler/forkRepository.go index e95551c..7853fb4 100644 --- a/handler/forkRepository.go +++ b/handler/forkRepository.go @@ -10,6 +10,7 @@ import ( "sync" "github.com/buger/jsonparser" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types/query" "github.com/cosmos/cosmos-sdk/types/tx" "github.com/gitopia/git-server/app" @@ -286,6 +287,7 @@ func (h *InvokeForkRepositoryEventHandler) BackfillMissedEvents(ctx context.Cont grpcConn, err := grpc.Dial(viper.GetString("gitopia_grpc_url"), grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithDefaultCallOptions(grpc.ForceCodec(codec.NewProtoCodec(nil).GRPCCodec())), ) if err != nil { errChan <- errors.Wrap(err, "dial err") diff --git a/handler/mergePullRequest.go b/handler/mergePullRequest.go index 25b7875..e6a6d39 100644 --- a/handler/mergePullRequest.go +++ b/handler/mergePullRequest.go @@ -13,6 +13,7 @@ import ( "time" "github.com/buger/jsonparser" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types/query" "github.com/cosmos/cosmos-sdk/types/tx" "github.com/gitopia/git-server/app" @@ -490,6 +491,7 @@ func (h *InvokeMergePullRequestEventHandler) BackfillMissedEvents(ctx context.Co grpcConn, err := grpc.Dial(viper.GetString("gitopia_grpc_url"), grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithDefaultCallOptions(grpc.ForceCodec(codec.NewProtoCodec(nil).GRPCCodec())), ) if err != nil { errChan <- errors.Wrap(err, "dial err") diff --git a/util.go b/util.go index b6a0ca7..61fffad 100644 --- a/util.go +++ b/util.go @@ -6,6 +6,7 @@ import ( "strconv" "strings" + "github.com/cosmos/cosmos-sdk/codec" "github.com/gitopia/gitopia/x/gitopia/types" "github.com/gitopia/gitopia/x/gitopia/utils" "github.com/spf13/viper" @@ -46,6 +47,7 @@ func HavePushPermission(repoId uint64, address string) (havePermission bool, err grpcUrl := viper.GetString("gitopia_grpc_url") grpcConn, err := grpc.Dial(grpcUrl, grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithDefaultCallOptions(grpc.ForceCodec(codec.NewProtoCodec(nil).GRPCCodec())), ) if err != nil { return false, err