Skip to content

feat(app-data): remove AppDataSdk.legacy methods - #946

Open
raq0x wants to merge 3 commits into
mainfrom
refactor/remove-app-data-legacy-api
Open

feat(app-data): remove AppDataSdk.legacy methods#946
raq0x wants to merge 3 commits into
mainfrom
refactor/remove-app-data-legacy-api

Conversation

@raq0x

@raq0x raq0x commented Jul 27, 2026

Copy link
Copy Markdown

What

Takes IPFS out of app-data. Removes the deprecated AppDataSdk.legacy surface (old sha2-256 / dag-pb CID derivation, Pinata upload) and the IPFS read path. The package now makes zero network calls: derivation, validation and schema only.

Why

sdk.legacy.appDataToCid() has thrown on every call since 5.1.0.

await new AppDataSdk().legacy.appDataToCid({ version: '0.7.0', appCode: 'x', metadata: {} })
// 💥 MetaDataError: Failed to calculate appDataHex: unexpected block API put

#869 (d6b30cf, 2026-04-28) swapped ipfs-only-hash for ipfs-unixfs-importer@16, which dropped the onlyHash option. You can see it commented out in utils/ipfs.ts. Without it the importer tries to persist blocks, calls block.put(), and the stub above it throws. That's been in every release since.

Nothing caught it because getAppDataInfo.spec.ts:36 mocked ipfsOnlyHash to return CID_LEGACY. So there's a passing happy-path test for a function that fails 100% of the time.

Only appDataToCid throws. The other legacy methods are just unused.

Reads go too. appData was originally stored on IPFS, but the backend indexes it internally now and backfilled every previously uploaded doc, so nothing is left that only exists on a gateway. The live path is stringifyDeterministic then keccak256 then orderBookApi.uploadAppData() then PUT /api/v1/app_data/{hash}, with GET /api/v1/app_data/{hash} to read back.

The read path was broken in its own right anyway: DEFAULT_IPFS_READ_URI pointed at cloudflare-ipfs.com, which no longer resolves, so fetchDocFromAppDataHex() without an explicit ipfsUri failed on DNS. fetchDocFromCid.spec.ts used fetchMock, which is why that went unnoticed too.

Changes

Removed from @cowprotocol/sdk-app-data and @cowprotocol/cow-sdk alike:

  • sdk.legacy.appDataToCid
  • sdk.legacy.appDataHexToCid
  • sdk.legacy.fetchDocFromAppDataHex
  • sdk.legacy.fetchDocFromCid
  • sdk.legacy.uploadMetadataDocToIpfs
  • sdk.fetchDocFromAppDataHex
  • the Ipfs type
  • the cross-fetch dependency

AppDataSdk keeps getAppDataSchema, generateAppDataDoc, validateAppDataDoc, getAppDataInfo, appDataHexToCid and cidToAppDataHex. Uploads go through OrderBookApi.uploadAppData, reads through GET /api/v1/app_data/{hash}.

New test: cidDerivation.integration.spec.ts

The existing specs mock the thing under test. appDataHexToCid.spec.ts:6 stubs base16.encode to return CID for any input, so expect(result).toEqual(CID) compares a constant with itself. Same pattern that hid the breakage above.

The new suite mocks nothing and asserts exact bytes across all three adapters. Flipping multicodec: 0x55 to 0x56 corrupts every CID the SDK produces, and this is the only suite that fails on it. appDataHex is the bytes32 in the on-chain order struct and the backend derives it independently, so drift here means rejected orders.

There's also a small smoke test on api/index.ts, which was at 0% coverage despite AppDataSdk being the package's only public export. It asserts the exact public method set, so the removals can't silently come back.

@raq0x
raq0x requested review from azebuado and shoom3301 July 27, 2026 10:04
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b8387c5b-0863-4ec6-88ea-6725e153c3c8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Changes

App-data API simplification

Layer / File(s) Summary
Canonical CID derivation and validation
packages/app-data/src/api/appDataHexToCid.ts, packages/app-data/src/api/getAppDataInfo.ts, packages/app-data/src/api/cidDerivation.integration.spec.ts, packages/app-data/src/api/*spec.ts
Legacy CID conversion is removed, getAppDataInfo uses canonical CIDv1 derivation, and adapter-based integration tests validate deterministic conversions and round trips.
Fetching and SDK export surface
packages/app-data/src/api/fetchDocFromAppData.ts, packages/app-data/src/api/fetchDocFromAppData.spec.ts, packages/app-data/src/api/index.ts, packages/app-data/src/api/index.spec.ts
Document fetching uses the canonical hex-to-CID path, while AppDataSdk no longer exposes legacy methods.
Legacy IPFS contracts and dependencies
packages/app-data/src/utils/ipfs.ts, packages/app-data/src/types.ts, packages/app-data/src/mocks.ts, packages/app-data/package.json, packages/app-data/setupTests.ts
Legacy IPFS hashing, public contracts, fixtures, test setup, and unused dependencies are removed.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: shoom3301, azebuado

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: removing the AppDataSdk legacy API surface.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/remove-app-data-legacy-api

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@raq0x raq0x changed the title feat(app-data)!: remove AppDataSdk.legacy methods feat(app-data): remove AppDataSdk.legacy methods Jul 27, 2026
@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedwagmi@​3.7.1801007998100
Addedturbo@​2.10.41001008597100

View full report

@github-actions

Copy link
Copy Markdown
Contributor

📦 GitHub Packages Published

Last updated: Jul 27, 2026, 03:14:06 PM UTC

The following packages have been published to GitHub Packages with pre-release version pr-946-e60561b1:

  • @cowprotocol/cow-sdk@9.2.4-pr-946-e60561b1.0
  • @cowprotocol/sdk-app-data@5.3.2-pr-946-e60561b1.0
  • @cowprotocol/sdk-bridging@4.3.1-pr-946-e60561b1.0
  • @cowprotocol/sdk-common@0.12.0-pr-946-e60561b1.0
  • @cowprotocol/sdk-composable@1.2.1-pr-946-e60561b1.0
  • @cowprotocol/sdk-config@2.3.1-pr-946-e60561b1.0
  • @cowprotocol/sdk-contracts-ts@3.3.1-pr-946-e60561b1.0
  • @cowprotocol/sdk-cow-shed@0.4.3-pr-946-e60561b1.0
  • @cowprotocol/sdk-ethers-v5-adapter@0.4.10-pr-946-e60561b1.0
  • @cowprotocol/sdk-ethers-v6-adapter@0.4.10-pr-946-e60561b1.0
  • @cowprotocol/sdk-flash-loans@3.3.1-pr-946-e60561b1.0
  • @cowprotocol/sdk-order-book@4.0.1-pr-946-e60561b1.0
  • @cowprotocol/sdk-order-signing@1.1.4-pr-946-e60561b1.0
  • @cowprotocol/sdk-subgraph@1.2.0-pr-946-e60561b1.0
  • @cowprotocol/sdk-trading@2.2.4-pr-946-e60561b1.0
  • @cowprotocol/sdk-viem-adapter@0.3.25-pr-946-e60561b1.0
  • @cowprotocol/sdk-weiroll@0.2.1-pr-946-e60561b1.0

Installation

These packages require authentication to install from GitHub Packages. First, create a .npmrc file:

# 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" >> .npmrc

To get your GitHub token:

  1. Go to https://github.com/settings/tokens
  2. Click "Generate new token (classic)"
  3. Check only the "read:packages" scope
  4. Copy the token and replace YOUR_GITHUB_TOKEN in the .npmrc file

Then install any of the packages above, either by exact version (i.e. @cowprotocol/cow-sdk@9.2.4-pr-946-e60561b1.0) or more conveniently by using the tag (@cowprotocol/cow-sdk@pr-946):

# Yarn
yarn add npm:@cowprotocol/cow-sdk@pr-946

# pnpm
pnpm install npm:@cowprotocol/cow-sdk@pr-946

# NPM
npm install npm:@cowprotocol/cow-sdk@pr-946

Update 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-sdk

View Packages

You can view the published packages at: https://github.com/cowprotocol/cow-sdk/packages

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