@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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xobelisk/sui-cli",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "description": "Tookit for interacting with move eps framework",
5
5
  "keywords": [
6
6
  "sui",
@@ -41,16 +41,14 @@
41
41
  "execa": "^7.0.0",
42
42
  "glob": "^8.0.3",
43
43
  "path": "^0.12.7",
44
- "prettier": "^2.8.4",
45
- "prettier-plugin-rust": "^0.1.9",
46
44
  "sqlite": "^5.1.1",
47
45
  "sqlite3": "^5.1.7",
48
46
  "typescript": "5.1.6",
49
47
  "yargs": "^17.7.1",
50
48
  "zod": "^3.22.3",
51
49
  "zod-validation-error": "^1.3.0",
52
- "@0xobelisk/sui-common": "1.1.6",
53
- "@0xobelisk/sui-client": "1.1.4"
50
+ "@0xobelisk/sui-client": "1.1.7",
51
+ "@0xobelisk/sui-common": "1.1.7"
54
52
  },
55
53
  "devDependencies": {
56
54
  "@types/ejs": "^3.1.1",
@@ -60,7 +58,10 @@
60
58
  "ts-node": "^10.9.1",
61
59
  "tsup": "^6.7.0",
62
60
  "tsx": "^3.12.6",
63
- "vitest": "0.31.4"
61
+ "vitest": "0.31.4",
62
+ "eslint": "^8.56.0",
63
+ "eslint-config-prettier": "^9.1.0",
64
+ "prettier": "3.3.3"
64
65
  },
65
66
  "scripts": {
66
67
  "build": "pnpm run type-check && pnpm run build:js",
@@ -69,6 +70,9 @@
69
70
  "clean:js": "rimraf dist",
70
71
  "dev": "tsup --watch",
71
72
  "lint": "eslint . --ext .ts",
72
- "type-check": "tsc --noEmit"
73
+ "format": "prettier --write .",
74
+ "format:check": "prettier --check .",
75
+ "type-check": "tsc --noEmit",
76
+ "validate": "pnpm format:check && pnpm type-check"
73
77
  }
74
78
  }
@@ -5,59 +5,59 @@ import { DubheConfig, loadConfig } from '@0xobelisk/sui-common';
5
5
  import { switchEnv, updateDubheDependency } from '../utils';
6
6
 
7
7
  type Options = {
8
- 'config-path': string;
9
- network: any;
10
- 'dump-bytecode-as-base64'?: boolean;
8
+ 'config-path': string;
9
+ network: any;
10
+ 'dump-bytecode-as-base64'?: boolean;
11
11
  };
12
12
 
13
13
  const commandModule: CommandModule<Options, Options> = {
14
- command: 'build',
15
- describe: 'Run tests in Dubhe contracts',
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
- network: {
24
- type: 'string',
25
- default: 'localnet',
26
- choices: ['mainnet', 'testnet', 'devnet', 'localnet'],
27
- desc: 'Node network (mainnet/testnet/devnet/localnet)',
28
- },
29
- 'dump-bytecode-as-base64': {
30
- type: 'boolean',
31
- default: false,
32
- desc: 'Dump bytecode as base64',
33
- },
34
- });
35
- },
14
+ command: 'build',
15
+ describe: 'Run tests in Dubhe contracts',
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
+ network: {
24
+ type: 'string',
25
+ default: 'localnet',
26
+ choices: ['mainnet', 'testnet', 'devnet', 'localnet'],
27
+ desc: 'Node network (mainnet/testnet/devnet/localnet)'
28
+ },
29
+ 'dump-bytecode-as-base64': {
30
+ type: 'boolean',
31
+ default: false,
32
+ desc: 'Dump bytecode as base64'
33
+ }
34
+ });
35
+ },
36
36
 
37
- async handler({
38
- 'config-path': configPath,
39
- network,
40
- 'dump-bytecode-as-base64': dumpBytecodeAsBase64,
41
- }) {
42
- // Start an internal anvil process if no world address is provided
43
- try {
44
- console.log('šŸš€ Running move build');
45
- const dubheConfig = (await loadConfig(configPath)) as DubheConfig;
46
- const path = process.cwd();
47
- const projectPath = `${path}/contracts/${dubheConfig.name}`;
48
- await switchEnv(network);
49
- await updateDubheDependency(projectPath + '/Move.toml', network);
50
- const command = `sui move build --path ${projectPath} ${
51
- dumpBytecodeAsBase64 ? ` --dump-bytecode-as-base64` : ''
52
- }`;
53
- const output = execSync(command, { encoding: 'utf-8' });
54
- console.log(output);
55
- } catch (error: any) {
56
- console.error(chalk.red('Error executing sui move build:'));
57
- console.log(error.stdout);
58
- process.exit(0);
59
- }
60
- },
37
+ async handler({
38
+ 'config-path': configPath,
39
+ network,
40
+ 'dump-bytecode-as-base64': dumpBytecodeAsBase64
41
+ }) {
42
+ // Start an internal anvil process if no world address is provided
43
+ try {
44
+ console.log('šŸš€ Running move build');
45
+ const dubheConfig = (await loadConfig(configPath)) as DubheConfig;
46
+ const path = process.cwd();
47
+ const projectPath = `${path}/contracts/${dubheConfig.name}`;
48
+ await switchEnv(network);
49
+ await updateDubheDependency(projectPath + '/Move.toml', network);
50
+ const command = `sui move build --path ${projectPath} ${
51
+ dumpBytecodeAsBase64 ? ` --dump-bytecode-as-base64` : ''
52
+ }`;
53
+ const output = execSync(command, { encoding: 'utf-8' });
54
+ console.log(output);
55
+ } catch (error: any) {
56
+ console.error(chalk.red('Error executing sui move build:'));
57
+ console.log(error.stdout);
58
+ process.exit(0);
59
+ }
60
+ }
61
61
  };
62
62
 
63
63
  export default commandModule;
@@ -4,87 +4,87 @@ import { callHandler } from '../utils';
4
4
  import { loadConfig, DubheConfig } from '@0xobelisk/sui-common';
5
5
 
6
6
  type Options = {
7
- network: 'mainnet' | 'testnet' | 'devnet' | 'localnet';
8
- module: string;
9
- function: string;
10
- 'config-path'?: string;
11
- 'package-id'?: string;
12
- 'metadata-path'?: string;
13
- params?: any[];
7
+ network: 'mainnet' | 'testnet' | 'devnet' | 'localnet';
8
+ module: string;
9
+ function: string;
10
+ 'config-path'?: string;
11
+ 'package-id'?: string;
12
+ 'metadata-path'?: string;
13
+ params?: any[];
14
14
  };
15
15
 
16
16
  /**
17
17
  * CLI command for calling a function in a module
18
18
  */
19
19
  const commandModule: CommandModule<Options, Options> = {
20
- command: 'call',
20
+ command: 'call',
21
21
 
22
- describe: 'Call a function in a module',
22
+ describe: 'Call a function in a module',
23
23
 
24
- builder: {
25
- network: {
26
- type: 'string',
27
- choices: ['mainnet', 'testnet', 'devnet', 'localnet'],
28
- desc: 'Node network (mainnet/testnet/devnet/localnet)',
29
- default: 'localnet',
30
- },
31
- module: {
32
- type: 'string',
33
- desc: 'Module name',
34
- demandOption: true,
35
- },
36
- function: {
37
- type: 'string',
38
- desc: 'Function name',
39
- demandOption: true,
40
- },
41
- 'config-path': {
42
- type: 'string',
43
- default: 'dubhe.config.ts',
44
- desc: 'Configuration file path',
45
- },
46
- 'package-id': {
47
- type: 'string',
48
- desc: 'Package ID (optional)',
49
- },
50
- 'metadata-path': {
51
- type: 'string',
52
- desc: 'Path to metadata JSON file (optional)',
53
- },
54
- params: {
55
- type: 'array',
56
- desc: 'Params for the function',
57
- string: true,
58
- },
59
- },
24
+ builder: {
25
+ network: {
26
+ type: 'string',
27
+ choices: ['mainnet', 'testnet', 'devnet', 'localnet'],
28
+ desc: 'Node network (mainnet/testnet/devnet/localnet)',
29
+ default: 'localnet'
30
+ },
31
+ module: {
32
+ type: 'string',
33
+ desc: 'Module name',
34
+ demandOption: true
35
+ },
36
+ function: {
37
+ type: 'string',
38
+ desc: 'Function name',
39
+ demandOption: true
40
+ },
41
+ 'config-path': {
42
+ type: 'string',
43
+ default: 'dubhe.config.ts',
44
+ desc: 'Configuration file path'
45
+ },
46
+ 'package-id': {
47
+ type: 'string',
48
+ desc: 'Package ID (optional)'
49
+ },
50
+ 'metadata-path': {
51
+ type: 'string',
52
+ desc: 'Path to metadata JSON file (optional)'
53
+ },
54
+ params: {
55
+ type: 'array',
56
+ desc: 'Params for the function',
57
+ string: true
58
+ }
59
+ },
60
60
 
61
- async handler({
62
- network,
63
- 'config-path': configPath,
64
- module: moduleName,
65
- function: funcName,
66
- 'package-id': packageId,
67
- 'metadata-path': metadataPath,
68
- params,
69
- }) {
70
- try {
71
- const dubheConfig = (await loadConfig(configPath)) as DubheConfig;
61
+ async handler({
62
+ network,
63
+ 'config-path': configPath,
64
+ module: moduleName,
65
+ function: funcName,
66
+ 'package-id': packageId,
67
+ 'metadata-path': metadataPath,
68
+ params
69
+ }) {
70
+ try {
71
+ const dubheConfig = (await loadConfig(configPath)) as DubheConfig;
72
72
 
73
- await callHandler({
74
- dubheConfig,
75
- moduleName,
76
- funcName,
77
- network,
78
- packageId,
79
- metadataFilePath: metadataPath,
80
- params,
81
- });
82
- } catch (error: any) {
83
- logError(error);
84
- process.exit(1);
85
- }
86
- process.exit(0);
87
- },
73
+ await callHandler({
74
+ dubheConfig,
75
+ moduleName,
76
+ funcName,
77
+ network,
78
+ packageId,
79
+ metadataFilePath: metadataPath,
80
+ params
81
+ });
82
+ } catch (error: any) {
83
+ logError(error);
84
+ process.exit(1);
85
+ }
86
+ process.exit(0);
87
+ }
88
88
  };
89
89
 
90
90
  export default commandModule;
@@ -2,29 +2,29 @@ import type { CommandModule } from 'yargs';
2
2
  import { checkBalanceHandler } from '../utils/checkBalance';
3
3
 
4
4
  type Options = {
5
- network: 'mainnet' | 'testnet' | 'devnet' | 'localnet';
5
+ network: 'mainnet' | 'testnet' | 'devnet' | 'localnet';
6
6
  };
7
7
 
8
8
  const commandModule: CommandModule<Options, Options> = {
9
- command: 'check-balance',
10
- describe: 'Check the balance of the account',
11
- builder: {
12
- network: {
13
- type: 'string',
14
- choices: ['mainnet', 'testnet', 'devnet', 'localnet'],
15
- desc: 'Network to check balance on',
16
- default: 'localnet',
17
- },
18
- },
19
- async handler({ network }) {
20
- try {
21
- await checkBalanceHandler(network);
22
- } catch (error) {
23
- console.error('Error checking balance:', error);
24
- process.exit(1);
25
- }
26
- process.exit(0);
27
- },
9
+ command: 'check-balance',
10
+ describe: 'Check the balance of the account',
11
+ builder: {
12
+ network: {
13
+ type: 'string',
14
+ choices: ['mainnet', 'testnet', 'devnet', 'localnet'],
15
+ desc: 'Network to check balance on',
16
+ default: 'localnet'
17
+ }
18
+ },
19
+ async handler({ network }) {
20
+ try {
21
+ await checkBalanceHandler(network);
22
+ } catch (error) {
23
+ console.error('Error checking balance:', error);
24
+ process.exit(1);
25
+ }
26
+ process.exit(0);
27
+ }
28
28
  };
29
29
 
30
30
  export default commandModule;
@@ -3,46 +3,42 @@ import { storeConfigHandler } from '../utils/storeConfig';
3
3
  import { loadConfig, DubheConfig } from '@0xobelisk/sui-common';
4
4
 
5
5
  type Options = {
6
- 'config-path': string;
7
- network: 'mainnet' | 'testnet' | 'devnet' | 'localnet';
8
- 'output-ts-path': string;
6
+ 'config-path': string;
7
+ network: 'mainnet' | 'testnet' | 'devnet' | 'localnet';
8
+ 'output-ts-path': string;
9
9
  };
10
10
 
11
11
  const commandModule: CommandModule<Options, Options> = {
12
- command: 'config-store',
12
+ command: 'config-store',
13
13
 
14
- describe: 'Store configuration for the Dubhe project',
14
+ describe: 'Store configuration for the Dubhe project',
15
15
 
16
- builder: {
17
- 'config-path': {
18
- type: 'string',
19
- default: 'dubhe.config.ts',
20
- desc: 'Path to the config file',
21
- },
22
- network: {
23
- type: 'string',
24
- choices: ['mainnet', 'testnet', 'devnet', 'localnet'],
25
- desc: 'Network to store config for',
26
- },
27
- 'output-ts-path': {
28
- type: 'string',
29
- desc: 'Specify the output path for the generated TypeScript configuration file (e.g., ./src/config/generated.ts)',
30
- },
31
- },
32
- async handler({
33
- 'config-path': configPath,
34
- network,
35
- 'output-ts-path': outputTsPath,
36
- }) {
37
- try {
38
- const dubheConfig = (await loadConfig(configPath)) as DubheConfig;
39
- await storeConfigHandler(dubheConfig, network, outputTsPath);
40
- } catch (error) {
41
- console.error('Error storing config:', error);
42
- process.exit(1);
43
- }
44
- process.exit(0);
45
- },
16
+ builder: {
17
+ 'config-path': {
18
+ type: 'string',
19
+ default: 'dubhe.config.ts',
20
+ desc: 'Path to the config file'
21
+ },
22
+ network: {
23
+ type: 'string',
24
+ choices: ['mainnet', 'testnet', 'devnet', 'localnet'],
25
+ desc: 'Network to store config for'
26
+ },
27
+ 'output-ts-path': {
28
+ type: 'string',
29
+ desc: 'Specify the output path for the generated TypeScript configuration file (e.g., ./src/config/generated.ts)'
30
+ }
31
+ },
32
+ async handler({ 'config-path': configPath, network, 'output-ts-path': outputTsPath }) {
33
+ try {
34
+ const dubheConfig = (await loadConfig(configPath)) as DubheConfig;
35
+ await storeConfigHandler(dubheConfig, network, outputTsPath);
36
+ } catch (error) {
37
+ console.error('Error storing config:', error);
38
+ process.exit(1);
39
+ }
40
+ process.exit(0);
41
+ }
46
42
  };
47
43
 
48
44
  export default commandModule;
@@ -1,96 +1,88 @@
1
1
  import { Dubhe } from '@0xobelisk/sui-client';
2
2
  import type { CommandModule } from 'yargs';
3
3
  import { requestSuiFromFaucetV0, getFaucetHost } from '@mysten/sui/faucet';
4
- import {
5
- SuiClient,
6
- getFullnodeUrl,
7
- GetBalanceParams,
8
- } from '@mysten/sui/client';
4
+ import { SuiClient, getFullnodeUrl, GetBalanceParams } from '@mysten/sui/client';
9
5
  import { validatePrivateKey, DubheCliError } from '../utils';
10
6
 
11
7
  type Options = {
12
- network: any;
13
- recipient?: string;
8
+ network: any;
9
+ recipient?: string;
14
10
  };
15
11
 
16
12
  const commandModule: CommandModule<Options, Options> = {
17
- command: 'faucet',
13
+ command: 'faucet',
18
14
 
19
- describe: 'Interact with a Dubhe faucet',
15
+ describe: 'Interact with a Dubhe faucet',
20
16
 
21
- builder(yargs) {
22
- return yargs.options({
23
- network: {
24
- type: 'string',
25
- desc: 'URL of the Dubhe faucet',
26
- choices: ['testnet', 'devnet', 'localnet'],
27
- default: 'localnet',
28
- },
29
- recipient: {
30
- type: 'string',
31
- desc: 'Sui address to fund',
32
- },
33
- });
34
- },
17
+ builder(yargs) {
18
+ return yargs.options({
19
+ network: {
20
+ type: 'string',
21
+ desc: 'URL of the Dubhe faucet',
22
+ choices: ['testnet', 'devnet', 'localnet'],
23
+ default: 'localnet'
24
+ },
25
+ recipient: {
26
+ type: 'string',
27
+ desc: 'Sui address to fund'
28
+ }
29
+ });
30
+ },
35
31
 
36
- async handler({ network, recipient }) {
37
- let faucet_address = '';
38
- if (recipient === undefined) {
39
- const privateKey = process.env.PRIVATE_KEY;
40
- if (!privateKey)
41
- throw new DubheCliError(
42
- `Missing PRIVATE_KEY environment variable.
32
+ async handler({ network, recipient }) {
33
+ let faucet_address = '';
34
+ if (recipient === undefined) {
35
+ const privateKey = process.env.PRIVATE_KEY;
36
+ if (!privateKey)
37
+ throw new DubheCliError(
38
+ `Missing PRIVATE_KEY environment variable.
43
39
  Run 'echo "PRIVATE_KEY=YOUR_PRIVATE_KEY" > .env'
44
40
  in your contracts directory to use the default sui private key.`
45
- );
41
+ );
46
42
 
47
- const privateKeyFormat = validatePrivateKey(privateKey);
48
- if (privateKeyFormat === false) {
49
- throw new DubheCliError(`Please check your PRIVATE_KEY.`);
50
- }
51
- const dubhe = new Dubhe({
52
- secretKey: privateKeyFormat,
53
- });
54
- faucet_address = dubhe.getAddress();
55
- } else {
56
- faucet_address = recipient;
57
- }
43
+ const privateKeyFormat = validatePrivateKey(privateKey);
44
+ if (privateKeyFormat === false) {
45
+ throw new DubheCliError(`Please check your PRIVATE_KEY.`);
46
+ }
47
+ const dubhe = new Dubhe({
48
+ secretKey: privateKeyFormat
49
+ });
50
+ faucet_address = dubhe.getAddress();
51
+ } else {
52
+ faucet_address = recipient;
53
+ }
58
54
 
59
- console.log('\n🌊 Starting Faucet Operation...');
60
- console.log(` ā”œā”€ Network: ${network}`);
55
+ console.log('\n🌊 Starting Faucet Operation...');
56
+ console.log(` ā”œā”€ Network: ${network}`);
61
57
 
62
- if (recipient === undefined) {
63
- console.log(' ā”œā”€ Using Environment PrivateKey');
64
- console.log(` ā”œā”€ Generated Address: ${faucet_address}`);
65
- } else {
66
- console.log(` ā”œā”€ Using Provided Address: ${faucet_address}`);
67
- }
58
+ if (recipient === undefined) {
59
+ console.log(' ā”œā”€ Using Environment PrivateKey');
60
+ console.log(` ā”œā”€ Generated Address: ${faucet_address}`);
61
+ } else {
62
+ console.log(` ā”œā”€ Using Provided Address: ${faucet_address}`);
63
+ }
68
64
 
69
- console.log(' ā”œā”€ Requesting funds from faucet...');
70
- await requestSuiFromFaucetV0({
71
- host: getFaucetHost(network),
72
- recipient: faucet_address,
73
- });
65
+ console.log(' ā”œā”€ Requesting funds from faucet...');
66
+ await requestSuiFromFaucetV0({
67
+ host: getFaucetHost(network),
68
+ recipient: faucet_address
69
+ });
74
70
 
75
- console.log(' └─ Checking balance...');
76
- const client = new SuiClient({ url: getFullnodeUrl(network) });
77
- let params = {
78
- owner: faucet_address,
79
- } as GetBalanceParams;
71
+ console.log(' └─ Checking balance...');
72
+ const client = new SuiClient({ url: getFullnodeUrl(network) });
73
+ let params = {
74
+ owner: faucet_address
75
+ } as GetBalanceParams;
80
76
 
81
- const balance = await client.getBalance(params);
77
+ const balance = await client.getBalance(params);
82
78
 
83
- console.log('\nšŸ’° Account Summary');
84
- console.log(` ā”œā”€ Address: ${faucet_address}`);
85
- console.log(
86
- ` └─ Balance: ${(
87
- Number(balance.totalBalance) / 1_000_000_000
88
- ).toFixed(4)} SUI`
89
- );
79
+ console.log('\nšŸ’° Account Summary');
80
+ console.log(` ā”œā”€ Address: ${faucet_address}`);
81
+ console.log(` └─ Balance: ${(Number(balance.totalBalance) / 1_000_000_000).toFixed(4)} SUI`);
90
82
 
91
- console.log('\nāœ… Faucet Operation Complete\n');
92
- process.exit(0);
93
- },
83
+ console.log('\nāœ… Faucet Operation Complete\n');
84
+ process.exit(0);
85
+ }
94
86
  };
95
87
 
96
88
  export default commandModule;