feat(PT9-502): add chained postInteraction (tail) encode/decode - #178
Open
rharutyunyan wants to merge 8 commits into
Open
feat(PT9-502): add chained postInteraction (tail) encode/decode#178rharutyunyan wants to merge 8 commits into
rharutyunyan wants to merge 8 commits into
Conversation
Let Fusion orders carry an extra postInteraction appended after the settlement's own FeeTaker-style data. Matches FeeTaker.sol semantics: after flags, fee recipients, optional custom receiver, fee/whitelist data and surplus params are consumed, a remaining tail of >= 20 bytes is called as IPostInteraction(address(bytes20(tail))) with tail[20:]. Based on the reference implementation by Caleb Rippey (1inch Support): belactriple9/fusion-sdk 0f925cd "Add chained post-interaction encoding". Adaptations to the reference diff: - (a) Narrowed the lenient target-only decode to the chained tail only. makerPermit/preInteraction keep strict Interaction.decode: a target-only permit is invalid on-chain and upstream never accepted a 20-byte preInteraction, so narrowing keeps the upstream change minimal; all inherited specs still pass. - (d) decodeInteraction rejects non-hex or <20-byte payloads with a clear assert. This validates raw chainedPostInteraction input at build time and makes a <20-byte decode leftover throw instead of silently producing a broken round-trip; an empty chunk concatenation ([]) is treated as no tail. - Chunked string[] input is validated per chunk (each must be valid even-length hex bytes) so odd-length chunks cannot silently merge into corrupted tail data.
Advisories published after the last green CI run (Jul 7) fail the pr-check Security step (pnpm audit --audit-level high) for any PR against main, independent of this branch's changes. Remediate the 11 high findings via the existing pnpm.overrides convention: - axios >=1.18.0 (proxy-after-interception advisory; extends the existing >=1.15.0 override) - brace-expansion: per-major patched releases (1.1.16 / 2.1.2 / 5.0.8) for the exponential-time DoS advisories - js-yaml 3.15.0 / 4.3.0 (merge-key quadratic CPU) - fast-uri >=3.1.4 (host confusion) GHSA-mh99-v99m-4gvg (brace-expansion OOM) is ignored via pnpm.auditConfig.ignoreGhsas: it marks every release below 5.0.8 vulnerable, but 5.x exports break the CJS consumers pinned to minimatch 3.x/9.x (eslint fails with 'expand is not a function' when forced to 5.0.8). Dev-tooling-only exposure: glob expansion of repo-controlled patterns in eslint/@swc/cli. Remaining low/moderate advisories (testcontainers tree) do not gate --audit-level high and are left untouched. Co-authored-by: Radik Harutyunyan <rharutyunyan@users.noreply.github.com>
Co-authored-by: Radik Harutyunyan <rharutyunyan@users.noreply.github.com>
rharutyunyan
marked this pull request as ready for review
July 27, 2026 12:50
publish.yml pinned 'version: 10' on pnpm/action-setup@v4 while package.json declares packageManager pnpm@10.26.2 (added on main in 1591f35, after the last 2.4.x publish). The action refuses the conflicting specs, so both publish jobs fail at the Install pnpm step ('Multiple versions of pnpm specified', run 30270683953 for v2.4.11-rc.0). Drop the input so the packageManager field is the single source of truth, matching pr-check.yml. Co-authored-by: Radik Harutyunyan <rharutyunyan@users.noreply.github.com>
Co-authored-by: Radik Harutyunyan <rharutyunyan@users.noreply.github.com>
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.
What
Adds
Extra.chainedPostInteraction(string | string[]) to Fusion orders: the raw bytes are encoded afterSurplusParamsin the FeeTaker-style settlementpostInteractionpayload and decoded back on the way in.This matches
FeeTaker.sol's on-chain semantics: after flags, fee recipients, optional custom receiver, fee/whitelist data and surplus params are consumed, a remaining tail of >= 20 bytes is called asIPostInteraction(address(bytes20(tail)))withtail[20:]as extraData. Needed for Ether.fi postInteraction chaining in Fusion swaps (same pattern as the earlier OKX integration).Details
string[]chunks are concatenated in order into a single tail; every chunk is validated as 0x-prefixed even-length hex before joining (odd-length chunks throw instead of silently merging into corrupted tail data). An empty concatenation ([]) means no tail.FeeTakercalls the target for any tail of at least 20 bytes); non-hex or <20-byte decode leftovers throwinvalid interactioninstead of silently producing a broken round-trip. The target-only stand-in lives insrc/fusion-order/target-only-interaction.ts(theInteractionconstructor rejects empty data, so a dedicated class is needed).makerPermit/preInteractiondecoding keeps strictInteraction.decode— the lenient target-only path applies only to the chained tail (a target-only permit is invalid on-chain and upstream never accepted a 20-byte preInteraction).CI fixes (separate commits)
pnpm audit --audit-level high) fails on main's unchanged lockfile with 11 high advisories published after the last green run (Jul 7) — any PR against main hits this today. Remediated via the existingpnpm.overridesconvention (axios >=1.18.0, brace-expansion per-major patched releases, js-yaml 3.15.0/4.3.0, fast-uri >=3.1.4). GHSA-mh99-v99m-4gvg (brace-expansion OOM, "patched" only in 5.0.8) is ignored viapnpm.auditConfig.ignoreGhsasbecause forcing 5.x onto the minimatch 3.x/9.x CJS consumers breaks eslint (expand is not a function); exposure is dev-tooling-only glob expansion of repo-controlled patterns. Remaining low/moderate advisories don't gate--audit-level highand are left untouched.publish.ymlpinnedversion: 10onpnpm/action-setup@v4, which conflicts with thepackageManager: pnpm@10.26.2field added topackage.jsonon main in 1591f35 (after the last 2.4.x publish) — the action hard-errors with "Multiple versions of pnpm specified", so both publish jobs failed at the Install pnpm step forv2.4.11-rc.0(run 30270683953). Dropped the input sopackageManageris the single source of truth, matching pr-check.yml. Note: tags cut before this fix (e.g. the existingv2.4.11-rc.0) still carry the broken workflow and must be re-cut from a head that includes it.Verification
pnpm lint:ci— 0 errors (19 pre-existing warnings in ws-api/connector)pnpm lint:types— cleanpnpm test— 17 suites / 104 tests passedpnpm build— esm + cjs + types cleanpnpm audit --audit-level high— exit 0Downstream
1inch/gasless-swap.1inch.io#1684 activates its chained-postInteraction target allowlist once the
@1inch/fusion-sdk-v2.2-surplusalias in gasless is bumped to a release that includes this change (until then, tailed orders are safely rejected at parse).Reference
Jira: PT9-502