Skip to content

Conversation

@SOGeKING-NUL
Copy link

Summary

closes #106

  • Implemented PERMIT2_TRANSFER_FROM_BATCH command encoding (command id 13)
  • Added chained encoder API to batch transfer multiple tokens via Permit2
  • Updated ABI builder and command map to support a tuple[] of AllowanceTransferDetails
  • Added unit test verifying exact calldata for a two-transfer batch

Implementation Details

  • Enums: Added RouterFunction.PERMIT2_TRANSFER_FROM_BATCH = 13

  • ABI:

    • New_build_permit2_transfer_from_batch()producing a single parameter: AllowanceTransferDetails[]
    • Struct layout: (from, to, amount, token) as (address, address, uint256, address)
    • Registered in build_abi_map
  • Encoder:

    • New permit2_transfer_from_batch(transfer_details: List[Dict])
    • Validates inputs and converts dicts to ordered tuples (from, to, amount, token) before ABI encode
    • Integrates into existing chained builder flow
  • Tests:

    • Core test asserts exact calldata for two transfers (USDC + WETH)
    • Validation test kept out per request to keep tests minimal

    Screenshot

image

@SOGeKING-NUL
Copy link
Author

@Elnaril any input or improvement for this pr?

@Elnaril
Copy link
Owner

Elnaril commented Oct 18, 2025

Hi @SOGeKING-NUL
Thanks for your PR, but it needs to pass the CI checks to be considered for review.
Or do you mean you need help with that ?

@SOGeKING-NUL
Copy link
Author

would like some help with that, what changes would I need to make for the CI checks to pass? do I need to tinker with some other files for this?

@Elnaril
Copy link
Owner

Elnaril commented Oct 20, 2025

You have a mypy error in _encoder.py:
image

@SOGeKING-NUL
Copy link
Author

@Elnaril fixed the issue, please review pr now :)

Copy link
Owner

@Elnaril Elnaril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @SOGeKING-NUL , thanks for this nice PR! :) The core is spot-on and well commented. 👍

Having said that, there are some missing parts:

  • I'd like to add the decoding of an actual mainnet transaction in test_decoder.py::test_decode_transaction (let me know if you can't find one)
  • Also an integration test should be added or modified to demonstrate the implementation of this new function works as expected.

Also, please have a look to my other comments.

@Elnaril
Copy link
Owner

Elnaril commented Oct 21, 2025

And the coverage must stay at 100%
image

@SOGeKING-NUL
Copy link
Author

noted, will work on changes

@SOGeKING-NUL
Copy link
Author

@Elnaril does this solve a lot of the issues? also could you tell me more about adding the decoding of an actual mainnet transaction

Copy link
Owner

@Elnaril Elnaril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SOGeKING-NUL Yes, it solved all the code issues and the coverage. 👍


also could you tell me more about adding the decoding of an actual mainnet transaction

The idea is to find a transaction which:

  • happened on Ethereum Mainnet
  • called PERMIT2_TRANSFER_FROM_BATCH
  • ideally performing more than one transfer using this function
  • decode it in test_decoder.py::test_decode_transaction

To find such transaction, you could either use Etherscan or figure out a programmatic approach.
Does it make sense ?


Apart from that, the remaining tasks are:

  • integration test
  • squash commits (so 1 PR =1 commit before I merge it)

@Elnaril
Copy link
Owner

Elnaril commented Oct 23, 2025

@SOGeKING-NUL
It does not seem easy to find an actual transaction using this newly supported UR command ...
So probably best not to waste too much time on this part. The integration test will be enough to prove the implementation is correct.

@Elnaril
Copy link
Owner

Elnaril commented Oct 24, 2025

Finally found one ! 😅
0x2ab1c28cf84f5e4b4db07e1be2e6f45f9c07e5d3b2ad80396e51c12d8db2b180
Please add it to test_decoder.py::test_decode_transaction

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.

Add support for PERMIT2_TRANSFER_FROM_BATCH

2 participants