@0xobelisk/sui-cli 1.2.0-pre.120 → 1.2.0-pre.122
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/dubhe.js +68 -68
- package/dist/dubhe.js.map +1 -1
- package/package.json +3 -3
- package/src/commands/convertJson.ts +13 -4
- package/src/commands/storeConfig.ts +1 -0
- package/src/utils/publishHandler.ts +10 -2
- package/src/utils/storeConfig.ts +4 -4
- package/src/utils/upgradeHandler.ts +10 -1
- package/src/utils/utils.ts +16 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xobelisk/sui-cli",
|
|
3
|
-
"version": "1.2.0-pre.
|
|
3
|
+
"version": "1.2.0-pre.122",
|
|
4
4
|
"description": "Tookit for interacting with move eps framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sui",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"yargs": "^17.7.1",
|
|
48
48
|
"zod": "^3.22.3",
|
|
49
49
|
"zod-validation-error": "^1.3.0",
|
|
50
|
-
"@0xobelisk/sui-client": "1.2.0-pre.
|
|
51
|
-
"@0xobelisk/sui-common": "1.2.0-pre.
|
|
50
|
+
"@0xobelisk/sui-client": "1.2.0-pre.122",
|
|
51
|
+
"@0xobelisk/sui-common": "1.2.0-pre.122"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/cli-progress": "^3.11.5",
|
|
@@ -15,7 +15,8 @@ const RUNTIME_FIELDS = [
|
|
|
15
15
|
'dubhe_object_id',
|
|
16
16
|
'original_dubhe_package_id',
|
|
17
17
|
'dapp_key',
|
|
18
|
-
'start_checkpoint'
|
|
18
|
+
'start_checkpoint',
|
|
19
|
+
'package_ids'
|
|
19
20
|
];
|
|
20
21
|
|
|
21
22
|
export function mergeConfigJsonRuntimeFields(
|
|
@@ -45,7 +46,7 @@ const commandModule: CommandModule<Options, Options> = {
|
|
|
45
46
|
'config-path': {
|
|
46
47
|
type: 'string',
|
|
47
48
|
default: 'dubhe.config.ts',
|
|
48
|
-
description: '
|
|
49
|
+
description: 'Path to the Dubhe config file'
|
|
49
50
|
},
|
|
50
51
|
'output-path': {
|
|
51
52
|
type: 'string',
|
|
@@ -62,7 +63,8 @@ const commandModule: CommandModule<Options, Options> = {
|
|
|
62
63
|
const schemaJson = JSON.parse(generateConfigJson(dubheConfig));
|
|
63
64
|
|
|
64
65
|
let existing: Record<string, unknown> = {};
|
|
65
|
-
|
|
66
|
+
const isUpdate = fs.existsSync(outputPath);
|
|
67
|
+
if (isUpdate) {
|
|
66
68
|
try {
|
|
67
69
|
existing = JSON.parse(fs.readFileSync(outputPath, 'utf-8'));
|
|
68
70
|
} catch {
|
|
@@ -71,10 +73,17 @@ const commandModule: CommandModule<Options, Options> = {
|
|
|
71
73
|
}
|
|
72
74
|
const merged = mergeConfigJsonRuntimeFields(schemaJson, existing);
|
|
73
75
|
|
|
76
|
+
// Log which runtime fields were preserved from the existing file
|
|
77
|
+
const preserved = RUNTIME_FIELDS.filter((f) => existing[f] !== undefined);
|
|
78
|
+
if (preserved.length > 0) {
|
|
79
|
+
console.log(chalk.gray(` preserved runtime fields: ${preserved.join(', ')}`));
|
|
80
|
+
}
|
|
81
|
+
|
|
74
82
|
fs.writeFileSync(outputPath, JSON.stringify(merged, null, 2));
|
|
83
|
+
console.log(chalk.green(`✅ ${isUpdate ? 'Updated' : 'Created'} ${outputPath}`));
|
|
75
84
|
} catch (error: any) {
|
|
76
85
|
console.error(chalk.red('Error executing convert json:'));
|
|
77
|
-
console.
|
|
86
|
+
if (error.message) console.error(error.message);
|
|
78
87
|
handlerExit(1);
|
|
79
88
|
}
|
|
80
89
|
handlerExit();
|
|
@@ -30,6 +30,7 @@ const commandModule: CommandModule<Options, Options> = {
|
|
|
30
30
|
},
|
|
31
31
|
'output-ts-path': {
|
|
32
32
|
type: 'string',
|
|
33
|
+
default: './deployment.ts',
|
|
33
34
|
desc: 'Specify the output path for the generated TypeScript configuration file (e.g., ./src/config/generated.ts)'
|
|
34
35
|
}
|
|
35
36
|
},
|
|
@@ -521,12 +521,20 @@ async function publishContract(
|
|
|
521
521
|
// Insert package id to dubhe config
|
|
522
522
|
let config = JSON.parse(fs.readFileSync(`${process.cwd()}/dubhe.config.json`, 'utf-8'));
|
|
523
523
|
config.original_package_id = packageId;
|
|
524
|
+
// Initialize the trusted package address list. The indexer uses this list to verify
|
|
525
|
+
// event.type_.address so that forged events from other contracts are rejected even
|
|
526
|
+
// when they embed the same dapp_key string.
|
|
527
|
+
config.package_ids = [packageId];
|
|
524
528
|
config.dubhe_object_id = frameworkDappHubId;
|
|
525
529
|
// When deploying the dubhe framework itself, the "original dubhe package ID" is
|
|
526
530
|
// the package we just published. For user packages, look up the well-known
|
|
527
531
|
// framework address for the target network from the client config.
|
|
528
|
-
|
|
529
|
-
|
|
532
|
+
// devnet has no fixed framework deployment so we skip this field.
|
|
533
|
+
if (dubheConfig.name === 'dubhe') {
|
|
534
|
+
config.original_dubhe_package_id = packageId;
|
|
535
|
+
} else if (network !== 'devnet') {
|
|
536
|
+
config.original_dubhe_package_id = await getOriginalDubhePackageId(network);
|
|
537
|
+
}
|
|
530
538
|
config.start_checkpoint = startCheckpoint;
|
|
531
539
|
// Canonical dapp_key type string: stable across upgrades, no "0x" prefix, padded to 64 hex chars.
|
|
532
540
|
// Matches the Move type_name::with_defining_ids<DappKey>().into_string() format.
|
package/src/utils/storeConfig.ts
CHANGED
|
@@ -23,17 +23,17 @@ async function storeConfig(
|
|
|
23
23
|
|
|
24
24
|
// Mirror getDubheDappHubId: for localnet the framework is deployed ephemerally so we
|
|
25
25
|
// read its package ID from src/dubhe/.history/sui_localnet/latest.json.
|
|
26
|
-
// For testnet/mainnet the
|
|
27
|
-
//
|
|
26
|
+
// For testnet/mainnet the hardcoded ID from @0xobelisk/sui-client defaultConfig is used.
|
|
27
|
+
// devnet has no fixed framework deployment, so frameworkPackageId stays undefined.
|
|
28
28
|
let frameworkPackageId: string | undefined;
|
|
29
|
-
if (network
|
|
29
|
+
if (network !== 'devnet') {
|
|
30
30
|
frameworkPackageId = await getOriginalDubhePackageId(network);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
const frameworkIdLine =
|
|
34
34
|
frameworkPackageId !== undefined
|
|
35
35
|
? `\n// Published package ID of the dubhe framework — required for proxy operations.\nexport const FrameworkPackageId: string | undefined = '${frameworkPackageId}';\n`
|
|
36
|
-
: `\n// Published package ID of the dubhe framework — required for proxy operations.\n//
|
|
36
|
+
: `\n// Published package ID of the dubhe framework — required for proxy operations.\n// Not available for devnet (no fixed framework deployment).\nexport const FrameworkPackageId: string | undefined = undefined;\n`;
|
|
37
37
|
|
|
38
38
|
const dappKey = buildDappKey(originalPackageId);
|
|
39
39
|
|
|
@@ -22,7 +22,8 @@ import {
|
|
|
22
22
|
readPublishedToml,
|
|
23
23
|
updateEphemeralPubFile,
|
|
24
24
|
getEphemeralPubFilePath,
|
|
25
|
-
updateMoveTomlAddress
|
|
25
|
+
updateMoveTomlAddress,
|
|
26
|
+
appendPackageIdToConfig
|
|
26
27
|
} from './utils';
|
|
27
28
|
import * as fs from 'fs';
|
|
28
29
|
import * as path from 'path';
|
|
@@ -302,6 +303,14 @@ export async function upgradeHandler(
|
|
|
302
303
|
dappStorageId || undefined
|
|
303
304
|
);
|
|
304
305
|
|
|
306
|
+
// Append the new package ID to dubhe.config.json so the indexer can verify
|
|
307
|
+
// event.type_.address against all known package versions on next startup.
|
|
308
|
+
const configJsonPath = `${process.cwd()}/dubhe.config.json`;
|
|
309
|
+
appendPackageIdToConfig(configJsonPath, newPackageId);
|
|
310
|
+
if (fs.existsSync(configJsonPath)) {
|
|
311
|
+
console.log(chalk.green(`✅ Appended ${newPackageId} to dubhe.config.json package_ids`));
|
|
312
|
+
}
|
|
313
|
+
|
|
305
314
|
// Only run the migration transaction if there are pending schema changes or a
|
|
306
315
|
// forced version bump was requested via --bump-version.
|
|
307
316
|
// A pure "bug-fix" upgrade with no new fields and no --bump-version flag does
|
package/src/utils/utils.ts
CHANGED
|
@@ -1234,3 +1234,19 @@ export function confirm(question: string): Promise<boolean> {
|
|
|
1234
1234
|
});
|
|
1235
1235
|
});
|
|
1236
1236
|
}
|
|
1237
|
+
|
|
1238
|
+
/**
|
|
1239
|
+
* Append a new package ID to the `package_ids` array in dubhe.config.json.
|
|
1240
|
+
* Idempotent — does nothing if the ID is already present or the file does not exist.
|
|
1241
|
+
* Called by upgradeHandler after a successful on-chain upgrade so the indexer
|
|
1242
|
+
* can verify event.type_.address against all known package versions on next startup.
|
|
1243
|
+
*/
|
|
1244
|
+
export function appendPackageIdToConfig(configJsonPath: string, newPackageId: string): void {
|
|
1245
|
+
if (!fs.existsSync(configJsonPath)) return;
|
|
1246
|
+
const configJson = JSON.parse(fs.readFileSync(configJsonPath, 'utf-8'));
|
|
1247
|
+
const existingIds: string[] = Array.isArray(configJson.package_ids) ? configJson.package_ids : [];
|
|
1248
|
+
if (!existingIds.includes(newPackageId)) {
|
|
1249
|
+
configJson.package_ids = [...existingIds, newPackageId];
|
|
1250
|
+
fs.writeFileSync(configJsonPath, JSON.stringify(configJson, null, 2));
|
|
1251
|
+
}
|
|
1252
|
+
}
|