@0xobelisk/sui-cli 1.2.0-pre.21 → 1.2.0-pre.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 +46 -46
- package/dist/dubhe.js.map +1 -1
- package/package.json +4 -3
- package/src/commands/build.ts +2 -1
- package/src/commands/call.ts +83 -83
- package/src/commands/convertJson.ts +49 -0
- package/src/commands/doctor.ts +348 -0
- package/src/commands/index.ts +10 -7
- package/src/commands/loadMetadata.ts +50 -0
- package/src/commands/localnode.ts +19 -5
- package/src/commands/publish.ts +3 -1
- package/src/commands/query.ts +101 -101
- package/src/commands/schemagen.ts +4 -1
- package/src/commands/upgrade.ts +38 -38
- package/src/dubhe.ts +7 -7
- package/src/utils/callHandler.ts +118 -118
- package/src/utils/index.ts +2 -2
- package/src/utils/metadataHandler.ts +16 -0
- package/src/utils/publishHandler.ts +82 -266
- package/src/utils/queryStorage.ts +141 -141
- package/src/utils/startNode.ts +113 -16
- package/src/utils/storeConfig.ts +5 -11
- package/src/utils/upgradeHandler.ts +250 -250
- package/src/utils/utils.ts +161 -21
package/src/utils/callHandler.ts
CHANGED
|
@@ -1,129 +1,129 @@
|
|
|
1
|
-
import { loadMetadata, Transaction, TransactionResult } from '@0xobelisk/sui-client';
|
|
2
|
-
import { DubheCliError } from './errors';
|
|
3
|
-
import { getOldPackageId, initializeDubhe } from './utils';
|
|
4
|
-
import { DubheConfig } from '@0xobelisk/sui-common';
|
|
5
|
-
import { loadMetadataFromFile } from './queryStorage';
|
|
1
|
+
// import { loadMetadata, Transaction, TransactionResult } from '@0xobelisk/sui-client';
|
|
2
|
+
// import { DubheCliError } from './errors';
|
|
3
|
+
// import { getOldPackageId, initializeDubhe } from './utils';
|
|
4
|
+
// import { DubheConfig } from '@0xobelisk/sui-common';
|
|
5
|
+
// import { loadMetadataFromFile } from './queryStorage';
|
|
6
6
|
|
|
7
|
-
const BaseTxType = [
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
];
|
|
7
|
+
// const BaseTxType = [
|
|
8
|
+
// 'u8',
|
|
9
|
+
// 'u16',
|
|
10
|
+
// 'u32',
|
|
11
|
+
// 'u64',
|
|
12
|
+
// 'u128',
|
|
13
|
+
// 'u256',
|
|
14
|
+
// 'bool',
|
|
15
|
+
// 'id',
|
|
16
|
+
// 'string',
|
|
17
|
+
// 'address',
|
|
18
|
+
// 'object'
|
|
19
|
+
// ];
|
|
20
20
|
|
|
21
|
-
function validateParams(params: any[]) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
21
|
+
// function validateParams(params: any[]) {
|
|
22
|
+
// try {
|
|
23
|
+
// params.forEach((param) => {
|
|
24
|
+
// const [type, _] = param.split(':');
|
|
25
|
+
// if (!BaseTxType.includes(type)) {
|
|
26
|
+
// throw new Error(`Invalid param type: ${type}`);
|
|
27
|
+
// }
|
|
28
|
+
// });
|
|
29
|
+
// } catch (error) {
|
|
30
|
+
// throw new Error(`Invalid params: ${error}`);
|
|
31
|
+
// }
|
|
32
|
+
// }
|
|
33
33
|
|
|
34
|
-
// param:
|
|
35
|
-
// u8:1
|
|
36
|
-
// u16:1
|
|
37
|
-
// u32:1
|
|
38
|
-
// u64:1
|
|
39
|
-
// u128:1
|
|
40
|
-
// u256:1
|
|
41
|
-
// object:0x1
|
|
42
|
-
// address:0x1
|
|
43
|
-
// bool:true
|
|
44
|
-
// string:"hello"
|
|
45
|
-
function formatBCS(tx: Transaction, param: string) {
|
|
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
|
-
}
|
|
34
|
+
// // param:
|
|
35
|
+
// // u8:1
|
|
36
|
+
// // u16:1
|
|
37
|
+
// // u32:1
|
|
38
|
+
// // u64:1
|
|
39
|
+
// // u128:1
|
|
40
|
+
// // u256:1
|
|
41
|
+
// // object:0x1
|
|
42
|
+
// // address:0x1
|
|
43
|
+
// // bool:true
|
|
44
|
+
// // string:"hello"
|
|
45
|
+
// function formatBCS(tx: Transaction, param: string) {
|
|
46
|
+
// const [type, value] = param.split(':');
|
|
47
|
+
// switch (type) {
|
|
48
|
+
// case 'u8':
|
|
49
|
+
// return tx.pure.u8(parseInt(value));
|
|
50
|
+
// case 'u16':
|
|
51
|
+
// return tx.pure.u16(parseInt(value));
|
|
52
|
+
// case 'u32':
|
|
53
|
+
// return tx.pure.u32(parseInt(value));
|
|
54
|
+
// case 'u64':
|
|
55
|
+
// return tx.pure.u64(parseInt(value));
|
|
56
|
+
// case 'u128':
|
|
57
|
+
// return tx.pure.u128(parseInt(value));
|
|
58
|
+
// case 'u256':
|
|
59
|
+
// return tx.pure.u256(parseInt(value));
|
|
60
|
+
// case 'object':
|
|
61
|
+
// return tx.object(value);
|
|
62
|
+
// case 'address':
|
|
63
|
+
// return tx.pure.address(value);
|
|
64
|
+
// case 'bool':
|
|
65
|
+
// return tx.pure.bool(value === 'true');
|
|
66
|
+
// case 'string':
|
|
67
|
+
// return tx.pure.string(value);
|
|
68
|
+
// default:
|
|
69
|
+
// throw new Error(`Invalid param type: ${type}`);
|
|
70
|
+
// }
|
|
71
|
+
// }
|
|
72
72
|
|
|
73
|
-
function formatBCSParams(tx: Transaction, params: any[]) {
|
|
74
|
-
|
|
75
|
-
}
|
|
73
|
+
// function formatBCSParams(tx: Transaction, params: any[]) {
|
|
74
|
+
// return params.map((param) => formatBCS(tx, param));
|
|
75
|
+
// }
|
|
76
76
|
|
|
77
|
-
export async function callHandler({
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}: {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}) {
|
|
94
|
-
|
|
95
|
-
|
|
77
|
+
// export async function callHandler({
|
|
78
|
+
// dubheConfig,
|
|
79
|
+
// moduleName,
|
|
80
|
+
// funcName,
|
|
81
|
+
// params,
|
|
82
|
+
// network,
|
|
83
|
+
// packageId,
|
|
84
|
+
// metadataFilePath
|
|
85
|
+
// }: {
|
|
86
|
+
// dubheConfig: DubheConfig;
|
|
87
|
+
// moduleName: string;
|
|
88
|
+
// funcName: string;
|
|
89
|
+
// params?: any[];
|
|
90
|
+
// network: 'mainnet' | 'testnet' | 'devnet' | 'localnet';
|
|
91
|
+
// packageId?: string;
|
|
92
|
+
// metadataFilePath?: string;
|
|
93
|
+
// }) {
|
|
94
|
+
// const path = process.cwd();
|
|
95
|
+
// const projectPath = `${path}/src/${dubheConfig.name}`;
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
// packageId = packageId || (await getOldPackageId(projectPath, network));
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
// // objectId = objectId || (await getObjectId(projectPath, network, schema));
|
|
100
100
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
101
|
+
// let metadata;
|
|
102
|
+
// if (metadataFilePath) {
|
|
103
|
+
// metadata = await loadMetadataFromFile(metadataFilePath);
|
|
104
|
+
// } else {
|
|
105
|
+
// metadata = await loadMetadata(network, packageId);
|
|
106
|
+
// }
|
|
107
|
+
// if (!metadata) {
|
|
108
|
+
// throw new DubheCliError(
|
|
109
|
+
// `Metadata file not found. Please provide a metadata file path or set the packageId.`
|
|
110
|
+
// );
|
|
111
|
+
// }
|
|
112
112
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
113
|
+
// const processedParams = params || [];
|
|
114
|
+
// validateParams(processedParams);
|
|
115
|
+
// const dubhe = initializeDubhe({
|
|
116
|
+
// network,
|
|
117
|
+
// packageId,
|
|
118
|
+
// metadata
|
|
119
|
+
// });
|
|
120
|
+
// const tx = new Transaction();
|
|
121
|
+
// const formattedParams = formatBCSParams(tx, processedParams);
|
|
122
122
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
123
|
+
// const result = (await dubhe.tx[moduleName][funcName]({
|
|
124
|
+
// tx,
|
|
125
|
+
// params: formattedParams
|
|
126
|
+
// })) as TransactionResult;
|
|
127
127
|
|
|
128
|
-
|
|
129
|
-
}
|
|
128
|
+
// console.log(JSON.stringify(result, null, 2));
|
|
129
|
+
// }
|
package/src/utils/index.ts
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DubheConfig } from '@0xobelisk/sui-common';
|
|
2
|
+
import { getOldPackageId, saveMetadata } from './utils';
|
|
3
|
+
|
|
4
|
+
export async function loadMetadataHandler(
|
|
5
|
+
dubheConfig: DubheConfig,
|
|
6
|
+
network: 'mainnet' | 'testnet' | 'devnet' | 'localnet',
|
|
7
|
+
packageId?: string
|
|
8
|
+
) {
|
|
9
|
+
if (packageId) {
|
|
10
|
+
await saveMetadata(dubheConfig.name, network, packageId);
|
|
11
|
+
} else {
|
|
12
|
+
const projectPath = `${process.cwd()}/src/${dubheConfig.name}`;
|
|
13
|
+
const packageId = await getOldPackageId(projectPath, network);
|
|
14
|
+
await saveMetadata(dubheConfig.name, network, packageId);
|
|
15
|
+
}
|
|
16
|
+
}
|