diff --git a/go.mod b/go.mod index da46d3180..313e9fcff 100644 --- a/go.mod +++ b/go.mod @@ -12,10 +12,10 @@ replace ( ) require ( + cosmossdk.io/errors v1.0.0-beta.7 github.com/GeertJohan/go.linenoise v0.0.0-20141120151038-1918ff89d613 github.com/aws/aws-sdk-go v1.44.159 github.com/bnb-chain/greenfield v0.0.5 - github.com/bnb-chain/greenfield-go-sdk v0.0.3 github.com/bnb-chain/greenfield-sdk-go v0.0.0-20230208161205-03ff5beb1419 github.com/bytedance/gopkg v0.0.0-20221122125632-68358b8ecec6 github.com/cloudflare/cfssl v1.6.3 @@ -45,7 +45,6 @@ require ( ) require ( - cosmossdk.io/errors v1.0.0-beta.7 // indirect cosmossdk.io/math v1.0.0-beta.3 // indirect filippo.io/edwards25519 v1.0.0-rc.1 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect diff --git a/go.sum b/go.sum index 8d2404b48..79dd76efa 100644 --- a/go.sum +++ b/go.sum @@ -207,8 +207,6 @@ github.com/bnb-chain/gnfd-tendermint v0.0.1 h1:KWFuxWv8m6t1vUi3ADyVcEG0qVnEzQt1t github.com/bnb-chain/gnfd-tendermint v0.0.1/go.mod h1:/v9z9F6cq0+f7EGG92lYSLBcPYQDILoK91X8YM28hWo= github.com/bnb-chain/greenfield v0.0.0-20230217070311-2a863e19f57d h1:1WdPI/6AncX/0JBytHkixtzGItoknwv4pbjkqWeDPNo= github.com/bnb-chain/greenfield v0.0.0-20230217070311-2a863e19f57d/go.mod h1:zWg5zWuPtfO7ZWP4/3YpCrAOXpWAC80SHV6G+yDhSqA= -github.com/bnb-chain/greenfield-go-sdk v0.0.3 h1:9NLShPEDJ36VHPapcuGJktloOyRPJeCutuj4xry4XKg= -github.com/bnb-chain/greenfield-go-sdk v0.0.3/go.mod h1:0O3Ktrh869xzFuxts9Xsdt0TL6O5bMFuJIrXkDRBc1Q= github.com/bnb-chain/greenfield-sdk-go v0.0.0-20230208161205-03ff5beb1419 h1:pMl5XQIBAL51WqkWWYUHITv6epA4y2ZmOjiDr9avbCk= github.com/bnb-chain/greenfield-sdk-go v0.0.0-20230208161205-03ff5beb1419/go.mod h1:+b9Ow9h0I6rmPxg54KlqUmrjUgGub7qu0RsUYUQzpYs= github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= diff --git a/service/client/gnfd_client.go b/service/client/gnfd_client.go index c1dfaa290..31b391d8a 100644 --- a/service/client/gnfd_client.go +++ b/service/client/gnfd_client.go @@ -7,16 +7,17 @@ import ( "sync" "cosmossdk.io/errors" - "github.com/bnb-chain/greenfield-go-sdk/client/chain" - "github.com/bnb-chain/greenfield-go-sdk/keys" - ctypes "github.com/bnb-chain/greenfield-go-sdk/types" + "github.com/bnb-chain/greenfield/sdk/client" + "github.com/bnb-chain/greenfield/sdk/keys" + ctypes "github.com/bnb-chain/greenfield/sdk/types" storagetypes "github.com/bnb-chain/greenfield/x/storage/types" - "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/tx" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto/secp256k1" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" merrors "github.com/bnb-chain/greenfield-storage-provider/model/errors" ptypes "github.com/bnb-chain/greenfield-storage-provider/pkg/types/v1" @@ -45,7 +46,7 @@ type GreenfieldChainSignClient struct { mu sync.Mutex gasLimit uint64 - greenfieldClients map[SignType]*chain.GreenfieldClient + greenfieldClients map[SignType]*client.GreenfieldClient } // NewGreenfieldChainSignClient return the GreenfieldChainSignClient instance @@ -63,27 +64,31 @@ func NewGreenfieldChainSignClient( if err != nil { return nil, err } - operatorClient := chain.NewGreenfieldClientWithKeyManager(gRPCAddr, chainID, operatorKM) + operatorClient := client.NewGreenfieldClient(gRPCAddr, chainID, client.WithKeyManager(operatorKM), + client.WithGrpcDialOption(grpc.WithTransportCredentials(insecure.NewCredentials()))) fundingKM, err := keys.NewPrivateKeyManager(fundingPrivateKey) if err != nil { return nil, err } - fundingClient := chain.NewGreenfieldClientWithKeyManager(gRPCAddr, chainID, fundingKM) + fundingClient := client.NewGreenfieldClient(gRPCAddr, chainID, client.WithKeyManager(fundingKM), + client.WithGrpcDialOption(grpc.WithTransportCredentials(insecure.NewCredentials()))) sealKM, err := keys.NewPrivateKeyManager(sealPrivateKey) if err != nil { return nil, err } - sealClient := chain.NewGreenfieldClientWithKeyManager(gRPCAddr, chainID, sealKM) + sealClient := client.NewGreenfieldClient(gRPCAddr, chainID, client.WithKeyManager(sealKM), + client.WithGrpcDialOption(grpc.WithTransportCredentials(insecure.NewCredentials()))) approvalKM, err := keys.NewPrivateKeyManager(approvalPrivateKey) if err != nil { return nil, err } - approvalClient := chain.NewGreenfieldClientWithKeyManager(gRPCAddr, chainID, approvalKM) - greenfieldClients := map[SignType]*chain.GreenfieldClient{ - SignOperator: &operatorClient, - SignFunding: &fundingClient, - SignSeal: &sealClient, - SignApproval: &approvalClient, + approvalClient := client.NewGreenfieldClient(gRPCAddr, chainID, client.WithKeyManager(approvalKM), + client.WithGrpcDialOption(grpc.WithTransportCredentials(insecure.NewCredentials()))) + greenfieldClients := map[SignType]*client.GreenfieldClient{ + SignOperator: operatorClient, + SignFunding: fundingClient, + SignSeal: sealClient, + SignApproval: approvalClient, } return &GreenfieldChainSignClient{ @@ -156,12 +161,12 @@ func (client *GreenfieldChainSignClient) SealObject(ctx context.Context, scope S defer client.mu.Unlock() var ( - secondarySPAccs = make([]types.AccAddress, 0, len(object.SecondarySps)) + secondarySPAccs = make([]sdk.AccAddress, 0, len(object.SecondarySps)) secondarySPSignatures = make([][]byte, 0, len(object.SecondarySps)) ) for _, sp := range object.SecondarySps { - secondarySPAccs = append(secondarySPAccs, types.AccAddress(sp.SpId)) + secondarySPAccs = append(secondarySPAccs, sdk.AccAddress(sp.SpId)) secondarySPSignatures = append(secondarySPSignatures, sp.Signature) } km, err := client.greenfieldClients[scope].GetKeyManager() @@ -179,7 +184,7 @@ func (client *GreenfieldChainSignClient) SealObject(ctx context.Context, scope S } resp, err := client.greenfieldClients[scope].BroadcastTx( - []types.Msg{msgSealObject}, txOpt) + []sdk.Msg{msgSealObject}, txOpt) if err != nil { log.CtxErrorw(ctx, "failed to broadcast tx", "err", err) return nil, merrors.ErrSealObjectOnChain