@0xobelisk/sui-cli 1.2.0-pre.120 → 1.2.0-pre.121
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 +66 -66
- package/dist/dubhe.js.map +1 -1
- package/package.json +3 -3
- package/src/commands/convertJson.ts +2 -1
- package/src/utils/publishHandler.ts +4 -0
- 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.121",
|
|
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.121",
|
|
51
|
+
"@0xobelisk/sui-common": "1.2.0-pre.121"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/cli-progress": "^3.11.5",
|
|
@@ -521,6 +521,10 @@ 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
|
|
@@ -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
|
+
}
|