@typemove/move 1.0.0-rc.4 → 1.0.0-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.
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ export * from './types.js';
2
+ export * from './utils.js';
3
+ export * from './account.js';
4
+ export * from './chain-adapter.js';
5
+ export * from './abstract-codegen.js';
6
+ export * from './abstract-move-coder.js';
7
+ export * from './internal-models.js';
8
+ //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,13 +1,18 @@
1
1
  {
2
2
  "name": "@typemove/move",
3
- "version": "1.0.0-rc.4",
3
+ "version": "1.0.0-rc.5",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
+ "exports": {
7
+ ".": "./dist/index.js"
8
+ },
9
+ "main": "./dist/index.js",
6
10
  "files": [
7
11
  "{lib,src}",
8
12
  "!**/*.test.{js,ts}",
9
13
  "!{lib,src}/*/tests"
10
14
  ],
15
+ "types": "./dist/index.d.ts",
11
16
  "dependencies": {
12
17
  "chalk": "^5.2.0",
13
18
  "radash": "^11.0.0"
@@ -189,7 +189,7 @@ export abstract class AbstractCodegen<NetworkType, ModuleTypes, StructType> {
189
189
  rootFileContent += `export * as _${parsed.name.replaceAll(
190
190
  '-',
191
191
  '_'
192
- )} from './${parsed.name}${this.maybeEsmPrefix()}\n`
192
+ )} from './${parsed.name}${this.maybeEsmPrefix()}'\n`
193
193
  }
194
194
  fs.writeFileSync(rootFile, rootFileContent)
195
195
 
@@ -204,17 +204,25 @@ export abstract class AbstractCodegen<NetworkType, ModuleTypes, StructType> {
204
204
  return 'MAIN_NET'
205
205
  }
206
206
 
207
+ protected generateModuleExtra(
208
+ module: InternalMoveModule,
209
+ allEventStructs: Map<string, InternalMoveStruct>,
210
+ network: NetworkType
211
+ ) {
212
+ return ''
213
+ }
214
+
207
215
  generateModule(
208
216
  module: InternalMoveModule,
209
217
  allEventStructs: Map<string, InternalMoveStruct>,
210
218
  network: NetworkType
211
219
  ) {
212
220
  const qname = moduleQname(module)
213
- const functions = this.GENERATE_ON_ENTRY
214
- ? module.exposedFunctions
215
- .map((f) => this.generateForEntryFunctions(module, f))
216
- .filter((s) => s !== '')
217
- : []
221
+ // const functions = this.GENERATE_ON_ENTRY
222
+ // ? module.exposedFunctions
223
+ // .map((f) => this.generateForEntryFunctions(module, f))
224
+ // .filter((s) => s !== '')
225
+ // : []
218
226
  const clientFunctions = this.GENERATE_CLIENT
219
227
  ? module.exposedFunctions
220
228
  .map((f) => this.generateClientFunctions(module, f))
@@ -239,53 +247,25 @@ export abstract class AbstractCodegen<NetworkType, ModuleTypes, StructType> {
239
247
  )
240
248
 
241
249
  const moduleName = normalizeToJSName(module.name)
242
- let processor = ''
243
250
  let client = ''
244
251
 
245
252
  if (clientFunctions.length > 0) {
246
253
  client = `
247
- export class ${moduleName}_client extends ModuleClient {
254
+ export class Client extends ModuleClient {
248
255
  ${clientFunctions.join('\n')}
249
256
  }
250
257
  `
251
258
  }
252
259
 
253
- if (functions.length > 0 || events.length > 0) {
254
- processor = `export class ${moduleName} extends ${
255
- this.PREFIX
256
- }BaseProcessor {
257
-
258
- constructor(options: ${this.PREFIX}BindOptions) {
259
- super("${module.name}", options)
260
- }
261
- static DEFAULT_OPTIONS: ${this.PREFIX}BindOptions = {
262
- address: "${module.address}",
263
- network: ${this.PREFIX}Network.${this.generateNetworkOption(network)}
264
- }
265
-
266
- static bind(options: Partial<${
267
- this.PREFIX
268
- }BindOptions> = {}): ${moduleName} {
269
- return new ${moduleName}({ ...${moduleName}.DEFAULT_OPTIONS, ...options })
270
- }
271
-
272
- ${functions.join('\n')}
273
-
274
- ${events.join('\n')}
275
- }
276
- `
277
- }
278
-
260
+ // TODO how to deal with callArgs
279
261
  return `
280
- ${client}
281
-
282
- ${processor}
262
+ ${this.generateModuleExtra(module, allEventStructs, network)}
283
263
 
284
264
  export namespace ${moduleName} {
285
265
  ${structs.join('\n')}
286
-
287
- ${callArgs.join('\n')}
288
- }
266
+
267
+ ${client}
268
+ }
289
269
  `
290
270
  }
291
271
 
@@ -446,12 +426,12 @@ export abstract class AbstractCodegen<NetworkType, ModuleTypes, StructType> {
446
426
  return source
447
427
  }
448
428
 
449
- generateForEntryFunctions(
450
- module: InternalMoveModule,
451
- func: InternalMoveFunction
452
- ) {
453
- return ''
454
- }
429
+ // generateForEntryFunctions(
430
+ // module: InternalMoveModule,
431
+ // func: InternalMoveFunction
432
+ // ) {
433
+ // return ''
434
+ // }
455
435
 
456
436
  generateForEvents(
457
437
  module: InternalMoveModule,
@@ -671,7 +651,7 @@ export class AccountCodegen<NetworkType, ModuleType, StructType> {
671
651
  const imports = `
672
652
  import { TypeDescriptor, ANY_TYPE } from "@typemove/move"
673
653
  import {
674
- MoveCoder, defaultMoveCoder, ${
654
+ MoveCoder, defaultMoveCoder, TypedEventInstance, ${
675
655
  this.moduleGen.PREFIX
676
656
  }Network } from "@typemove/${this.moduleGen.PREFIX.toLowerCase()}"
677
657
  import { ${
package/src/index.ts CHANGED
@@ -2,3 +2,6 @@ export * from './types.js'
2
2
  export * from './utils.js'
3
3
  export * from './account.js'
4
4
  export * from './chain-adapter.js'
5
+ export * from './abstract-codegen.js'
6
+ export * from './abstract-move-coder.js'
7
+ export * from './internal-models.js'