diff --git a/.changeset/popular-pugs-lie.md b/.changeset/popular-pugs-lie.md new file mode 100644 index 000000000000..38620a0be0a2 --- /dev/null +++ b/.changeset/popular-pugs-lie.md @@ -0,0 +1,5 @@ +--- +"@ledgerhq/hw-app-eth": minor +--- + +Force entries order in EIP-712 Structs when providing their implementation. diff --git a/libs/ledgerjs/packages/hw-app-eth/src/modules/EIP712/index.ts b/libs/ledgerjs/packages/hw-app-eth/src/modules/EIP712/index.ts index 845df49c392e..6f682e4352f8 100644 --- a/libs/ledgerjs/packages/hw-app-eth/src/modules/EIP712/index.ts +++ b/libs/ledgerjs/packages/hw-app-eth/src/modules/EIP712/index.ts @@ -120,7 +120,8 @@ const makeRecursiveFieldStructImplem = ({ await recursiveFieldStructImplem([typeDescription, restSizes], entry, entryPath); } } else if (isCustomType) { - for (const [fieldName, fieldValue] of Object.entries(data as EIP712Message["message"])) { + for (const fieldName of Object.keys(typesMap[typeDescription?.name || ""])) { + const fieldValue = data[fieldName]; const fieldType = typesMap[typeDescription?.name || ""]?.[fieldName]; if (fieldType) { diff --git a/libs/ledgerjs/packages/hw-app-eth/tests/fixtures/messages/15-permit.json b/libs/ledgerjs/packages/hw-app-eth/tests/fixtures/messages/15-permit.json index 33cee73446a7..a5e795b14ac6 100644 --- a/libs/ledgerjs/packages/hw-app-eth/tests/fixtures/messages/15-permit.json +++ b/libs/ledgerjs/packages/hw-app-eth/tests/fixtures/messages/15-permit.json @@ -8,10 +8,10 @@ "primaryType": "Permit", "message": { "deadline": 1718992051, - "nonce": 0, "spender": "0x111111125421ca6dc452d289314280a0f8842a65", - "owner": "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d", - "value": "115792089237316195423570985008687907853269984665640564039457584007913129639935" + "nonce": 0, + "value": "115792089237316195423570985008687907853269984665640564039457584007913129639935", + "owner": "0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d" }, "types": { "EIP712Domain": [ diff --git a/libs/ledgerjs/packages/hw-app-eth/tests/fixtures/messages/16-permit2.json b/libs/ledgerjs/packages/hw-app-eth/tests/fixtures/messages/16-permit2.json index 2cb95f866ae0..d63e100ec165 100644 --- a/libs/ledgerjs/packages/hw-app-eth/tests/fixtures/messages/16-permit2.json +++ b/libs/ledgerjs/packages/hw-app-eth/tests/fixtures/messages/16-permit2.json @@ -7,10 +7,10 @@ "primaryType": "PermitSingle", "message": { "details": { - "token": "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619", - "amount": "69420000000000000000", "expiration": "1718184249", - "nonce": "0" + "amount": "69420000000000000000", + "nonce": "0", + "token": "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619" }, "spender": "0xec7be89e9d109e7e3fec59c222cf297125fefda2", "sigDeadline": "1715594049" diff --git a/libs/ledgerjs/packages/hw-app-eth/tests/fixtures/messages/17-uniswapx.json b/libs/ledgerjs/packages/hw-app-eth/tests/fixtures/messages/17-uniswapx.json index 9e9c1914e126..e398f75919b7 100644 --- a/libs/ledgerjs/packages/hw-app-eth/tests/fixtures/messages/17-uniswapx.json +++ b/libs/ledgerjs/packages/hw-app-eth/tests/fixtures/messages/17-uniswapx.json @@ -15,11 +15,11 @@ "deadline": "1718467096", "witness": { "info": { - "reactor": "0x6000da47483062a0d734ba3dc7576ce6a0b645c4", - "swapper": "0x224cbc440944c72e951507e97d8bf5ffa2e3d2b9", "nonce": "1993354326232431306240697018571020274189859638820531235067341608173853199105", - "deadline": "1718467096", + "swapper": "0x224cbc440944c72e951507e97d8bf5ffa2e3d2b9", "additionalValidationContract": "0x0000000000000000000000000000000000000000", + "reactor": "0x6000da47483062a0d734ba3dc7576ce6a0b645c4", + "deadline": "1718467096", "additionalValidationData": "0x" }, "decayStartTime": "1718467024", @@ -31,15 +31,15 @@ "inputEndAmount": "100000000000000000", "outputs": [ { - "token": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "startAmount": "348572327", + "token": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "endAmount": "332452012", "recipient": "0x224cbc440944c72e951507e97d8bf5ffa2e3d2b9" }, { + "endAmount": "833213", "token": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "startAmount": "873614", - "endAmount": "833213", "recipient": "0x27213e28d7fda5c57fe9e5dd923818dbccf71c47" } ]