Skip to content

Commit

Permalink
pull in not available function for conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
skosito committed Dec 16, 2024
1 parent 5f87c53 commit 153b32d
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions cmd/zetae2e/local/get_zetaclient_bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/spf13/cobra"
"gitlab.com/thorchain/tss/go-tss/conversion"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"

legacybech32 "github.com/cosmos/cosmos-sdk/types/bech32/legacybech32"
crypto2 "github.com/libp2p/go-libp2p/core/crypto"
"github.com/zeta-chain/node/pkg/rpc"
"github.com/zeta-chain/node/pkg/sdkconfig"
observertypes "github.com/zeta-chain/node/x/observer/types"
Expand All @@ -32,6 +34,18 @@ func NewGetZetaclientBootstrap() *cobra.Command {
return cmd
}

func bech32PubkeyToPeerID(pubKey string) (peer.ID, error) {
bech32PubKey, err := legacybech32.UnmarshalPubKey(legacybech32.AccPK, pubKey)
if err != nil {
return "", err
}
secp256k1PubKey, err := crypto2.UnmarshalSecp256k1PublicKey(bech32PubKey.Bytes())
if err != nil {
return "", err
}
return peer.IDFromPublicKey(secp256k1PubKey)
}

func getZetaclientBootstrap(cmd *cobra.Command, _ []string) error {
sdkconfig.SetDefault(true)
grpcURL, _ := cmd.Flags().GetString(grpcURLFlag)
Expand Down Expand Up @@ -72,7 +86,7 @@ func getZetaclientBootstrap(cmd *cobra.Command, _ []string) error {
// in localnet, moniker is also the hostname
moniker := validatorRes.Validator.Description.Moniker

peerID, err := conversion.Bech32PubkeyToPeerID(account.GranteePubkey.Secp256k1.String())
peerID, err := bech32PubkeyToPeerID(account.GranteePubkey.Secp256k1.String())
if err != nil {
return fmt.Errorf("converting pubkey to peerID: %w", err)
}
Expand Down

0 comments on commit 153b32d

Please sign in to comment.