Skip to content

feat: add preInteraction support#169

Open
edvardg wants to merge 2 commits intomainfrom
fix/preinteraction-v2.4.6
Open

feat: add preInteraction support#169
edvardg wants to merge 2 commits intomainfrom
fix/preinteraction-v2.4.6

Conversation

@edvardg
Copy link
Copy Markdown
Contributor

@edvardg edvardg commented Apr 2, 2026

Change Summary

What does this PR change?

Fix: preserve preInteraction in extension round-trip

Problem

Orders containing a preInteraction field (e.g., Permit2 approve-then-swap flows used by OKX) were rejected with "invalid salt for passed extension".

When FusionOrder.fromDataAndExtension() validates an incoming order, it decodes the extension, rebuilds it from parsed fields, and compares the hash against the salt. The preInteraction field was silently dropped during rebuild, producing a shorter extension with a different hash — causing the salt mismatch.

Changes

  • types.ts — Add optional preInteraction?: string to Extra with JSDoc documenting the 0x{target}{calldata} format
  • fusion-order.ts
    • Constructor: decode extra.preInteraction and pass to FusionExtension
    • Constructor: set PRE_INTERACTION_CALL_FLAG (bit 252) in makerTraits when present
    • fromDataAndExtension(): preserve extension.preInteraction through to the constructor
  • fusion-extension.ts
    • Add preInteraction?: Interaction to constructor's extra type
    • fromExtension(): parse preInteraction from Extension bytes
    • build(): emit preInteraction via ExtensionBuilder.withPreInteraction()
    • Pass through both return paths (with-fees and no-fees)
  • fusion-order.spec.ts — 4 new tests:
    • preInteraction sets PRE_INTERACTION_CALL_FLAG in makerTraits
    • Flag not set when preInteraction is absent
    • Full round-trip: new()build()fromDataAndExtension() preserves salt and extension
    • Real OKX customer data that was failing in production

Notes

  • Fully backward compatible — preInteraction is optional, existing orders without it are unaffected

Related Issue/Ticket:
https://1inch.atlassian.net/browse/PT9-335

Testing & Verification

How was this tested?

  • Unit tests
  • Integration tests
  • Manual testing (describe steps)
  • Verified on staging

Risk Assessment

Risk Level:

  • Low - Minor changes, no operational impact
  • Medium - Moderate changes, limited impact, standard rollback available
  • High - Significant changes, potential operational impact, complex rollback

Risks & Impact

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.

2 participants