@0xobelisk/sui-cli 0.5.22 ā 0.5.24
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 +39 -31
- package/dist/dubhe.js.map +1 -1
- package/package.json +3 -3
- package/src/commands/index.ts +2 -2
- package/src/commands/publish.ts +1 -1
- package/src/commands/upgrade.ts +43 -53
- package/src/utils/localnode/status.ts +1 -1
- package/src/utils/publishHandler.ts +49 -11
- package/src/utils/upgradeHandler.ts +238 -246
- package/src/utils/utils.ts +23 -3
|
@@ -14,31 +14,49 @@ import {
|
|
|
14
14
|
validatePrivateKey,
|
|
15
15
|
schema,
|
|
16
16
|
} from './utils';
|
|
17
|
+
import { DubheConfig } from '@0xobelisk/sui-common';
|
|
17
18
|
|
|
18
19
|
async function getDappsObjectId(
|
|
19
20
|
network: 'mainnet' | 'testnet' | 'devnet' | 'localnet'
|
|
20
21
|
) {
|
|
21
22
|
switch (network) {
|
|
22
23
|
case 'testnet':
|
|
23
|
-
return '
|
|
24
|
+
return '0x181befc40b3dafe2740b41d5a970e49bed2cca20205506ee6be2cfb73ff2d3e9';
|
|
24
25
|
default:
|
|
25
|
-
return '
|
|
26
|
+
return '0x181befc40b3dafe2740b41d5a970e49bed2cca20205506ee6be2cfb73ff2d3e9';
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
29
|
|
|
30
|
+
function capitalizeAndRemoveUnderscores(input: string): string {
|
|
31
|
+
return input
|
|
32
|
+
.split('_')
|
|
33
|
+
.map((word, index) => {
|
|
34
|
+
return index === 0
|
|
35
|
+
? word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()
|
|
36
|
+
: word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
|
37
|
+
})
|
|
38
|
+
.join('');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function getLastSegment(input: string): string {
|
|
42
|
+
const segments = input.split('::');
|
|
43
|
+
return segments.length > 0 ? segments[segments.length - 1] : '';
|
|
44
|
+
}
|
|
45
|
+
|
|
29
46
|
export async function publishHandler(
|
|
30
|
-
|
|
47
|
+
dubheConfig: DubheConfig,
|
|
31
48
|
network: 'mainnet' | 'testnet' | 'devnet' | 'localnet',
|
|
32
49
|
dappsObjectId?: string
|
|
33
50
|
) {
|
|
34
|
-
|
|
35
|
-
console.log(` āā Project: ${name}`);
|
|
36
|
-
console.log(` āā Network: ${network}`);
|
|
51
|
+
|
|
37
52
|
|
|
38
53
|
const path = process.cwd();
|
|
39
|
-
const projectPath = `${path}/contracts/${name}`;
|
|
54
|
+
const projectPath = `${path}/contracts/${dubheConfig.name}`;
|
|
40
55
|
dappsObjectId = dappsObjectId || (await getDappsObjectId(network));
|
|
41
56
|
|
|
57
|
+
console.log('\nš Starting Contract Publication...');
|
|
58
|
+
console.log(` āā Project: ${projectPath}`);
|
|
59
|
+
console.log(` āā Network: ${network}`);
|
|
42
60
|
console.log(' āā Validating Environment...');
|
|
43
61
|
const privateKey = process.env.PRIVATE_KEY;
|
|
44
62
|
if (!privateKey) {
|
|
@@ -108,6 +126,7 @@ in your contracts directory to use the default sui private key.`
|
|
|
108
126
|
let packageId = '';
|
|
109
127
|
let schemas: schema[] = [];
|
|
110
128
|
let upgradeCapId = '';
|
|
129
|
+
let schemaHubId = '';
|
|
111
130
|
|
|
112
131
|
result.objectChanges!.map(object => {
|
|
113
132
|
if (object.type === 'published') {
|
|
@@ -121,6 +140,13 @@ in your contracts directory to use the default sui private key.`
|
|
|
121
140
|
console.log(` āā Upgrade Cap: ${object.objectId}`);
|
|
122
141
|
upgradeCapId = object.objectId;
|
|
123
142
|
}
|
|
143
|
+
if (
|
|
144
|
+
object.type === 'created' &&
|
|
145
|
+
object.objectType.includes("schema_hub")
|
|
146
|
+
) {
|
|
147
|
+
console.log(` āā Schema Hub: ${object.objectId}`);
|
|
148
|
+
schemaHubId = object.objectId;
|
|
149
|
+
}
|
|
124
150
|
});
|
|
125
151
|
|
|
126
152
|
console.log(` āā Transaction: ${result.digest}`);
|
|
@@ -132,7 +158,9 @@ in your contracts directory to use the default sui private key.`
|
|
|
132
158
|
deployHookTx.moveCall({
|
|
133
159
|
target: `${packageId}::deploy_hook::run`,
|
|
134
160
|
arguments: [
|
|
161
|
+
deployHookTx.object(schemaHubId),
|
|
135
162
|
deployHookTx.object(dappsObjectId),
|
|
163
|
+
deployHookTx.object(upgradeCapId),
|
|
136
164
|
deployHookTx.object('0x6'),
|
|
137
165
|
],
|
|
138
166
|
});
|
|
@@ -158,24 +186,34 @@ in your contracts directory to use the default sui private key.`
|
|
|
158
186
|
deployHookResult.objectChanges?.map(object => {
|
|
159
187
|
if (
|
|
160
188
|
object.type === 'created' &&
|
|
161
|
-
object.objectType.includes('
|
|
189
|
+
object.objectType.includes('_schema') && !object.objectType.includes("dynamic_field")
|
|
162
190
|
) {
|
|
163
191
|
console.log(` āā ${object.objectType}`);
|
|
164
192
|
console.log(` āā ID: ${object.objectId}`);
|
|
193
|
+
|
|
194
|
+
let structure: Record<string, string> = {};
|
|
195
|
+
for (let schemaKey in dubheConfig.schemas) {
|
|
196
|
+
if (capitalizeAndRemoveUnderscores(schemaKey) === getLastSegment(object.objectType)) {
|
|
197
|
+
structure = dubheConfig.schemas[schemaKey].structure;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
165
201
|
schemas.push({
|
|
166
202
|
name: object.objectType,
|
|
167
203
|
objectId: object.objectId,
|
|
204
|
+
structure,
|
|
168
205
|
});
|
|
169
206
|
}
|
|
170
207
|
});
|
|
171
208
|
|
|
172
209
|
saveContractData(
|
|
173
|
-
name,
|
|
210
|
+
dubheConfig.name,
|
|
174
211
|
network,
|
|
175
212
|
packageId,
|
|
176
|
-
schemas,
|
|
177
213
|
upgradeCapId,
|
|
178
|
-
|
|
214
|
+
schemaHubId,
|
|
215
|
+
version,
|
|
216
|
+
schemas,
|
|
179
217
|
);
|
|
180
218
|
console.log('\nā
Contract Publication Complete\n');
|
|
181
219
|
} else {
|
|
@@ -1,246 +1,238 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
//
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
// worldId,
|
|
240
|
-
// upgradeCap,
|
|
241
|
-
// adminCap,
|
|
242
|
-
// oldVersion
|
|
243
|
-
// );
|
|
244
|
-
// await updateVersionInFile(projectPath, oldVersion.toString());
|
|
245
|
-
// }
|
|
246
|
-
// }
|
|
1
|
+
import { Dubhe } from '@0xobelisk/sui-client';
|
|
2
|
+
import { Transaction, UpgradePolicy } from '@mysten/sui/transactions';
|
|
3
|
+
import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
|
|
4
|
+
import { execSync } from 'child_process';
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
import { DubheCliError, UpgradeError } from './errors';
|
|
7
|
+
import {
|
|
8
|
+
updateVersionInFile,
|
|
9
|
+
getOldPackageId,
|
|
10
|
+
getVersion,
|
|
11
|
+
getUpgradeCap,
|
|
12
|
+
saveContractData,
|
|
13
|
+
validatePrivateKey, getOnchainSchemas, getSchemaHub,
|
|
14
|
+
} from './utils';
|
|
15
|
+
import * as fs from 'fs';
|
|
16
|
+
import * as path from 'path';
|
|
17
|
+
import { DubheConfig } from '@0xobelisk/sui-common';
|
|
18
|
+
|
|
19
|
+
type ObjectContent = {
|
|
20
|
+
type: string;
|
|
21
|
+
fields: Record<string, any>;
|
|
22
|
+
hasPublicTransfer: boolean;
|
|
23
|
+
dataType: string;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
type Field = {
|
|
27
|
+
name: string;
|
|
28
|
+
type: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
type Migration = {
|
|
32
|
+
schemaName: string;
|
|
33
|
+
fields: Field[];
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
function updateMigrateMethod(projectPath: string, migrations: Migration[]): void {
|
|
37
|
+
migrations.forEach((migration) => {
|
|
38
|
+
let filePath = `${projectPath}/sources/codegen/schemas/${migration.schemaName}.move`;
|
|
39
|
+
const fileContent = fs.readFileSync(filePath, 'utf-8');
|
|
40
|
+
const migrateMethodRegex = new RegExp(`public fun migrate\\(_${migration.schemaName}: &mut ${capitalizeAndRemoveUnderscores(migration.schemaName)}, _cap: &UpgradeCap\\) {[^}]*}`);
|
|
41
|
+
const newMigrateMethod = `
|
|
42
|
+
public fun migrate(assets: &mut Assets, _cap: &UpgradeCap) {
|
|
43
|
+
${migration.fields.map((field) => {
|
|
44
|
+
let storage_type = ""
|
|
45
|
+
if (field.type.includes('StorageValue')) {
|
|
46
|
+
storage_type = `storage_value::new()`;
|
|
47
|
+
} else if (field.type.includes('StorageMap')) {
|
|
48
|
+
storage_type = `storage_map::new()`;
|
|
49
|
+
} else if (
|
|
50
|
+
field.type.includes('StorageDoubleMap')
|
|
51
|
+
) {
|
|
52
|
+
storage_type = `storage_double_map::new()`;
|
|
53
|
+
}
|
|
54
|
+
return `storage_migrate::add_field<${field.type}>(&mut assets.id, b"${field.name}", ${storage_type});`}).join('')}
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
57
|
+
|
|
58
|
+
const updatedContent = fileContent.replace(migrateMethodRegex, newMigrateMethod);
|
|
59
|
+
fs.writeFileSync(filePath, updatedContent, 'utf-8');
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function capitalizeAndRemoveUnderscores(input: string): string {
|
|
66
|
+
return input
|
|
67
|
+
.split('_')
|
|
68
|
+
.map((word, index) => {
|
|
69
|
+
return index === 0
|
|
70
|
+
? word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()
|
|
71
|
+
: word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
|
72
|
+
})
|
|
73
|
+
.join('');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function getLastSegment(input: string): string {
|
|
77
|
+
const segments = input.split('::');
|
|
78
|
+
return segments.length > 0 ? segments[segments.length - 1] : '';
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export async function upgradeHandler(
|
|
82
|
+
config: DubheConfig,
|
|
83
|
+
name: string,
|
|
84
|
+
network: 'mainnet' | 'testnet' | 'devnet' | 'localnet',
|
|
85
|
+
) {
|
|
86
|
+
const path = process.cwd();
|
|
87
|
+
const projectPath = `${path}/contracts/${name}`;
|
|
88
|
+
const privateKey = process.env.PRIVATE_KEY;
|
|
89
|
+
if (!privateKey)
|
|
90
|
+
throw new DubheCliError(
|
|
91
|
+
`Missing PRIVATE_KEY environment variable.
|
|
92
|
+
Run 'echo "PRIVATE_KEY=YOUR_PRIVATE_KEY" > .env'
|
|
93
|
+
in your contracts directory to use the default sui private key.`
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
const privateKeyFormat = validatePrivateKey(privateKey);
|
|
97
|
+
if (privateKeyFormat === false) {
|
|
98
|
+
throw new DubheCliError(`Please check your privateKey.`);
|
|
99
|
+
}
|
|
100
|
+
const dubhe = new Dubhe({
|
|
101
|
+
secretKey: privateKeyFormat,
|
|
102
|
+
});
|
|
103
|
+
const keypair = dubhe.getKeypair();
|
|
104
|
+
|
|
105
|
+
const client = new SuiClient({
|
|
106
|
+
url: getFullnodeUrl(network),
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
let oldVersion = Number(await getVersion(projectPath, network));
|
|
110
|
+
let oldPackageId = await getOldPackageId(projectPath, network);
|
|
111
|
+
let schemaHub = await getSchemaHub(projectPath, network);
|
|
112
|
+
let upgradeCap = await getUpgradeCap(projectPath, network);
|
|
113
|
+
// let adminCap = await getAdminCap(projectPath, network);
|
|
114
|
+
|
|
115
|
+
let pendingMigration: Migration[] = [];
|
|
116
|
+
let schemas = await getOnchainSchemas(projectPath, network);
|
|
117
|
+
for (let schemaKey in config.schemas) {
|
|
118
|
+
schemas.forEach((schema) => {
|
|
119
|
+
if (capitalizeAndRemoveUnderscores(schemaKey) == getLastSegment(schema.name)) {
|
|
120
|
+
let migrate: Migration = { schemaName: '', fields: [] };
|
|
121
|
+
let fields: Field[] = [];
|
|
122
|
+
let isMigration = false;
|
|
123
|
+
for (const key in config.schemas[schemaKey].structure) {
|
|
124
|
+
if (!(key in schema.structure)) {
|
|
125
|
+
isMigration = true;
|
|
126
|
+
fields.push({
|
|
127
|
+
name: key,
|
|
128
|
+
type: config.schemas[schemaKey].structure[key],
|
|
129
|
+
})
|
|
130
|
+
schema.structure[key] = config.schemas[schemaKey].structure[key];
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (isMigration) {
|
|
134
|
+
migrate.schemaName = schemaKey;
|
|
135
|
+
migrate.fields = fields;
|
|
136
|
+
pendingMigration.push(migrate)
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
})
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
pendingMigration.forEach((migration) => {
|
|
144
|
+
console.log(`\nš Starting Migration for ${migration.schemaName}...`);
|
|
145
|
+
console.log('š Migration Fields:', migration.fields);
|
|
146
|
+
});
|
|
147
|
+
updateMigrateMethod(projectPath, pendingMigration);
|
|
148
|
+
|
|
149
|
+
try {
|
|
150
|
+
let modules: any, dependencies: any, digest: any;
|
|
151
|
+
try {
|
|
152
|
+
const {
|
|
153
|
+
modules: extractedModules,
|
|
154
|
+
dependencies: extractedDependencies,
|
|
155
|
+
digest: extractedDigest,
|
|
156
|
+
} = JSON.parse(
|
|
157
|
+
execSync(
|
|
158
|
+
`sui move build --dump-bytecode-as-base64 --path ${path}/contracts/${name}`,
|
|
159
|
+
{
|
|
160
|
+
encoding: 'utf-8',
|
|
161
|
+
}
|
|
162
|
+
)
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
modules = extractedModules;
|
|
166
|
+
dependencies = extractedDependencies;
|
|
167
|
+
digest = extractedDigest;
|
|
168
|
+
} catch (error: any) {
|
|
169
|
+
throw new UpgradeError(error.stdout);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
console.log('\nš Starting Upgrade Process...');
|
|
173
|
+
console.log('š OldPackageId:', oldPackageId);
|
|
174
|
+
console.log('š UpgradeCap Object Id:', upgradeCap);
|
|
175
|
+
console.log('š OldVersion:', oldVersion);
|
|
176
|
+
|
|
177
|
+
const tx = new Transaction();
|
|
178
|
+
const ticket = tx.moveCall({
|
|
179
|
+
target: '0x2::package::authorize_upgrade',
|
|
180
|
+
arguments: [
|
|
181
|
+
tx.object(upgradeCap),
|
|
182
|
+
tx.pure.u8(UpgradePolicy.COMPATIBLE),
|
|
183
|
+
tx.pure.vector('u8', digest),
|
|
184
|
+
],
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
const receipt = tx.upgrade({
|
|
188
|
+
modules,
|
|
189
|
+
dependencies,
|
|
190
|
+
package: oldPackageId,
|
|
191
|
+
ticket,
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
tx.moveCall({
|
|
195
|
+
target: '0x2::package::commit_upgrade',
|
|
196
|
+
arguments: [tx.object(upgradeCap), receipt],
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
const result = await client.signAndExecuteTransaction({
|
|
200
|
+
signer: keypair,
|
|
201
|
+
transaction: tx,
|
|
202
|
+
options: {
|
|
203
|
+
showObjectChanges: true,
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
let newPackageId = '';
|
|
208
|
+
result.objectChanges!.map(object => {
|
|
209
|
+
if (object.type === 'published') {
|
|
210
|
+
console.log(
|
|
211
|
+
chalk.blue(`${name} PackageId: ${object.packageId}`)
|
|
212
|
+
);
|
|
213
|
+
console.log(
|
|
214
|
+
chalk.blue(`${name} Version: ${oldVersion + 1}`)
|
|
215
|
+
);
|
|
216
|
+
newPackageId = object.packageId;
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
console.log(
|
|
221
|
+
chalk.green(`Upgrade Transaction Digest: ${result.digest}`)
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
saveContractData(
|
|
225
|
+
name,
|
|
226
|
+
network,
|
|
227
|
+
newPackageId,
|
|
228
|
+
upgradeCap,
|
|
229
|
+
schemaHub,
|
|
230
|
+
oldVersion + 1,
|
|
231
|
+
schemas,
|
|
232
|
+
);
|
|
233
|
+
|
|
234
|
+
} catch (error: any) {
|
|
235
|
+
console.log(chalk.red('Upgrade failed!'));
|
|
236
|
+
console.error(error.message);
|
|
237
|
+
}
|
|
238
|
+
}
|