-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgenerate-client.mjs
73 lines (69 loc) · 1.73 KB
/
generate-client.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env zx
import "zx/globals";
import * as k from "kinobi";
import path from "path";
import { rootNodeFromAnchor } from '@kinobi-so/nodes-from-anchor';
import { renderVisitor as renderJavaScriptVisitor } from "@kinobi-so/renderers-js";
// Instantiate Kinobi.
const idl = rootNodeFromAnchor(require(path.resolve(__dirname, 'idl.json')));
console.log(idl)
const kinobi = k.createFromRoot(idl);
// Update programs.
kinobi.update(
k.updateProgramsVisitor({
"dephyKwilExample": { name: "kwil" },
})
);
// Update accounts.
kinobi.update(
k.updateAccountsVisitor({
publisherAccount: {
seeds: [
k.constantPdaSeedNodeFromString("utf8", "PUBLISHER"),
k.variablePdaSeedNode(
"did_atoken",
k.publicKeyTypeNode(),
"The DID of publisher"
),
],
},
linkedAccount: {
seeds: [
k.constantPdaSeedNodeFromString("utf8", "LINKED"),
k.variablePdaSeedNode(
"user",
k.publicKeyTypeNode(),
"The user pubkey"
),
k.variablePdaSeedNode(
"eth_address",
k.bytesTypeNode(),
"ETH address"
),
]
},
subscriberAccount: {
seeds: [
k.constantPdaSeedNodeFromString("utf8", "SUBSCRIBER"),
k.variablePdaSeedNode(
"publisher",
k.publicKeyTypeNode(),
"The publisher account"
),
k.variablePdaSeedNode(
"linked",
k.publicKeyTypeNode(),
"The linked account"
),
]
},
})
);
// Render JavaScript.
const indexerPlugin = path.join(__dirname, "indexer", "src", "plugins");
await kinobi.accept(
renderJavaScriptVisitor(
path.join(indexerPlugin, "kwil", "generated"),
{}
)
);