@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.
@@ -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
- 'u8',
9
- 'u16',
10
- 'u32',
11
- 'u64',
12
- 'u128',
13
- 'u256',
14
- 'bool',
15
- 'id',
16
- 'string',
17
- 'address',
18
- 'object'
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
- 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
- }
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
- 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
- }
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
- return params.map((param) => formatBCS(tx, param));
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
- 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}`;
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
- packageId = packageId || (await getOldPackageId(projectPath, network));
97
+ // packageId = packageId || (await getOldPackageId(projectPath, network));
98
98
 
99
- // objectId = objectId || (await getObjectId(projectPath, network, schema));
99
+ // // objectId = objectId || (await getObjectId(projectPath, network, schema));
100
100
 
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
- }
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
- 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);
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
- const result = (await dubhe.tx[moduleName][funcName]({
124
- tx,
125
- params: formattedParams
126
- })) as TransactionResult;
123
+ // const result = (await dubhe.tx[moduleName][funcName]({
124
+ // tx,
125
+ // params: formattedParams
126
+ // })) as TransactionResult;
127
127
 
128
- console.log(JSON.stringify(result, null, 2));
129
- }
128
+ // console.log(JSON.stringify(result, null, 2));
129
+ // }
@@ -3,5 +3,5 @@ export * from './publishHandler';
3
3
  export * from './errors';
4
4
  export * from './printDubhe';
5
5
  export * from './utils';
6
- export * from './queryStorage';
7
- export * from './callHandler';
6
+ // export * from './queryStorage';
7
+ // export * from './callHandler';
@@ -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
+ }