@sentio/sdk 2.13.2-rc.4 → 2.13.2-rc.5

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.
@@ -33,20 +33,25 @@ class SuiCodegen extends AbstractCodegen {
33
33
  return res;
34
34
  }
35
35
  generateStructs(module, struct, events) {
36
+ let content = '';
36
37
  switch (structQname(module, struct)) {
37
38
  // TODO they should still have module code generated
38
39
  case '0x1::ascii::Char':
39
40
  case '0x1::ascii::String':
40
41
  case '0x2::object::ID':
41
- return `export type ${struct.name} = string`;
42
+ content += `export type ${struct.name} = string`;
43
+ break;
42
44
  case '0x2::coin::Coin':
43
- return `export type ${struct.name}<T> = string`;
45
+ content += `export type ${struct.name}<T> = string`;
46
+ break;
44
47
  case '0x2::balance::Balance':
45
- return `export type ${struct.name}<T> = bigint`;
48
+ content += `export type ${struct.name}<T> = bigint`;
49
+ break;
46
50
  case '0x1::option::Option':
47
- return `export type Option<T> = T | undefined`;
51
+ content += `export type Option<T> = T | undefined`;
52
+ break;
48
53
  }
49
- return super.generateStructs(module, struct, events);
54
+ return content + super.generateStructs(module, struct, events, content !== '');
50
55
  }
51
56
  generateOnEvents(module, struct) {
52
57
  switch (structQname(module, struct)) {
@@ -1 +1 @@
1
- {"version":3,"file":"codegen.js","sourceRoot":"","sources":["../../../src/sui/codegen/codegen.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAEzD,MAAM,CAAC,KAAK,UAAU,OAAO,CAC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;YAC9C,KAAK,iBAAiB;gBACpB,OAAO,eAAe,MAAM,CAAC,IAAI,cAAc,CAAA;YACjD,KAAK,uBAAuB;gBAC1B,OAAO,eAAe,MAAM,CAAC,IAAI,cAAc,CAAA;YACjD,KAAK,qBAAqB;gBACxB,OAAO,uCAAuC,CAAA;SACjD;QACD,OAAO,KAAK,CAAC,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;IACtD,CAAC;IAED,gBAAgB,CAAC,MAA0B,EAAE,MAA0B;QACrE,QAAQ,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE;YACnC,KAAK,kBAAkB,CAAC;YACxB,KAAK,oBAAoB,CAAC;YAC1B,KAAK,iBAAiB,CAAC;YACvB,KAAK,iBAAiB,CAAC;YACvB,KAAK,qBAAqB,CAAC;YAC3B,KAAK,uBAAuB;gBAC1B,OAAO,EAAE,CAAA;SACZ;QACD,OAAO,KAAK,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/C,CAAC;CACF","sourcesContent":["import { SuiMoveNormalizedModule, SuiEvent, SuiMoveObject } from '@mysten/sui.js'\n\nimport { SuiNetwork } from '../network.js'\nimport * as fs from 'fs'\nimport chalk from 'chalk'\nimport { InternalMoveModule, InternalMoveStruct } from '../../move/internal-models.js'\nimport { AbstractCodegen } from '../../move/abstract-codegen.js'\nimport { structQname } from '../../move/index.js'\nimport { join } from 'path'\nimport { SuiChainAdapter } from '../sui-chain-adapter.js'\n\nexport async function codegen(\n abisDir: string,\n outDir = join('src', 'types', 'sui'),\n genExample = false,\n builtin = false\n) {\n if (!fs.existsSync(abisDir)) {\n return\n }\n const gen = new SuiCodegen()\n const numFiles = await gen.generate(abisDir, outDir, builtin)\n console.log(chalk.green(`Generated ${numFiles} for Sui`))\n}\n\nclass SuiCodegen extends AbstractCodegen<SuiNetwork, SuiMoveNormalizedModule, SuiEvent | SuiMoveObject> {\n ADDRESS_TYPE = 'SuiAddress'\n // ADDRESS_TYPE = 'string'\n MAIN_NET = SuiNetwork.MAIN_NET\n TEST_NET = SuiNetwork.TEST_NET\n PREFIX = 'Sui'\n // STRUCT_FIELD_NAME = 'fields'\n // GENERATE_ON_ENTRY = true\n PAYLOAD_OPTIONAL = true\n\n constructor() {\n super(new SuiChainAdapter())\n }\n\n readModulesFile(fullPath: string) {\n const res = super.readModulesFile(fullPath)\n if (res.result) {\n return res.result\n }\n return res\n }\n\n generateStructs(module: InternalMoveModule, struct: InternalMoveStruct, events: Set<string>): string {\n switch (structQname(module, struct)) {\n // TODO they should still have module code generated\n case '0x1::ascii::Char':\n case '0x1::ascii::String':\n case '0x2::object::ID':\n return `export type ${struct.name} = string`\n case '0x2::coin::Coin':\n return `export type ${struct.name}<T> = string`\n case '0x2::balance::Balance':\n return `export type ${struct.name}<T> = bigint`\n case '0x1::option::Option':\n return `export type Option<T> = T | undefined`\n }\n return super.generateStructs(module, struct, events)\n }\n\n generateOnEvents(module: InternalMoveModule, struct: InternalMoveStruct): string {\n switch (structQname(module, struct)) {\n case '0x1::ascii::Char':\n case '0x1::ascii::String':\n case '0x2::object::ID':\n case '0x2::coin::Coin':\n case '0x1::option::Option':\n case '0x2::balance::Balance':\n return ''\n }\n return super.generateOnEvents(module, struct)\n }\n}\n"]}
1
+ {"version":3,"file":"codegen.js","sourceRoot":"","sources":["../../../src/sui/codegen/codegen.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAEzD,MAAM,CAAC,KAAK,UA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;gBACpB,OAAO,IAAI,eAAe,MAAM,CAAC,IAAI,WAAW,CAAA;gBAChD,MAAK;YACP,KAAK,iBAAiB;gBACpB,OAAO,IAAI,eAAe,MAAM,CAAC,IAAI,cAAc,CAAA;gBACnD,MAAK;YACP,KAAK,uBAAuB;gBAC1B,OAAO,IAAI,eAAe,MAAM,CAAC,IAAI,cAAc,CAAA;gBACnD,MAAK;YACP,KAAK,qBAAqB;gBACxB,OAAO,IAAI,uCAAuC,CAAA;gBAClD,MAAK;SACR;QACD,OAAO,OAAO,GAAG,KAAK,CAAC,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,EAAE,CAAC,CAAA;IAChF,CAAC;IAED,gBAAgB,CAAC,MAA0B,EAAE,MAA0B;QACrE,QAAQ,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE;YACnC,KAAK,kBAAkB,CAAC;YACxB,KAAK,oBAAoB,CAAC;YAC1B,KAAK,iBAAiB,CAAC;YACvB,KAAK,iBAAiB,CAAC;YACvB,KAAK,qBAAqB,CAAC;YAC3B,KAAK,uBAAuB;gBAC1B,OAAO,EAAE,CAAA;SACZ;QACD,OAAO,KAAK,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/C,CAAC;CACF","sourcesContent":["import { SuiMoveNormalizedModule, SuiEvent, SuiMoveObject } from '@mysten/sui.js'\n\nimport { SuiNetwork } from '../network.js'\nimport * as fs from 'fs'\nimport chalk from 'chalk'\nimport { InternalMoveModule, InternalMoveStruct } from '../../move/internal-models.js'\nimport { AbstractCodegen } from '../../move/abstract-codegen.js'\nimport { structQname } from '../../move/index.js'\nimport { join } from 'path'\nimport { SuiChainAdapter } from '../sui-chain-adapter.js'\n\nexport async function codegen(\n abisDir: string,\n outDir = join('src', 'types', 'sui'),\n genExample = false,\n builtin = false\n) {\n if (!fs.existsSync(abisDir)) {\n return\n }\n const gen = new SuiCodegen()\n const numFiles = await gen.generate(abisDir, outDir, builtin)\n console.log(chalk.green(`Generated ${numFiles} for Sui`))\n}\n\nclass SuiCodegen extends AbstractCodegen<SuiNetwork, SuiMoveNormalizedModule, SuiEvent | SuiMoveObject> {\n ADDRESS_TYPE = 'SuiAddress'\n // ADDRESS_TYPE = 'string'\n MAIN_NET = SuiNetwork.MAIN_NET\n TEST_NET = SuiNetwork.TEST_NET\n PREFIX = 'Sui'\n // STRUCT_FIELD_NAME = 'fields'\n // GENERATE_ON_ENTRY = true\n PAYLOAD_OPTIONAL = true\n\n constructor() {\n super(new SuiChainAdapter())\n }\n\n readModulesFile(fullPath: string) {\n const res = super.readModulesFile(fullPath)\n if (res.result) {\n return res.result\n }\n return res\n }\n\n generateStructs(module: InternalMoveModule, struct: InternalMoveStruct, events: Set<string>): string {\n let content = ''\n switch (structQname(module, struct)) {\n // TODO they should still have module code generated\n case '0x1::ascii::Char':\n case '0x1::ascii::String':\n case '0x2::object::ID':\n content += `export type ${struct.name} = string`\n break\n case '0x2::coin::Coin':\n content += `export type ${struct.name}<T> = string`\n break\n case '0x2::balance::Balance':\n content += `export type ${struct.name}<T> = bigint`\n break\n case '0x1::option::Option':\n content += `export type Option<T> = T | undefined`\n break\n }\n return content + super.generateStructs(module, struct, events, content !== '')\n }\n\n generateOnEvents(module: InternalMoveModule, struct: InternalMoveStruct): string {\n switch (structQname(module, struct)) {\n case '0x1::ascii::Char':\n case '0x1::ascii::String':\n case '0x2::object::ID':\n case '0x2::coin::Coin':\n case '0x1::option::Option':\n case '0x2::balance::Balance':\n return ''\n }\n return super.generateOnEvents(module, struct)\n }\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sentio/sdk",
3
3
  "license": "Apache-2.0",
4
- "version": "2.13.2-rc.4",
4
+ "version": "2.13.2-rc.5",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "compile": "tsc && cp src/utils/*.csv lib/utils && cp src/tsup.config.ts lib",
@@ -23,8 +23,8 @@
23
23
  "@project-serum/anchor": "^0.26.0",
24
24
  "@sentio/bigdecimal": "^9.1.1-patch.3",
25
25
  "@sentio/ethers-v6": "^1.0.28",
26
- "@sentio/protos": "^2.13.2-rc.4",
27
- "@sentio/runtime": "^2.13.2-rc.4",
26
+ "@sentio/protos": "^2.13.2-rc.5",
27
+ "@sentio/runtime": "^2.13.2-rc.5",
28
28
  "@solana/web3.js": "^1.74.0",
29
29
  "@types/prettier": "^2.7.2",
30
30
  "aptos-sdk": "npm:aptos@^1.8.3",
@@ -88,5 +88,5 @@
88
88
  "engines": {
89
89
  "node": ">=16"
90
90
  },
91
- "gitHead": "219e58354c9bc8276061e94dbf41d6de24003e15"
91
+ "gitHead": "919872e118404b5327a255f793a69e43cb12b380"
92
92
  }
@@ -220,7 +220,7 @@ export abstract class AbstractCodegen<NetworkType, ModuleTypes, StructType> {
220
220
  `
221
221
  }
222
222
 
223
- generateStructs(module: InternalMoveModule, struct: InternalMoveStruct, events: Set<string>) {
223
+ generateStructs(module: InternalMoveModule, struct: InternalMoveStruct, events: Set<string>, typeOnly = false) {
224
224
  const typeParams = struct.typeParams || []
225
225
  const genericString = this.generateStructTypeParameters(struct)
226
226
  const genericStringAny = this.generateStructTypeParameters(struct, true)
@@ -232,17 +232,6 @@ export abstract class AbstractCodegen<NetworkType, ModuleTypes, StructType> {
232
232
  return `${field.name}: ${type}`
233
233
  })
234
234
 
235
- let eventPayload = ''
236
- if (events.has(moduleQname(module) + SPLITTER + struct.name)) {
237
- eventPayload = `
238
- export interface ${structName}Instance extends
239
- TypedEventInstance<${structName}${genericStringAny}> {
240
- ${this.STRUCT_FIELD_NAME}_decoded: ${structName}${genericStringAny}
241
- type_arguments: [${struct.typeParams.map((_) => 'string').join(', ')}]
242
- }
243
- `
244
- }
245
-
246
235
  const typeParamApplyArg = typeParams
247
236
  .map((v, idx) => {
248
237
  return `arg${idx}: TypeDescriptor<T${idx}> = ANY_TYPE`
@@ -254,23 +243,38 @@ export abstract class AbstractCodegen<NetworkType, ModuleTypes, StructType> {
254
243
  })
255
244
  .join(',')
256
245
 
257
- const typeWithArg = `
246
+ const typeDescriptor = `
247
+ export namespace ${structName}{
248
+ export const TYPE_QNAME = '${module.address}::${module.name}::${struct.name}'
249
+
250
+ const TYPE = new TypeDescriptor<${structName}${genericStringAny}>(${structName}.TYPE_QNAME)
251
+
258
252
  export function type${genericString}(${typeParamApplyArg}): TypeDescriptor<${structName}${genericString}> {
259
253
  return TYPE.apply(${typeParamApply})
260
- }`
254
+ }
255
+ }
256
+ `
257
+ if (typeOnly) {
258
+ return typeDescriptor
259
+ }
260
+
261
+ let eventPayload = ''
262
+ if (events.has(moduleQname(module) + SPLITTER + struct.name)) {
263
+ eventPayload = `
264
+ export interface ${structName}Instance extends
265
+ TypedEventInstance<${structName}${genericStringAny}> {
266
+ ${this.STRUCT_FIELD_NAME}_decoded: ${structName}${genericStringAny}
267
+ type_arguments: [${struct.typeParams.map((_) => 'string').join(', ')}]
268
+ }
269
+ `
270
+ }
261
271
 
262
272
  return `
263
273
  export interface ${structName}${genericString} {
264
274
  ${fields.join('\n')}
265
275
  }
266
276
 
267
- export namespace ${structName}{
268
- export const TYPE_QNAME = '${module.address}::${module.name}::${struct.name}'
269
-
270
- const TYPE = new TypeDescriptor<${structName}${genericStringAny}>(${structName}.TYPE_QNAME)
271
-
272
- ${typeWithArg}
273
- }
277
+ ${typeDescriptor}
274
278
 
275
279
  ${eventPayload}
276
280
  `
@@ -22,7 +22,26 @@ export namespace address {}
22
22
 
23
23
  export namespace ascii {
24
24
  export type Char = string;
25
+ export namespace Char {
26
+ export const TYPE_QNAME = "0x1::ascii::Char";
27
+
28
+ const TYPE = new TypeDescriptor<Char>(Char.TYPE_QNAME);
29
+
30
+ export function type(): TypeDescriptor<Char> {
31
+ return TYPE.apply();
32
+ }
33
+ }
34
+
25
35
  export type String = string;
36
+ export namespace String {
37
+ export const TYPE_QNAME = "0x1::ascii::String";
38
+
39
+ const TYPE = new TypeDescriptor<String>(String.TYPE_QNAME);
40
+
41
+ export function type(): TypeDescriptor<String> {
42
+ return TYPE.apply();
43
+ }
44
+ }
26
45
  }
27
46
 
28
47
  export namespace bcs {}
@@ -133,6 +152,17 @@ export namespace hash {}
133
152
 
134
153
  export namespace option {
135
154
  export type Option<T> = T | undefined;
155
+ export namespace Option {
156
+ export const TYPE_QNAME = "0x1::option::Option";
157
+
158
+ const TYPE = new TypeDescriptor<Option<any>>(Option.TYPE_QNAME);
159
+
160
+ export function type<T0>(
161
+ arg0: TypeDescriptor<T0> = ANY_TYPE
162
+ ): TypeDescriptor<Option<T0>> {
163
+ return TYPE.apply(arg0);
164
+ }
165
+ }
136
166
  }
137
167
 
138
168
  export class string_ extends SuiBaseProcessor {
@@ -41,6 +41,17 @@ export namespace bag {
41
41
 
42
42
  export namespace balance {
43
43
  export type Balance<T> = bigint;
44
+ export namespace Balance {
45
+ export const TYPE_QNAME = "0x2::balance::Balance";
46
+
47
+ const TYPE = new TypeDescriptor<Balance<any>>(Balance.TYPE_QNAME);
48
+
49
+ export function type<T0>(
50
+ arg0: TypeDescriptor<T0> = ANY_TYPE
51
+ ): TypeDescriptor<Balance<T0>> {
52
+ return TYPE.apply(arg0);
53
+ }
54
+ }
44
55
 
45
56
  export interface Supply<T0> {
46
57
  value: bigint;
@@ -303,6 +314,17 @@ export class coin extends SuiBaseProcessor {
303
314
 
304
315
  export namespace coin {
305
316
  export type Coin<T> = string;
317
+ export namespace Coin {
318
+ export const TYPE_QNAME = "0x2::coin::Coin";
319
+
320
+ const TYPE = new TypeDescriptor<Coin<any>>(Coin.TYPE_QNAME);
321
+
322
+ export function type<T0>(
323
+ arg0: TypeDescriptor<T0> = ANY_TYPE
324
+ ): TypeDescriptor<Coin<T0>> {
325
+ return TYPE.apply(arg0);
326
+ }
327
+ }
306
328
 
307
329
  export interface CoinMetadata<T0> {
308
330
  id: object_.UID;
@@ -1176,6 +1198,15 @@ export namespace math {}
1176
1198
 
1177
1199
  export namespace object_ {
1178
1200
  export type ID = string;
1201
+ export namespace ID {
1202
+ export const TYPE_QNAME = "0x2::object::ID";
1203
+
1204
+ const TYPE = new TypeDescriptor<ID>(ID.TYPE_QNAME);
1205
+
1206
+ export function type(): TypeDescriptor<ID> {
1207
+ return TYPE.apply();
1208
+ }
1209
+ }
1179
1210
 
1180
1211
  export interface UID {
1181
1212
  id: object_.ID;
@@ -46,20 +46,25 @@ class SuiCodegen extends AbstractCodegen<SuiNetwork, SuiMoveNormalizedModule, Su
46
46
  }
47
47
 
48
48
  generateStructs(module: InternalMoveModule, struct: InternalMoveStruct, events: Set<string>): string {
49
+ let content = ''
49
50
  switch (structQname(module, struct)) {
50
51
  // TODO they should still have module code generated
51
52
  case '0x1::ascii::Char':
52
53
  case '0x1::ascii::String':
53
54
  case '0x2::object::ID':
54
- return `export type ${struct.name} = string`
55
+ content += `export type ${struct.name} = string`
56
+ break
55
57
  case '0x2::coin::Coin':
56
- return `export type ${struct.name}<T> = string`
58
+ content += `export type ${struct.name}<T> = string`
59
+ break
57
60
  case '0x2::balance::Balance':
58
- return `export type ${struct.name}<T> = bigint`
61
+ content += `export type ${struct.name}<T> = bigint`
62
+ break
59
63
  case '0x1::option::Option':
60
- return `export type Option<T> = T | undefined`
64
+ content += `export type Option<T> = T | undefined`
65
+ break
61
66
  }
62
- return super.generateStructs(module, struct, events)
67
+ return content + super.generateStructs(module, struct, events, content !== '')
63
68
  }
64
69
 
65
70
  generateOnEvents(module: InternalMoveModule, struct: InternalMoveStruct): string {