@offckb/cli 0.3.0-canary-e0c0069.0 → 0.3.0-canary-884fccd.0
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/deploy/index.js
CHANGED
|
@@ -79,7 +79,7 @@ function deployBinary(binPath, privateKey, enableTypeId, ckb) {
|
|
|
79
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
80
80
|
const bin = yield (0, fs_1.readFileToUint8Array)(binPath);
|
|
81
81
|
const contractName = path_1.default.basename(binPath);
|
|
82
|
-
const result = enableTypeId
|
|
82
|
+
const result = !enableTypeId
|
|
83
83
|
? yield ckb.deployScript(bin, privateKey)
|
|
84
84
|
: migration_1.Migration.isDeployedWithTypeId(contractName, ckb.network)
|
|
85
85
|
? yield ckb.upgradeTypeIdScript(contractName, bin, privateKey)
|
|
@@ -89,11 +89,16 @@ function deployBinary(binPath, privateKey, enableTypeId, ckb) {
|
|
|
89
89
|
yield ckb.waitForTxConfirm(result.txHash);
|
|
90
90
|
console.log('tx committed.');
|
|
91
91
|
const txHash = result.txHash;
|
|
92
|
+
const typeIdScript = result.typeId;
|
|
92
93
|
const index = result.scriptOutputCellIndex;
|
|
93
94
|
const tx = result.tx;
|
|
94
95
|
const dataByteLen = BigInt(tx.outputsData[+index].slice(2).length / 2);
|
|
95
96
|
const dataShannonLen = dataByteLen * BigInt('100000000');
|
|
96
97
|
const occupiedCapacity = '0x' + dataShannonLen.toString(16);
|
|
98
|
+
if (enableTypeId && typeIdScript == null) {
|
|
99
|
+
throw new Error('type id script is null while enableTypeId is true.');
|
|
100
|
+
}
|
|
101
|
+
const typeIdScriptHash = enableTypeId ? (0, utils_1.computeScriptHash)(typeIdScript) : undefined;
|
|
97
102
|
// todo: handle multiple cell recipes?
|
|
98
103
|
return {
|
|
99
104
|
deploymentOptions: {
|
|
@@ -110,7 +115,7 @@ function deployBinary(binPath, privateKey, enableTypeId, ckb) {
|
|
|
110
115
|
index: '0x' + index.toString(16),
|
|
111
116
|
occupiedCapacity,
|
|
112
117
|
dataHash: (0, utils_1.ckbHash)(tx.outputsData[+index]),
|
|
113
|
-
typeId:
|
|
118
|
+
typeId: typeIdScriptHash,
|
|
114
119
|
},
|
|
115
120
|
],
|
|
116
121
|
depGroupRecipes: [],
|
|
@@ -45,6 +45,6 @@ export declare function generateDeploymentMigrationFile(name: string, deployment
|
|
|
45
45
|
export declare function readDeploymentMigrationFile(filePath: string): DeploymentRecipe;
|
|
46
46
|
export declare function getFormattedMigrationDate(): string;
|
|
47
47
|
export declare function getMigrationFolderPath(scriptName: string, network: Network): string;
|
|
48
|
-
export declare function getNewestMigrationFile(folderPath: string): string |
|
|
48
|
+
export declare function getNewestMigrationFile(folderPath: string): string | null;
|
|
49
49
|
export declare function deploymentRecipeToJson(recipe: DeploymentRecipe): MigrationJson;
|
|
50
50
|
export declare function deploymentRecipeFromJson(json: MigrationJson): DeploymentRecipe;
|
package/dist/deploy/migration.js
CHANGED
|
@@ -94,6 +94,9 @@ function getMigrationFolderPath(scriptName, network) {
|
|
|
94
94
|
}
|
|
95
95
|
exports.getMigrationFolderPath = getMigrationFolderPath;
|
|
96
96
|
function getNewestMigrationFile(folderPath) {
|
|
97
|
+
if (!fs_1.default.existsSync(folderPath) || !fs_1.default.lstatSync(folderPath).isDirectory()) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
97
100
|
const files = fs_1.default
|
|
98
101
|
.readdirSync(folderPath)
|
|
99
102
|
.filter((file) => file.endsWith('.json')) // Ensure only JSON files are considered
|
|
@@ -104,7 +107,7 @@ function getNewestMigrationFile(folderPath) {
|
|
|
104
107
|
return timestampA.localeCompare(timestampB);
|
|
105
108
|
});
|
|
106
109
|
// Return the full path of the newest file (last in sorted array) or undefined if no files
|
|
107
|
-
return files.length > 0 ? path_1.default.join(folderPath, files[files.length - 1]) :
|
|
110
|
+
return files.length > 0 ? path_1.default.join(folderPath, files[files.length - 1]) : null;
|
|
108
111
|
}
|
|
109
112
|
exports.getNewestMigrationFile = getNewestMigrationFile;
|
|
110
113
|
function deploymentRecipeToJson(recipe) {
|