Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions ethereum/eip712/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package eip712
import (
"errors"
"fmt"
"strconv"

apitypes "github.com/ethereum/go-ethereum/signer/core/apitypes"

Expand Down Expand Up @@ -101,8 +102,17 @@ func decodeAminoSignDoc(signDocBytes []byte) (apitypes.TypedData, error) {
return apitypes.TypedData{}, err
}

// Extract the chain ID from the sign doc itself for EIP-712 domain
// This ensures we use the same chain ID that was used during signing
chainID := eip155ChainID
if aminoDoc.ChainID != "" {
if parsedChainID, err := parseChainID(aminoDoc.ChainID); err == nil {
chainID = parsedChainID
}
}

typedData, err := WrapTxToTypedData(
eip155ChainID,
chainID,
signDocBytes,
)
if err != nil {
Expand Down Expand Up @@ -176,8 +186,17 @@ func decodeProtobufSignDoc(signDocBytes []byte) (apitypes.TypedData, error) {
body.Memo,
)

// Extract the chain ID from the sign doc itself for EIP-712 domain
// This ensures we use the same chain ID that was used during signing
chainID := eip155ChainID
if signDoc.ChainId != "" {
if parsedChainID, err := parseChainID(signDoc.ChainId); err == nil {
chainID = parsedChainID
}
}

typedData, err := WrapTxToTypedData(
eip155ChainID,
chainID,
signBytes,
)
if err != nil {
Expand Down Expand Up @@ -227,3 +246,9 @@ func validatePayloadMessages(msgs []sdk.Msg) error {

return nil
}

// parseChainID attempts to parse the chain ID string as a uint64.
// The chain ID in the sign doc should be the EIP-155 chain ID.
func parseChainID(chainIDStr string) (uint64, error) {
return strconv.ParseUint(chainIDStr, 10, 64)
}
6 changes: 5 additions & 1 deletion wallets/usbwallet/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,11 @@ func (hub *Hub) refreshWallets() {
for _, info := range infos {
for _, id := range hub.productIDs {
// Windows and macOS use UsageID matching, Linux uses Interface matching
if info.ProductID == id && (info.UsagePage == hub.usageID || info.Interface == hub.endpointID) {
// Ledger product IDs use MMII format where MM is device model and II is interface flags.
// Match either exact legacy IDs (0x0001, 0x0004, etc.) or device model prefix for
// WebUSB/app-specific IDs (e.g., 0x4011 matches 0x4000 prefix for Nano X with Ethereum app).
modelMatch := id >= 0x1000 && (info.ProductID>>8 == id>>8)
if (info.ProductID == id || modelMatch) && (info.UsagePage == hub.usageID || info.Interface == hub.endpointID) {
devices = append(devices, info)
break
}
Expand Down
Loading