Sync Cargo.toml dependencies when generating code#70
Merged
lorisleiva merged 1 commit intomainfrom Feb 17, 2026
Merged
Conversation
🦋 Changeset detectedLatest commit: e86900a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Member
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
8e32350 to
15517a1
Compare
lorisleiva
commented
Dec 1, 2025
Comment on lines
41
to
60
| export const DEFAULT_DEPENDENCY_VERSIONS: CargoDependencies = { | ||
| 'anchor-lang': '~0.31', | ||
| borsh: '^0.10', | ||
| kaigan: '0.2.6', | ||
| 'num-derive': '^0.4', | ||
| 'num-traits': '^0.2', | ||
| serde: '^1.0', | ||
| 'serde-big-array': '^0.5', | ||
| serde_with: '^3.0', | ||
| 'solana-account': '~2.2', | ||
| 'solana-account-info': '~2.3', | ||
| 'solana-client': '~2.2', | ||
| 'solana-cpi': '~2.2', | ||
| 'solana-decode-error': '~2.3', | ||
| 'solana-instruction': '~2.3', | ||
| 'solana-program-error': '~2.2', | ||
| 'solana-pubkey': '~2.3', | ||
| 'solana-sdk': '~2.3', | ||
| thiserror: '^1.0', | ||
| }; |
Member
Author
There was a problem hiding this comment.
This section requires extra attention when reviewing. It defines the default version requirements for the generated code. Note that if the user uses stricter or newer versions for some of these, they will not be updated.
Cargo.toml when generating code
Cargo.toml when generating codeCargo.toml dependencies when generating code
52967b6 to
45f11ba
Compare
cfc7371 to
5fdbdfd
Compare
5fdbdfd to
def218c
Compare
def218c to
e86900a
Compare
Merged
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.

This PR adds 2 new options to the renderer which enable the
Cargo.tomlof the generated client to be created and/or updated such that its dependencies match what the generated code expect.These options are:
syncCargoToml: Whether or not we should update the existingCargo.tomlif some of its dependencies are falling behind or create a newCargo.tomlif missing (default:false). Note that this requires the existingcrateFolderoption to be provided for this to work as, otherwise, we won't know where to look for theCargo.toml. A warning message is logged if this is not the case.dependencyVersions: ARecord<string, CargoDependency>such that keys are the name of external dependencies — e.g.solana-pubkey— and the values are the version ranges we want to support — e.g.^3.0— or the equivalent dependency object — e.g.{ version: "^3.0" }. The renderer offer default values for all external dependencies it relies on but this option may be used to override some of these values or add new ones.Additionally, even when the
syncCargoTomloption isfalse, if thecrateFolderis provided and there is an existingCargo.toml, the renderer will go through its dependencies and check if any are missing or out of date for the generated code. A warning message will be logged if that's the case.Note, when bumping the Rust renderer to the next major version (v2), we can make sure the required path is not the path to the generated folder but the crate folder instead. That way, we can make the
syncCargoTomloption default totrue. This would meancrateFolderwould be replaced bygeneratedFolderand would default tosrc/generated.