Repository navigation
fix(prolink): keep leading zero bytes of call data and extraData - #430
Open
erkancamli wants to merge 1 commit into
Open
erkancamli wants to merge 1 commit into
erkancamli wants to merge 1 commit into
Conversation
decodeProlink turned generic call data and SpendPermission extraData into hex with bytesToHex, which strips leading zeros because it is meant for integers. Call data that starts with a zero nibble, such as approve(address,uint256) (0x095ea7b3), came back as odd length hex, and data starting with a zero byte lost bytes (0x00000000 became 0x0). A changed extraData also changes the SpendPermission digest a wallet signs. Decode these raw bytes fields with a new rawBytesToHex helper that keeps every byte, as EIP-8050 specifies for calldata and bytes values.
Collaborator
🟡 Heimdall Review Status
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
decodeProlinkturned genericwallet_sendCallscall data and SpendPermissionextraDatainto hex withbytesToHex, the integer formatter inutils/encoding.ts, which strips leading zero digits. These fields are raw bytes (EIP-8050: calldata as-is,extraDataas"0x" + extra_data.hex()), so:approve(address,uint256)0x095ea7b3…decodes to0x95ea7b3…0x00000000decodes to0x0extraData0x0001decodes to0x1, so the EIP-712 digest a wallet signs differs from the one the app builtThe encoder is fine; only the decoder (
decodeWalletSendCallsinshortcuts/sendCalls.ts,decodeWalletSigninshortcuts/sign.ts) is affected. This adds arawBytesToHexhelper (Hex.fromBytes,0xfor empty) and uses it for those two fields. Amount fields keepbytesToHex.The salt and nonce fields have the same class of problem, but #395 already covers them, so they are left out here.
How did you test your changes?
New tests for the call data and
extraDataround trips, the helper, and an end-to-endencodeProlink→decodeProlinkcase withapprovecall data and0x00000000. On master (1c31057) they fail (5 failed, 205 passed inprolink/); with this change all 210 pass.In
packages/account-sdk:yarn vitest --runpasses (76 files, 1053 tests),yarn typecheckpasses, andbiome checkis clean on the changed files. With 2000 random call data values through encode and decode, 133 changed on master and none with this change.