@0xobelisk/sui-cli 1.1.5 → 1.1.6

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.
@@ -2,34 +2,34 @@ import type { CommandModule } from 'yargs';
2
2
  import { generateAccountHandler } from '../utils/generateAccount';
3
3
 
4
4
  type Options = {
5
- force?: boolean;
6
- 'output-ts-path'?: string;
5
+ force?: boolean;
6
+ 'output-ts-path'?: string;
7
7
  };
8
8
 
9
9
  const commandModule: CommandModule<Options, Options> = {
10
- command: 'generate-key',
11
- describe:
12
- 'Generate a new account key pair and save it to a .env file, with an option to output to a TypeScript file.',
13
- builder: {
14
- force: {
15
- type: 'boolean',
16
- default: false,
17
- desc: 'Force generate a new key pair',
18
- },
19
- 'output-ts-path': {
20
- type: 'string',
21
- desc: 'Specify the path to output the TypeScript file containing the key pair (e.g., ./src/config/key.ts)',
22
- },
23
- },
24
- async handler({ force, 'output-ts-path': outputTsPath }) {
25
- try {
26
- await generateAccountHandler(force, outputTsPath);
27
- } catch (error) {
28
- console.error('Error generating account:', error);
29
- process.exit(1);
30
- }
31
- process.exit(0);
32
- },
10
+ command: 'generate-key',
11
+ describe:
12
+ 'Generate a new account key pair and save it to a .env file, with an option to output to a TypeScript file.',
13
+ builder: {
14
+ force: {
15
+ type: 'boolean',
16
+ default: false,
17
+ desc: 'Force generate a new key pair'
18
+ },
19
+ 'output-ts-path': {
20
+ type: 'string',
21
+ desc: 'Specify the path to output the TypeScript file containing the key pair (e.g., ./src/config/key.ts)'
22
+ }
23
+ },
24
+ async handler({ force, 'output-ts-path': outputTsPath }) {
25
+ try {
26
+ await generateAccountHandler(force, outputTsPath);
27
+ } catch (error) {
28
+ console.error('Error generating account:', error);
29
+ process.exit(1);
30
+ }
31
+ process.exit(0);
32
+ }
33
33
  };
34
34
 
35
35
  export default commandModule;
@@ -1,10 +1,10 @@
1
- import type { CommandModule } from "yargs";
2
- import { printDubhe } from "../utils";
1
+ import type { CommandModule } from 'yargs';
2
+ import { printDubhe } from '../utils';
3
3
 
4
4
  const commandModule: CommandModule = {
5
- command: "hello",
5
+ command: 'hello',
6
6
 
7
- describe: "hello, dubhe",
7
+ describe: 'hello, dubhe',
8
8
 
9
9
  builder(yargs) {
10
10
  return yargs;
@@ -12,7 +12,7 @@ const commandModule: CommandModule = {
12
12
 
13
13
  async handler() {
14
14
  printDubhe();
15
- },
15
+ }
16
16
  };
17
17
 
18
18
  export default commandModule;
@@ -18,19 +18,19 @@ import watch from './watch';
18
18
 
19
19
  // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Each command has different options
20
20
  export const commands: CommandModule<any, any>[] = [
21
- localnode,
22
- publish,
23
- call,
24
- query,
25
- faucet,
26
- schemagen,
27
- upgrade,
28
- test,
29
- build,
30
- hello,
31
- generateKey,
32
- checkBalance,
33
- configStore,
34
- indexer,
35
- watch,
21
+ localnode,
22
+ publish,
23
+ call,
24
+ query,
25
+ faucet,
26
+ schemagen,
27
+ upgrade,
28
+ test,
29
+ build,
30
+ hello,
31
+ generateKey,
32
+ checkBalance,
33
+ configStore,
34
+ indexer,
35
+ watch
36
36
  ];
@@ -4,58 +4,53 @@ import { indexerHandler } from '../utils';
4
4
  import { loadConfig, DubheConfig } from '@0xobelisk/sui-common';
5
5
 
6
6
  type Options = {
7
- network: any;
8
- 'config-path': string;
9
- 'db': string;
10
- 'schemaId'?: string;
7
+ network: any;
8
+ 'config-path': string;
9
+ db: string;
10
+ schemaId?: string;
11
11
  };
12
12
 
13
13
  const commandModule: CommandModule<Options, Options> = {
14
- command: 'indexer',
14
+ command: 'indexer',
15
15
 
16
- describe: 'Dubhe indexer',
16
+ describe: 'Dubhe indexer',
17
17
 
18
- builder(yargs) {
19
- return yargs.options({
20
- network: {
21
- type: 'string',
22
- choices: ['mainnet', 'testnet', 'devnet', 'localnet'],
23
- desc: 'Node network (mainnet/testnet/devnet/localnet)',
24
- default: 'localnet',
25
- },
26
- 'config-path': {
27
- type: 'string',
28
- default: 'dubhe.config.ts',
29
- desc: 'Configuration file path',
30
- },
31
- 'schemaId': {
32
- type: 'string',
33
- desc: 'Schema ID',
34
- },
35
- 'db': {
36
- type: 'string',
37
- choices: ['sqlite', 'postgres'],
38
- desc: 'Optional gas budget for the transaction',
39
- default: 'sqlite',
40
- },
41
- });
42
- },
18
+ builder(yargs) {
19
+ return yargs.options({
20
+ network: {
21
+ type: 'string',
22
+ choices: ['mainnet', 'testnet', 'devnet', 'localnet'],
23
+ desc: 'Node network (mainnet/testnet/devnet/localnet)',
24
+ default: 'localnet'
25
+ },
26
+ 'config-path': {
27
+ type: 'string',
28
+ default: 'dubhe.config.ts',
29
+ desc: 'Configuration file path'
30
+ },
31
+ schemaId: {
32
+ type: 'string',
33
+ desc: 'Schema ID'
34
+ },
35
+ db: {
36
+ type: 'string',
37
+ choices: ['sqlite', 'postgres'],
38
+ desc: 'Optional gas budget for the transaction',
39
+ default: 'sqlite'
40
+ }
41
+ });
42
+ },
43
43
 
44
- async handler({
45
- network,
46
- 'config-path': configPath,
47
- db,
48
- schemaId: schemaId,
49
- }) {
50
- try {
51
- const dubheConfig = (await loadConfig(configPath)) as DubheConfig;
52
- await indexerHandler(dubheConfig, network, db, schemaId);
53
- } catch (error: any) {
54
- logError(error);
55
- process.exit(1);
56
- }
57
- process.exit(0);
58
- },
44
+ async handler({ network, 'config-path': configPath, db, schemaId: schemaId }) {
45
+ try {
46
+ const dubheConfig = (await loadConfig(configPath)) as DubheConfig;
47
+ await indexerHandler(dubheConfig, network, db, schemaId);
48
+ } catch (error: any) {
49
+ logError(error);
50
+ process.exit(1);
51
+ }
52
+ process.exit(0);
53
+ }
59
54
  };
60
55
 
61
56
  export default commandModule;
@@ -2,22 +2,22 @@ import type { CommandModule } from 'yargs';
2
2
  import { startLocalNode } from '../utils/startNode';
3
3
 
4
4
  const commandModule: CommandModule = {
5
- command: 'node',
5
+ command: 'node',
6
6
 
7
- describe: 'Manage local Sui node',
7
+ describe: 'Manage local Sui node',
8
8
 
9
- builder(yargs) {
10
- return yargs
11
- },
9
+ builder(yargs) {
10
+ return yargs;
11
+ },
12
12
 
13
- async handler() {
14
- try {
15
- await startLocalNode();
16
- } catch (error) {
17
- console.error('Error executing command:', error);
18
- process.exit(1);
19
- }
20
- },
13
+ async handler() {
14
+ try {
15
+ await startLocalNode();
16
+ } catch (error) {
17
+ console.error('Error executing command:', error);
18
+ process.exit(1);
19
+ }
20
+ }
21
21
  };
22
22
 
23
23
  export default commandModule;
@@ -4,51 +4,47 @@ import { publishHandler } from '../utils';
4
4
  import { loadConfig, DubheConfig } from '@0xobelisk/sui-common';
5
5
 
6
6
  type Options = {
7
- network: any;
8
- 'config-path': string;
9
- 'gas-budget'?: number;
7
+ network: any;
8
+ 'config-path': string;
9
+ 'gas-budget'?: number;
10
10
  };
11
11
 
12
12
  const commandModule: CommandModule<Options, Options> = {
13
- command: 'publish',
13
+ command: 'publish',
14
14
 
15
- describe: 'Publish dubhe move contract',
15
+ describe: 'Publish dubhe move contract',
16
16
 
17
- builder(yargs) {
18
- return yargs.options({
19
- network: {
20
- type: 'string',
21
- choices: ['mainnet', 'testnet', 'devnet', 'localnet'],
22
- default: 'localnet',
23
- desc: 'Node network (mainnet/testnet/devnet/localnet)',
24
- },
25
- 'config-path': {
26
- type: 'string',
27
- default: 'dubhe.config.ts',
28
- desc: 'Configuration file path',
29
- },
30
- 'gas-budget': {
31
- type: 'number',
32
- desc: 'Optional gas budget for the transaction',
33
- optional: true,
34
- },
35
- });
36
- },
17
+ builder(yargs) {
18
+ return yargs.options({
19
+ network: {
20
+ type: 'string',
21
+ choices: ['mainnet', 'testnet', 'devnet', 'localnet'],
22
+ default: 'localnet',
23
+ desc: 'Node network (mainnet/testnet/devnet/localnet)'
24
+ },
25
+ 'config-path': {
26
+ type: 'string',
27
+ default: 'dubhe.config.ts',
28
+ desc: 'Configuration file path'
29
+ },
30
+ 'gas-budget': {
31
+ type: 'number',
32
+ desc: 'Optional gas budget for the transaction',
33
+ optional: true
34
+ }
35
+ });
36
+ },
37
37
 
38
- async handler({
39
- network,
40
- 'config-path': configPath,
41
- 'gas-budget': gasBudget,
42
- }) {
43
- try {
44
- const dubheConfig = (await loadConfig(configPath)) as DubheConfig;
45
- await publishHandler(dubheConfig, network, gasBudget);
46
- } catch (error: any) {
47
- logError(error);
48
- process.exit(1);
49
- }
50
- process.exit(0);
51
- },
38
+ async handler({ network, 'config-path': configPath, 'gas-budget': gasBudget }) {
39
+ try {
40
+ const dubheConfig = (await loadConfig(configPath)) as DubheConfig;
41
+ await publishHandler(dubheConfig, network, gasBudget);
42
+ } catch (error: any) {
43
+ logError(error);
44
+ process.exit(1);
45
+ }
46
+ process.exit(0);
47
+ }
52
48
  };
53
49
 
54
50
  export default commandModule;
@@ -4,13 +4,13 @@ import { queryStorage } from '../utils';
4
4
  import { loadConfig, DubheConfig } from '@0xobelisk/sui-common';
5
5
 
6
6
  type Options = {
7
- network: 'mainnet' | 'testnet' | 'devnet' | 'localnet';
8
- 'config-path'?: string;
9
- schema: string;
10
- 'object-id'?: string;
11
- 'package-id'?: string;
12
- 'metadata-path'?: string;
13
- params?: any[];
7
+ network: 'mainnet' | 'testnet' | 'devnet' | 'localnet';
8
+ 'config-path'?: string;
9
+ schema: string;
10
+ 'object-id'?: string;
11
+ 'package-id'?: string;
12
+ 'metadata-path'?: string;
13
+ params?: any[];
14
14
  };
15
15
 
16
16
  /**
@@ -36,73 +36,73 @@ type Options = {
36
36
  * ```
37
37
  */
38
38
  const commandModule: CommandModule<Options, Options> = {
39
- command: 'query',
39
+ command: 'query',
40
40
 
41
- describe: 'Query dubhe schema struct state',
41
+ describe: 'Query dubhe schema struct state',
42
42
 
43
- builder: {
44
- network: {
45
- type: 'string',
46
- choices: ['mainnet', 'testnet', 'devnet', 'localnet'],
47
- default: 'localnet',
48
- desc: 'Node network (mainnet/testnet/devnet/localnet)',
49
- },
50
- 'config-path': {
51
- type: 'string',
52
- default: 'dubhe.config.ts',
53
- desc: 'Configuration file path',
54
- },
55
- schema: {
56
- type: 'string',
57
- desc: 'Schema name',
58
- demandOption: true,
59
- },
60
- 'object-id': {
61
- type: 'string',
62
- desc: 'Object ID (optional)',
63
- },
64
- 'package-id': {
65
- type: 'string',
66
- desc: 'Package ID (optional)',
67
- },
68
- 'metadata-path': {
69
- type: 'string',
70
- desc: 'Path to metadata JSON file (optional)',
71
- },
72
- params: {
73
- type: 'array',
74
- desc: 'Params for storage type: StorageValue(no params), StorageMap(1 param), StorageDoubleMap(2 params)',
75
- string: true,
76
- },
77
- },
43
+ builder: {
44
+ network: {
45
+ type: 'string',
46
+ choices: ['mainnet', 'testnet', 'devnet', 'localnet'],
47
+ default: 'localnet',
48
+ desc: 'Node network (mainnet/testnet/devnet/localnet)'
49
+ },
50
+ 'config-path': {
51
+ type: 'string',
52
+ default: 'dubhe.config.ts',
53
+ desc: 'Configuration file path'
54
+ },
55
+ schema: {
56
+ type: 'string',
57
+ desc: 'Schema name',
58
+ demandOption: true
59
+ },
60
+ 'object-id': {
61
+ type: 'string',
62
+ desc: 'Object ID (optional)'
63
+ },
64
+ 'package-id': {
65
+ type: 'string',
66
+ desc: 'Package ID (optional)'
67
+ },
68
+ 'metadata-path': {
69
+ type: 'string',
70
+ desc: 'Path to metadata JSON file (optional)'
71
+ },
72
+ params: {
73
+ type: 'array',
74
+ desc: 'Params for storage type: StorageValue(no params), StorageMap(1 param), StorageDoubleMap(2 params)',
75
+ string: true
76
+ }
77
+ },
78
78
 
79
- async handler({
80
- network,
81
- 'config-path': configPath,
82
- schema,
83
- 'object-id': objectId,
84
- 'package-id': packageId,
85
- 'metadata-path': metadataPath,
86
- params,
87
- }) {
88
- try {
89
- const dubheConfig = (await loadConfig(configPath)) as DubheConfig;
79
+ async handler({
80
+ network,
81
+ 'config-path': configPath,
82
+ schema,
83
+ 'object-id': objectId,
84
+ 'package-id': packageId,
85
+ 'metadata-path': metadataPath,
86
+ params
87
+ }) {
88
+ try {
89
+ const dubheConfig = (await loadConfig(configPath)) as DubheConfig;
90
90
 
91
- await queryStorage({
92
- dubheConfig,
93
- schema,
94
- objectId,
95
- network,
96
- packageId,
97
- metadataFilePath: metadataPath,
98
- params,
99
- });
100
- } catch (error: any) {
101
- logError(error);
102
- process.exit(1);
103
- }
104
- process.exit(0);
105
- },
91
+ await queryStorage({
92
+ dubheConfig,
93
+ schema,
94
+ objectId,
95
+ network,
96
+ packageId,
97
+ metadataFilePath: metadataPath,
98
+ params
99
+ });
100
+ } catch (error: any) {
101
+ logError(error);
102
+ process.exit(1);
103
+ }
104
+ process.exit(0);
105
+ }
106
106
  };
107
107
 
108
108
  export default commandModule;
@@ -3,38 +3,38 @@ import { schemaGen, loadConfig, DubheConfig } from '@0xobelisk/sui-common';
3
3
  import chalk from 'chalk';
4
4
 
5
5
  type Options = {
6
- 'config-path'?: string;
7
- network?: 'mainnet' | 'testnet' | 'devnet' | 'localnet';
6
+ 'config-path'?: string;
7
+ network?: 'mainnet' | 'testnet' | 'devnet' | 'localnet';
8
8
  };
9
9
 
10
10
  const commandModule: CommandModule<Options, Options> = {
11
- command: 'schemagen',
11
+ command: 'schemagen',
12
12
 
13
- describe: 'Autogenerate Dubhe schemas based on the config file',
13
+ describe: 'Autogenerate Dubhe schemas based on the config file',
14
14
 
15
- builder: {
16
- 'config-path': {
17
- type: 'string',
18
- default: 'dubhe.config.ts',
19
- desc: 'Path to the config file',
20
- },
21
- network: {
22
- type: 'string',
23
- choices: ['mainnet', 'testnet', 'devnet', 'localnet'] as const,
24
- desc: 'Node network (mainnet/testnet/devnet/localnet)',
25
- },
26
- },
15
+ builder: {
16
+ 'config-path': {
17
+ type: 'string',
18
+ default: 'dubhe.config.ts',
19
+ desc: 'Path to the config file'
20
+ },
21
+ network: {
22
+ type: 'string',
23
+ choices: ['mainnet', 'testnet', 'devnet', 'localnet'] as const,
24
+ desc: 'Node network (mainnet/testnet/devnet/localnet)'
25
+ }
26
+ },
27
27
 
28
- async handler({ 'config-path': configPath, network }) {
29
- try {
30
- const dubheConfig = (await loadConfig(configPath)) as DubheConfig;
31
- await schemaGen(dubheConfig, undefined, network);
32
- process.exit(0);
33
- } catch (error: any) {
34
- console.log(chalk.red('Schemagen failed!'));
35
- console.error(error.message);
36
- }
37
- },
28
+ async handler({ 'config-path': configPath, network }) {
29
+ try {
30
+ const dubheConfig = (await loadConfig(configPath)) as DubheConfig;
31
+ await schemaGen(dubheConfig, undefined, network);
32
+ process.exit(0);
33
+ } catch (error: any) {
34
+ console.log(chalk.red('Schemagen failed!'));
35
+ console.error(error.message);
36
+ }
37
+ }
38
38
  };
39
39
 
40
40
  export default commandModule;
@@ -3,49 +3,49 @@ import { execSync } from 'child_process';
3
3
  import { DubheConfig, loadConfig } from '@0xobelisk/sui-common';
4
4
 
5
5
  type Options = {
6
- 'config-path': string;
7
- test?: string;
8
- 'gas-limit'?: string;
6
+ 'config-path': string;
7
+ test?: string;
8
+ 'gas-limit'?: string;
9
9
  };
10
10
 
11
11
  const commandModule: CommandModule<Options, Options> = {
12
- command: 'test',
12
+ command: 'test',
13
13
 
14
- describe: 'Run tests in Dubhe contracts',
14
+ describe: 'Run tests in Dubhe contracts',
15
15
 
16
- builder(yargs) {
17
- return yargs.options({
18
- 'config-path': {
19
- type: 'string',
20
- default: 'dubhe.config.ts',
21
- description: 'Options to pass to forge test',
22
- },
23
- test: {
24
- type: 'string',
25
- desc: 'Run a specific test',
26
- },
27
- 'gas-limit': {
28
- type: 'string',
29
- desc: 'Set the gas limit for the test',
30
- },
31
- });
32
- },
16
+ builder(yargs) {
17
+ return yargs.options({
18
+ 'config-path': {
19
+ type: 'string',
20
+ default: 'dubhe.config.ts',
21
+ description: 'Options to pass to forge test'
22
+ },
23
+ test: {
24
+ type: 'string',
25
+ desc: 'Run a specific test'
26
+ },
27
+ 'gas-limit': {
28
+ type: 'string',
29
+ desc: 'Set the gas limit for the test'
30
+ }
31
+ });
32
+ },
33
33
 
34
- async handler({ 'config-path': configPath, test, 'gas-limit': gasLimit }) {
35
- // Start an internal anvil process if no world address is provided
36
- try {
37
- console.log('🚀 Running move test');
38
- const dubheConfig = (await loadConfig(configPath)) as DubheConfig;
39
- const path = process.cwd();
40
- const projectPath = `${path}/contracts/${dubheConfig.name}`;
41
- const command = `sui move test --path ${projectPath} ${
42
- test ? ` --test ${test}` : ''
43
- } ${gasLimit ? ` --gas-limit ${gasLimit}` : ''}`;
44
- execSync(command, { stdio: 'inherit', encoding: 'utf-8' });
45
- } catch (error: any) {
46
- process.exit(0);
47
- }
48
- },
34
+ async handler({ 'config-path': configPath, test, 'gas-limit': gasLimit }) {
35
+ // Start an internal anvil process if no world address is provided
36
+ try {
37
+ console.log('🚀 Running move test');
38
+ const dubheConfig = (await loadConfig(configPath)) as DubheConfig;
39
+ const path = process.cwd();
40
+ const projectPath = `${path}/contracts/${dubheConfig.name}`;
41
+ const command = `sui move test --path ${projectPath} ${
42
+ test ? ` --test ${test}` : ''
43
+ } ${gasLimit ? ` --gas-limit ${gasLimit}` : ''}`;
44
+ execSync(command, { stdio: 'inherit', encoding: 'utf-8' });
45
+ } catch (error: any) {
46
+ process.exit(0);
47
+ }
48
+ }
49
49
  };
50
50
 
51
51
  export default commandModule;