Skip to content

Commit

Permalink
fix: replace greenfield-go-sdk by greenfield/sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
j75689 committed Feb 17, 2023
1 parent a580aa4 commit 9fb6c43
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
39 changes: 22 additions & 17 deletions service/client/gnfd_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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{
Expand Down Expand Up @@ -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()
Expand All @@ -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
Expand Down

0 comments on commit 9fb6c43

Please sign in to comment.