@sentio/sdk 2.51.0-rc.5 → 2.52.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../../../src/solana/codegen/codegen.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../../../src/solana/codegen/codegen.ts"],"names":[],"mappings":"AAaA,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,SAAsC,EAAE,UAAU,UAAQ,QAwB5G"}
|
@@ -32,6 +32,8 @@ import { SolanaBaseProcessor, SolanaContext, SolanaBindOptions } from "@sentio/s
|
|
32
32
|
import { ${idlName}_idl } from "./${idlName}.js"
|
33
33
|
import { PublicKey } from '@solana/web3.js'
|
34
34
|
|
35
|
+
${idlObj.types?.map((def) => codeGenType(def)).join('')}
|
36
|
+
|
35
37
|
export class ${idlNamePascalCase}Processor extends SolanaBaseProcessor {
|
36
38
|
static DEFAULT_OPTIONS = {
|
37
39
|
name: '${idlNamePascalCase}',
|
@@ -46,6 +48,46 @@ export class ${idlNamePascalCase}Processor extends SolanaBaseProcessor {
|
|
46
48
|
}
|
47
49
|
`;
|
48
50
|
}
|
51
|
+
function codeGenDefinedFields(fields) {
|
52
|
+
if (typeof fields[0] == 'object' && 'name' in fields[0]) {
|
53
|
+
return fields.map(({ name, type }) => `${name}: ${mapType(type)},`);
|
54
|
+
}
|
55
|
+
return fields.map((t) => mapType(t));
|
56
|
+
}
|
57
|
+
function codeGenType({ name, type }) {
|
58
|
+
switch (type.kind) {
|
59
|
+
case 'struct':
|
60
|
+
const fields = type.fields ? codeGenDefinedFields(type.fields).join('\n ') : '';
|
61
|
+
return `
|
62
|
+
interface ${name} {
|
63
|
+
${fields}
|
64
|
+
}
|
65
|
+
`;
|
66
|
+
case 'enum':
|
67
|
+
const variants = type.variants
|
68
|
+
.map(({ name, fields }) => {
|
69
|
+
if (fields) {
|
70
|
+
const body = codeGenDefinedFields(fields).join('\n ');
|
71
|
+
return `{
|
72
|
+
${name}: {
|
73
|
+
${body}
|
74
|
+
}
|
75
|
+
}`;
|
76
|
+
}
|
77
|
+
return `{ ${name}: {} }`;
|
78
|
+
})
|
79
|
+
.join('\n | ');
|
80
|
+
return `
|
81
|
+
type ${name} = ${variants}
|
82
|
+
`;
|
83
|
+
case 'type':
|
84
|
+
return `
|
85
|
+
type ${name} = ${mapType(type.alias)}
|
86
|
+
`;
|
87
|
+
default:
|
88
|
+
return '';
|
89
|
+
}
|
90
|
+
}
|
49
91
|
function codeGenSolanaInstruction(idlName, ins) {
|
50
92
|
const instructionName = ins.name;
|
51
93
|
const argsType = codeGenInstructionArgsType(ins.args);
|
@@ -85,7 +127,24 @@ function codeGenAccountTypeArgs(args) {
|
|
85
127
|
}
|
86
128
|
// Reference: https://github.com/coral-xyz/anchor/blob/93332766f13e86efbe77c9986722731742317ede/ts/src/program/namespace/types.ts#L104
|
87
129
|
function mapType(tpe) {
|
88
|
-
|
130
|
+
if (typeof tpe == 'object') {
|
131
|
+
if ('array' in tpe) {
|
132
|
+
//IdlTypeArray
|
133
|
+
return `${mapType(tpe.array[0])}[]`;
|
134
|
+
}
|
135
|
+
if ('defined' in tpe) {
|
136
|
+
// IdlTypeDefined
|
137
|
+
return tpe.defined.name;
|
138
|
+
}
|
139
|
+
if ('option' in tpe) {
|
140
|
+
// IdlTypeOption
|
141
|
+
return mapType(tpe.option) + ' | null | undefined';
|
142
|
+
}
|
143
|
+
if ('vec' in tpe) {
|
144
|
+
//IdlTypeVec
|
145
|
+
return `${mapType(tpe.vec)}[]`;
|
146
|
+
}
|
147
|
+
}
|
89
148
|
switch (tpe) {
|
90
149
|
case 'pubkey':
|
91
150
|
return 'PublicKey';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"codegen.js","sourceRoot":"","sources":["../../../src/solana/codegen/codegen.ts"],"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,KAAK,KAAK,CAAC;QACX,KAAK,KAAK,CAAC;QACX,KAAK,KAAK,CAAC;QACX,KAAK,KAAK,CAAC;QACX,KAAK,KAAK,CAAC;QACX,KAAK,KAAK;YACR,OAAO,QAAQ,CAAA;QACjB,KAAK,KAAK,CAAC;QACX,KAAK,KAAK,CAAC;QACX,KAAK,MAAM,CAAC;QACZ,KAAK,MAAM;YACT,OAAO,QAAQ,CAAA;QACjB;YACE,OAAO,KAAK,CAAA;IAChB,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,GAAW;IAC/B,OAAO,GAAG,GAAG,EAAE;SACZ,WAAW,EAAE;SACb,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC;SACtC,OAAO,CAAC,IAAI,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC;SACvC,OAAO,CAAC,IAAI,MAAM,CAAC,aAAa,EAAE,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,GAAG,EAAE,EAAE,CAAC;SACnF,OAAO,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAA;AACtD,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sentio/sdk",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.52.0-rc.1",
|
4
4
|
"license": "Apache-2.0",
|
5
5
|
"type": "module",
|
6
6
|
"exports": {
|
@@ -84,8 +84,8 @@
|
|
84
84
|
"typechain": "^8.3.2",
|
85
85
|
"utility-types": "^3.11.0",
|
86
86
|
"yaml": "^2.3.4",
|
87
|
-
"@sentio/protos": "2.
|
88
|
-
"@sentio/runtime": "^2.
|
87
|
+
"@sentio/protos": "2.52.0-rc.1",
|
88
|
+
"@sentio/runtime": "^2.52.0-rc.1"
|
89
89
|
},
|
90
90
|
"peerDependencies": {
|
91
91
|
"tsup": "npm:@sentio/tsup@^8.3.5-rc.1"
|
@@ -2,7 +2,14 @@ import path from 'path'
|
|
2
2
|
import fs from 'fs'
|
3
3
|
import chalk from 'chalk'
|
4
4
|
import { Idl } from '@coral-xyz/anchor'
|
5
|
-
import {
|
5
|
+
import {
|
6
|
+
IdlField,
|
7
|
+
IdlInstruction,
|
8
|
+
IdlType,
|
9
|
+
IdlInstructionAccountItem,
|
10
|
+
IdlDefinedFields,
|
11
|
+
IdlTypeDef
|
12
|
+
} from '@coral-xyz/anchor/dist/esm/idl.js'
|
6
13
|
|
7
14
|
export function codegen(abisDir: string, targetPath = path.join('src', 'types', 'solana'), genExample = false) {
|
8
15
|
if (!fs.existsSync(abisDir)) {
|
@@ -33,12 +40,14 @@ export function codegen(abisDir: string, targetPath = path.join('src', 'types',
|
|
33
40
|
function codeGenSolanaIdlProcessor(idlObj: Idl): string {
|
34
41
|
const idlName = idlObj.metadata.name
|
35
42
|
const idlNamePascalCase = toPascalCase(idlName)
|
36
|
-
const instructions
|
43
|
+
const instructions = idlObj.instructions
|
37
44
|
return `import { BorshInstructionCoder, Instruction, Idl } from '@sentio/sdk/solana'
|
38
45
|
import { SolanaBaseProcessor, SolanaContext, SolanaBindOptions } from "@sentio/sdk/solana"
|
39
46
|
import { ${idlName}_idl } from "./${idlName}.js"
|
40
47
|
import { PublicKey } from '@solana/web3.js'
|
41
48
|
|
49
|
+
${idlObj.types?.map((def) => codeGenType(def)).join('')}
|
50
|
+
|
42
51
|
export class ${idlNamePascalCase}Processor extends SolanaBaseProcessor {
|
43
52
|
static DEFAULT_OPTIONS = {
|
44
53
|
name: '${idlNamePascalCase}',
|
@@ -54,6 +63,49 @@ export class ${idlNamePascalCase}Processor extends SolanaBaseProcessor {
|
|
54
63
|
`
|
55
64
|
}
|
56
65
|
|
66
|
+
function codeGenDefinedFields(fields: IdlDefinedFields): string[] {
|
67
|
+
if (typeof fields[0] == 'object' && 'name' in fields[0]) {
|
68
|
+
return (fields as IdlField[]).map(({ name, type }) => `${name}: ${mapType(type)},`)
|
69
|
+
}
|
70
|
+
|
71
|
+
return (fields as IdlType[]).map((t) => mapType(t))
|
72
|
+
}
|
73
|
+
|
74
|
+
function codeGenType({ name, type }: IdlTypeDef): string {
|
75
|
+
switch (type.kind) {
|
76
|
+
case 'struct':
|
77
|
+
const fields = type.fields ? codeGenDefinedFields(type.fields).join('\n ') : ''
|
78
|
+
return `
|
79
|
+
interface ${name} {
|
80
|
+
${fields}
|
81
|
+
}
|
82
|
+
`
|
83
|
+
case 'enum':
|
84
|
+
const variants = type.variants
|
85
|
+
.map(({ name, fields }) => {
|
86
|
+
if (fields) {
|
87
|
+
const body = codeGenDefinedFields(fields).join('\n ')
|
88
|
+
return `{
|
89
|
+
${name}: {
|
90
|
+
${body}
|
91
|
+
}
|
92
|
+
}`
|
93
|
+
}
|
94
|
+
return `{ ${name}: {} }`
|
95
|
+
})
|
96
|
+
.join('\n | ')
|
97
|
+
return `
|
98
|
+
type ${name} = ${variants}
|
99
|
+
`
|
100
|
+
case 'type':
|
101
|
+
return `
|
102
|
+
type ${name} = ${mapType(type.alias)}
|
103
|
+
`
|
104
|
+
default:
|
105
|
+
return ''
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
57
109
|
function codeGenSolanaInstruction(idlName: string, ins: IdlInstruction): string {
|
58
110
|
const instructionName = ins.name
|
59
111
|
|
@@ -103,7 +155,24 @@ function codeGenAccountTypeArgs(args: IdlInstructionAccountItem[]): string {
|
|
103
155
|
|
104
156
|
// Reference: https://github.com/coral-xyz/anchor/blob/93332766f13e86efbe77c9986722731742317ede/ts/src/program/namespace/types.ts#L104
|
105
157
|
function mapType(tpe: IdlType): string {
|
106
|
-
|
158
|
+
if (typeof tpe == 'object') {
|
159
|
+
if ('array' in tpe) {
|
160
|
+
//IdlTypeArray
|
161
|
+
return `${mapType(tpe.array[0])}[]`
|
162
|
+
}
|
163
|
+
if ('defined' in tpe) {
|
164
|
+
// IdlTypeDefined
|
165
|
+
return tpe.defined.name
|
166
|
+
}
|
167
|
+
if ('option' in tpe) {
|
168
|
+
// IdlTypeOption
|
169
|
+
return mapType(tpe.option) + ' | null | undefined'
|
170
|
+
}
|
171
|
+
if ('vec' in tpe) {
|
172
|
+
//IdlTypeVec
|
173
|
+
return `${mapType(tpe.vec)}[]`
|
174
|
+
}
|
175
|
+
}
|
107
176
|
switch (tpe) {
|
108
177
|
case 'pubkey':
|
109
178
|
return 'PublicKey'
|