Skip to content

Commit bfff0e4

Browse files
committed
Merge branch 'rust-fetch-functions' of https://github.com/wjthieme/kinobi into rust-fetch-functions
2 parents 9ff3981 + bd2075e commit bfff0e4

File tree

127 files changed

+4752
-2102
lines changed

Some content is hidden

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

127 files changed

+4752
-2102
lines changed

.eslintrc.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ jobs:
3232
- name: Install dependencies
3333
run: pnpm install --frozen-lockfile
3434

35+
- name: Compile JS and types
36+
run: pnpm run build
37+
3538
- name: Check linting
3639
run: pnpm run lint
3740

@@ -101,3 +104,22 @@ jobs:
101104
env:
102105
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
103106
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
107+
108+
dependabot:
109+
runs-on: ubuntu-latest
110+
if: github.event_name == 'pull_request' && github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'codama-idl/codama'
111+
needs: [lint, tests]
112+
permissions:
113+
contents: write
114+
pull-requests: write
115+
steps:
116+
- name: Auto-approve the PR
117+
run: gh pr review --approve "$PR_URL"
118+
env:
119+
PR_URL: ${{ github.event.pull_request.html_url }}
120+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
121+
- name: Enable auto-merge
122+
run: gh pr merge --auto --squash "$PR_URL"
123+
env:
124+
PR_URL: ${{ github.event.pull_request.html_url }}
125+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ Because everything is designed as a `Node`, we can transform the IDL, aggregate
3131

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

34-
- **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.
35-
- **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.
34+
- **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.
35+
- **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.
3636

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

45-
- **By hand**. If your Solana program cannot be updated to use Codama macros and you dont 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.
45+
- **By hand**. If your Solana program cannot be updated to use Codama macros and you dont 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.
4646

4747
## Transforming Codama
4848

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

6262
_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 youd like to contribute to this Codama ecosystem._
6363

64-
- **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:
64+
- **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/solana-labs/solana-web3.js).
67-
- `@codama/renderers-js-umi`: Renders a JavaScript client compatible with Metaplexs [Umi](https://github.com/metaplex-foundation/umi) framework.
68-
- `@codama/renderers-rust`: Renders a Rust client that removes the need for publishing the program crate and offers a better developer experience.
69-
- _And more to come._
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/solana-labs/solana-web3.js).
67+
- `@codama/renderers-js-umi`: Renders a JavaScript client compatible with Metaplexs [Umi](https://github.com/metaplex-foundation/umi) framework.
68+
- `@codama/renderers-rust`: Renders a Rust client that removes the need for publishing the program crate and offers a better developer experience.
69+
- _And more to come._
7070

7171
Heres an example of how to generate JavaScript and Rust client code for your program.
7272

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

80-
- **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 dont need and generate a bespoke client for their app that only contains the functions the app needs.
81-
- **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.
82-
- **Rendering documentation** (_Not yet available_). Similarly to CLIs, we may easily generate documentation in various formats from the information held by our Codama IDL.
80+
- **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 dont need and generate a bespoke client for their app that only contains the functions the app needs.
81+
- **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.
82+
- **Rendering documentation** (_Not yet available_). Similarly to CLIs, we may easily generate documentation in various formats from the information held by our Codama IDL.

eslint.config.mjs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import solanaConfig from '@solana/eslint-config-solana';
2+
import tseslint from 'typescript-eslint';
3+
4+
export default tseslint.config([
5+
{
6+
files: ['**/*.ts', '**/*.(c|m)?js'],
7+
ignores: ['**/dist/**', '**/e2e/**'],
8+
extends: [solanaConfig],
9+
},
10+
{
11+
files: ['packages/nodes/**', 'packages/node-types/**'],
12+
rules: {
13+
'sort-keys-fix/sort-keys-fix': 'off',
14+
'typescript-sort-keys/interface': 'off',
15+
},
16+
},
17+
]);

package.json

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,28 @@
1313
},
1414
"devDependencies": {
1515
"@changesets/changelog-github": "^0.5.0",
16-
"@changesets/cli": "^2.27.9",
16+
"@changesets/cli": "^2.27.11",
1717
"@codama/internals": "workspace:*",
18-
"@solana/eslint-config-solana": "^3.0.3",
18+
"@eslint/js": "^9.17.0",
19+
"@eslint/json": "^0.9.0",
20+
"@solana/eslint-config-solana": "^4.0.0",
1921
"@solana/prettier-config-solana": "0.0.5",
20-
"@types/node": "^20",
21-
"@typescript-eslint/eslint-plugin": "^6.21.0",
22-
"@typescript-eslint/parser": "^6.0.0",
22+
"@types/node": "^22",
23+
"@typescript-eslint/eslint-plugin": "^8.19.1",
24+
"@typescript-eslint/parser": "^8.19.1",
2325
"agadoo": "^3.0.0",
24-
"eslint": "^8.57.1",
25-
"eslint-config-turbo": "^2.2.3",
26-
"eslint-plugin-simple-import-sort": "^10.0.0",
26+
"eslint": "^9.17.0",
27+
"eslint-plugin-simple-import-sort": "^12.1.1",
2728
"eslint-plugin-sort-keys-fix": "^1.1.2",
2829
"eslint-plugin-typescript-sort-keys": "^3.3.0",
29-
"happy-dom": "^15.11.0",
30-
"prettier": "^3.3.3",
30+
"happy-dom": "^16.5.3",
31+
"prettier": "^3.4.2",
3132
"rimraf": "6.0.1",
3233
"tsup": "^8.3.5",
33-
"turbo": "^2.2.3",
34-
"typescript": "^5.6.3",
35-
"vitest": "^2.1.4",
36-
"zx": "^8.2.0"
34+
"turbo": "^2.3.3",
35+
"typescript": "^5.7.3",
36+
"vitest": "^2.1.8",
37+
"zx": "^8.3.0"
3738
},
3839
"engines": {
3940
"node": ">=18.0.0"

packages/dynamic-codecs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codama/dynamic-codecs",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "Get codecs on demand for Codama IDLs",
55
"exports": {
66
"types": "./dist/types/index.d.ts",

packages/dynamic-codecs/src/codecs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ export function getNodeCodecVisitor(
249249
return transformCodec(
250250
getMapCodec(key, value, { size }),
251251
(value: object) => new Map(Object.entries(value)),
252-
(map: Map<unknown, unknown>): object => Object.fromEntries(map),
252+
(map: Map<unknown, unknown>) => Object.fromEntries(map) as object,
253253
) as Codec<unknown>;
254254
},
255255
visitNumberType(node) {

packages/dynamic-codecs/src/values.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export function getValueNodeVisitor(
6767
const value = visit(entry.value, this);
6868
return [key, value];
6969
}),
70-
);
70+
) as unknown;
7171
},
7272
visitNoneValue() {
7373
return { __option: 'None' };

packages/dynamic-parsers/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codama/dynamic-parsers",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "Helpers to dynamically identify and parse accounts and instructions",
55
"exports": {
66
"types": "./dist/types/index.d.ts",

packages/dynamic-parsers/src/parsers.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ export function parseInstruction(
5353
): ParsedInstruction | undefined {
5454
const parsedData = parseInstructionData(root, instruction.data);
5555
if (!parsedData) return undefined;
56-
instruction.accounts;
5756
const instructionNode = getLastNodeFromPath(parsedData.path);
5857
const accounts: ParsedInstructionAccounts = instructionNode.accounts.flatMap((account, index) => {
5958
const accountMeta = instruction.accounts[index];

0 commit comments

Comments
 (0)