@peakd/hive-tx-cli 0.1.0
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 +172 -0
- package/bin/hive.js +2 -0
- package/dist/commands/broadcast.d.ts +3 -0
- package/dist/commands/broadcast.d.ts.map +1 -0
- package/dist/commands/broadcast.js +213 -0
- package/dist/commands/broadcast.js.map +1 -0
- package/dist/commands/config.d.ts +3 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +98 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/query.d.ts +3 -0
- package/dist/commands/query.d.ts.map +1 -0
- package/dist/commands/query.js +99 -0
- package/dist/commands/query.js.map +1 -0
- package/dist/config.d.ts +6 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +30 -0
- package/dist/config.js.map +1 -0
- package/dist/hive-client.d.ts +8 -0
- package/dist/hive-client.d.ts.map +1 -0
- package/dist/hive-client.js +33 -0
- package/dist/hive-client.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +50 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +12 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +21 -0
- package/dist/utils.js.map +1 -0
- package/package.json +48 -0
package/README.md
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# Hive CLI
|
|
2
|
+
|
|
3
|
+
A command-line interface wrapper for the Hive blockchain API using [hive-tx](https://github.com/mahdiyari/hive-tx) v6.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Query Operations**: Get account info, blocks, posts, and make raw API calls
|
|
8
|
+
- **Broadcast Operations**: Vote, comment, transfer, and broadcast custom JSON
|
|
9
|
+
- **Secure Configuration**: Store account credentials safely in `~/.hive-cli/config.json` (permissions 600)
|
|
10
|
+
- **Interactive Setup**: Easy configuration with prompts
|
|
11
|
+
- **Node.js 22**: Built for modern Node.js with TypeScript
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# Clone or download the project
|
|
17
|
+
git clone <repository-url>
|
|
18
|
+
cd hive-cli
|
|
19
|
+
|
|
20
|
+
# Install dependencies
|
|
21
|
+
pnpm install
|
|
22
|
+
|
|
23
|
+
# Build the project
|
|
24
|
+
pnpm build
|
|
25
|
+
|
|
26
|
+
# Link globally (optional)
|
|
27
|
+
pnpm link --global
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Quick Start
|
|
31
|
+
|
|
32
|
+
1. **Configure your account:**
|
|
33
|
+
```bash
|
|
34
|
+
hive config
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
2. **Check configuration status:**
|
|
38
|
+
```bash
|
|
39
|
+
hive status
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
3. **Query an account:**
|
|
43
|
+
```bash
|
|
44
|
+
hive account mahdiyari
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Commands
|
|
48
|
+
|
|
49
|
+
### Configuration
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Interactive configuration setup
|
|
53
|
+
hive config
|
|
54
|
+
|
|
55
|
+
# Show current configuration
|
|
56
|
+
hive config --show
|
|
57
|
+
|
|
58
|
+
# Set a specific value
|
|
59
|
+
hive config set account myaccount
|
|
60
|
+
hive config set postingKey <your-posting-key>
|
|
61
|
+
|
|
62
|
+
# Get a specific value
|
|
63
|
+
hive config get account
|
|
64
|
+
|
|
65
|
+
# Clear all configuration
|
|
66
|
+
hive config --clear
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Query Commands
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Get account information
|
|
73
|
+
hive account <username>
|
|
74
|
+
|
|
75
|
+
# Get dynamic global properties
|
|
76
|
+
hive props
|
|
77
|
+
|
|
78
|
+
# Get block by number
|
|
79
|
+
hive block <number>
|
|
80
|
+
|
|
81
|
+
# Get content (post/comment)
|
|
82
|
+
hive content <author> <permlink>
|
|
83
|
+
|
|
84
|
+
# Make a raw API call
|
|
85
|
+
hive call database_api get_accounts '[["username"]]'
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Broadcast Commands
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# Vote on a post/comment
|
|
92
|
+
hive vote --author <author> --permlink <permlink> --weight 100
|
|
93
|
+
|
|
94
|
+
# Create a post
|
|
95
|
+
hive comment --permlink my-post --title "My Post" --body "Content here" --tags "hive,blockchain"
|
|
96
|
+
|
|
97
|
+
# Create a comment
|
|
98
|
+
hive comment --permlink my-reply --body "Comment text" --parent-author <author> --parent-permlink <permlink>
|
|
99
|
+
|
|
100
|
+
# Transfer HIVE or HBD (requires active key)
|
|
101
|
+
hive transfer --to <recipient> --amount "1.000 HIVE" --memo "Thanks!"
|
|
102
|
+
|
|
103
|
+
# Broadcast custom JSON
|
|
104
|
+
hive custom-json --id <app-id> --json '{"key":"value"}'
|
|
105
|
+
|
|
106
|
+
# Broadcast raw operations
|
|
107
|
+
hive broadcast '["vote",{"voter":"me","author":"you","permlink":"post","weight":10000}]' --key-type posting
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Global Options
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
# Specify a different Hive node
|
|
114
|
+
hive --node https://api.hive.blog account mahdiyari
|
|
115
|
+
|
|
116
|
+
# Specify account for this command only
|
|
117
|
+
hive --account myaccount vote --author author --permlink permlink --weight 100
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Configuration File
|
|
121
|
+
|
|
122
|
+
Configuration is stored in `~/.hive-cli/config.json` with 600 permissions (read/write only for owner):
|
|
123
|
+
|
|
124
|
+
```json
|
|
125
|
+
{
|
|
126
|
+
"account": "your-username",
|
|
127
|
+
"postingKey": "your-posting-private-key",
|
|
128
|
+
"activeKey": "your-active-private-key",
|
|
129
|
+
"node": "https://api.hive.blog"
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**Security Note**: Never commit your private keys to version control!
|
|
134
|
+
|
|
135
|
+
## Development
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
# Run in development mode
|
|
139
|
+
pnpm dev
|
|
140
|
+
|
|
141
|
+
# Build for production
|
|
142
|
+
pnpm build
|
|
143
|
+
|
|
144
|
+
# Run specific command in dev mode
|
|
145
|
+
pnpm dev -- account mahdiyari
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Dependencies
|
|
149
|
+
|
|
150
|
+
- [hive-tx](https://github.com/mahdiyari/hive-tx) v6 - Hive blockchain transaction library
|
|
151
|
+
- [commander](https://github.com/tj/commander.js) - CLI framework
|
|
152
|
+
- [chalk](https://github.com/chalk/chalk) - Terminal styling
|
|
153
|
+
- [inquirer](https://github.com/SBoudrias/Inquirer.js) - Interactive prompts
|
|
154
|
+
- [ora](https://github.com/sindresorhus/ora) - Loading spinners
|
|
155
|
+
- [fs-extra](https://github.com/jprichardson/node-fs-extra) - Enhanced file system operations
|
|
156
|
+
|
|
157
|
+
## Requirements
|
|
158
|
+
|
|
159
|
+
- Node.js >= 22.0.0
|
|
160
|
+
- pnpm (package manager)
|
|
161
|
+
|
|
162
|
+
## License
|
|
163
|
+
|
|
164
|
+
MIT
|
|
165
|
+
|
|
166
|
+
## Contributing
|
|
167
|
+
|
|
168
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
169
|
+
|
|
170
|
+
## Support
|
|
171
|
+
|
|
172
|
+
For issues and questions related to hive-tx, visit: https://github.com/mahdiyari/hive-tx
|
package/bin/hive.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"broadcast.d.ts","sourceRoot":"","sources":["../../src/commands/broadcast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA0OpC,eAAO,MAAM,iBAAiB,WAAkE,CAAC"}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import ora from 'ora';
|
|
4
|
+
import inquirer from 'inquirer';
|
|
5
|
+
import { getConfig } from '../config.js';
|
|
6
|
+
import { HiveClient } from '../hive-client.js';
|
|
7
|
+
async function getClient() {
|
|
8
|
+
const config = await getConfig();
|
|
9
|
+
if (!config) {
|
|
10
|
+
console.error(chalk.red('Configuration not found. Run "hive config" first.'));
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
return new HiveClient(config);
|
|
14
|
+
}
|
|
15
|
+
function getAccountName(config, options) {
|
|
16
|
+
return options.account || config?.account || process.env.HIVE_ACCOUNT;
|
|
17
|
+
}
|
|
18
|
+
const voteCmd = new Command('vote')
|
|
19
|
+
.description('Vote on a post or comment')
|
|
20
|
+
.requiredOption('-a, --author <name>', 'Author of the content')
|
|
21
|
+
.requiredOption('-p, --permlink <string>', 'Permlink of the content')
|
|
22
|
+
.requiredOption('-w, --weight <number>', 'Vote weight (1-100)', '100')
|
|
23
|
+
.option('--account <name>', 'Voter account name (defaults to configured account)')
|
|
24
|
+
.action(async (options) => {
|
|
25
|
+
const config = await getConfig();
|
|
26
|
+
const voter = getAccountName(config, options);
|
|
27
|
+
if (!voter) {
|
|
28
|
+
console.error(chalk.red('Account not specified. Use --account or configure with "hive config"'));
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
const weight = parseInt(options.weight) * 100; // Convert to basis points
|
|
32
|
+
const operations = [
|
|
33
|
+
{
|
|
34
|
+
type: 'vote',
|
|
35
|
+
value: {
|
|
36
|
+
voter,
|
|
37
|
+
author: options.author,
|
|
38
|
+
permlink: options.permlink,
|
|
39
|
+
weight,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
const spinner = ora('Broadcasting vote...').start();
|
|
44
|
+
try {
|
|
45
|
+
const client = await getClient();
|
|
46
|
+
const result = await client.broadcast(operations, 'posting');
|
|
47
|
+
spinner.succeed('Vote broadcasted successfully');
|
|
48
|
+
console.log(JSON.stringify(result, null, 2));
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
spinner.fail(error.message);
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
const commentCmd = new Command('comment')
|
|
56
|
+
.description('Create a post or comment')
|
|
57
|
+
.requiredOption('-p, --permlink <string>', 'Permlink for the post/comment')
|
|
58
|
+
.requiredOption('-t, --title <string>', 'Title (for posts)')
|
|
59
|
+
.requiredOption('-b, --body <string>', 'Content body')
|
|
60
|
+
.option('--parent-author <name>', 'Parent author (for comments)', '')
|
|
61
|
+
.option('--parent-permlink <string>', 'Parent permlink (for comments)', '')
|
|
62
|
+
.option('--tags <tags>', 'Comma-separated tags', '')
|
|
63
|
+
.option('--account <name>', 'Author account name (defaults to configured account)')
|
|
64
|
+
.action(async (options) => {
|
|
65
|
+
const config = await getConfig();
|
|
66
|
+
const author = getAccountName(config, options);
|
|
67
|
+
if (!author) {
|
|
68
|
+
console.error(chalk.red('Account not specified. Use --account or configure with "hive config"'));
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
const jsonMetadata = options.tags
|
|
72
|
+
? JSON.stringify({ tags: options.tags.split(',').map((t) => t.trim()) })
|
|
73
|
+
: '';
|
|
74
|
+
const operations = [
|
|
75
|
+
{
|
|
76
|
+
type: 'comment',
|
|
77
|
+
value: {
|
|
78
|
+
parent_author: options.parentAuthor || '',
|
|
79
|
+
parent_permlink: options.parentPermlink || options.permlink,
|
|
80
|
+
author,
|
|
81
|
+
permlink: options.permlink,
|
|
82
|
+
title: options.title,
|
|
83
|
+
body: options.body,
|
|
84
|
+
json_metadata: jsonMetadata,
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
];
|
|
88
|
+
const spinner = ora('Broadcasting comment...').start();
|
|
89
|
+
try {
|
|
90
|
+
const client = await getClient();
|
|
91
|
+
const result = await client.broadcast(operations, 'posting');
|
|
92
|
+
spinner.succeed('Comment broadcasted successfully');
|
|
93
|
+
console.log(JSON.stringify(result, null, 2));
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
spinner.fail(error.message);
|
|
97
|
+
process.exit(1);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
const transferCmd = new Command('transfer')
|
|
101
|
+
.description('Transfer HIVE or HBD')
|
|
102
|
+
.requiredOption('-t, --to <name>', 'Recipient account')
|
|
103
|
+
.requiredOption('-a, --amount <string>', 'Amount (e.g., "1.000 HIVE")')
|
|
104
|
+
.option('-m, --memo <string>', 'Transfer memo', '')
|
|
105
|
+
.option('--account <name>', 'Sender account name (defaults to configured account)')
|
|
106
|
+
.action(async (options) => {
|
|
107
|
+
const config = await getConfig();
|
|
108
|
+
const from = getAccountName(config, options);
|
|
109
|
+
if (!from) {
|
|
110
|
+
console.error(chalk.red('Account not specified. Use --account or configure with "hive config"'));
|
|
111
|
+
process.exit(1);
|
|
112
|
+
}
|
|
113
|
+
if (!config?.activeKey) {
|
|
114
|
+
const { proceed } = await inquirer.prompt([
|
|
115
|
+
{
|
|
116
|
+
type: 'confirm',
|
|
117
|
+
name: 'proceed',
|
|
118
|
+
message: chalk.yellow('Active key not configured. This operation requires an active key. Continue anyway?'),
|
|
119
|
+
default: false,
|
|
120
|
+
},
|
|
121
|
+
]);
|
|
122
|
+
if (!proceed) {
|
|
123
|
+
console.log(chalk.dim('Cancelled'));
|
|
124
|
+
process.exit(0);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const operations = [
|
|
128
|
+
{
|
|
129
|
+
type: 'transfer',
|
|
130
|
+
value: {
|
|
131
|
+
from,
|
|
132
|
+
to: options.to,
|
|
133
|
+
amount: options.amount,
|
|
134
|
+
memo: options.memo,
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
];
|
|
138
|
+
const spinner = ora('Broadcasting transfer...').start();
|
|
139
|
+
try {
|
|
140
|
+
const client = await getClient();
|
|
141
|
+
const result = await client.broadcast(operations, 'active');
|
|
142
|
+
spinner.succeed('Transfer broadcasted successfully');
|
|
143
|
+
console.log(JSON.stringify(result, null, 2));
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
spinner.fail(error.message);
|
|
147
|
+
process.exit(1);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
const customJsonCmd = new Command('custom-json')
|
|
151
|
+
.description('Broadcast custom JSON operation')
|
|
152
|
+
.requiredOption('-i, --id <string>', 'Operation ID')
|
|
153
|
+
.requiredOption('-j, --json <string>', 'JSON payload')
|
|
154
|
+
.option('--required-posting <accounts>', 'Required posting auths (comma-separated)', '')
|
|
155
|
+
.option('--required-active <accounts>', 'Required active auths (comma-separated)', '')
|
|
156
|
+
.option('--account <name>', 'Account name (defaults to configured account)')
|
|
157
|
+
.action(async (options) => {
|
|
158
|
+
const config = await getConfig();
|
|
159
|
+
const account = getAccountName(config, options);
|
|
160
|
+
if (!account) {
|
|
161
|
+
console.error(chalk.red('Account not specified. Use --account or configure with "hive config"'));
|
|
162
|
+
process.exit(1);
|
|
163
|
+
}
|
|
164
|
+
const requiredPostingAuths = options.requiredPosting
|
|
165
|
+
? options.requiredPosting.split(',').map((a) => a.trim())
|
|
166
|
+
: [account];
|
|
167
|
+
const requiredAuths = options.requiredActive
|
|
168
|
+
? options.requiredActive.split(',').map((a) => a.trim())
|
|
169
|
+
: [];
|
|
170
|
+
const operations = [
|
|
171
|
+
{
|
|
172
|
+
type: 'custom_json',
|
|
173
|
+
value: {
|
|
174
|
+
required_auths: requiredAuths,
|
|
175
|
+
required_posting_auths: requiredPostingAuths,
|
|
176
|
+
id: options.id,
|
|
177
|
+
json: options.json,
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
];
|
|
181
|
+
const spinner = ora('Broadcasting custom JSON...').start();
|
|
182
|
+
try {
|
|
183
|
+
const client = await getClient();
|
|
184
|
+
const keyType = requiredAuths.length > 0 ? 'active' : 'posting';
|
|
185
|
+
const result = await client.broadcast(operations, keyType);
|
|
186
|
+
spinner.succeed('Custom JSON broadcasted successfully');
|
|
187
|
+
console.log(JSON.stringify(result, null, 2));
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
spinner.fail(error.message);
|
|
191
|
+
process.exit(1);
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
const broadcastCmd = new Command('broadcast')
|
|
195
|
+
.description('Broadcast raw operations')
|
|
196
|
+
.argument('<operations>', 'JSON array of operations')
|
|
197
|
+
.option('-k, --key-type <type>', 'Key type (posting or active)', 'posting')
|
|
198
|
+
.action(async (operations, options) => {
|
|
199
|
+
const parsedOperations = JSON.parse(operations);
|
|
200
|
+
const spinner = ora('Broadcasting operations...').start();
|
|
201
|
+
try {
|
|
202
|
+
const client = await getClient();
|
|
203
|
+
const result = await client.broadcast(parsedOperations, options.keyType);
|
|
204
|
+
spinner.succeed('Operations broadcasted successfully');
|
|
205
|
+
console.log(JSON.stringify(result, null, 2));
|
|
206
|
+
}
|
|
207
|
+
catch (error) {
|
|
208
|
+
spinner.fail(error.message);
|
|
209
|
+
process.exit(1);
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
export const broadcastCommands = [voteCmd, commentCmd, transferCmd, customJsonCmd, broadcastCmd];
|
|
213
|
+
//# sourceMappingURL=broadcast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"broadcast.js","sourceRoot":"","sources":["../../src/commands/broadcast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,QAAQ,MAAM,UAAU,C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CAAC,CAAC,CAAC;IAC/C,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC5B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,eAAO,MAAM,aAAa,SA6DtB,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import inquirer from 'inquirer';
|
|
4
|
+
import { getConfig, saveConfig, clearConfig } from '../config.js';
|
|
5
|
+
export const configCommand = new Command('config')
|
|
6
|
+
.description('Manage Hive CLI configuration')
|
|
7
|
+
.option('-s, --show', 'Show current configuration')
|
|
8
|
+
.option('--clear', 'Clear all configuration')
|
|
9
|
+
.action(async (options) => {
|
|
10
|
+
if (options.show) {
|
|
11
|
+
const config = await getConfig();
|
|
12
|
+
if (config) {
|
|
13
|
+
console.log(JSON.stringify(config, null, 2));
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
console.log(chalk.yellow('No configuration set'));
|
|
17
|
+
}
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (options.clear) {
|
|
21
|
+
await clearConfig();
|
|
22
|
+
console.log(chalk.green('Configuration cleared'));
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const existingConfig = await getConfig();
|
|
26
|
+
const answers = await inquirer.prompt([
|
|
27
|
+
{
|
|
28
|
+
type: 'input',
|
|
29
|
+
name: 'account',
|
|
30
|
+
message: 'Hive account name:',
|
|
31
|
+
default: existingConfig?.account || '',
|
|
32
|
+
validate: (input) => input.length > 0 || 'Account name is required',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
type: 'input',
|
|
36
|
+
name: 'postingKey',
|
|
37
|
+
message: 'Posting key (optional but recommended):',
|
|
38
|
+
default: existingConfig?.postingKey || '',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
type: 'input',
|
|
42
|
+
name: 'activeKey',
|
|
43
|
+
message: 'Active key (optional, required for transfers):',
|
|
44
|
+
default: existingConfig?.activeKey || '',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
type: 'input',
|
|
48
|
+
name: 'node',
|
|
49
|
+
message: 'Hive node URL:',
|
|
50
|
+
default: existingConfig?.node || 'https://api.hive.blog',
|
|
51
|
+
},
|
|
52
|
+
]);
|
|
53
|
+
const config = {
|
|
54
|
+
account: answers.account,
|
|
55
|
+
postingKey: answers.postingKey || undefined,
|
|
56
|
+
activeKey: answers.activeKey || undefined,
|
|
57
|
+
node: answers.node,
|
|
58
|
+
};
|
|
59
|
+
await saveConfig(config);
|
|
60
|
+
console.log(chalk.green('✔ Configuration saved'));
|
|
61
|
+
console.log(chalk.dim(`Config location: ~/.hive-cli/config.json`));
|
|
62
|
+
});
|
|
63
|
+
configCommand
|
|
64
|
+
.command('set <key> <value>')
|
|
65
|
+
.description('Set a specific configuration value')
|
|
66
|
+
.action(async (key, value) => {
|
|
67
|
+
const config = await getConfig() || { account: '' };
|
|
68
|
+
if (!['account', 'postingKey', 'activeKey', 'node'].includes(key)) {
|
|
69
|
+
console.error(chalk.red(`Invalid key: ${key}`));
|
|
70
|
+
console.log(chalk.dim('Valid keys: account, postingKey, activeKey, node'));
|
|
71
|
+
process.exit(1);
|
|
72
|
+
}
|
|
73
|
+
config[key] = value;
|
|
74
|
+
await saveConfig(config);
|
|
75
|
+
console.log(chalk.green(`✔ Set ${key}`));
|
|
76
|
+
});
|
|
77
|
+
configCommand
|
|
78
|
+
.command('get <key>')
|
|
79
|
+
.description('Get a specific configuration value')
|
|
80
|
+
.action(async (key) => {
|
|
81
|
+
const config = await getConfig();
|
|
82
|
+
if (!config) {
|
|
83
|
+
console.log(chalk.yellow('No configuration found'));
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
if (!['account', 'postingKey', 'activeKey', 'node'].includes(key)) {
|
|
87
|
+
console.error(chalk.red(`Invalid key: ${key}`));
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
90
|
+
const value = config[key];
|
|
91
|
+
if (value) {
|
|
92
|
+
console.log(value);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
console.log(chalk.yellow('Not set'));
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGlE,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;KAC/C,WAAW,CAAC,+BAA+B,CAAC;KAC5C,MAAM,CAAC,YAAY,EAAE,4BAA4B,CAAC;KAClD,MAAM,CAAC,SAAS,EAAE,yBAAyB,CAAC;KAC5C,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACxB,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC;QACjC,IAAI,MAAM,EAAE,CAAC;YACX,OAAO,CAAC,GAAG,CAAC,IAAI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5B,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC;IAEjC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC,CAAC;QACpD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,IAAI,CAAC,CAAC,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAClE,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,gBAAgB,GAAG,EAAE,CAAC,CAAC,CAAC;QAChD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,MAAM,KAAK,GAAI,MAAc,CAAC,GAAG,CAAC,CAAC;IACnC,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;IACvC,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/commands/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAmGpC,eAAO,MAAM,aAAa,WAAqE,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import ora from 'ora';
|
|
4
|
+
import { getConfig } from '../config.js';
|
|
5
|
+
import { HiveClient } from '../hive-client.js';
|
|
6
|
+
async function getClient() {
|
|
7
|
+
const config = await getConfig();
|
|
8
|
+
if (!config) {
|
|
9
|
+
console.error(chalk.red('Configuration not found. Run "hive config" first.'));
|
|
10
|
+
process.exit(1);
|
|
11
|
+
}
|
|
12
|
+
return new HiveClient(config);
|
|
13
|
+
}
|
|
14
|
+
const accountCmd = new Command('account')
|
|
15
|
+
.description('Get account information')
|
|
16
|
+
.argument('<name>', 'Account name')
|
|
17
|
+
.action(async (name) => {
|
|
18
|
+
const spinner = ora('Fetching account...').start();
|
|
19
|
+
try {
|
|
20
|
+
const client = await getClient();
|
|
21
|
+
const result = await client.call('condenser_api', 'get_accounts', [[name]]);
|
|
22
|
+
spinner.stop();
|
|
23
|
+
console.log(JSON.stringify(result, null, 2));
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
spinner.fail(error.message);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
const dynamicGlobalPropsCmd = new Command('props')
|
|
31
|
+
.description('Get dynamic global properties')
|
|
32
|
+
.alias('dynamic-global-properties')
|
|
33
|
+
.action(async () => {
|
|
34
|
+
const spinner = ora('Fetching properties...').start();
|
|
35
|
+
try {
|
|
36
|
+
const client = await getClient();
|
|
37
|
+
const result = await client.call('database_api', 'get_dynamic_global_properties', {});
|
|
38
|
+
spinner.stop();
|
|
39
|
+
console.log(JSON.stringify(result, null, 2));
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
spinner.fail(error.message);
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
const blockCmd = new Command('block')
|
|
47
|
+
.description('Get block by number')
|
|
48
|
+
.argument('<number>', 'Block number')
|
|
49
|
+
.action(async (number) => {
|
|
50
|
+
const spinner = ora(`Fetching block ${number}...`).start();
|
|
51
|
+
try {
|
|
52
|
+
const client = await getClient();
|
|
53
|
+
const result = await client.call('block_api', 'get_block', [{ block_num: parseInt(number) }]);
|
|
54
|
+
spinner.stop();
|
|
55
|
+
console.log(JSON.stringify(result, null, 2));
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
spinner.fail(error.message);
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
const contentCmd = new Command('content')
|
|
63
|
+
.description('Get content (post/comment)')
|
|
64
|
+
.argument('<author>', 'Author username')
|
|
65
|
+
.argument('<permlink>', 'Permlink')
|
|
66
|
+
.action(async (author, permlink) => {
|
|
67
|
+
const spinner = ora('Fetching content...').start();
|
|
68
|
+
try {
|
|
69
|
+
const client = await getClient();
|
|
70
|
+
const result = await client.call('bridge', 'get_post', { author, permlink });
|
|
71
|
+
spinner.stop();
|
|
72
|
+
console.log(JSON.stringify(result, null, 2));
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
spinner.fail(error.message);
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
const callCmd = new Command('call')
|
|
80
|
+
.description('Make a raw API call')
|
|
81
|
+
.argument('<api>', 'API name (e.g., database_api)')
|
|
82
|
+
.argument('<method>', 'Method name')
|
|
83
|
+
.argument('[params]', 'JSON parameters', '{}')
|
|
84
|
+
.action(async (api, method, params) => {
|
|
85
|
+
const spinner = ora(`Calling ${api}.${method}...`).start();
|
|
86
|
+
try {
|
|
87
|
+
const client = await getClient();
|
|
88
|
+
const parsedParams = JSON.parse(params);
|
|
89
|
+
const result = await client.call(api, method, Array.isArray(parsedParams) ? parsedParams : [parsedParams]);
|
|
90
|
+
spinner.stop();
|
|
91
|
+
console.log(JSON.stringify(result, null, 2));
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
spinner.fail(error.message);
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
export const queryCommands = [accountCmd, dynamicGlobalPropsCmd, blockCmd, contentCmd, callCmd];
|
|
99
|
+
//# sourceMappingURL=query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../src/commands/query.ts"],"names":[],"mappings":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>;
|
|
3
|
+
export declare function saveConfig(config: Config): Promise<void>;
|
|
4
|
+
export declare function clearConfig(): Promise<void>;
|
|
5
|
+
export declare function hasConfig(): Promise<boolean>;
|
|
6
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAKzC,wBAAsB,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAUxD;AAED,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG9D;AAED,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAIjD;AAED,wBAAsB,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC,CAElD"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { homedir } from 'os';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import fs from 'fs-extra';
|
|
4
|
+
const CONFIG_DIR = join(homedir(), '.hive-cli');
|
|
5
|
+
const CONFIG_FILE = join(CONFIG_DIR, 'config.json');
|
|
6
|
+
export async function getConfig() {
|
|
7
|
+
try {
|
|
8
|
+
if (!(await fs.pathExists(CONFIG_FILE))) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
const config = await fs.readJson(CONFIG_FILE);
|
|
12
|
+
return config;
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export async function saveConfig(config) {
|
|
19
|
+
await fs.ensureDir(CONFIG_DIR);
|
|
20
|
+
await fs.writeJson(CONFIG_FILE, config, { spaces: 2, mode: 0o600 });
|
|
21
|
+
}
|
|
22
|
+
export async function clearConfig() {
|
|
23
|
+
if (await fs.pathExists(CONFIG_FILE)) {
|
|
24
|
+
await fs.remove(CONFIG_FILE);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export async function hasConfig() {
|
|
28
|
+
return fs.pathExists(CONFIG_FILE);
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,MAAM,UAAU,CAAC;AAG1B,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,WAAW,CAAC,CAAC;AAChD,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;AAEpD,MAAM,CAAC,KAAK,UAAU,SAAS;IAC7B,IAAI,CAAC;QACH,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC;YACxC,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QAC9C,OAAO,MAAgB,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,MAAc;IAC7C,MAAM,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAC/B,MAAM,EAAE,CAAC,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AACtE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW;IAC/B,IAAI,MAAM,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QACrC,MAAM,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC/B,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,SAAS;IAC7B,OAAO,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Config, HiveOperation } from './types.js';
|
|
2
|
+
export declare class HiveClient {
|
|
3
|
+
private config;
|
|
4
|
+
constructor(config: Config);
|
|
5
|
+
call(api: string, method: string, params?: any): Promise<unknown>;
|
|
6
|
+
broadcast(operations: HiveOperation[], keyType?: 'posting' | 'active'): Promise<unknown>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=hive-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hive-client.d.ts","sourceRoot":"","sources":["../src/hive-client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAKxD,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,EAAE,MAAM;IAOpB,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAE,GAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;IAMrE,SAAS,CAAC,UAAU,EAAE,aAAa,EAAE,EAAE,OAAO,GAAE,SAAS,GAAG,QAAoB,GAAG,OAAO,CAAC,OAAO,CAAC;CAoB1G"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { PrivateKey, Transaction, call, config as hiveConfig } from 'hive-tx';
|
|
2
|
+
const DEFAULT_NODE = 'https://api.hive.blog';
|
|
3
|
+
const DEFAULT_CHAIN_ID = 'beeab0de00000000000000000000000000000000000000000000000000000000';
|
|
4
|
+
export class HiveClient {
|
|
5
|
+
config;
|
|
6
|
+
constructor(config) {
|
|
7
|
+
this.config = config;
|
|
8
|
+
// Set up hive-tx config
|
|
9
|
+
hiveConfig.node = config.node || DEFAULT_NODE;
|
|
10
|
+
hiveConfig.chain_id = config.chainId || DEFAULT_CHAIN_ID;
|
|
11
|
+
}
|
|
12
|
+
async call(api, method, params = []) {
|
|
13
|
+
const fullMethod = `${api}.${method}`;
|
|
14
|
+
const response = await call(fullMethod, params);
|
|
15
|
+
return response;
|
|
16
|
+
}
|
|
17
|
+
async broadcast(operations, keyType = 'posting') {
|
|
18
|
+
const key = keyType === 'active' ? this.config.activeKey : this.config.postingKey;
|
|
19
|
+
if (!key) {
|
|
20
|
+
throw new Error(`${keyType} key is not configured. Run 'hive config' to set up your keys.`);
|
|
21
|
+
}
|
|
22
|
+
if (!this.config.account) {
|
|
23
|
+
throw new Error('Account is not configured. Run "hive config" to set up your account.');
|
|
24
|
+
}
|
|
25
|
+
const privateKey = PrivateKey.fromString(key);
|
|
26
|
+
const tx = new Transaction();
|
|
27
|
+
await tx.create(operations.map(op => [op.type, op.value]));
|
|
28
|
+
tx.sign(privateKey);
|
|
29
|
+
const result = await tx.broadcast();
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=hive-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hive-client.js","sourceRoot":"","sources":["../src/hive-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,SAAS,CAAC;AAG9E,MAAM,YAAY,GAAG,uBAAuB,CAAC;AAC7C,MAAM,gBAAgB,GAAG,kEAAkE,CAAC;AAE5F,MAAM,OAAO,UAAU;IACb,MAAM,CAAS;IAEvB,YAAY,MAAc;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,wBAAwB;QACxB,UAAU,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,YAAY,CAAC;QAC9C,UAAU,CAAC,Q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d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { getConfig } from './config.js';
|
|
5
|
+
import { configCommand } from './commands/config.js';
|
|
6
|
+
import { queryCommands } from './commands/query.js';
|
|
7
|
+
import { broadcastCommands } from './commands/broadcast.js';
|
|
8
|
+
import { packageJson } from './utils.js';
|
|
9
|
+
const program = new Command();
|
|
10
|
+
program
|
|
11
|
+
.name('hive')
|
|
12
|
+
.description('CLI wrapper for the Hive blockchain API')
|
|
13
|
+
.version(packageJson.version)
|
|
14
|
+
.option('-n, --node <url>', 'Hive node URL')
|
|
15
|
+
.option('-a, --account <name>', 'Hive account name')
|
|
16
|
+
.hook('preAction', async (command) => {
|
|
17
|
+
const opts = command.opts();
|
|
18
|
+
const config = await getConfig();
|
|
19
|
+
if (opts.node) {
|
|
20
|
+
process.env.HIVE_NODE = opts.node;
|
|
21
|
+
}
|
|
22
|
+
if (opts.account) {
|
|
23
|
+
process.env.HIVE_ACCOUNT = opts.account;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
program.addCommand(configCommand);
|
|
27
|
+
for (const cmd of queryCommands) {
|
|
28
|
+
program.addCommand(cmd);
|
|
29
|
+
}
|
|
30
|
+
for (const cmd of broadcastCommands) {
|
|
31
|
+
program.addCommand(cmd);
|
|
32
|
+
}
|
|
33
|
+
program
|
|
34
|
+
.command('status')
|
|
35
|
+
.description('Show configuration status')
|
|
36
|
+
.action(async () => {
|
|
37
|
+
const config = await getConfig();
|
|
38
|
+
if (!config) {
|
|
39
|
+
console.log(chalk.yellow('⚠ No configuration found'));
|
|
40
|
+
console.log(chalk.dim('Run "hive config" to set up your account'));
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
console.log(chalk.green('✔ Configuration found'));
|
|
44
|
+
console.log(` Account: ${chalk.bold(config.account || 'Not set')}`);
|
|
45
|
+
console.log(` Node: ${config.node || 'Default (api.hive.blog)'}`);
|
|
46
|
+
console.log(` Posting Key: ${config.postingKey ? chalk.green('✔ Set') : chalk.red('✗ Not set')}`);
|
|
47
|
+
console.log(` Active Key: ${config.activeKey ? chalk.green('✔ Set') : chalk.yellow('○ Not set')}`);
|
|
48
|
+
});
|
|
49
|
+
program.parse();
|
|
50
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,MAAM,CAAC;KACZ,WAAW,CAAC,yCAAyC,CAAC;KACtD,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC;KAC5B,MAAM,CAAC,kBAAkB,EAAE,eAAe,CAAC;KAC3C,MAAM,CAAC,sBAAsB,EAAE,mBAAmB,CAAC;KACnD,IAAI,CAAC,WAAW,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;IACnC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAC5B,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC;IAEjC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QACd,OAAO,CAAC,GAAG,CAA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,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IACnG,OAAO,CAAC,GAAG,CAAC,iBAAiB,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;AACtG,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface Config {
|
|
2
|
+
account: string;
|
|
3
|
+
postingKey?: string;
|
|
4
|
+
activeKey?: string;
|
|
5
|
+
node?: string;
|
|
6
|
+
chainId?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface HiveOperation {
|
|
9
|
+
type: string;
|
|
10
|
+
value: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAwBA,eAAO,MAAM,WAAW,KAEvB,CAAC"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { readFileSync, existsSync } from 'fs';
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
import { dirname, join } from 'path';
|
|
4
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
5
|
+
const __dirname = dirname(__filename);
|
|
6
|
+
function findPackageJson() {
|
|
7
|
+
// Try relative paths from current file
|
|
8
|
+
const paths = [
|
|
9
|
+
join(__dirname, '../package.json'), // From dist/
|
|
10
|
+
join(__dirname, '../../package.json'), // From src/
|
|
11
|
+
join(process.cwd(), 'package.json'), // From cwd
|
|
12
|
+
];
|
|
13
|
+
for (const path of paths) {
|
|
14
|
+
if (existsSync(path)) {
|
|
15
|
+
return path;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
throw new Error('Could not find package.json');
|
|
19
|
+
}
|
|
20
|
+
export const packageJson = JSON.parse(readFileSync(findPackageJson(), 'utf-8'));
|
|
21
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAErC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC,SAAS,eAAe;IACtB,uCAAuC;IACvC,MAAM,KAAK,GAAG;QACZ,IAAI,CAAC,SAAS,EAAE,iBAAiB,CAAC,EAAM,aAAa;QACrD,IAAI,CAAC,SAAS,EAAE,oBAAoB,CAAC,EAAI,YAAY;QACrD,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,EAAM,WAAW;KACrD,CAAC;IAEF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACrB,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CACnC,YAAY,CAAC,eAAe,EAAE,EAAE,OAAO,CAAC,CACzC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@peakd/hive-tx-cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A CLI wrapper for the Hive blockchain API using hive-tx",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"bin": {
|
|
9
|
+
"hive": "./bin/hive.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"bin/",
|
|
13
|
+
"dist/",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc",
|
|
18
|
+
"build:binary": "bun build --compile --minify src/index.ts --outfile hive",
|
|
19
|
+
"dev": "tsx src/index.ts",
|
|
20
|
+
"start": "node dist/index.js",
|
|
21
|
+
"prepare": "pnpm build"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"hive",
|
|
25
|
+
"blockchain",
|
|
26
|
+
"cli",
|
|
27
|
+
"hive-tx"
|
|
28
|
+
],
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"chalk": "^5.6.2",
|
|
31
|
+
"commander": "^14.0.3",
|
|
32
|
+
"fs-extra": "^11.3.3",
|
|
33
|
+
"hive-tx": "^6.1.9",
|
|
34
|
+
"inquirer": "^13.2.2",
|
|
35
|
+
"ora": "^9.1.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/fs-extra": "^11.0.4",
|
|
39
|
+
"@types/inquirer": "^9.0.9",
|
|
40
|
+
"@types/node": "^25.2.0",
|
|
41
|
+
"tsx": "^4.21.0",
|
|
42
|
+
"typescript": "^5.9.3"
|
|
43
|
+
},
|
|
44
|
+
"packageManager": "pnpm@10.23.0",
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=22.0.0"
|
|
47
|
+
}
|
|
48
|
+
}
|