@0xobelisk/sui-common 0.5.19 → 0.5.21

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,69 +1,75 @@
1
1
  import { SchemaType, DubheConfig } from '../../types';
2
2
  import { rmdirSync, existsSync } from 'fs';
3
3
  import { deleteFolderRecursive } from './common';
4
- import { generateSystem } from './generateSystem';
5
4
  import { generateToml } from './generateToml';
6
5
  import { generateSchemaData, generateSchemaStructure } from './generateSchema';
7
6
  import { generateDeployHook, generateMigrate } from './generateScript';
8
7
  import { generateDappKey } from './generateDappKey';
8
+ import { generateSchemaEvent } from './generateEvent';
9
+ import { generateSystem } from './generateSystem';
10
+ import { generateSchemaHub } from './generateSchemaHub';
9
11
 
10
12
  function matchFrameworkId(
11
- network: 'mainnet' | 'testnet' | 'devnet' | 'localnet'
13
+ network: 'mainnet' | 'testnet' | 'devnet' | 'localnet',
12
14
  ): string {
13
- switch (network) {
14
- case 'testnet':
15
- return '0x1736475f476c5dec96f33c03c778843f572239d3a887d795eef66d2836484c28';
16
- case 'localnet':
17
- return '0x1736475f476c5dec96f33c03c778843f572239d3a887d795eef66d2836484c28';
18
- default:
19
- return '0x1736475f476c5dec96f33c03c778843f572239d3a887d795eef66d2836484c28';
20
- }
15
+ switch (network) {
16
+ case 'testnet':
17
+ return '0x417ad1864a56a29ad0b5aaddd2e11bac1eeab6a68883ef53184a4cc5c293fec6';
18
+ case 'localnet':
19
+ return '0x417ad1864a56a29ad0b5aaddd2e11bac1eeab6a68883ef53184a4cc5c293fec6';
20
+ default:
21
+ return '0x417ad1864a56a29ad0b5aaddd2e11bac1eeab6a68883ef53184a4cc5c293fec6';
22
+ }
21
23
  }
22
24
 
23
25
  export async function schemaGen(
24
- config: DubheConfig,
25
- srcPrefix?: string,
26
- network?: 'mainnet' | 'testnet' | 'devnet' | 'localnet',
27
- frameworkId?: string
26
+ config: DubheConfig,
27
+ srcPrefix?: string,
28
+ network?: 'mainnet' | 'testnet' | 'devnet' | 'localnet',
29
+ frameworkId?: string,
28
30
  ) {
29
- console.log('\nšŸš€ Starting Schema Generation Process...');
30
- console.log('šŸ“‹ Project Configuration:');
31
- console.log(` ā”œā”€ Name: ${config.name}`);
32
- console.log(
33
- ` ā”œā”€ Description: ${config.description || 'No description provided'}`
34
- );
35
- console.log(` ā”œā”€ Network: ${network || 'testnet'}`);
36
- console.log(
37
- ` └─ Framework ID: ${
38
- frameworkId || matchFrameworkId(network ?? 'testnet')
39
- }\n`
40
- );
31
+ console.log('\nšŸš€ Starting Schema Generation Process...');
32
+ console.log('šŸ“‹ Project Configuration:');
33
+ console.log(` ā”œā”€ Name: ${config.name}`);
34
+ console.log(
35
+ ` ā”œā”€ Description: ${config.description || 'No description provided'}`,
36
+ );
37
+ console.log(` ā”œā”€ Network: ${network || 'testnet'}`);
38
+ console.log(
39
+ ` └─ Framework ID: ${
40
+ frameworkId || matchFrameworkId(network ?? 'testnet')
41
+ }\n`,
42
+ );
43
+
44
+ const path = srcPrefix ?? process.cwd();
41
45
 
42
- const path = srcPrefix ?? process.cwd();
46
+ frameworkId = frameworkId || matchFrameworkId(network ?? 'testnet');
43
47
 
44
- frameworkId = frameworkId || matchFrameworkId(network ?? 'testnet');
48
+ if (existsSync(`${path}/contracts/${config.name}`)) {
49
+ deleteFolderRecursive(
50
+ `${path}/contracts/${config.name}/sources/codegen`,
51
+ );
52
+ }
45
53
 
46
- if (existsSync(`${path}/contracts/${config.name}`)) {
47
- deleteFolderRecursive(
48
- `${path}/contracts/${config.name}/sources/codegen`
49
- );
50
- }
54
+ if (!existsSync(`${path}/contracts/${config.name}/Move.toml`)) {
55
+ await generateToml(config, path, frameworkId);
56
+ }
51
57
 
52
- if (!existsSync(`${path}/contracts/${config.name}/Move.toml`)) {
53
- await generateToml(config, path, frameworkId);
54
- }
58
+ if (
59
+ !existsSync(
60
+ `${path}/contracts/${config.name}/sources/script/deploy_hook.move`,
61
+ )
62
+ ) {
63
+ await generateDeployHook(config, path);
64
+ }
55
65
 
56
- if (
57
- !existsSync(
58
- `${path}/contracts/${config.name}/sources/script/deploy_hook.move`
59
- )
60
- ) {
61
- await generateDeployHook(config, path);
62
- }
66
+ await generateSchemaData(config.name, config.schemas, path);
67
+ await generateSchemaStructure(config.name, config.schemas, path);
68
+ await generateSchemaEvent(config.name, config.schemas, path);
69
+ await generateDappKey(config, path);
70
+ await generateSchemaHub(config, path);
71
+ await generateSystem(config, path);
72
+ await generateMigrate(config, path);
63
73
 
64
- await generateSystem(config, path);
65
- await generateSchemaData(config.name, config.schemas, path);
66
- await generateSchemaStructure(config.name, config.schemas, path);
67
- await generateDappKey(config, path);
68
- console.log('āœ… Schema Generation Process Complete!\n');
74
+ console.log('āœ… Schema Generation Process Complete!\n');
69
75
  }