Skip to content

Commit

Permalink
chore: fix misc lints from v0.27 branch (#2049)
Browse files Browse the repository at this point in the history
* chore: fix misc lints from v0.27 branch

* ci: update mergify backport rule labels
  • Loading branch information
pirtleshell authored Nov 4, 2024
1 parent e951240 commit 4af6545
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 8 deletions.
20 changes: 20 additions & 0 deletions .github/mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ pull_request_rules:
- release/v0.24.x
- release/v0.25.x
- release/v0.26.x
- release/v0.26.x-iavl-v1
- release/v0.27.x

- name: Backport patches to the release/v0.17.x branch
conditions:
Expand Down Expand Up @@ -99,3 +101,21 @@ pull_request_rules:
backport:
branches:
- release/v0.26.x

- name: Backport patches to the release/v0.26.x-iavl-v1 branch
conditions:
- base=master
- label=A:backport/v0.26.x-iavl-v1
actions:
backport:
branches:
- release/v0.26.x-iavl-v1

- name: Backport patches to the release/v0.27.x branch
conditions:
- base=master
- label=A:backport/v0.27.x
actions:
backport:
branches:
- release/v0.27.x
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 4af6545

Please sign in to comment.