Skip to content

feat: migrate SVM utils from contracts repo to SDK (ACP-56)#1359

Draft
fusmanii wants to merge 13 commits intomasterfrom
faisal/acp-71-migrate-svm-utils-to-sdk-repo
Draft

feat: migrate SVM utils from contracts repo to SDK (ACP-56)#1359
fusmanii wants to merge 13 commits intomasterfrom
faisal/acp-71-migrate-svm-utils-to-sdk-repo

Conversation

@fusmanii
Copy link
Copy Markdown
Contributor

@fusmanii fusmanii commented Mar 23, 2026

Summary

Migrates production Solana/SVM TypeScript utilities from @across-protocol/contracts into the SDK, as outlined in
https://linear.app/uma/issue/ACP-56. The contracts repo should remain focused on smart contracts and test infrastructure, while production TS
utils live in the SDK.

What moved:

  • web3-v1/ — Relay hash utils, address conversion, coders, program connectors, CCTP helpers, constants
  • web3-v2/ — Solana Kit event reading, transaction utils
  • assets/ and clients/ — Auto-generated IDL definitions and Codama program clients (gitignored, generated at build time)
  • types.svm.ts — SVM type definitions

New subpath export: @across-protocol/sdk/svm

Key changes:

  • Add src/svm/ with hand-written web3-v1, web3-v2, and type files
  • Add ./svm subpath export in package.json
  • Add Codama generation pipeline (scripts/svm/) that reads IDLs from the installed @across-protocol/contracts package and generates
    clients/assets locally — no file copying between repos
  • Gitignore auto-generated assets/ and clients/ (matching contracts repo pattern), only clients/index.ts barrel is tracked
  • Update internal src/arch/svm/ imports to use local src/svm/ instead of @across-protocol/contracts
  • Add IDL JSON copy step to CJS/ESM builds
  • Add Solana dependencies: @solana/web3.js, @solana/spl-token, @coral-xyz/borsh, borsh, buffer-layout
  • Add Codama devDeps: codama, @codama/nodes-from-anchor, @codama/renderers-js
  • Fix ES5 target compatibility (BigInt literals, iterator spread, borsh schema types, @solana/web3.js version mismatches)
  • Fix all ESLint errors in migrated files

Downstream PRs:

Test plan

  • yarn build passes (CJS, ESM, types)
  • yarn test passes (253 tests)
  • yarn lint-check passes
  • Relayer builds and resolves all SVM imports from @across-protocol/sdk/svm
  • Frontend builds, all 59 unit tests pass
  • Auto-generated assets/clients are gitignored and regenerated via yarn generate-svm-artifacts

Move production Solana/SVM TypeScript utilities from @across-protocol/contracts
into the SDK under src/svm/. This includes web3-v1 utils, web3-v2 utils,
auto-generated Codama clients, and IDL assets.

- Add src/svm/ with web3-v1, web3-v2, assets, clients copied from contracts
- Add ./svm subpath export in package.json for `@across-protocol/sdk/svm`
- Update internal arch/svm imports to use local src/svm instead of contracts
- Add IDL JSON copy to CJS/ESM build steps
- Add sync-svm-clients.sh script for syncing generated clients from contracts
- Add @solana/web3.js, borsh, buffer-layout and other Solana deps
- Fix ES5 target compatibility (BigInt literals, iterator spread, borsh types)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@linear
Copy link
Copy Markdown

linear bot commented Mar 23, 2026

@pxrl
Copy link
Copy Markdown
Collaborator

pxrl commented Mar 23, 2026

@fusmanii I see this is still draft so it's not really intended for comments yet, but the +94k lines is catching my eye. Is there a way we can break this up into smaller chunks?

@fusmanii
Copy link
Copy Markdown
Contributor Author

fusmanii commented Apr 1, 2026

@pxrl yes for sure, I just had claude do a first pass but def need to split this up

@fusmanii
Copy link
Copy Markdown
Contributor Author

fusmanii commented Apr 1, 2026

@pxrl I see, looks like claude added auto-generated files (like IDL & codama files), will remove them

fusmanii and others added 12 commits April 1, 2026 11:29
These files are synced from the contracts repo via `yarn sync-svm-clients`
and should not be committed, matching the contracts repo's approach.
Only clients/index.ts (the hand-written barrel) is tracked.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace the sync-from-contracts approach with self-contained generation:
- Add generateSvmAssets.sh: copies IDL JSONs and generates type re-exports
  from the installed @across-protocol/contracts package
- Add generateSvmClients.ts: runs Codama to produce TypeScript clients
- Add renameClientsImports.ts: post-processes @solana/web3.js -> @solana/kit
- Add codama, @codama/nodes-from-anchor, @codama/renderers-js as devDeps
- Wire into build: yarn generate-svm-artifacts runs before TypeScript compile
- Remove sync-svm-clients.sh (no longer needed)
- Bump @across-protocol/contracts to 5.0.4
- Export all web3-v1 utils at top level of svm barrel (needed by consumers)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix no-explicit-any with eslint-disable-next-line comments
- Merge duplicate superstruct imports in cctpV2Helpers
- Replace restricted @ethersproject/bignumber import with ethers
- Change while(true) to for(;;) for no-constant-condition
- Remove async from subscribeToCpiEventsForProgram (no await)
- Add eslint-disable for require-await on encode() (base class requires async)
- Exclude auto-generated src/svm/assets and src/svm/clients from eslint

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The selective exports (only 5 functions) caused downstream consumers to
get "not a function" errors for utils like encodeMessageHeader, intToU8Array32,
getSpokePoolProgram, etc. Export everything from web3-v1 at the top level,
with web3-v2 conflicting names aliased with V2 suffix.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Pin borsh to 0.7.0 (was ^2.0.0 which resolves to 2.x in CI, breaking
  the old-style Map schema API used by relayHashUtils and helpers)
- Bump TypeScript target from ES5 to ES2020 to fix "Class constructor
  BorshAccountsCoder cannot be invoked without 'new'" — ES5 __extends
  can't extend native ES6 classes from @coral-xyz/anchor

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The SDK had @coral-xyz/anchor ^0.30.1 while contracts uses ^0.31.1.
When ts-mocha loads SDK source files, the BorshAccountsCoder from 0.30
receives an IDL formatted for 0.31, causing accountLayouts to be
empty/undefined. Bumping to ^0.31.1 aligns the versions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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