soluser 1.0.5 → 1.0.7

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/README.md CHANGED
@@ -7,7 +7,7 @@ npm install -g soluser@latest
7
7
  ```shell
8
8
  $ soluser new charlie
9
9
  $ soluser new alice --word-length 12
10
- $ soluser new bob --word-length 24 --no-bip39-passphrase
10
+ $ soluser new bob --word-length 24 --without-passphrase
11
11
  ```
12
12
 
13
13
  ## 切换账号
@@ -35,3 +35,13 @@ $ soluser address alice
35
35
  $ soluser balance alice
36
36
  ```
37
37
 
38
+ ## airdrop 给alias
39
+ ```shell
40
+ $ soluser airdrop 5 alice
41
+ Requesting airdrop of 5 SOL
42
+
43
+ Signature: 4BLUt5uxutbEwVywBTbAoBnG4EKb6QgsHgk3JRfjy6uJCoNjxdyYodbAhsWPXquBBwVzui1WyQxKn9d39JnwS3Pb
44
+
45
+ 500000005 SOL
46
+ ```
47
+
package/bin/index.js CHANGED
@@ -8,6 +8,15 @@ const removeAccount = require('../src/commands/remove');
8
8
 
9
9
  // 导入地址查询命令
10
10
  const showAddress = require('../src/commands/address');
11
+ // 导入余额查询命令
12
+ const checkBalance = require('../src/commands/balance');
13
+ // Import the airdrop command
14
+ const requestAirdrop = require('../src/commands/airdrop');
15
+
16
+ // Get version from package.json
17
+ const packageJson = require('../package.json');
18
+ // Set program version
19
+ program.version(packageJson.version);
11
20
 
12
21
  // 定义地址查询命令
13
22
  program
@@ -18,9 +27,18 @@ program
18
27
  showAddress(alias);
19
28
  });
20
29
 
21
- // 导入余额查询命令
22
- const checkBalance = require('../src/commands/balance');
23
30
 
31
+ // Define the airdrop command
32
+ program
33
+ .command('airdrop')
34
+ .description('Request an airdrop of SOL to a Solana account')
35
+ .argument('<amount>', 'Amount of SOL to request')
36
+ .argument('<alias>', 'Alias of the account to receive the airdrop')
37
+ .action((amount, alias) => {
38
+ requestAirdrop(amount, alias);
39
+ });
40
+
41
+ // ... existing code ...
24
42
  // 定义余额查询命令
25
43
  program
26
44
  .command('balance')
package/package.json CHANGED
@@ -1,21 +1,23 @@
1
1
  {
2
- "name": "soluser",
3
- "version": "1.0.5",
2
+ "name": "soluser",
3
+ "version": "1.0.7",
4
4
  "description": "A CLI tool to manage Solana accounts (new, switch, list)",
5
- "main": "bin/index.js",
5
+ "main": "bin/index.js",
6
6
  "bin": {
7
7
  "soluser": "./bin/index.js"
8
8
  },
9
- "keywords": ["solana", "cli", "account", "wallet"],
9
+ "keywords": [
10
+ "solana",
11
+ "cli",
12
+ "account",
13
+ "wallet"
14
+ ],
10
15
  "author": "guahuzi",
11
- "license": "MIT",
16
+ "license": "MIT",
12
17
  "dependencies": {
13
- "commander": "^11.1.0",
14
- "cli-table3": "^0.6.3"
15
18
  },
16
19
  "repository": {
17
20
  "type": "git",
18
21
  "url": "https://github.com/nextuser/soluser.git"
19
22
  }
20
23
  }
21
-
@@ -12,7 +12,7 @@ function showAddress(alias) {
12
12
  // 2. 解析并输出 base58 地址
13
13
  try {
14
14
  const address = getAddress(alias); // 复用之前的 getAddress 函数(基于 solana-keygen)
15
- console.log(address); // 直接输出地址(方便脚本调用)
15
+ process.stdout.write(address); // 直接输出地址(方便脚本调用)
16
16
  } catch (err) {
17
17
  console.error(`Error: Failed to parse address for "${alias}": ${err.message}`);
18
18
  process.exit(1);
@@ -0,0 +1,20 @@
1
+ // src/commands/airdrop.js
2
+ const { execCommand } = require('../utils/solana');
3
+ const { getAddress } = require('../utils/solana');
4
+ function requestAirdrop(amount, alias) {
5
+
6
+
7
+ try {
8
+ const address = getAddress(alias);
9
+ // Execute the solana airdrop command with the amount and resolved address
10
+ const cmd = `solana airdrop ${amount} ${address}`;
11
+ const result = execCommand(cmd);
12
+ console.log(result);
13
+ } catch (error) {
14
+ console.log("eroror in call requestAirdrop ${amount} ${alias}");
15
+ console.error(`Failed to request airdrop: ${error.message} \n `);
16
+ process.exit(1);
17
+ }
18
+ }
19
+
20
+ module.exports = requestAirdrop;