Skip to content

Commit

Permalink
account-pubkey: change to cosmos type
Browse files Browse the repository at this point in the history
  • Loading branch information
dungtt-astra committed Apr 24, 2023
1 parent 82828bf commit 51735e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion account/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ func (a *Account) ImportPrivateKey(privateKeyStr string) (*PrivateKeySerialized,
return NewPrivateKeySerialized("", privateKey), nil
}

return nil, nil
privateKey := hd.Secp256k1.Generate()(priv)
return NewPrivateKeySerialized("", privateKey), nil
}

func (a *Account) ImportHdPath(mnemonic, hdPath string) (*PrivateKeySerialized, error) {
Expand Down
11 changes: 7 additions & 4 deletions account/pubkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,28 @@ import (
"encoding/hex"
"strings"

"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
cryptoTypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/types"
"github.com/evmos/ethermint/crypto/ethsecp256k1"
//"github.com/evmos/ethermint/crypto/ethsecp256k1"
)

type PKAccount struct {
publicKey ethsecp256k1.PubKey
//publicKey ethsecp256k1.PubKey //evm
publicKey secp256k1.PubKey
}

func NewPKAccount(pubkey string) (*PKAccount, error) {
pubkey = strings.Split(strings.Split(pubkey, "{")[1], "}")[0]

key, err := hex.DecodeString(pubkey)
if err != nil {
return nil, err
}

return &PKAccount{
publicKey: ethsecp256k1.PubKey{
publicKey: secp256k1.PubKey{
//publicKey: ethsecp256k1.PubKey{
Key: key,
},
}, nil
Expand Down

0 comments on commit 51735e1

Please sign in to comment.