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.
Dynamic Components Resolver
Motivation
Composability on Solana is currently limited by the fact that typically crates must be available in order to interact with a program. Although Rust crates can be generated automatically if the IDL is published, this process is usually time-consuming and error-prone, as the crates could become outdated. Furthermore, the ECS pattern offers a way to structure logic in a very decoupled way, where common data structures (components) can be reused within or outside a project. This also allows anyone to write or propose logic (system) very easily. Therefore, having a simple way to use components/accounts in a new program is essential to promote composability and reuse.
Solution
Introduce a built-in mechanism in Bolt to automatically generate Rust types for the components, using the IDL published on-chain. Automatically build the types when needed in a system.
Specification
#[system_input]
, the bundle of input components.component_id
macro.Generation
bolt build
includes a pre-step that automatically parses all systems, identifies the missing types, and autogenerates the crates.bolt build
will use the default cluster (as specified in the Anchor.toml) to retrieve the components IDL, parse it and generate the rust code.bolt build --provider.cluster devnet
will use the specified cluster to retrieve the IDL.bolt build --rebuild-types
to force regeneration of the types (in case the IDL is updated on-chain).Issues
Closes #23