@0xobelisk/sui-cli 1.2.0-pre.4 → 1.2.0-pre.41

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,141 +1,141 @@
1
- import { loadMetadata } from '@0xobelisk/sui-client';
2
- import { DubheCliError } from './errors';
3
- import { getOldPackageId, getSchemaId, initializeDubhe } from './utils';
4
- import { DubheConfig } from '@0xobelisk/sui-common';
5
- import * as fs from 'fs';
6
- import * as path from 'path';
7
-
8
- function validateParams(storageType: string, params: any[]): boolean {
9
- const formatStorageType = storageType.split('<')[0].trim();
10
- switch (formatStorageType) {
11
- case 'StorageValue':
12
- return params.length === 0;
13
- case 'StorageMap':
14
- return params.length === 1;
15
- case 'StorageDoubleMap':
16
- return params.length === 2;
17
- default:
18
- return false;
19
- }
20
- }
21
-
22
- function getExpectedParamsCount(storageType: string): number {
23
- const formatStorageType = storageType.split('<')[0].trim();
24
- switch (formatStorageType) {
25
- case 'StorageValue':
26
- return 0;
27
- case 'StorageMap':
28
- return 1;
29
- case 'StorageDoubleMap':
30
- return 2;
31
- default:
32
- return 0;
33
- }
34
- }
35
-
36
- export async function queryStorage({
37
- dubheConfig,
38
- schema,
39
- params,
40
- network,
41
- objectId,
42
- packageId,
43
- metadataFilePath
44
- }: {
45
- dubheConfig: DubheConfig;
46
- schema: string;
47
- params?: any[];
48
- network: 'mainnet' | 'testnet' | 'devnet' | 'localnet';
49
- objectId?: string;
50
- packageId?: string;
51
- metadataFilePath?: string;
52
- }) {
53
- const path = process.cwd();
54
- const projectPath = `${path}/contracts/${dubheConfig.name}`;
55
-
56
- packageId = packageId || (await getOldPackageId(projectPath, network));
57
-
58
- objectId = objectId || (await getSchemaId(projectPath, network));
59
-
60
- let metadata;
61
- if (metadataFilePath) {
62
- metadata = await loadMetadataFromFile(metadataFilePath);
63
- } else {
64
- metadata = await loadMetadata(network, packageId);
65
- }
66
- if (!metadata) {
67
- throw new DubheCliError(
68
- `Metadata file not found. Please provide a metadata file path or set the packageId.`
69
- );
70
- }
71
-
72
- if (!dubheConfig.schemas[schema]) {
73
- throw new DubheCliError(
74
- `Schema "${schema}" not found in dubhe config. Available schemas: ${Object.keys(
75
- dubheConfig.schemas
76
- ).join(', ')}`
77
- );
78
- }
79
-
80
- const storageType = dubheConfig.schemas[schema];
81
-
82
- const processedParams = params || [];
83
- if (!validateParams(storageType, processedParams)) {
84
- throw new Error(
85
- `Invalid params count for ${storageType}. ` +
86
- `Expected: ${getExpectedParamsCount(storageType)}, ` +
87
- `Got: ${processedParams.length}`
88
- );
89
- }
90
-
91
- const dubhe = initializeDubhe({
92
- network,
93
- packageId,
94
- metadata
95
- });
96
- const result = await dubhe.parseState({
97
- schema,
98
- objectId,
99
- storageType,
100
- params: processedParams
101
- });
102
-
103
- console.log(result);
104
- }
105
-
106
- /**
107
- * Load metadata from a JSON file and construct the metadata structure
108
- * @param metadataFilePath Path to the metadata JSON file
109
- * @param network Network type
110
- * @param packageId Package ID
111
- * @returns Constructed metadata object
112
- */
113
- export async function loadMetadataFromFile(metadataFilePath: string) {
114
- // Verify file extension is .json
115
- if (path.extname(metadataFilePath) !== '.json') {
116
- throw new Error('Metadata file must be in JSON format');
117
- }
118
-
119
- try {
120
- // Read JSON file content
121
- const rawData = fs.readFileSync(metadataFilePath, 'utf8');
122
- const jsonData = JSON.parse(rawData);
123
-
124
- // Validate JSON structure
125
- if (!jsonData || typeof jsonData !== 'object') {
126
- throw new Error('Invalid JSON format');
127
- }
128
-
129
- // Construct metadata structure
130
- const metadata = {
131
- ...jsonData
132
- };
133
-
134
- return metadata;
135
- } catch (error) {
136
- if (error instanceof Error) {
137
- throw new Error(`Failed to read metadata file: ${error.message}`);
138
- }
139
- throw error;
140
- }
141
- }
1
+ // import { loadMetadata } from '@0xobelisk/sui-client';
2
+ // import { DubheCliError } from './errors';
3
+ // import { getOldPackageId, getSchemaId, initializeDubhe } from './utils';
4
+ // import { DubheConfig } from '@0xobelisk/sui-common';
5
+ // import * as fs from 'fs';
6
+ // import * as path from 'path';
7
+
8
+ // function validateParams(storageType: string, params: any[]): boolean {
9
+ // const formatStorageType = storageType.split('<')[0].trim();
10
+ // switch (formatStorageType) {
11
+ // case 'StorageValue':
12
+ // return params.length === 0;
13
+ // case 'StorageMap':
14
+ // return params.length === 1;
15
+ // case 'StorageDoubleMap':
16
+ // return params.length === 2;
17
+ // default:
18
+ // return false;
19
+ // }
20
+ // }
21
+
22
+ // function getExpectedParamsCount(storageType: string): number {
23
+ // const formatStorageType = storageType.split('<')[0].trim();
24
+ // switch (formatStorageType) {
25
+ // case 'StorageValue':
26
+ // return 0;
27
+ // case 'StorageMap':
28
+ // return 1;
29
+ // case 'StorageDoubleMap':
30
+ // return 2;
31
+ // default:
32
+ // return 0;
33
+ // }
34
+ // }
35
+
36
+ // export async function queryStorage({
37
+ // dubheConfig,
38
+ // schema,
39
+ // params,
40
+ // network,
41
+ // objectId,
42
+ // packageId,
43
+ // metadataFilePath
44
+ // }: {
45
+ // dubheConfig: DubheConfig;
46
+ // schema: string;
47
+ // params?: any[];
48
+ // network: 'mainnet' | 'testnet' | 'devnet' | 'localnet';
49
+ // objectId?: string;
50
+ // packageId?: string;
51
+ // metadataFilePath?: string;
52
+ // }) {
53
+ // const path = process.cwd();
54
+ // const projectPath = `${path}/src/${dubheConfig.name}`;
55
+
56
+ // packageId = packageId || (await getOldPackageId(projectPath, network));
57
+
58
+ // objectId = objectId || (await getSchemaId(projectPath, network));
59
+
60
+ // let metadata;
61
+ // if (metadataFilePath) {
62
+ // metadata = await loadMetadataFromFile(metadataFilePath);
63
+ // } else {
64
+ // metadata = await loadMetadata(network, packageId);
65
+ // }
66
+ // if (!metadata) {
67
+ // throw new DubheCliError(
68
+ // `Metadata file not found. Please provide a metadata file path or set the packageId.`
69
+ // );
70
+ // }
71
+
72
+ // if (!dubheConfig.schemas[schema]) {
73
+ // throw new DubheCliError(
74
+ // `Schema "${schema}" not found in dubhe config. Available schemas: ${Object.keys(
75
+ // dubheConfig.schemas
76
+ // ).join(', ')}`
77
+ // );
78
+ // }
79
+
80
+ // const storageType = dubheConfig.schemas[schema];
81
+
82
+ // const processedParams = params || [];
83
+ // if (!validateParams(storageType, processedParams)) {
84
+ // throw new Error(
85
+ // `Invalid params count for ${storageType}. ` +
86
+ // `Expected: ${getExpectedParamsCount(storageType)}, ` +
87
+ // `Got: ${processedParams.length}`
88
+ // );
89
+ // }
90
+
91
+ // const dubhe = initializeDubhe({
92
+ // network,
93
+ // packageId,
94
+ // metadata
95
+ // });
96
+ // const result = await dubhe.parseState({
97
+ // schema,
98
+ // objectId,
99
+ // storageType,
100
+ // params: processedParams
101
+ // });
102
+
103
+ // console.log(result);
104
+ // }
105
+
106
+ // /**
107
+ // * Load metadata from a JSON file and construct the metadata structure
108
+ // * @param metadataFilePath Path to the metadata JSON file
109
+ // * @param network Network type
110
+ // * @param packageId Package ID
111
+ // * @returns Constructed metadata object
112
+ // */
113
+ // export async function loadMetadataFromFile(metadataFilePath: string) {
114
+ // // Verify file extension is .json
115
+ // if (path.extname(metadataFilePath) !== '.json') {
116
+ // throw new Error('Metadata file must be in JSON format');
117
+ // }
118
+
119
+ // try {
120
+ // // Read JSON file content
121
+ // const rawData = fs.readFileSync(metadataFilePath, 'utf8');
122
+ // const jsonData = JSON.parse(rawData);
123
+
124
+ // // Validate JSON structure
125
+ // if (!jsonData || typeof jsonData !== 'object') {
126
+ // throw new Error('Invalid JSON format');
127
+ // }
128
+
129
+ // // Construct metadata structure
130
+ // const metadata = {
131
+ // ...jsonData
132
+ // };
133
+
134
+ // return metadata;
135
+ // } catch (error) {
136
+ // if (error instanceof Error) {
137
+ // throw new Error(`Failed to read metadata file: ${error.message}`);
138
+ // }
139
+ // throw error;
140
+ // }
141
+ // }
@@ -1,20 +1,106 @@
1
1
  import { execSync, spawn } from 'child_process';
2
2
  import chalk from 'chalk';
3
3
  import { printDubhe } from './printDubhe';
4
- import { existsSync, mkdirSync, appendFileSync } from 'fs';
5
- import { join } from 'path';
4
+ import { delay, DubheCliError, validatePrivateKey } from '../utils';
5
+ import { Dubhe } from '@0xobelisk/sui-client';
6
+ import * as fs from 'fs';
7
+
8
+ export function stopLocalNode(): void {
9
+ console.log(chalk.yellow('🔔 Stopping existing Local Node...'));
10
+
11
+ let processStopped = false;
12
+
13
+ if (process.platform === 'win32') {
14
+ // Windows: Kill all sui.exe processes
15
+ try {
16
+ execSync('taskkill /F /IM sui.exe', { stdio: 'ignore' });
17
+ processStopped = true;
18
+ } catch (error) {
19
+ // Process not found
20
+ }
21
+ } else {
22
+ // Unix-like systems: Try multiple patterns to find sui processes
23
+ const patterns = [
24
+ 'sui start', // Exact match
25
+ 'sui.*start', // Pattern with any flags
26
+ '^sui', // Any sui command
27
+ 'sui.*--with-faucet' // Match our specific startup pattern
28
+ ];
29
+
30
+ for (const pattern of patterns) {
31
+ try {
32
+ const result = execSync(`pgrep -f "${pattern}"`, { stdio: 'pipe' }).toString().trim();
33
+ if (result) {
34
+ const pids = result.split('\n').filter((pid) => pid);
35
+ console.log(chalk.cyan(` ├─ Found ${pids.length} process(es) matching "${pattern}"`));
36
+
37
+ pids.forEach((pid) => {
38
+ try {
39
+ // First try graceful termination
40
+ execSync(`kill -TERM ${pid}`, { stdio: 'ignore' });
41
+ console.log(chalk.cyan(` ├─ Sent SIGTERM to process ${pid}`));
42
+ } catch (error) {
43
+ // If graceful termination fails, force kill
44
+ try {
45
+ execSync(`kill -KILL ${pid}`, { stdio: 'ignore' });
46
+ console.log(chalk.cyan(` ├─ Force killed process ${pid}`));
47
+ } catch (killError) {
48
+ console.log(chalk.gray(` ├─ Process ${pid} already terminated`));
49
+ }
50
+ }
51
+ });
52
+ processStopped = true;
53
+ break; // Stop after first successful pattern match
54
+ }
55
+ } catch (error) {
56
+ // This pattern didn't match any processes, continue to next pattern
57
+ continue;
58
+ }
59
+ }
60
+ }
61
+
62
+ if (processStopped) {
63
+ console.log(chalk.green(' └─ Local Node stopped successfully'));
64
+ } else {
65
+ console.log(chalk.gray(' └─ No running Local Node found'));
66
+ }
67
+ }
68
+
69
+ export function removeDirectory(dirPath: string): void {
70
+ try {
71
+ if (fs.existsSync(dirPath)) {
72
+ console.log(chalk.yellow(`🗑️ Removing directory: ${dirPath}`));
73
+ fs.rmSync(dirPath, { recursive: true, force: true });
74
+ console.log(chalk.green(' └─ Directory removed successfully'));
75
+ } else {
76
+ console.log(chalk.gray(` └─ Directory ${dirPath} does not exist`));
77
+ }
78
+ } catch (error: any) {
79
+ console.error(chalk.red(` └─ Error removing directory: ${error.message}`));
80
+ }
81
+ }
6
82
 
7
83
  function isSuiStartRunning(): boolean {
8
84
  try {
9
- const cmd =
10
- process.platform === 'win32'
11
- ? `tasklist /FI "IMAGENAME eq sui.exe" /FO CSV /NH`
12
- : 'pgrep -f "sui start"';
13
-
14
- const result = execSync(cmd).toString().trim();
15
- return process.platform === 'win32'
16
- ? result.toLowerCase().includes('sui.exe')
17
- : result.length > 0;
85
+ if (process.platform === 'win32') {
86
+ const result = execSync(`tasklist /FI "IMAGENAME eq sui.exe" /FO CSV /NH`).toString().trim();
87
+ return result.toLowerCase().includes('sui.exe');
88
+ } else {
89
+ // Try multiple patterns to detect running sui processes
90
+ const patterns = ['sui start', 'sui.*start', '^sui', 'sui.*--with-faucet'];
91
+
92
+ for (const pattern of patterns) {
93
+ try {
94
+ const result = execSync(`pgrep -f "${pattern}"`, { stdio: 'pipe' }).toString().trim();
95
+ if (result && result.length > 0) {
96
+ return true;
97
+ }
98
+ } catch (error) {
99
+ continue;
100
+ }
101
+ }
102
+ return false;
103
+ }
18
104
  } catch (error) {
19
105
  return false;
20
106
  }
@@ -22,37 +108,39 @@ function isSuiStartRunning(): boolean {
22
108
 
23
109
  async function printAccounts() {
24
110
  // These private keys are used for testing purposes only, do not use them in production.
25
- const accounts = [
26
- {
27
- privateKey: 'suiprivkey1qq3ez3dje66l8pypgxynr7yymwps6uhn7vyczespj84974j3zya0wdpu76v',
28
- address: '0xe7f93ad7493035bcd674f287f78526091e195a6df9d64f23def61a7ce3adada9'
29
- },
30
- {
31
- privateKey: 'suiprivkey1qp6vcyg8r2x88fllmjmxtpzjl95gd9dugqrgz7xxf50w6rqdqzetg7x4d7s',
32
- address: '0x492404a537c32b46610bd6ae9f7f16ba16ff5a607d272543fe86cada69d8cf44'
33
- },
34
- {
35
- privateKey: 'suiprivkey1qpy3a696eh3m55fwa8h38ss063459u4n2dm9t24w2hlxxzjp2x34q8sdsnc',
36
- address: '0xd27e203483700d837a462d159ced6104619d8e36f737bf2a20c251153bf39f24'
37
- },
38
- {
39
- privateKey: 'suiprivkey1qzxwp29favhzrjd95f6uj9nskjwal6nh9g509jpun395y6g72d6jqlmps4c',
40
- address: '0x018f1f175c9b6739a14bc9c81e7984c134ebf9031015cf796fefcef04b8c4990'
41
- },
42
- {
43
- privateKey: 'suiprivkey1qzhq4lv38sesah4uzsqkkmeyjx860xqjdz8qgw36tmrdd5tnle3evxpng57',
44
- address: '0x932f6aab2bc636a25374f99794dc8451c4e27c91e87083e301816ed08bc98ed0'
45
- },
46
- {
47
- privateKey: 'suiprivkey1qzez45sjjsepjgtksqvpq6jw7dzw3zq0dx7a4sulfypd73acaynw5jl9x2c',
48
- address: '0x9a66b2da3036badd22529e3de8a00b0cd7dbbfe589873aa03d5f885f5f8c6501'
49
- }
111
+ const privateKeys = [
112
+ 'suiprivkey1qq3ez3dje66l8pypgxynr7yymwps6uhn7vyczespj84974j3zya0wdpu76v',
113
+ 'suiprivkey1qp6vcyg8r2x88fllmjmxtpzjl95gd9dugqrgz7xxf50w6rqdqzetg7x4d7s',
114
+ 'suiprivkey1qpy3a696eh3m55fwa8h38ss063459u4n2dm9t24w2hlxxzjp2x34q8sdsnc',
115
+ 'suiprivkey1qzxwp29favhzrjd95f6uj9nskjwal6nh9g509jpun395y6g72d6jqlmps4c',
116
+ 'suiprivkey1qzhq4lv38sesah4uzsqkkmeyjx860xqjdz8qgw36tmrdd5tnle3evxpng57',
117
+ 'suiprivkey1qzez45sjjsepjgtksqvpq6jw7dzw3zq0dx7a4sulfypd73acaynw5jl9x2c'
50
118
  ];
51
119
  console.log('📝Accounts');
52
120
  console.log('==========');
53
- accounts.forEach((account, index) => {
54
- console.log(` ┌─ Account #${index}: ${account.address}(100000 SUI)`);
55
- console.log(` └─ Private Key: ${account.privateKey}`);
121
+ privateKeys.forEach((privateKey, index) => {
122
+ const dubhe = new Dubhe({ secretKey: privateKey });
123
+ const keypair = dubhe.getSigner();
124
+ spawn(
125
+ 'curl',
126
+ [
127
+ '--location',
128
+ '--request',
129
+ 'POST',
130
+ 'http://127.0.0.1:9123/gas',
131
+ '--header',
132
+ 'Content-Type: application/json',
133
+ '--data-raw',
134
+ `{"FixedAmountRequest": {"recipient": "${keypair.toSuiAddress()}"}}`
135
+ ],
136
+ {
137
+ env: { ...process.env },
138
+ stdio: 'ignore',
139
+ detached: true
140
+ }
141
+ );
142
+ console.log(` ┌─ Account #${index}: ${keypair.toSuiAddress()}(1000 SUI)`);
143
+ console.log(` └─ Private Key: ${privateKey}`);
56
144
  });
57
145
  console.log('==========');
58
146
  console.log(
@@ -63,51 +151,6 @@ async function printAccounts() {
63
151
  );
64
152
  }
65
153
 
66
- async function setupDirectories() {
67
- const nodeLogsDir = join(process.cwd(), 'node_logs');
68
- const logsDir = join(nodeLogsDir, 'logs');
69
-
70
- if (!existsSync(nodeLogsDir)) {
71
- mkdirSync(nodeLogsDir, { recursive: true });
72
- }
73
-
74
- if (!existsSync(logsDir)) {
75
- mkdirSync(logsDir, { recursive: true });
76
- }
77
-
78
- return { nodeLogsDir, logsDir };
79
- }
80
-
81
- async function generateGenesisConfig(nodeLogsDir: string, logsDir: string) {
82
- console.log(' ├─ Generating genesis configuration...');
83
- execSync(`sui genesis --write-config ${join(nodeLogsDir, 'sui.yaml')}`);
84
-
85
- const additionalConfig = `
86
- - address: "0xe7f93ad7493035bcd674f287f78526091e195a6df9d64f23def61a7ce3adada9"
87
- gas_amounts:
88
- - 100000000000000
89
- - address: "0x492404a537c32b46610bd6ae9f7f16ba16ff5a607d272543fe86cada69d8cf44"
90
- gas_amounts:
91
- - 100000000000000
92
- - address: "0xd27e203483700d837a462d159ced6104619d8e36f737bf2a20c251153bf39f24"
93
- gas_amounts:
94
- - 100000000000000
95
- - address: "0x018f1f175c9b6739a14bc9c81e7984c134ebf9031015cf796fefcef04b8c4990"
96
- gas_amounts:
97
- - 100000000000000
98
- - address: "0x932f6aab2bc636a25374f99794dc8451c4e27c91e87083e301816ed08bc98ed0"
99
- gas_amounts:
100
- - 100000000000000
101
- - address: "0x9a66b2da3036badd22529e3de8a00b0cd7dbbfe589873aa03d5f885f5f8c6501"
102
- gas_amounts:
103
- - 100000000000000
104
- `;
105
- appendFileSync(join(nodeLogsDir, 'sui.yaml'), additionalConfig);
106
-
107
- console.log(' ├─ Initializing genesis...');
108
- execSync(`sui genesis --working-dir ${logsDir} -f --from-config ${join(nodeLogsDir, 'sui.yaml')}`);
109
- }
110
-
111
154
  function handleProcessSignals(suiProcess: ReturnType<typeof spawn> | null) {
112
155
  const cleanup = () => {
113
156
  console.log(chalk.yellow('\n🔔 Stopping Local Node...'));
@@ -121,8 +164,15 @@ function handleProcessSignals(suiProcess: ReturnType<typeof spawn> | null) {
121
164
  process.on('SIGTERM', cleanup);
122
165
  }
123
166
 
124
- export async function startLocalNode(options: { forceRegenesis?: boolean } = {}) {
125
- if (isSuiStartRunning()) {
167
+ export async function startLocalNode(data_dir: string, force?: boolean) {
168
+ if (force) {
169
+ console.log(chalk.cyan('\n🔄 Force mode enabled'));
170
+ stopLocalNode();
171
+ console.log(chalk.yellow(' ├─ Waiting for processes to terminate...'));
172
+ await delay(3000); // Wait longer for process to fully stop
173
+ removeDirectory(data_dir);
174
+ console.log('');
175
+ } else if (isSuiStartRunning()) {
126
176
  console.log(chalk.yellow('\n⚠️ Warning: Local Node Already Running'));
127
177
  console.log(chalk.yellow(' ├─ Cannot start a new instance'));
128
178
  console.log(chalk.yellow(' └─ Please stop the existing process first'));
@@ -131,34 +181,39 @@ export async function startLocalNode(options: { forceRegenesis?: boolean } = {})
131
181
 
132
182
  printDubhe();
133
183
  console.log('🚀 Starting Local Node...');
134
-
135
184
  let suiProcess: ReturnType<typeof spawn> | null = null;
136
-
137
185
  try {
138
- const { nodeLogsDir, logsDir } = await setupDirectories();
186
+ suiProcess = spawn(
187
+ 'sui',
188
+ ['start', '--with-faucet', '--force-regenesis', '--data-ingestion-dir', data_dir],
189
+ {
190
+ env: { ...process.env, RUST_LOG: 'off,sui_node=info' },
191
+ stdio: 'ignore'
192
+ }
193
+ );
139
194
 
140
- if (options.forceRegenesis) {
141
- console.log(' ├─ Force Regenesis: Yes');
142
- await generateGenesisConfig(nodeLogsDir, logsDir);
143
- } else {
144
- console.log(' ├─ Force Regenesis: No');
145
- }
146
-
195
+ suiProcess.on('error', (error) => {
196
+ console.error(chalk.red('\n❌ Failed to Start Local Node'));
197
+ console.error(chalk.red(` └─ Error: ${error.message}`));
198
+ });
199
+ await delay(5000);
147
200
  console.log(' ├─ Faucet: Enabled');
201
+ console.log(' └─ Force Regenesis: Yes');
148
202
  console.log(' └─ HTTP server: http://127.0.0.1:9000/');
149
203
  console.log(' └─ Faucet server: http://127.0.0.1:9123/');
204
+
150
205
  await printAccounts();
151
- console.log(chalk.green('🎉 Local environment is ready!'));
152
206
 
153
- suiProcess = spawn('sui', [
154
- 'start',
155
- '--with-faucet',
156
- '--network.config',
157
- join(logsDir, 'network.yaml')
158
- ], {
159
- env: { ...process.env, RUST_LOG: 'off,sui_node=info' },
160
- stdio: 'ignore'
161
- });
207
+ await delay(2000);
208
+
209
+ const privateKeyFormat = validatePrivateKey(
210
+ 'suiprivkey1qzez45sjjsepjgtksqvpq6jw7dzw3zq0dx7a4sulfypd73acaynw5jl9x2c'
211
+ );
212
+ if (privateKeyFormat === false) {
213
+ throw new DubheCliError(`Please check your privateKey.`);
214
+ }
215
+
216
+ console.log(chalk.green('🎉 Local environment is ready!'));
162
217
 
163
218
  handleProcessSignals(suiProcess);
164
219
 
@@ -1,21 +1,15 @@
1
1
  import { mkdirSync, writeFileSync } from 'fs';
2
2
  import { dirname } from 'path';
3
3
  import { DubheConfig } from '@0xobelisk/sui-common';
4
- import { getDeploymentJson, getDubheSchemaId } from './utils';
4
+ import { getDeploymentJson, getDubheDappHub } from './utils';
5
5
 
6
- async function storeConfig(
7
- network: string,
8
- packageId: string,
9
- schemaId: string,
10
- outputPath: string
11
- ) {
12
- const dubheSchemaId = await getDubheSchemaId(network);
6
+ async function storeConfig(network: string, packageId: string, outputPath: string) {
7
+ const dubheDappHub = await getDubheDappHub(network);
13
8
  let code = `type NetworkType = 'testnet' | 'mainnet' | 'devnet' | 'localnet';
14
9
 
15
10
  export const NETWORK: NetworkType = '${network}';
16
11
  export const PACKAGE_ID = '${packageId}';
17
- export const SCHEMA_ID = '${schemaId}';
18
- export const DUBHE_SCHEMA_ID = '${dubheSchemaId}';
12
+ export const DUBHE_SCHEMA_ID = '${dubheDappHub}';
19
13
  `;
20
14
 
21
15
  writeOutput(code, outputPath, 'storeConfig');
@@ -40,7 +34,7 @@ export async function storeConfigHandler(
40
34
  outputPath: string
41
35
  ) {
42
36
  const path = process.cwd();
43
- const contractPath = `${path}/contracts/${dubheConfig.name}`;
37
+ const contractPath = `${path}/src/${dubheConfig.name}`;
44
38
  const deployment = await getDeploymentJson(contractPath, network);
45
- await storeConfig(deployment.network, deployment.packageId, deployment.schemaId, outputPath);
39
+ await storeConfig(deployment.network, deployment.packageId, outputPath);
46
40
  }