Skip to content

fix: send native ETH to recipient in prepareSpendCallData - #433

Open
rms-devv wants to merge 1 commit into
base:masterfrom
rms-devv:fix/native-token-spend-recipient
Open

rms-devv wants to merge 1 commit into
base:masterfrom
rms-devv:fix/native-token-spend-recipient

Conversation

@rms-devv

Copy link
Copy Markdown

Summary

Fixes #424.

For a native token spend permission (token = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE), prepareSpendCallData(permission, amount, recipient) appended an ERC20 transfer(recipient, amount) call to the ERC-7528 placeholder address. That address has no code, so the call succeeds without doing anything: the recipient receives nothing and the spent ETH stays with the spender.

SpendPermissionManager.spend sends native tokens to the spender (_transferFrom → SafeTransferLib.safeTransferETH(spender, value)), so the spender can forward them with a plain value transfer. For native token permissions, the recipient call is now:

{ to: recipient, data: '0x', value: spendAmount }

The token address is compared case-insensitively. The ERC20 path is unchanged. The JSDoc for recipient now describes both cases.

How did you test your changes?

New unit tests in prepareSpendCallData.test.ts (native token permission block):

  • native token + recipient → spend call, then a value transfer to the recipient, with no ERC20 transfer encoded
  • lowercase native token address + recipient → same value transfer
  • native token + max-remaining-allowance + recipient, not yet approved → approve, spend, then a value transfer of the remaining spend
  • native token without recipient → only the spend call

The existing ERC20 recipient tests pass unchanged. The three recipient tests fail on master and pass with this change.

yarn lint, yarn format:check and yarn typecheck pass. In packages/account-sdk, yarn test --run passes, except for 6 tests in createSmartAccount.test.ts. Those time out locally because they call a live RPC through http(), and this change does not touch them.

For native token spend permissions, the recipient call was an ERC20 transfer to the ERC-7528 placeholder address, which has no code, so the recipient never received the spent ETH. Append a plain value transfer to the recipient instead. The ERC20 path is unchanged.

Fixes base#424
@cb-heimdall

Copy link
Copy Markdown
Collaborator

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
1 if authored by an app that is not allowlisted and lacks verified human attribution 0
Sum 1

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: prepareSpendCallData with a recipient sends nothing to the recipient for a native token (ETH) spend permission

2 participants