Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ Because everything is designed as a `Node`, we can transform the IDL, aggregate

There are various ways to extract information from your Solana programs in order to obtain a Codama IDL.

- **Using Codama macros**. This is not yet available but you will soon have access to a set of Rust macros that help attach IDL information directly within your Rust code. These macros enable Codama IDLs to be generated whenever you build your programs.
- **From Anchor IDLs**. If you are using [Anchor programs](https://github.com/coral-xyz/anchor) or [Shank macros](https://github.com/metaplex-foundation/shank), then you can get an Anchor IDL from them. You can then use the `@codama/nodes-from-anchor` package to convert that IDL into a Codama IDL as shown in the code snippet below. Note that the Anchor IDL might not offer all the information that Codama can hold and therefore, you may want to transform your Codama IDL to provide additional information. You can learn more about this in the next section.
- **Using Codama macros**. This is not yet available but you will soon have access to a set of Rust macros that help attach IDL information directly within your Rust code. These macros enable Codama IDLs to be generated whenever you build your programs.
- **From Anchor IDLs**. If you are using [Anchor programs](https://github.com/coral-xyz/anchor) or [Shank macros](https://github.com/metaplex-foundation/shank), then you can get an Anchor IDL from them. You can then use the `@codama/nodes-from-anchor` package to convert that IDL into a Codama IDL as shown in the code snippet below. Note that the Anchor IDL might not offer all the information that Codama can hold and therefore, you may want to transform your Codama IDL to provide additional information. You can learn more about this in the next section.

```ts
import { createFromRoot } from 'codama';
Expand All @@ -42,7 +42,7 @@ There are various ways to extract information from your Solana programs in order
const codama = createFromRoot(rootNodeFromAnchor(anchorIdl));
```

- **By hand**. If your Solana program cannot be updated to use Codama macros and you don’t have an Anchor IDL, you may design your Codama IDL by hand. We may provide tools such as a Codama Playground to help with that in the future.
- **By hand**. If your Solana program cannot be updated to use Codama macros and you don’t have an Anchor IDL, you may design your Codama IDL by hand. We may provide tools such as a Codama Playground to help with that in the future.

## Transforming Codama

Expand All @@ -61,12 +61,12 @@ Now that you have the perfect Codama IDL for your Solana program, you can benefi

_Note that some features such as rendering CLIs are not yet available. However, because the Codama IDL is designed as a tree of nodes, these features are only a visitor away from being ready. Feel free to reach out if you’d like to contribute to this Codama ecosystem._

- **Rendering client code**. Want people to start interacting with your Solana program? You can use special visitors that go through your Codama IDL and generate client code that you can then publish for your end-users. Currently, we have the following renderers available:
- **Rendering client code**. Want people to start interacting with your Solana program? You can use special visitors that go through your Codama IDL and generate client code that you can then publish for your end-users. Currently, we have the following renderers available:

- `@codama/renderers-js`: Renders a JavaScript client compatible with the soon-to-be-released 2.0 line of [`@solana/web3.js`](https://github.com/solana-labs/solana-web3.js).
- `@codama/renderers-js-umi`: Renders a JavaScript client compatible with Metaplex’s [Umi](https://github.com/metaplex-foundation/umi) framework.
- `@codama/renderers-rust`: Renders a Rust client that removes the need for publishing the program crate and offers a better developer experience.
- _And more to come._
- `@codama/renderers-js`: Renders a JavaScript client compatible with the soon-to-be-released 2.0 line of [`@solana/web3.js`](https://github.com/solana-labs/solana-web3.js).
- `@codama/renderers-js-umi`: Renders a JavaScript client compatible with Metaplex’s [Umi](https://github.com/metaplex-foundation/umi) framework.
- `@codama/renderers-rust`: Renders a Rust client that removes the need for publishing the program crate and offers a better developer experience.
- _And more to come._

Here’s an example of how to generate JavaScript and Rust client code for your program.

Expand All @@ -77,6 +77,6 @@ _Note that some features such as rendering CLIs are not yet available. However,
codama.accept(renderRustVisitor('clients/rust/src/generated', { ... }));
```

- **Registering your Codama IDL on-chain** (_Coming soon_). Perhaps the biggest benefit of having a Codama IDL from your program is that you can share it on-chain with the rest of the ecosystem. This means explorers may now use this information to provide a better experience for users of your programs. Additionally, anyone can now grab your Codama IDL, select the portion they are interested in and benefit from the same ecosystem of Codama visitors to iterate over it. For instance, an app could decide to grab the IDLs of all programs they depend on, filter out the accounts and instructions they don’t need and generate a bespoke client for their app that only contains the functions the app needs.
- **Rendering CLIs** (_Not yet available_). Whilst not available yet, we can imagine a set of CLI commands that can be generated from our Codama IDL (much like our clients) so that end-users can fetch decoded accounts and send instructions directly from their terminal.
- **Rendering documentation** (_Not yet available_). Similarly to CLIs, we may easily generate documentation in various formats from the information held by our Codama IDL.
- **Registering your Codama IDL on-chain** (_Coming soon_). Perhaps the biggest benefit of having a Codama IDL from your program is that you can share it on-chain with the rest of the ecosystem. This means explorers may now use this information to provide a better experience for users of your programs. Additionally, anyone can now grab your Codama IDL, select the portion they are interested in and benefit from the same ecosystem of Codama visitors to iterate over it. For instance, an app could decide to grab the IDLs of all programs they depend on, filter out the accounts and instructions they don’t need and generate a bespoke client for their app that only contains the functions the app needs.
- **Rendering CLIs** (_Not yet available_). Whilst not available yet, we can imagine a set of CLI commands that can be generated from our Codama IDL (much like our clients) so that end-users can fetch decoded accounts and send instructions directly from their terminal.
- **Rendering documentation** (_Not yet available_). Similarly to CLIs, we may easily generate documentation in various formats from the information held by our Codama IDL.
8 changes: 4 additions & 4 deletions packages/errors/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ To add a new error in Codama, follow these steps:

### Removing an error message

- Don't remove errors.
- Don't change the meaning of an error message.
- Don't change or reorder error codes.
- Don't change or remove members of an error's context.
- Don't remove errors.
- Don't change the meaning of an error message.
- Don't change or reorder error codes.
- Don't change or remove members of an error's context.

When an older client throws an error, we want to make sure that they can always decode the error. If you make any of the changes above, old clients will, by definition, not have received your changes. This could make the errors that they throw impossible to decode going forward.
18 changes: 9 additions & 9 deletions packages/library/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ pnpm install codama

This package includes the following packages. Note that some of them also re-export other packages.

- [`@codama/errors`](../errors)
- [`@codama/nodes`](../nodes)
- [`@codama/node-types`](../node-types)
- [`@codama/validators`](../validators)
- [`@codama/visitors`](../visitors)
- [`@codama/visitor-core`](../visitor-core)
- [`@codama/errors`](../errors)
- [`@codama/nodes`](../nodes)
- [`@codama/node-types`](../node-types)
- [`@codama/validators`](../validators)
- [`@codama/visitors`](../visitors)
- [`@codama/visitor-core`](../visitor-core)

## The Codama helper

Expand Down Expand Up @@ -70,9 +70,9 @@ codama.update(

Other helper functions include:

- `clone()`: Creates a new instance of the `Codama` interface with a deep copy of the wrapped `RootNode`.
- `getJson()`: Returns the JSON representation of the Codama IDL.
- `getRoot()`: Returns the wrapped `RootNode`.
- `clone()`: Creates a new instance of the `Codama` interface with a deep copy of the wrapped `RootNode`.
- `getJson()`: Returns the JSON representation of the Codama IDL.
- `getRoot()`: Returns the wrapped `RootNode`.

```ts
const clonedCodama = codama.clone();
Expand Down
Loading