@0xobelisk/sui-cli 1.0.7 → 1.0.9

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.
@@ -0,0 +1,232 @@
1
+ import { DubheCliError } from './errors';
2
+ import {delay, getSchemaId} from './utils';
3
+ import { DubheConfig } from '@0xobelisk/sui-common';
4
+ import {getFullnodeUrl, SuiClient, SuiTransactionBlockResponse} from "@mysten/sui/client";
5
+ import sqlite3 from 'sqlite3';
6
+ import {Database, open} from 'sqlite';
7
+ import chalk from "chalk";
8
+
9
+ let sqliteDB: Database;
10
+
11
+ const createDB = async (name: string) => {
12
+ sqliteDB = await open({
13
+ filename: `./${name}.db`,
14
+ driver: sqlite3.Database
15
+ });
16
+ await createTable(sqliteDB, name);
17
+ await createTxsTable(sqliteDB);
18
+ return sqliteDB;
19
+ }
20
+ const createTable = async (sqliteDB: Database, name: string) => {
21
+ let sql = `
22
+ CREATE TABLE IF NOT EXISTS ${name} (
23
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
24
+ last_update_checkpoint TEXT,
25
+ last_update_digest TEXT,
26
+ name TEXT,
27
+ key1 TEXT,
28
+ key2 TEXT,
29
+ value TEXT,
30
+ is_removed BOOLEAN DEFAULT FALSE
31
+ )`;
32
+ await sqliteDB.exec(sql);
33
+ }
34
+
35
+ const createTxsTable = async (sqliteDB: Database) => {
36
+ let sql = `
37
+ CREATE TABLE IF NOT EXISTS dapp_transaction (
38
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
39
+ checkpoint TEXT,
40
+ digest TEXT
41
+ )
42
+ `
43
+ await sqliteDB.exec(sql);
44
+ }
45
+
46
+ type SetRecord = {
47
+ name: string,
48
+ key1: string | object,
49
+ key2: string | object,
50
+ value: string | object
51
+ }
52
+
53
+ type RemoveRecord = {
54
+ name: string,
55
+ key1: string | object,
56
+ key2: string | object,
57
+ }
58
+
59
+ const processSetRecord = async (sqliteDB: Database, dbName: string, checkpoint: string, digest: string, event: unknown) => {
60
+ let res = event as SetRecord;
61
+ if ((typeof res.key1 === 'object' && res.key1 !== null) || Array.isArray(res.key1)) {
62
+ res.key1 = serializeData(res.key1);
63
+ } else if ((typeof res.key2 === 'object' && res.key2 !== null) || Array.isArray(res.key2)) {
64
+ res.key2 = serializeData(res.key2);
65
+ } else if (typeof res.value === 'object' || Array.isArray(res.value)) {
66
+ res.value = serializeData(res.value);
67
+ }
68
+ await insertData(sqliteDB, dbName, {
69
+ checkpoint: checkpoint,
70
+ digest: digest,
71
+ event: res
72
+ });
73
+ }
74
+
75
+ const processRemoveRecord = async (sqliteDB: Database, dbName: string, checkpoint: string, digest: string, event: unknown) => {
76
+ let res = event as RemoveRecord;
77
+ if ((typeof res.key1 === 'object' && res.key1 !== null) || Array.isArray(res.key1)) {
78
+ res.key1 = serializeData(res.key1);
79
+ } else if ((typeof res.key2 === 'object' && res.key2 !== null) || Array.isArray(res.key2)) {
80
+ res.key2 = serializeData(res.key2);
81
+ }
82
+ await removeData(sqliteDB, dbName, {
83
+ checkpoint: checkpoint,
84
+ digest: digest,
85
+ event: res
86
+ });
87
+ }
88
+
89
+ type SetData = {
90
+ checkpoint: string,
91
+ digest: string,
92
+ event: SetRecord
93
+ }
94
+
95
+ type RemoveData = {
96
+ checkpoint: string,
97
+ digest: string,
98
+ event: RemoveRecord
99
+ }
100
+
101
+ const serializeData = (data: object): string => {
102
+ if (data.hasOwnProperty("fields")) {
103
+ // @ts-ignore
104
+ return JSON.stringify(data["fields"]);
105
+ }
106
+ return JSON.stringify(data);
107
+ };
108
+
109
+ async function insertData(sqliteDB: Database, dbName: string, data: SetData) {
110
+ const { checkpoint, digest, event } = data;
111
+
112
+ let sql = `
113
+ INSERT OR REPLACE INTO ${dbName} (id, last_update_checkpoint, last_update_digest, name, key1, key2, value)
114
+ VALUES (
115
+ (SELECT id FROM ${dbName} WHERE name = ? AND (key1 = ? OR key1 IS NULL) AND (key2 = ? OR key2 IS NULL)),
116
+ ?, ?, ?, ?, ?, ?
117
+ )
118
+ `;
119
+
120
+ const values = [event.name, event.key1, event.key2, checkpoint, digest, event.name, event.key1, event.key2, event.value];
121
+
122
+ await sqliteDB.run(sql, values);
123
+ console.log("Insert or update data: ", checkpoint, digest, dbName, data);
124
+ }
125
+
126
+ async function removeData(sqliteDB: Database, dbName: string, data: RemoveData) {
127
+ const { checkpoint, digest, event } = data;
128
+
129
+ let sql = `
130
+ UPDATE ${dbName}
131
+ SET is_removed = TRUE
132
+ WHERE name = ? AND (key1 = ? OR key1 IS NULL) AND (key2 = ? OR key2 IS NULL)
133
+ `;
134
+
135
+ await sqliteDB.run(sql, [event.name, event.key1, event.key2]);
136
+ console.log("Remove data: ", checkpoint, digest, dbName, data);
137
+ }
138
+
139
+ async function insertTx(sqliteDB: Database, checkpoint: string, digest: string) {
140
+ let sql = `
141
+ INSERT INTO dapp_transaction (checkpoint, digest)
142
+ VALUES (?, ?)
143
+ `;
144
+
145
+ await sqliteDB.run(sql, [checkpoint, digest]);
146
+ console.log("Insert transaction: ", checkpoint, digest);
147
+ }
148
+
149
+ async function getLastDigest(sqliteDB: Database): Promise<string | null> {
150
+ const row = await sqliteDB.get(`
151
+ SELECT digest FROM dapp_transaction
152
+ ORDER BY id DESC
153
+ LIMIT 1
154
+ `);
155
+
156
+ return row ? row.digest : null;
157
+ }
158
+
159
+ export async function indexerHandler(
160
+ dubheConfig: DubheConfig,
161
+ network: 'mainnet' | 'testnet' | 'devnet' | 'localnet',
162
+ db: string,
163
+ schemaId: string | undefined,
164
+ ) {
165
+ const path = process.cwd();
166
+ const projectPath = `${path}/contracts/${dubheConfig.name}`;
167
+
168
+ schemaId = schemaId || (await getSchemaId(projectPath, network));
169
+
170
+ console.log('\n🚀 Sqlite Started');
171
+ console.log(` ├─ Project: ${projectPath}`);
172
+ console.log(` ├─ Network: ${network}`);
173
+ console.log(` ├─ Database: ${db}`);
174
+ console.log(` ├─ Schema ID: ${schemaId}`);
175
+
176
+ if (!schemaId) {
177
+ throw new DubheCliError(
178
+ `Schema ID not found. Please provide a schema ID with the --schemaId flag.`
179
+ );
180
+ }
181
+ const client = new SuiClient({url: getFullnodeUrl(network) });
182
+
183
+ if(db === 'sqlite') {
184
+ sqliteDB = await createDB(dubheConfig.name);
185
+ while (true) {
186
+ await delay(2000);
187
+ const cursor = await getLastDigest(sqliteDB)
188
+ const response = await client.queryTransactionBlocks({
189
+ filter: {
190
+ // Transaction: 'FD43PRNS2PyNcYExFxwuouLqTVvonTd6NtDYMiVB7ZxZ'
191
+ // MoveFunction: {
192
+ // package: '0x2dd117c4f48a6be9d2dd20eff67903ebf07080c7e259c7c589078fe21bb78471',
193
+ // module: 'message_system',
194
+ // function: 'send'
195
+ // }
196
+ ChangedObject: schemaId
197
+ },
198
+ order: "ascending",
199
+ cursor: cursor,
200
+ // limit: 2,
201
+ options: {
202
+ showEvents: true
203
+ }
204
+ });
205
+ const txs = response.data as SuiTransactionBlockResponse[]
206
+ // console.log("New Transactions: ", txs);
207
+ for (const tx of txs) {
208
+ await insertTx(sqliteDB, tx.checkpoint?.toString() as string, tx.digest);
209
+ if (tx.events) {
210
+ for (const event of tx.events) {
211
+ // @ts-ignore
212
+ if (event.parsedJson.hasOwnProperty("value")) {
213
+ await processSetRecord(sqliteDB, dubheConfig.name, tx.checkpoint?.toString() as string, tx.digest, event.parsedJson);
214
+ } else {
215
+ await processRemoveRecord(sqliteDB, dubheConfig.name, tx.checkpoint?.toString() as string, tx.digest, event.parsedJson);
216
+ }
217
+ }
218
+ }
219
+ }
220
+ };
221
+ } else {
222
+ throw new DubheCliError(
223
+ `Database "${db}" not supported. Supported databases: sqlite`
224
+ );
225
+ }
226
+ }
227
+
228
+ process.on('SIGINT', async () => {
229
+ await sqliteDB.close();
230
+ console.log(chalk.green('✅ Sqlite Stopped'));
231
+ process.exit();
232
+ });
@@ -1,18 +1,10 @@
1
- import { Dubhe } from '@0xobelisk/sui-client';
2
- import { Transaction } from '@mysten/sui/transactions';
3
- import {
4
- getFullnodeUrl,
5
- SuiClient,
6
- SuiTransactionBlockResponse,
7
- } from '@mysten/sui/client';
1
+ import { Dubhe, Transaction } from '@0xobelisk/sui-client';
8
2
  import { execSync } from 'child_process';
9
3
  import chalk from 'chalk';
10
4
  import { DubheCliError } from './errors';
11
5
  import {
12
- updateVersionInFile,
13
6
  saveContractData,
14
7
  validatePrivateKey,
15
- schema,
16
8
  updateDubheDependency,
17
9
  switchEnv,
18
10
  delay,
@@ -123,21 +115,21 @@ published-version = "${config.publishedVersion}"
123
115
 
124
116
  fs.writeFileSync(envFilePath, newEnvContent, 'utf-8');
125
117
  }
126
- function capitalizeAndRemoveUnderscores(input: string): string {
127
- return input
128
- .split('_')
129
- .map((word, index) => {
130
- return index === 0
131
- ? word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()
132
- : word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
133
- })
134
- .join('');
135
- }
136
-
137
- function getLastSegment(input: string): string {
138
- const segments = input.split('::');
139
- return segments.length > 0 ? segments[segments.length - 1] : '';
140
- }
118
+ // function capitalizeAndRemoveUnderscores(input: string): string {
119
+ // return input
120
+ // .split('_')
121
+ // .map((word, index) => {
122
+ // return index === 0
123
+ // ? word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()
124
+ // : word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
125
+ // })
126
+ // .join('');
127
+ // }
128
+ //
129
+ // function getLastSegment(input: string): string {
130
+ // const segments = input.split('::');
131
+ // return segments.length > 0 ? segments[segments.length - 1] : '';
132
+ // }
141
133
 
142
134
  function buildContract(projectPath: string): string[][] {
143
135
  let modules: any, dependencies: any;
@@ -163,14 +155,14 @@ function buildContract(projectPath: string): string[][] {
163
155
  }
164
156
 
165
157
  async function publishContract(
166
- client: SuiClient,
167
158
  dubhe: Dubhe,
168
159
  dubheConfig: DubheConfig,
169
160
  network: 'mainnet' | 'testnet' | 'devnet' | 'localnet',
170
161
  projectPath: string,
171
162
  gasBudget?: number
172
163
  ) {
173
- const chainId = await client.getChainIdentifier();
164
+ const chainId =
165
+ await dubhe.suiInteractor.currentClient.getChainIdentifier();
174
166
  await removeEnvContent(`${projectPath}/Move.lock`, network);
175
167
  console.log('\n🚀 Starting Contract Publication...');
176
168
  console.log(` ├─ Project: ${projectPath}`);
@@ -178,8 +170,7 @@ async function publishContract(
178
170
  console.log(` ├─ ChainId: ${chainId}`);
179
171
  console.log(' ├─ Validating Environment...');
180
172
 
181
- const keypair = dubhe.getKeypair();
182
- console.log(` └─ Account: ${keypair.toSuiAddress()}`);
173
+ console.log(` └─ Account: ${dubhe.getAddress()}`);
183
174
 
184
175
  console.log('\n📦 Building Contract...');
185
176
  const [modules, dependencies] = buildContract(projectPath);
@@ -190,15 +181,11 @@ async function publishContract(
190
181
  tx.setGasBudget(gasBudget);
191
182
  }
192
183
  const [upgradeCap] = tx.publish({ modules, dependencies });
193
- tx.transferObjects([upgradeCap], keypair.toSuiAddress());
184
+ tx.transferObjects([upgradeCap], dubhe.getAddress());
194
185
 
195
- let result: SuiTransactionBlockResponse;
186
+ let result;
196
187
  try {
197
- result = await client.signAndExecuteTransaction({
198
- signer: keypair,
199
- transaction: tx,
200
- options: { showObjectChanges: true },
201
- });
188
+ result = await dubhe.signAndSendTxn(tx);
202
189
  } catch (error: any) {
203
190
  console.error(chalk.red(' └─ Publication failed'));
204
191
  console.error(error.message);
@@ -213,7 +200,8 @@ async function publishContract(
213
200
  console.log(' ├─ Processing publication results...');
214
201
  let version = 1;
215
202
  let packageId = '';
216
- let schemas: schema[] = [];
203
+ let schemaId = '';
204
+ let schemas = dubheConfig.schemas;
217
205
  let upgradeCapId = '';
218
206
 
219
207
  result.objectChanges!.map(object => {
@@ -249,13 +237,9 @@ async function publishContract(
249
237
  arguments: [deployHookTx.object('0x6')],
250
238
  });
251
239
 
252
- let deployHookResult: SuiTransactionBlockResponse;
240
+ let deployHookResult;
253
241
  try {
254
- deployHookResult = await client.signAndExecuteTransaction({
255
- signer: keypair,
256
- transaction: deployHookTx,
257
- options: { showEffects: true, showObjectChanges: true },
258
- });
242
+ deployHookResult = await dubhe.signAndSendTxn(deployHookTx);
259
243
  } catch (error: any) {
260
244
  console.error(chalk.red(' └─ Deploy hook execution failed'));
261
245
  console.error(error.message);
@@ -268,29 +252,16 @@ async function publishContract(
268
252
 
269
253
  console.log('\n📋 Created Schemas:');
270
254
  deployHookResult.objectChanges?.map(object => {
255
+ if (object.type === 'created' && object.objectType.includes('schema::Schema')) {
256
+ schemaId = object.objectId;
257
+ }
271
258
  if (
272
259
  object.type === 'created' &&
273
- object.objectType.includes('_schema') &&
260
+ object.objectType.includes('schema') &&
274
261
  !object.objectType.includes('dynamic_field')
275
262
  ) {
276
263
  console.log(` ├─ ${object.objectType}`);
277
264
  console.log(` └─ ID: ${object.objectId}`);
278
-
279
- let structure: Record<string, string> = {};
280
- for (let schemaKey in dubheConfig.schemas) {
281
- if (
282
- capitalizeAndRemoveUnderscores(schemaKey) ===
283
- getLastSegment(object.objectType)
284
- ) {
285
- structure = dubheConfig.schemas[schemaKey].structure;
286
- }
287
- }
288
-
289
- schemas.push({
290
- name: object.objectType,
291
- objectId: object.objectId,
292
- structure,
293
- });
294
265
  }
295
266
  });
296
267
 
@@ -298,6 +269,7 @@ async function publishContract(
298
269
  dubheConfig.name,
299
270
  network,
300
271
  packageId,
272
+ schemaId,
301
273
  upgradeCapId,
302
274
  version,
303
275
  schemas
@@ -343,7 +315,6 @@ async function checkDubheFramework(projectPath: string): Promise<boolean> {
343
315
  }
344
316
 
345
317
  export async function publishDubheFramework(
346
- client: SuiClient,
347
318
  dubhe: Dubhe,
348
319
  network: 'mainnet' | 'testnet' | 'devnet' | 'localnet'
349
320
  ) {
@@ -355,14 +326,15 @@ export async function publishDubheFramework(
355
326
  return;
356
327
  }
357
328
 
358
- const chainId = await client.getChainIdentifier();
329
+ // const chainId = await client.getChainIdentifier();
330
+ const chainId =
331
+ await dubhe.suiInteractor.currentClient.getChainIdentifier();
359
332
  await removeEnvContent(`${projectPath}/Move.lock`, network);
360
333
  console.log('\n🚀 Starting Contract Publication...');
361
334
  console.log(` ├─ Project: ${projectPath}`);
362
335
  console.log(` ├─ Network: ${network}`);
363
336
 
364
- const keypair = dubhe.getKeypair();
365
- console.log(` └─ Account: ${keypair.toSuiAddress()}`);
337
+ console.log(` └─ Account: ${dubhe.getAddress()}`);
366
338
 
367
339
  console.log('\n📦 Building Contract...');
368
340
  const [modules, dependencies] = buildContract(projectPath);
@@ -370,15 +342,11 @@ export async function publishDubheFramework(
370
342
  console.log('\n🔄 Publishing Contract...');
371
343
  const tx = new Transaction();
372
344
  const [upgradeCap] = tx.publish({ modules, dependencies });
373
- tx.transferObjects([upgradeCap], keypair.toSuiAddress());
345
+ tx.transferObjects([upgradeCap], dubhe.getAddress());
374
346
 
375
- let result: SuiTransactionBlockResponse;
347
+ let result;
376
348
  try {
377
- result = await client.signAndExecuteTransaction({
378
- signer: keypair,
379
- transaction: tx,
380
- options: { showObjectChanges: true },
381
- });
349
+ result = await dubhe.signAndSendTxn(tx);
382
350
  } catch (error: any) {
383
351
  console.error(chalk.red(' └─ Publication failed'));
384
352
  console.error(error.message);
@@ -392,7 +360,7 @@ export async function publishDubheFramework(
392
360
 
393
361
  let version = 1;
394
362
  let packageId = '';
395
- let schemas: schema[] = [];
363
+ let schemas: Record<string, string> = {};
396
364
  let upgradeCapId = '';
397
365
 
398
366
  result.objectChanges!.map(object => {
@@ -423,10 +391,12 @@ export async function publishDubheFramework(
423
391
  'dubhe-framework',
424
392
  network,
425
393
  packageId,
394
+ '',
426
395
  upgradeCapId,
427
396
  version,
428
397
  schemas
429
398
  );
399
+ await delay(1000);
430
400
  console.log(chalk.green('\n✅ Dubhe Framework deployed successfully'));
431
401
  }
432
402
 
@@ -450,22 +420,17 @@ in your contracts directory to use the default sui private key.`
450
420
  throw new DubheCliError(`Please check your privateKey.`);
451
421
  }
452
422
 
453
- const dubhe = new Dubhe({ secretKey: privateKeyFormat });
454
- const client = new SuiClient({ url: getFullnodeUrl(network) });
423
+ const dubhe = new Dubhe({
424
+ secretKey: privateKeyFormat,
425
+ networkType: network,
426
+ });
455
427
 
456
428
  if (network === 'localnet') {
457
- await publishDubheFramework(client, dubhe, network);
429
+ await publishDubheFramework(dubhe, network);
458
430
  }
459
431
 
460
432
  const path = process.cwd();
461
433
  const projectPath = `${path}/contracts/${dubheConfig.name}`;
462
- updateDubheDependency(`${projectPath}/Move.toml`, network);
463
- await publishContract(
464
- client,
465
- dubhe,
466
- dubheConfig,
467
- network,
468
- projectPath,
469
- gasBudget
470
- );
434
+ await updateDubheDependency(`${projectPath}/Move.toml`, network);
435
+ await publishContract(dubhe, dubheConfig, network, projectPath, gasBudget);
471
436
  }
@@ -1,6 +1,6 @@
1
1
  import { Dubhe, loadMetadata } from '@0xobelisk/sui-client';
2
2
  import { DubheCliError } from './errors';
3
- import { validatePrivateKey, getOldPackageId, getObjectId } from './utils';
3
+ import { validatePrivateKey, getOldPackageId, getSchemaId } from './utils';
4
4
  import { DubheConfig } from '@0xobelisk/sui-common';
5
5
  import * as fs from 'fs';
6
6
  import * as path from 'path';
@@ -36,7 +36,6 @@ function getExpectedParamsCount(storageType: string): number {
36
36
  export async function queryStorage({
37
37
  dubheConfig,
38
38
  schema,
39
- field,
40
39
  params,
41
40
  network,
42
41
  objectId,
@@ -45,7 +44,6 @@ export async function queryStorage({
45
44
  }: {
46
45
  dubheConfig: DubheConfig;
47
46
  schema: string;
48
- field: string;
49
47
  params?: any[];
50
48
  network: 'mainnet' | 'testnet' | 'devnet' | 'localnet';
51
49
  objectId?: string;
@@ -70,7 +68,7 @@ in your contracts directory to use the default sui private key.`
70
68
 
71
69
  packageId = packageId || (await getOldPackageId(projectPath, network));
72
70
 
73
- objectId = objectId || (await getObjectId(projectPath, network, schema));
71
+ objectId = objectId || (await getSchemaId(projectPath, network));
74
72
 
75
73
  let metadata;
76
74
  if (metadataFilePath) {
@@ -92,15 +90,7 @@ in your contracts directory to use the default sui private key.`
92
90
  );
93
91
  }
94
92
 
95
- if (!dubheConfig.schemas[schema][field]) {
96
- throw new DubheCliError(
97
- `Field "${field}" not found in schema "${schema}". Available fields: ${Object.keys(
98
- dubheConfig.schemas[schema]
99
- ).join(', ')}`
100
- );
101
- }
102
-
103
- const storageType = dubheConfig.schemas[schema][field];
93
+ const storageType = dubheConfig.schemas[schema];
104
94
 
105
95
  const processedParams = params || [];
106
96
  if (!validateParams(storageType, processedParams)) {
@@ -117,9 +107,8 @@ in your contracts directory to use the default sui private key.`
117
107
  packageId,
118
108
  metadata,
119
109
  });
120
- const result = await dubhe.state({
110
+ const result = await dubhe.parseState({
121
111
  schema,
122
- field,
123
112
  objectId,
124
113
  storageType,
125
114
  params: processedParams,
@@ -1,14 +1,8 @@
1
1
  import { execSync, spawn } from 'child_process';
2
2
  import chalk from 'chalk';
3
3
  import { printDubhe } from './printDubhe';
4
- import {
5
- delay,
6
- DubheCliError,
7
- publishDubheFramework,
8
- validatePrivateKey,
9
- } from '../utils';
4
+ import { delay, DubheCliError, validatePrivateKey } from '../utils';
10
5
  import { Dubhe } from '@0xobelisk/sui-client';
11
- import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
12
6
 
13
7
  function isSuiStartRunning(): boolean {
14
8
  try {
@@ -40,7 +34,7 @@ async function printAccounts() {
40
34
  console.log('==========');
41
35
  privateKeys.forEach((privateKey, index) => {
42
36
  const dubhe = new Dubhe({ secretKey: privateKey });
43
- const keypair = dubhe.getKeypair();
37
+ const keypair = dubhe.getSigner();
44
38
  spawn(
45
39
  'curl',
46
40
  [
@@ -1,8 +1,7 @@
1
1
  import * as fsAsync from 'fs/promises';
2
2
  import { mkdirSync, writeFileSync } from 'fs';
3
- import { exit } from 'process';
4
3
  import { dirname } from 'path';
5
- import { DeploymentJsonType, schema } from './utils';
4
+ import { DeploymentJsonType } from './utils';
6
5
  import { DubheConfig } from '@0xobelisk/sui-common';
7
6
 
8
7
  async function getDeploymentJson(
@@ -25,24 +24,16 @@ async function getDeploymentJson(
25
24
  function storeConfig(
26
25
  network: string,
27
26
  packageId: string,
28
- schemas: schema[],
27
+ schemaId: string,
29
28
  outputPath: string
30
29
  ) {
31
30
  let code = `type NetworkType = 'testnet' | 'mainnet' | 'devnet' | 'localnet';
32
31
 
33
32
  export const NETWORK: NetworkType = '${network}';
34
-
35
33
  export const PACKAGE_ID = '${packageId}'
34
+ export const SCHEMA_ID = '${schemaId}'
35
+ `
36
36
 
37
- ${schemas
38
- .map(
39
- schema =>
40
- `export const ${schema.name.split('::')[2]}_Object_Id = '${
41
- schema.objectId
42
- }'`
43
- )
44
- .join('\n')}
45
- `;
46
37
  // if (outputPath) {
47
38
  writeOutput(code, outputPath, 'storeConfig');
48
39
  // writeOutput(code, `${path}/src/chain/config.ts`, 'storeConfig');
@@ -73,7 +64,7 @@ export async function storeConfigHandler(
73
64
  storeConfig(
74
65
  deployment.network,
75
66
  deployment.packageId,
76
- deployment.schemas,
67
+ deployment.schemaId,
77
68
  outputPath
78
69
  );
79
70
  }