55 "fmt"
66 "os"
77
8- "github.com/cosmos/cosmos-sdk/client"
9- "github.com/cosmos/cosmos-sdk/client/flags"
108 "github.com/cosmos/cosmos-sdk/client/tx"
119 "github.com/cosmos/cosmos-sdk/codec"
1210 codectypes "github.com/cosmos/cosmos-sdk/codec/types"
@@ -15,7 +13,6 @@ import (
1513 sdkkeyring "github.com/cosmos/cosmos-sdk/crypto/keyring"
1614 cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
1715 sdk "github.com/cosmos/cosmos-sdk/types"
18- "github.com/cosmos/cosmos-sdk/version"
1916 "github.com/gitopia/git-remote-gitopia/config"
2017 glib "github.com/gitopia/gitopia-go"
2118 "github.com/gitopia/gitopia-go/logger"
@@ -25,13 +22,6 @@ import (
2522 "github.com/sirupsen/logrus"
2623 "github.com/spf13/pflag"
2724
28- "github.com/cosmos/cosmos-sdk/std"
29- authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
30- authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
31- gtypes "github.com/gitopia/gitopia/v2/x/gitopia/types"
32- otypes "github.com/gitopia/gitopia/v2/x/offchain/types"
33- rtypes "github.com/gitopia/gitopia/v2/x/rewards/types"
34-
3525 "github.com/pkg/errors"
3626 "google.golang.org/grpc"
3727)
@@ -96,7 +86,7 @@ func InitOSKeyringWallet() (Wallet, error) {
9686 ctx := logger .ContextWithValue (context .Background (), l )
9787 glib .WithGitopiaAddr (config .GRPCHost )
9888 glib .WithGasPrices (config .GasPrices )
99- cc , err := NewContext ( key )
89+ cc , err := glib . GetClientContextWithOptions ( AppName , key , backend )
10090 if err != nil {
10191 return nil , errors .Wrap (err , "error creating cosmos client context" )
10292 }
@@ -116,55 +106,6 @@ func InitOSKeyringWallet() (Wallet, error) {
116106 return o , nil
117107}
118108
119- func NewContext (from string ) (client.Context , error ) {
120- version .Name = AppName
121- clientCtx := client.Context {}
122-
123- interfaceRegistry := codectypes .NewInterfaceRegistry ()
124- std .RegisterInterfaces (interfaceRegistry )
125- cryptocodec .RegisterInterfaces (interfaceRegistry )
126- authtypes .RegisterInterfaces (interfaceRegistry )
127- gtypes .RegisterInterfaces (interfaceRegistry )
128- rtypes .RegisterInterfaces (interfaceRegistry )
129- otypes .RegisterInterfaces (interfaceRegistry )
130-
131- marshaler := codec .NewProtoCodec (interfaceRegistry )
132- txCfg := authtx .NewTxConfig (marshaler , authtx .DefaultSignModes )
133- clientCtx = clientCtx .
134- WithCodec (marshaler ).
135- WithInterfaceRegistry (interfaceRegistry ).
136- WithAccountRetriever (authtypes.AccountRetriever {}).
137- WithTxConfig (txCfg ).
138- WithInput (os .Stdin )
139-
140- clientCtx = clientCtx .WithChainID (config .ChainId )
141- clientCtx = clientCtx .WithNodeURI (config .TmAddr )
142- c , err := client .NewClientFromNode (clientCtx .NodeURI )
143- if err != nil {
144- return clientCtx , errors .Wrap (err , "error creatig tm client" )
145- }
146- clientCtx = clientCtx .WithClient (c )
147- clientCtx = clientCtx .WithBroadcastMode (flags .BroadcastSync )
148- clientCtx = clientCtx .WithSkipConfirmation (true )
149-
150- kr , err := client .NewKeyringFromBackend (clientCtx , keyring .BackendOS )
151- if err != nil {
152- return clientCtx , errors .Wrap (err , "error creating keyring backend" )
153- }
154- clientCtx = clientCtx .WithKeyring (kr )
155-
156- fromAddr , fromName , _ , err := client .GetFromFields (clientCtx , kr , from )
157- if err != nil {
158- return clientCtx , errors .Wrap (err , "error parsing from Addr" )
159- }
160-
161- clientCtx = clientCtx .WithFrom (from ).WithFromAddress (fromAddr ).WithFromName (fromName )
162-
163- feeGranterAddr := sdk .MustAccAddressFromBech32 (config .FeeGranterAddr )
164- clientCtx = clientCtx .WithFeeGranterAddress (feeGranterAddr )
165- return clientCtx , nil
166- }
167-
168109func (o OSKeyring ) SignData (data []byte ) (string , error ) {
169110 var privKey offchaintypes.SignatureProvider
170111
0 commit comments