feat: migrate SVM utils from contracts repo to SDK (ACP-56)#1359
Draft
feat: migrate SVM utils from contracts repo to SDK (ACP-56)#1359
Conversation
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>
Collaborator
|
@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? |
Contributor
Author
|
@pxrl yes for sure, I just had claude do a first pass but def need to split this up |
Contributor
Author
|
@pxrl I see, looks like claude added auto-generated files (like IDL & codama files), will remove them |
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>
…cp-71-migrate-svm-utils-to-sdk-repo
- 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>
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.
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:
New subpath export: @across-protocol/sdk/svm
Key changes:
clients/assets locally — no file copying between repos
Downstream PRs:
Test plan