Skip to content

Commit 7e275ab

Browse files
authored
Update Codama to use @solana/kit@^2.1.0 instead of @solana/web3.js (#485)
1 parent 04a34b7 commit 7e275ab

File tree

132 files changed

+474
-467
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+474
-467
lines changed

.changeset/soft-trainers-vanish.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@codama/errors": patch
3+
"@codama/renderers-js": patch
4+
---
5+
6+
The JS renderer depends on `@solana/web3.js` at version 2. That library has been renamed to `@solana/kit` starting from version 2.1. Codama has been updated to use `@solana/kit@^2.1.0` instead of `@solana/web3.js`

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ _Note that some features such as rendering CLIs are not yet available. However,
6363

6464
- **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:
6565

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

packages/errors/src/cli/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Heavily inspired by @solana/errors.
3-
* @see https://github.com/anza-xyz/solana-web3.js/blob/main/packages/errors
3+
* @see https://github.com/anza-xyz/kit/blob/main/packages/errors
44
*/
55

66
import chalk from 'chalk';

packages/errors/src/codes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Heavily inspired by @solana/errors.
3-
* @see https://github.com/anza-xyz/solana-web3.js/blob/main/packages/errors
3+
* @see https://github.com/anza-xyz/kit/blob/main/packages/errors
44
*
55
* ---
66
*

packages/errors/src/context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Heavily inspired by @solana/errors.
3-
* @see https://github.com/anza-xyz/solana-web3.js/blob/main/packages/errors
3+
* @see https://github.com/anza-xyz/kit/blob/main/packages/errors
44
*/
55

66
import {

packages/errors/src/error.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Heavily inspired by @solana/errors.
3-
* @see https://github.com/anza-xyz/solana-web3.js/blob/main/packages/errors
3+
* @see https://github.com/anza-xyz/kit/blob/main/packages/errors
44
*/
55

66
import { CodamaErrorCode } from './codes';

packages/errors/src/message-formatter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Heavily inspired by @solana/errors.
3-
* @see https://github.com/anza-xyz/solana-web3.js/blob/main/packages/errors
3+
* @see https://github.com/anza-xyz/kit/blob/main/packages/errors
44
*/
55

66
import { CodamaErrorCode } from './codes';

packages/errors/src/messages.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Heavily inspired by @solana/errors.
3-
* @see https://github.com/anza-xyz/solana-web3.js/blob/main/packages/errors
3+
* @see https://github.com/anza-xyz/kit/blob/main/packages/errors
44
*/
55

66
import {

packages/errors/src/stack-trace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Heavily inspired by @solana/errors.
3-
* @see https://github.com/anza-xyz/solana-web3.js/blob/main/packages/errors
3+
* @see https://github.com/anza-xyz/kit/blob/main/packages/errors
44
*/
55

66
export function safeCaptureStackTrace(...args: Parameters<typeof Error.captureStackTrace>): void {

packages/renderers-js/README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
[npm-image]: https://img.shields.io/npm/v/@codama/renderers-js.svg?style=flat&label=%40codama%2Frenderers-js
88
[npm-url]: https://www.npmjs.com/package/@codama/renderers-js
99

10-
This package generates JavaScript clients from your Codama IDLs. The generated clients are compatible with the soon-to-be-released 2.0 line of [`@solana/web3.js`](https://github.com/anza-xyz/solana-web3.js).
10+
This package generates JavaScript clients from your Codama IDLs. The generated clients are compatible with [`@solana/kit`](https://github.com/anza-xyz/kit).
1111

1212
## Installation
1313

@@ -37,18 +37,18 @@ codama.accept(renderVisitor(pathToGeneratedFolder, options));
3737

3838
The `renderVisitor` accepts the following options.
3939

40-
| Name | Type | Default | Description |
41-
| ----------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
42-
| `deleteFolderBeforeRendering` | `boolean` | `true` | Whether the base directory should be cleaned before generating new files. |
43-
| `formatCode` | `boolean` | `true` | Whether we should use Prettier to format the generated code. |
44-
| `prettierOptions` | `PrettierOptions` | `{}` | The options to use when formatting the code using Prettier. |
45-
| `asyncResolvers` | `string[]` | `[]` | The exhaustive list of `ResolverValueNode`'s names whose implementation is asynchronous in JavaScript. |
46-
| `customAccountData` | `string[]` | `[]` | The names of all `AccountNodes` whose data should be manually written in JavaScript. |
47-
| `customInstructionData` | `string[]` | `[]` | The names of all `InstructionNodes` whose data should be manually written in JavaScript. |
48-
| `linkOverrides` | `Record<'accounts' \| 'definedTypes' \| 'instructions' \| 'pdas' \| 'programs' \| 'resolvers', Record<string, string>>` | `{}` | A object that overrides the import path of link nodes. For instance, `{ definedTypes: { counter: 'hooked' } }` uses the `hooked` folder to import any link node referring to the `counter` type. |
49-
| `dependencyMap` | `Record<string, string>` | `{}` | A mapping between import aliases and their actual package name or path in JavaScript. |
50-
| `internalNodes` | `string[]` | `[]` | The names of all nodes that should be generated but not exported by the `index.ts` files. |
51-
| `nameTransformers` | `Partial<NameTransformers>` | `{}` | An object that enables us to override the names of any generated type, constant or function. |
52-
| `nonScalarEnums` | `string[]` | `[]` | The names of enum variants with no data that should be treated as a data union instead of a native `enum` type. This is only useful if you are referencing an enum value in your Codama IDL. |
53-
| `renderParentInstructions` | `boolean` | `false` | When using nested instructions, whether the parent instructions should also be rendered. When set to `false` (default), only the instruction leaves are being rendered. |
54-
| `useGranularImports` | `boolean` | `false` | Whether to import the `@solana/web3.js` library using sub-packages such as `@solana/addresses` or `@solana/codecs-strings`. When set to `true`, the main `@solana/web3.js` library is used which enables generated clients to install it as a `peerDependency`. |
40+
| Name | Type | Default | Description |
41+
| ----------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
42+
| `deleteFolderBeforeRendering` | `boolean` | `true` | Whether the base directory should be cleaned before generating new files. |
43+
| `formatCode` | `boolean` | `true` | Whether we should use Prettier to format the generated code. |
44+
| `prettierOptions` | `PrettierOptions` | `{}` | The options to use when formatting the code using Prettier. |
45+
| `asyncResolvers` | `string[]` | `[]` | The exhaustive list of `ResolverValueNode`'s names whose implementation is asynchronous in JavaScript. |
46+
| `customAccountData` | `string[]` | `[]` | The names of all `AccountNodes` whose data should be manually written in JavaScript. |
47+
| `customInstructionData` | `string[]` | `[]` | The names of all `InstructionNodes` whose data should be manually written in JavaScript. |
48+
| `linkOverrides` | `Record<'accounts' \| 'definedTypes' \| 'instructions' \| 'pdas' \| 'programs' \| 'resolvers', Record<string, string>>` | `{}` | A object that overrides the import path of link nodes. For instance, `{ definedTypes: { counter: 'hooked' } }` uses the `hooked` folder to import any link node referring to the `counter` type. |
49+
| `dependencyMap` | `Record<string, string>` | `{}` | A mapping between import aliases and their actual package name or path in JavaScript. |
50+
| `internalNodes` | `string[]` | `[]` | The names of all nodes that should be generated but not exported by the `index.ts` files. |
51+
| `nameTransformers` | `Partial<NameTransformers>` | `{}` | An object that enables us to override the names of any generated type, constant or function. |
52+
| `nonScalarEnums` | `string[]` | `[]` | The names of enum variants with no data that should be treated as a data union instead of a native `enum` type. This is only useful if you are referencing an enum value in your Codama IDL. |
53+
| `renderParentInstructions` | `boolean` | `false` | When using nested instructions, whether the parent instructions should also be rendered. When set to `false` (default), only the instruction leaves are being rendered. |
54+
| `useGranularImports` | `boolean` | `false` | Whether to import the `@solana/kit` library using sub-packages such as `@solana/addresses` or `@solana/codecs-strings`. When set to `true`, the main `@solana/kit` library is used which enables generated clients to install it as a `peerDependency`. |

0 commit comments

Comments
 (0)