1
1
#!/usr/bin/env zx
2
2
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';
5
5
{% if jsClient %}
6
- import { renderVisitor as renderJavaScriptVisitor } from '@kinobi-so /renderers-js';
6
+ import { renderVisitor as renderJavaScriptVisitor } from '@codama /renderers-js';
7
7
{% endif %}
8
8
{% if rustClient %}
9
- import { renderVisitor as renderRustVisitor } from '@kinobi-so /renderers-rust';
9
+ import { renderVisitor as renderRustVisitor } from '@codama /renderers-rust';
10
10
{% endif %}
11
11
import { getAllProgramIdls } from './utils.mjs';
12
12
13
- // Instanciate Kinobi .
13
+ // Instanciate Codama .
14
14
const [idl, ...additionalIdls] = getAllProgramIdls().map((idl) =>
15
15
rootNodeFromAnchor(require(idl))
16
16
);
17
- const kinobi = k .createFromRoot(idl, additionalIdls);
17
+ const codama = c .createFromRoot(idl, additionalIdls);
18
18
19
19
// Update programs.
20
- kinobi .update(
21
- k .updateProgramsVisitor({
20
+ codama .update(
21
+ c .updateProgramsVisitor({
22
22
{{ programCrateName | camelCase }} : { name: '{{ programName | camelCase }} ' },
23
23
})
24
24
);
25
25
26
26
{% if programFramework == = ' shank' %}
27
27
// Update accounts.
28
- kinobi .update(
29
- k .updateAccountsVisitor({
28
+ codama .update(
29
+ c .updateAccountsVisitor({
30
30
counter: {
31
31
seeds: [
32
- k .constantPdaSeedNodeFromString('utf8', 'counter'),
33
- k .variablePdaSeedNode(
32
+ c .constantPdaSeedNodeFromString('utf8', 'counter'),
33
+ c .variablePdaSeedNode(
34
34
'authority',
35
- k .publicKeyTypeNode(),
35
+ c .publicKeyTypeNode(),
36
36
'The authority of the counter account'
37
37
),
38
38
],
@@ -41,30 +41,30 @@ kinobi.update(
41
41
);
42
42
43
43
// Update instructions.
44
- kinobi .update(
45
- k .updateInstructionsVisitor({
44
+ codama .update(
45
+ c .updateInstructionsVisitor({
46
46
create: {
47
- byteDeltas: [k .instructionByteDeltaNode(k .accountLinkNode('counter'))],
47
+ byteDeltas: [c .instructionByteDeltaNode(c .accountLinkNode('counter'))],
48
48
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') },
51
51
},
52
52
},
53
53
increment: {
54
54
accounts: {
55
- counter: { defaultValue: k .pdaValueNode('counter') },
55
+ counter: { defaultValue: c .pdaValueNode('counter') },
56
56
},
57
57
arguments: {
58
- amount: { defaultValue: k .noneValueNode() },
58
+ amount: { defaultValue: c .noneValueNode() },
59
59
},
60
60
},
61
61
})
62
62
);
63
63
64
64
// 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({
68
68
counter: key('counter'),
69
69
})
70
70
);
@@ -73,7 +73,7 @@ kinobi.update(
73
73
{% if jsClient %}
74
74
// Render JavaScript.
75
75
const jsClient = path.join(__dirname, '..', 'clients', 'js');
76
- kinobi .accept(
76
+ codama .accept(
77
77
renderJavaScriptVisitor(path.join(jsClient, 'src', 'generated'), {
78
78
prettierOptions: require(path.join(jsClient, '.prettierrc.json')),
79
79
})
@@ -83,7 +83,7 @@ kinobi.accept(
83
83
{% if rustClient %}
84
84
// Render Rust.
85
85
const rustClient = path.join(__dirname, '..', 'clients', 'rust');
86
- kinobi .accept(
86
+ codama .accept(
87
87
renderRustVisitor(path.join(rustClient, 'src', 'generated'), {
88
88
formatCode: true,
89
89
crateFolder: rustClient,
0 commit comments