@0xobelisk/sui-cli 1.2.0-pre.49 → 1.2.0-pre.50

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.
@@ -119,6 +119,14 @@ export async function getOnchainComponents(
119
119
  return deployment.components;
120
120
  }
121
121
 
122
+ export async function getOnchainResources(
123
+ projectPath: string,
124
+ network: string
125
+ ): Promise<Record<string, Component | MoveType>> {
126
+ const deployment = await getDeploymentJson(projectPath, network);
127
+ return deployment.resources;
128
+ }
129
+
122
130
  export async function getVersion(projectPath: string, network: string): Promise<number> {
123
131
  const deployment = await getDeploymentJson(projectPath, network);
124
132
  return deployment.version;
@@ -547,3 +555,27 @@ export function updateMoveTomlAddress(path: string, packageAddress: string) {
547
555
  const updatedContent = moveTomlContent.replace(/dubhe\s*=\s*"[^"]*"/, `dubhe = "${packageAddress}"`);
548
556
  fs.writeFileSync(moveTomlPath, updatedContent, 'utf-8');
549
557
  }
558
+
559
+ export function updateGenesisUpgradeFunction(path: string, tables: string[]) {
560
+ const genesisPath = `${path}/sources/codegen/genesis.move`;
561
+ const genesisContent = fs.readFileSync(genesisPath, 'utf-8');
562
+
563
+ // Match the first pair of // ========================================== lines (with any content, including empty, between them)
564
+ const separatorRegex = /(\/\/ ==========================================)[\s\S]*?(\/\/ ==========================================)/;
565
+ const match = genesisContent.match(separatorRegex);
566
+
567
+ if (!match) {
568
+ throw new Error('Could not find separator comments in genesis.move');
569
+ }
570
+
571
+ // Generate new table registration code
572
+ const registerTablesCode = tables.map((table) => ` ${table}::register_table(dapp_hub, _ctx);`).join('\n');
573
+
574
+ // Build new content, preserve separators, replace middle content
575
+ const newContent = `${match[1]}\n${registerTablesCode}\n${match[2]}`;
576
+
577
+ // Replace matched content
578
+ const updatedContent = genesisContent.replace(separatorRegex, newContent);
579
+
580
+ fs.writeFileSync(genesisPath, updatedContent, 'utf-8');
581
+ }