Skip to content
Merged
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
### BUG FIXES

- [\#748](https://github.com/cosmos/evm/pull/748) Fix DynamicFeeChecker in Cosmos ante handler to respect NoBaseFee feemarkets' parameter.
- [\#690](https://github.com/cosmos/evm/pull/690) Fix Ledger hardware wallet support for coin type 60.
- [\#766](https://github.com/cosmos/evm/pull/766) Align gas estimation logic with go-ethereum v1.16.3
- [\#769](https://github.com/cosmos/evm/pull/769) Fix erc20 ibc middleware to not to validate sender address format.
- [\#756](https://github.com/cosmos/evm/pull/756) Fix error message typo in NewMsgCancelProposal.
Expand Down
37 changes: 36 additions & 1 deletion client/keys/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"bytes"
"encoding/json"
"errors"
"flag"
"fmt"
"io"
"os"
Expand All @@ -13,7 +14,9 @@ import (
"github.com/spf13/cobra"

cryptohd "github.com/cosmos/evm/crypto/hd"
evmkeyring "github.com/cosmos/evm/crypto/keyring"
bip39 "github.com/cosmos/go-bip39"
ledger "github.com/cosmos/ledger-cosmos-go"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
Expand All @@ -22,6 +25,8 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
cosmosLedger "github.com/cosmos/cosmos-sdk/crypto/ledger"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
Expand Down Expand Up @@ -172,7 +177,37 @@ func RunAddCmd(ctx client.Context, cmd *cobra.Command, args []string, inBuf *buf
// If we're using ledger, only thing we need is the path and the bech32 prefix.
if useLedger {
bech32PrefixAccAddr := sdk.GetConfig().GetBech32AccountAddrPrefix()

needHardware := flag.Lookup("test.v") == nil && os.Getenv("GO_TEST") != "1"
if needHardware {
switch coinType {
case 60:
cosmosLedger.SetDiscoverLedger(func() (cosmosLedger.SECP256K1, error) {
return evmkeyring.LedgerDerivation()
})
cosmosLedger.SetCreatePubkey(func(key []byte) cryptotypes.PubKey {
return evmkeyring.CreatePubkey(key)
})
cosmosLedger.SetAppName(evmkeyring.AppName)
cosmosLedger.SetDERConversion(false)
case 118:
cosmosLedger.SetDiscoverLedger(func() (cosmosLedger.SECP256K1, error) {
device, err := ledger.FindLedgerCosmosUserApp()
if err != nil {
return nil, err
}
return device, nil
})
cosmosLedger.SetCreatePubkey(func(key []byte) cryptotypes.PubKey {
return &secp256k1.PubKey{Key: key}
})
cosmosLedger.SetAppName(cosmosLedger.AppName)
cosmosLedger.SetDERConversion(true)
default:
return fmt.Errorf(
"unsupported coin type %d for Ledger. Supported coin types: 60 (Ethereum app), 118 (Cosmos app)", coinType,
)
}
}
// use the provided algo to save the ledger key
k, err := kb.SaveLedgerKey(name, algo, bech32PrefixAccAddr, coinType, account, index)
if err != nil {
Expand Down
9 changes: 5 additions & 4 deletions evmd/cmd/evmd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package cmd

import (
"errors"
"github.com/cosmos/evm/utils"
"github.com/cosmos/evm/x/vm/types"
"io"
"os"

"github.com/cosmos/evm/utils"
"github.com/cosmos/evm/x/vm/types"

banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/spf13/cast"
"github.com/spf13/cobra"
Expand All @@ -18,7 +19,7 @@ import (
dbm "github.com/cosmos/cosmos-db"
cosmosevmcmd "github.com/cosmos/evm/client"
evmdebug "github.com/cosmos/evm/client/debug"
cosmosevmkeyring "github.com/cosmos/evm/crypto/keyring"
"github.com/cosmos/evm/crypto/hd"
"github.com/cosmos/evm/evmd"
"github.com/cosmos/evm/evmd/config"
cosmosevmserver "github.com/cosmos/evm/server"
Expand Down Expand Up @@ -81,7 +82,7 @@ func NewRootCmd() *cobra.Command {
WithHomeDir(config.MustGetDefaultNodeHome()).
WithViper(""). // In simapp, we don't use any prefix for env variables.
// Cosmos EVM specific setup
WithKeyringOptions(cosmosevmkeyring.Option()).
WithKeyringOptions(hd.EthSecp256k1Option()).
WithLedgerHasProtobuf(true)

rootCmd := &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ require (
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/gogoproto v1.7.0
github.com/cosmos/ibc-go/v10 v10.0.0-beta.0.0.20251027215440-22f0033d0aee
github.com/cosmos/ledger-cosmos-go v0.16.0
github.com/creachadair/tomledit v0.0.28
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
github.com/ethereum/go-ethereum v1.16.5
Expand Down Expand Up @@ -123,7 +124,6 @@ require (
github.com/cosmos/gogogateway v1.2.0 // indirect
github.com/cosmos/iavl v1.2.6 // indirect
github.com/cosmos/ics23/go v0.11.0 // indirect
github.com/cosmos/ledger-cosmos-go v0.16.0 // indirect
github.com/crate-crypto/go-eth-kzg v1.3.0 // indirect
github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a // indirect
github.com/creachadair/atomicfile v0.3.7 // indirect
Expand Down
22 changes: 9 additions & 13 deletions wallets/usbwallet/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,22 @@ type Hub struct {
func NewLedgerHub() (*Hub, error) {
return newHub(LedgerScheme, 0x2c97, []uint16{
// Device definitions taken from
// https://github.com/LedgerHQ/ledger-live/blob/38012bc8899e0f07149ea9cfe7e64b2c146bc92b/libs/ledgerjs/packages/devices/src/index.ts
// https://github.com/LedgerHQ/ledger-live/blob/595cb73b7e6622dbbcfc11867082ddc886f1bf01/libs/ledgerjs/packages/devices/src/index.ts

// Original product IDs
0x0000, /* Ledger Blue */
0x0001, /* Ledger Nano S */
0x0004, /* Ledger Nano X */
0x0005, /* Ledger Nano S Plus */
0x0006, /* Ledger Nano FTS */

0x0015, /* HID + U2F + WebUSB Ledger Blue */
0x1015, /* HID + U2F + WebUSB Ledger Nano S */
0x4015, /* HID + U2F + WebUSB Ledger Nano X */
0x5015, /* HID + U2F + WebUSB Ledger Nano S Plus */
0x6015, /* HID + U2F + WebUSB Ledger Nano FTS */

0x0011, /* HID + WebUSB Ledger Blue */
0x1011, /* HID + WebUSB Ledger Nano S */
0x4011, /* HID + WebUSB Ledger Nano X */
0x5011, /* HID + WebUSB Ledger Nano S Plus */
0x6011, /* HID + WebUSB Ledger Nano FTS */
0x0007, /* Ledger Flex */

0x0000, /* WebUSB Ledger Blue */
0x1000, /* WebUSB Ledger Nano S */
0x4000, /* WebUSB Ledger Nano X */
0x5000, /* WebUSB Ledger Nano S Plus */
0x6000, /* WebUSB Ledger Nano FTS */
0x7000, /* WebUSB Ledger Flex */
}, 0xffa0, 0, newLedgerDriver)
}

Expand Down
Loading