@offckb/cli 0.3.0-canary-95ee88f.0 → 0.3.0-canary-ce4cd80.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/cmd/deploy.js +9 -4
- package/dist/deploy/migration.d.ts +4 -4
- package/dist/deploy/migration.js +16 -8
- package/dist/deploy/toml.d.ts +1 -1
- package/dist/deploy/toml.js +2 -2
- package/package.json +1 -1
package/dist/cmd/deploy.js
CHANGED
|
@@ -131,21 +131,26 @@ function deployBinary(binPath, from, ckb) {
|
|
|
131
131
|
console.log(`contract ${contractName} deployed, tx hash:`, res);
|
|
132
132
|
console.log('wait 4 blocks..');
|
|
133
133
|
yield ckb.indexer.waitForSync(-4); // why negative 4? a bug in ckb-lumos
|
|
134
|
+
const txHash = result.scriptConfig.TX_HASH;
|
|
135
|
+
const index = result.scriptConfig.INDEX;
|
|
136
|
+
const dataByteLen = BigInt(tx.outputsData[+index].slice(2).length / 2);
|
|
137
|
+
const dataShannonLen = dataByteLen * BigInt('100000000');
|
|
138
|
+
const occupiedCapacity = '0x' + dataShannonLen.toString(16);
|
|
134
139
|
// todo: handle multiple cell recipes?
|
|
135
140
|
return {
|
|
136
141
|
deploymentOptions: {
|
|
137
142
|
name: contractName,
|
|
138
143
|
binFilePath: binPath,
|
|
139
144
|
enableTypeId: true,
|
|
140
|
-
lockScript: tx.outputs[+
|
|
145
|
+
lockScript: tx.outputs[+index].lock,
|
|
141
146
|
},
|
|
142
147
|
deploymentRecipe: {
|
|
143
148
|
cellRecipes: [
|
|
144
149
|
{
|
|
145
150
|
name: contractName,
|
|
146
|
-
txHash
|
|
147
|
-
index
|
|
148
|
-
occupiedCapacity
|
|
151
|
+
txHash,
|
|
152
|
+
index,
|
|
153
|
+
occupiedCapacity,
|
|
149
154
|
dataHash: (0, utils_1.ckbHash)(tx.outputsData[+result.scriptConfig.INDEX]),
|
|
150
155
|
typeId: (0, utils_1.computeScriptHash)(result.typeId),
|
|
151
156
|
},
|
|
@@ -23,17 +23,17 @@ export interface DeploymentRecipeJson {
|
|
|
23
23
|
cell_recipes: {
|
|
24
24
|
name: string;
|
|
25
25
|
tx_hash: string;
|
|
26
|
-
index:
|
|
27
|
-
occupied_capacity:
|
|
26
|
+
index: number;
|
|
27
|
+
occupied_capacity: number;
|
|
28
28
|
data_hash: string;
|
|
29
29
|
type_id?: string;
|
|
30
30
|
}[];
|
|
31
31
|
dep_group_recipes: {
|
|
32
32
|
name: string;
|
|
33
33
|
tx_hash: string;
|
|
34
|
-
index:
|
|
34
|
+
index: number;
|
|
35
35
|
data_hash: string;
|
|
36
|
-
occupied_capacity:
|
|
36
|
+
occupied_capacity: number;
|
|
37
37
|
}[];
|
|
38
38
|
}
|
|
39
39
|
export declare function generateDeploymentRecipeJsonFile(name: string, deploymentRecipe: DeploymentRecipe, network?: Network): void;
|
package/dist/deploy/migration.js
CHANGED
|
@@ -84,22 +84,30 @@ exports.getNewestMigrationFile = getNewestMigrationFile;
|
|
|
84
84
|
function deploymentRecipeToJson(recipe) {
|
|
85
85
|
return {
|
|
86
86
|
cell_recipes: recipe.cellRecipes.map((val) => {
|
|
87
|
+
if (BigInt(val.occupiedCapacity) > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
88
|
+
// CKB blocksize limit is 500k, so it should be impossible to have a cell occupied data larger than Number.MAX_SAFE_INTEGER which is 9007,1992,5474,0991
|
|
89
|
+
console.error(`invalid occupiedCapacity: ${val.occupiedCapacity}, the cell_recipes json might be incorrect for cell outpoint ${val.txHash}:${+val.index}`);
|
|
90
|
+
}
|
|
87
91
|
return {
|
|
88
92
|
name: val.name,
|
|
89
93
|
tx_hash: val.txHash,
|
|
90
|
-
index: val.index,
|
|
91
|
-
occupied_capacity: val.occupiedCapacity,
|
|
94
|
+
index: +val.index,
|
|
95
|
+
occupied_capacity: +BigInt(val.occupiedCapacity).toString(10),
|
|
92
96
|
data_hash: val.dataHash,
|
|
93
97
|
type_id: val.typeId,
|
|
94
98
|
};
|
|
95
99
|
}),
|
|
96
100
|
dep_group_recipes: recipe.depGroupRecipes.map((val) => {
|
|
101
|
+
if (BigInt(val.occupiedCapacity) > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
102
|
+
// CKB blocksize limit is 500k, so it should be impossible to have a cell occupied data larger than Number.MAX_SAFE_INTEGER which is 9007,1992,5474,0991
|
|
103
|
+
console.error(`invalid occupiedCapacity: ${val.occupiedCapacity}, the dep_group_recipes json might be incorrect for cell outpoint ${val.txHash}:${+val.index}`);
|
|
104
|
+
}
|
|
97
105
|
return {
|
|
98
106
|
name: val.name,
|
|
99
107
|
tx_hash: val.txHash,
|
|
100
|
-
index: val.index,
|
|
108
|
+
index: +val.index,
|
|
101
109
|
data_hash: val.dataHash,
|
|
102
|
-
occupied_capacity: val.occupiedCapacity,
|
|
110
|
+
occupied_capacity: +BigInt(val.occupiedCapacity).toString(10),
|
|
103
111
|
};
|
|
104
112
|
}),
|
|
105
113
|
};
|
|
@@ -111,8 +119,8 @@ function deploymentRecipeFromJson(json) {
|
|
|
111
119
|
return {
|
|
112
120
|
name: val.name,
|
|
113
121
|
txHash: val.tx_hash,
|
|
114
|
-
index: val.index,
|
|
115
|
-
occupiedCapacity: val.occupied_capacity,
|
|
122
|
+
index: '0x' + val.index.toString(16),
|
|
123
|
+
occupiedCapacity: '0x' + val.occupied_capacity.toString(16),
|
|
116
124
|
dataHash: val.data_hash,
|
|
117
125
|
typeId: val.type_id,
|
|
118
126
|
};
|
|
@@ -121,9 +129,9 @@ function deploymentRecipeFromJson(json) {
|
|
|
121
129
|
return {
|
|
122
130
|
name: val.name,
|
|
123
131
|
txHash: val.tx_hash,
|
|
124
|
-
index: val.index,
|
|
132
|
+
index: '0x' + val.index.toString(16),
|
|
125
133
|
dataHash: val.data_hash,
|
|
126
|
-
occupiedCapacity: val.occupied_capacity,
|
|
134
|
+
occupiedCapacity: '0x' + val.occupied_capacity.toString(16),
|
|
127
135
|
};
|
|
128
136
|
}),
|
|
129
137
|
};
|
package/dist/deploy/toml.d.ts
CHANGED
package/dist/deploy/toml.js
CHANGED
|
@@ -13,7 +13,7 @@ function generateDeploymentToml(options, network) {
|
|
|
13
13
|
cells: [
|
|
14
14
|
{
|
|
15
15
|
name: options.name,
|
|
16
|
-
enable_type_id: options.enableTypeId
|
|
16
|
+
enable_type_id: options.enableTypeId,
|
|
17
17
|
location: {
|
|
18
18
|
file: options.binFilePath,
|
|
19
19
|
},
|
|
@@ -44,7 +44,7 @@ function readDeploymentToml(scriptName, network) {
|
|
|
44
44
|
cells: [
|
|
45
45
|
{
|
|
46
46
|
name: data.cells[0].name,
|
|
47
|
-
enableTypeId: data.cells[0].enable_type_id
|
|
47
|
+
enableTypeId: data.cells[0].enable_type_id,
|
|
48
48
|
location: {
|
|
49
49
|
file: data.cells[0].location.file,
|
|
50
50
|
},
|