Skip to content

Commit

Permalink
chore: fix misc lints from v0.27 branch
Browse files Browse the repository at this point in the history
  • Loading branch information
pirtleshell committed Nov 4, 2024
1 parent e951240 commit 26a2033
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
12 changes: 10 additions & 2 deletions tests/util/addresses.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import (
"github.com/ethereum/go-ethereum/common"
)

const (
MnemonicEntropyBits = 128
)

func SdkToEvmAddress(addr sdk.AccAddress) common.Address {
return common.BytesToAddress(addr.Bytes())
}
Expand All @@ -17,9 +21,13 @@ func EvmToSdkAddress(addr common.Address) sdk.AccAddress {

// RandomMnemonic generates a random BIP39 mnemonic from 128 bits of entropy
func RandomMnemonic() (string, error) {
entropy, err := bip39.NewEntropy(128)
entropy, err := bip39.NewEntropy(MnemonicEntropyBits)
if err != nil {
return "", errorsmod.Wrap(err, "failed to generate entropy for new mnemonic")
}
return bip39.NewMnemonic(entropy)
mnemonic, err := bip39.NewMnemonic(entropy)
if err != nil {
return mnemonic, errorsmod.Wrap(err, "failed to create mnemonic")
}
return mnemonic, nil
}
9 changes: 5 additions & 4 deletions tests/util/evmsigner.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/evmos/ethermint/crypto/ethsecp256k1"
etherminttypes "github.com/evmos/ethermint/types"
)

var (
Expand Down Expand Up @@ -81,19 +82,19 @@ func NewEvmSigner(
}, nil
}

func NewEvmSignerFromMnemonic(evmClient *ethclient.Client, evmChainId *big.Int, mnemonic string) (*EvmSigner, error) {
hdPath := hd.CreateHDPath(60, 0, 0)
func NewEvmSignerFromMnemonic(evmClient *ethclient.Client, evmChainID *big.Int, mnemonic string) (*EvmSigner, error) {
hdPath := hd.CreateHDPath(etherminttypes.Bip44CoinType, 0, 0)
privKeyBytes, err := hd.Secp256k1.Derive()(mnemonic, "", hdPath.String())
if err != nil {
return nil, errorsmod.Wrap(err, "failed to derive private key from mnemonic")
}
privKey := &ethsecp256k1.PrivKey{Key: privKeyBytes}
ecdsaPrivKey, err := crypto.HexToECDSA(hex.EncodeToString(privKey.Bytes()))
if err != nil {
return nil, err
return nil, errorsmod.Wrap(err, "failed to convert hex to ECDSA")
}

return NewEvmSigner(evmClient, ecdsaPrivKey, evmChainId)
return NewEvmSigner(evmClient, ecdsaPrivKey, evmChainID)
}

func (s *EvmSigner) Run(requests <-chan EvmTxRequest) <-chan EvmTxResponse {
Expand Down
4 changes: 2 additions & 2 deletions x/hard/keeper/borrow_test.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
//nolint:lll // these tests have some long lines :D
package keeper_test

import (
"time"

"github.com/kava-labs/kava/x/hard/keeper"

sdkmath "cosmossdk.io/math"
"github.com/cometbft/cometbft/crypto"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
tmtime "github.com/cometbft/cometbft/types/time"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/hard"
"github.com/kava-labs/kava/x/hard/keeper"
"github.com/kava-labs/kava/x/hard/types"
pricefeedtypes "github.com/kava-labs/kava/x/pricefeed/types"
)
Expand Down

0 comments on commit 26a2033

Please sign in to comment.