feat(composable): add JIT poller SDK support - #927
Conversation
📝 WalkthroughWalkthroughAdds typed Composable Cow poller schedules, a contract ABI, schedule ID derivation, calldata encoders, package exports, multi-adapter tests, and JIT poller documentation. ChangesComposable Cow JIT Poller
Estimated code review effort: 2 (Simple) | ~15 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
All contributors have signed the CLA ✍️ ✅ |
📦 GitHub Packages PublishedLast updated: Jul 28, 2026, 11:07:04 AM UTC The following packages have been published to GitHub Packages with pre-release version
InstallationThese packages require authentication to install from GitHub Packages. First, create a # Create .npmrc file in your project root
echo "@cowprotocol:registry=https://npm.pkg.github.com" > .npmrc
echo "//npm.pkg.github.com/:_authToken=YOUR_GITHUB_TOKEN" >> .npmrcTo get your GitHub token:
Then install any of the packages above, either by exact version (i.e. # Yarn
yarn add npm:@cowprotocol/cow-sdk@pr-927
# pnpm
pnpm install npm:@cowprotocol/cow-sdk@pr-927
# NPM
npm install npm:@cowprotocol/cow-sdk@pr-927Update to the latest version (only if you used the tag)Every commit will publish a new package. To upgrade to the latest version, run: # Yarn
yarn upgrade @cowprotocol/cow-sdk
# pnpm
pnpm update @cowprotocol/cow-sdk
# NPM
npm update @cowprotocol/cow-sdkView PackagesYou can view the published packages at: https://github.com/cowprotocol/cow-sdk/packages |
|
I have read the CLA Document and I hereby sign the CLA |
5d12778 to
e640f37
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/composable/tests/ComposableCowPoller.spec.ts (1)
3-10: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExercise the package entry point in this test.
These imports bypass
packages/composable/src/index.ts, so the suite can pass even if the new public barrel export is broken. Import the helpers from../srcor add a dedicated root-export assertion.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/composable/tests/ComposableCowPoller.spec.ts` around lines 3 - 10, Update the imports in ComposableCowPoller.spec.ts to consume ComposableCowPollerAbi, encodePollFunds, encodeRegister, encodeRevoke, and getScheduleId through the package entry point ../src instead of the implementation module. Keep the ComposableCowPollerSchedule type import appropriately sourced, and ensure the test exercises the public barrel exports.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/composable/tests/ComposableCowPoller.spec.ts`:
- Around line 27-52: Restore the shared global adapter after each test in the
“ComposableCowPoller - Multi-Adapter Tests” suite. Capture the current adapter
before each test and reset it in afterEach, or use an equivalent adapter-scoped
helper, while preserving the existing setGlobalAdapter calls.
---
Nitpick comments:
In `@packages/composable/tests/ComposableCowPoller.spec.ts`:
- Around line 3-10: Update the imports in ComposableCowPoller.spec.ts to consume
ComposableCowPollerAbi, encodePollFunds, encodeRegister, encodeRevoke, and
getScheduleId through the package entry point ../src instead of the
implementation module. Keep the ComposableCowPollerSchedule type import
appropriately sourced, and ensure the test exercises the public barrel exports.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 033cf80e-6b63-478c-9ce6-27ca0c99f78e
📒 Files selected for processing (6)
packages/composable/README.mdpackages/composable/src/ComposableCowPoller.tspackages/composable/src/abis/ComposableCowPollerAbi.tspackages/composable/src/index.tspackages/composable/src/types.tspackages/composable/tests/ComposableCowPoller.spec.ts
| describe('ComposableCowPoller - Multi-Adapter Tests', () => { | ||
| const adapters = createAdapters() | ||
|
|
||
| test('derives the Solidity schedule ID across adapters', () => { | ||
| for (const adapter of Object.values(adapters)) { | ||
| setGlobalAdapter(adapter) | ||
| expect(getScheduleId(SCHEDULE)).toEqual(SCHEDULE_ID) | ||
| } | ||
| }) | ||
|
|
||
| test('does not include staticInput in the schedule ID', () => { | ||
| const updatedStaticInput = { ...SCHEDULE, staticInput: '0xdeadbeef' } | ||
|
|
||
| for (const adapter of Object.values(adapters)) { | ||
| setGlobalAdapter(adapter) | ||
| expect(getScheduleId(updatedStaticInput)).toEqual(SCHEDULE_ID) | ||
| } | ||
| }) | ||
|
|
||
| test('encodes final poller calls across adapters', () => { | ||
| for (const adapter of Object.values(adapters)) { | ||
| setGlobalAdapter(adapter) | ||
| expect(encodeRegister(SCHEDULE)).toEqual(REGISTER_CALLDATA) | ||
| expect(encodePollFunds(SCHEDULE_ID)).toEqual(POLL_FUNDS_CALLDATA) | ||
| expect(encodeRevoke(SCHEDULE_ID)).toEqual(REVOKE_CALLDATA) | ||
| } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "Files:"
git ls-files | rg 'ComposableCowPoller\.spec\.ts|adapter|Adapter' || true
echo
echo "Target file excerpt:"
if [ -f packages/composable/tests/ComposableCowPoller.spec.ts ]; then
sed -n '1,140p' packages/composable/tests/ComposableCowPoller.spec.ts | cat -n
fi
echo
echo "Search setGlobalAdapter definitions/usages:"
rg -n "setGlobalAdapter|getGlobalAdapter|globalAdapter|afterEach|beforeEach|describe" packages/composable -S || trueRepository: cowprotocol/cow-sdk
Length of output: 27873
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "Adapter context implementation:"
cat -n packages/common/src/adapters/context.ts
echo
echo "Composable Cow Poller helper semantics:"
cat -n packages/composable/src/ComposableCowPoller.ts
echo
echo "Adjacent imports and setup files:"
fd -a 'setup\.(ts|js)$|index\.spec\.ts$|Utils\.spec\.ts$|ConditionalOrder\.spec\.ts$' packages/composable tests 2>/dev/null || true
sed -n '1,120p' packages/composable/tests/setup.ts 2>/dev/null || true
sed -n '1,80p' packages/composable/tests/index.spec.ts 2>/dev/null || true
sed -n '1,80p' packages/composable/tests/ConditionalOrder.spec.ts 2>/dev/null || trueRepository: cowprotocol/cow-sdk
Length of output: 9721
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "Root/package lock adapter context version references:"
for f in package.json pnpm-lock.yaml yarn.lock package-lock.json; do
[ -f "$f" ] && (echo "--- $f"; rg -n '"`@cowprotocol/sdk-common`"|`@cowprotocol/sdk-common`|AdapterContext|getGlobalAdapter|setGlobalAdapter' "$f" | head -80 || true)
done
echo
echo "Composable package test config and scripts:"
sed -n '1,220p' packages/composable/package.json 2>/dev/null || true
rg -n "setupFiles|testEnvironment|afterEach|jest|vitest|test:|jest:" package.json packages/composable/package.json -S || true
echo
echo "Jest/Vitest top-level adapter usages in composable tests:"
rg -n "use .beforeAll|beforeEach\(\(\) \=>|beforeAll\(\(\) \=>|afterEach\(\(\) \=>|setGlobalAdapter\(.*AdapterContext|const .*AdapterContext|AdapterContext" packages/composable/tests packages/composable/src -S || true
echo
echo "Static behavior probe for AdapterContext state mutation (data only):"
python3 - <<'PY'
from pathlib import Path
p = Path('packages/common/src/adapters/context.ts').read_text()
checks = {
'setGlobalAdapter_overwrites_singleton': 'this.setAdapter(adapter)' in p and '_instance' in p,
'getGlobalAdapter_returns_singleton_adapter': 'return AdapterContext.getInstance().getAdapter()' in p,
'test_has_afterEach_hook': Path('packages/composable/tests/ComposableCowPoller.spec.ts').read_text().count('afterEach(') == 0,
'poller_helpers_use_global_adapter': 'getGlobalAdapter()' in Path('packages/composable/src/ComposableCowPoller.ts').read_text(),
}
for k, v in checks.items():
print(f'{k}={v}')
PYRepository: cowprotocol/cow-sdk
Length of output: 4527
Restore the global adapter between tests.
setGlobalAdapter stores the adapter on the shared AdapterContext, so this suite leaves the last adapter installed for later tests. Capture getGlobalAdapter() before each test and restore it in afterEach, or use an adapter-scoped helper.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/composable/tests/ComposableCowPoller.spec.ts` around lines 27 - 52,
Restore the shared global adapter after each test in the “ComposableCowPoller -
Multi-Adapter Tests” suite. Capture the current adapter before each test and
reset it in afterEach, or use an equivalent adapter-scoped helper, while
preserving the existing setGlobalAdapter calls.
What and why
Add JIT Poller support to
@cowprotocol/sdk-composable: the contract ABI, schedule types, schedule ID derivation, and calldata encoders forregister,pollFunds, andrevoke.The ABI matches the CowShed-aware contract in ComposableCoW #128. Applications provide the deployed Poller address and may submit
registerandrevokedirectly or through the funder’s canonical CowShed.Related: https://linear.app/cowswap/project/twap-for-eoas-07d3dae536ea/overview
Test
pnpm --filter @cowprotocol/sdk-composable testSummary by CodeRabbit