Skip to content

Commit e5c620d

Browse files
authored
Use Codama v1.0.0 (#93)
1 parent 2594fb8 commit e5c620d

File tree

5 files changed

+34
-29
lines changed

5 files changed

+34
-29
lines changed

.changeset/hungry-laws-jam.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"create-solana-program": patch
3+
---
4+
5+
Use Codama v1.0.0 (See https://github.com/codama-idl/codama/pull/234)

template/clients/base/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"validator:stop": "zx ./scripts/stop-validator.mjs"
88
},
99
"devDependencies": {
10-
"kinobi": "^0.21.5",
11-
"@kinobi-so/nodes-from-anchor": "^0.21.3"
10+
"codama": "^1.0.0",
11+
"@codama/nodes-from-anchor": "^1.0.0"
1212
}
1313
}

template/clients/base/scripts/generate-clients.mjs.njk

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
#!/usr/bin/env zx
22
import 'zx/globals';
3-
import * as k from 'kinobi';
4-
import { rootNodeFromAnchor } from '@kinobi-so/nodes-from-anchor';
3+
import * as c from 'codama';
4+
import { rootNodeFromAnchor } from '@codama/nodes-from-anchor';
55
{% if jsClient %}
6-
import { renderVisitor as renderJavaScriptVisitor } from '@kinobi-so/renderers-js';
6+
import { renderVisitor as renderJavaScriptVisitor } from '@codama/renderers-js';
77
{% endif %}
88
{% if rustClient %}
9-
import { renderVisitor as renderRustVisitor } from '@kinobi-so/renderers-rust';
9+
import { renderVisitor as renderRustVisitor } from '@codama/renderers-rust';
1010
{% endif %}
1111
import { getAllProgramIdls } from './utils.mjs';
1212

13-
// Instanciate Kinobi.
13+
// Instanciate Codama.
1414
const [idl, ...additionalIdls] = getAllProgramIdls().map((idl) =>
1515
rootNodeFromAnchor(require(idl))
1616
);
17-
const kinobi = k.createFromRoot(idl, additionalIdls);
17+
const codama = c.createFromRoot(idl, additionalIdls);
1818

1919
// Update programs.
20-
kinobi.update(
21-
k.updateProgramsVisitor({
20+
codama.update(
21+
c.updateProgramsVisitor({
2222
{{ programCrateName | camelCase }}: { name: '{{ programName | camelCase }}' },
2323
})
2424
);
2525

2626
{% if programFramework === 'shank' %}
2727
// Update accounts.
28-
kinobi.update(
29-
k.updateAccountsVisitor({
28+
codama.update(
29+
c.updateAccountsVisitor({
3030
counter: {
3131
seeds: [
32-
k.constantPdaSeedNodeFromString('utf8', 'counter'),
33-
k.variablePdaSeedNode(
32+
c.constantPdaSeedNodeFromString('utf8', 'counter'),
33+
c.variablePdaSeedNode(
3434
'authority',
35-
k.publicKeyTypeNode(),
35+
c.publicKeyTypeNode(),
3636
'The authority of the counter account'
3737
),
3838
],
@@ -41,30 +41,30 @@ kinobi.update(
4141
);
4242

4343
// Update instructions.
44-
kinobi.update(
45-
k.updateInstructionsVisitor({
44+
codama.update(
45+
c.updateInstructionsVisitor({
4646
create: {
47-
byteDeltas: [k.instructionByteDeltaNode(k.accountLinkNode('counter'))],
47+
byteDeltas: [c.instructionByteDeltaNode(c.accountLinkNode('counter'))],
4848
accounts: {
49-
counter: { defaultValue: k.pdaValueNode('counter') },
50-
payer: { defaultValue: k.accountValueNode('authority') },
49+
counter: { defaultValue: c.pdaValueNode('counter') },
50+
payer: { defaultValue: c.accountValueNode('authority') },
5151
},
5252
},
5353
increment: {
5454
accounts: {
55-
counter: { defaultValue: k.pdaValueNode('counter') },
55+
counter: { defaultValue: c.pdaValueNode('counter') },
5656
},
5757
arguments: {
58-
amount: { defaultValue: k.noneValueNode() },
58+
amount: { defaultValue: c.noneValueNode() },
5959
},
6060
},
6161
})
6262
);
6363

6464
// Set account discriminators.
65-
const key = (name) => ({ field: 'key', value: k.enumValueNode('Key', name) });
66-
kinobi.update(
67-
k.setAccountDiscriminatorFromFieldVisitor({
65+
const key = (name) => ({ field: 'key', value: c.enumValueNode('Key', name) });
66+
codama.update(
67+
c.setAccountDiscriminatorFromFieldVisitor({
6868
counter: key('counter'),
6969
})
7070
);
@@ -73,7 +73,7 @@ kinobi.update(
7373
{% if jsClient %}
7474
// Render JavaScript.
7575
const jsClient = path.join(__dirname, '..', 'clients', 'js');
76-
kinobi.accept(
76+
codama.accept(
7777
renderJavaScriptVisitor(path.join(jsClient, 'src', 'generated'), {
7878
prettierOptions: require(path.join(jsClient, '.prettierrc.json')),
7979
})
@@ -83,7 +83,7 @@ kinobi.accept(
8383
{% if rustClient %}
8484
// Render Rust.
8585
const rustClient = path.join(__dirname, '..', 'clients', 'rust');
86-
kinobi.accept(
86+
codama.accept(
8787
renderRustVisitor(path.join(rustClient, 'src', 'generated'), {
8888
formatCode: true,
8989
crateFolder: rustClient,

template/clients/js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
"clients:js:test": "zx ./scripts/client/test-js.mjs"
77
},
88
"devDependencies": {
9-
"@kinobi-so/renderers-js": "^0.21.9"
9+
"@codama/renderers-js": "^1.0.0"
1010
}
1111
}

template/clients/rust/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
"clients:rust:test": "zx ./scripts/client/test-rust.mjs"
77
},
88
"devDependencies": {
9-
"@kinobi-so/renderers-rust": "^0.21.7"
9+
"@codama/renderers-rust": "^1.0.0"
1010
}
1111
}

0 commit comments

Comments
 (0)