hufi-cli 1.0.2 → 1.0.3
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/LICENSE +13 -0
- package/README.md +44 -38
- package/dist/cli.js +27 -4
- package/package.json +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
DO WHAT THE F*** YOU WANT TO PUBLIC LICENSE
|
|
2
|
+
Version 2, December 2004
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2024 hu-fi
|
|
5
|
+
|
|
6
|
+
Everyone is permitted to copy and distribute verbatim or modified
|
|
7
|
+
copies of this license document, and changing it is allowed as long
|
|
8
|
+
as the name is changed.
|
|
9
|
+
|
|
10
|
+
DO WHAT THE F*** YOU WANT TO PUBLIC LICENSE
|
|
11
|
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
|
12
|
+
|
|
13
|
+
0. You just DO WHAT THE F*** YOU WANT TO.
|
package/README.md
CHANGED
|
@@ -1,32 +1,34 @@
|
|
|
1
1
|
# hufi-cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](http://www.wtfpl.net/about/)
|
|
4
|
+
|
|
5
|
+
CLI tool for the [hu.fi](https://hu.finance) platform.
|
|
4
6
|
|
|
5
7
|
## Install
|
|
6
8
|
|
|
7
9
|
```bash
|
|
8
|
-
bun install -g hufi
|
|
10
|
+
bun install -g hufi-cli
|
|
9
11
|
```
|
|
10
12
|
|
|
11
13
|
Or run without installing:
|
|
12
14
|
|
|
13
15
|
```bash
|
|
14
|
-
bunx hufi <command>
|
|
16
|
+
bunx hufi-cli <command>
|
|
15
17
|
```
|
|
16
18
|
|
|
17
|
-
All examples below assume global install. Otherwise replace `hufi` with `bunx hufi`.
|
|
19
|
+
All examples below assume global install. Otherwise replace `hufi-cli` with `bunx hufi-cli`.
|
|
18
20
|
|
|
19
21
|
## Quick Start
|
|
20
22
|
|
|
21
23
|
```bash
|
|
22
24
|
# Generate a wallet
|
|
23
|
-
hufi auth generate
|
|
25
|
+
hufi-cli auth generate
|
|
24
26
|
|
|
25
27
|
# Login with saved key
|
|
26
|
-
hufi auth login
|
|
28
|
+
hufi-cli auth login
|
|
27
29
|
|
|
28
30
|
# Browse campaigns
|
|
29
|
-
hufi campaign list
|
|
31
|
+
hufi-cli campaign list
|
|
30
32
|
```
|
|
31
33
|
|
|
32
34
|
## Commands
|
|
@@ -40,9 +42,9 @@ hufi campaign list
|
|
|
40
42
|
| `auth status` | Show current auth status |
|
|
41
43
|
|
|
42
44
|
```bash
|
|
43
|
-
hufi auth generate --json
|
|
44
|
-
hufi auth login --private-key <key>
|
|
45
|
-
hufi auth status
|
|
45
|
+
hufi-cli auth generate --json
|
|
46
|
+
hufi-cli auth login --private-key <key>
|
|
47
|
+
hufi-cli auth status
|
|
46
48
|
```
|
|
47
49
|
|
|
48
50
|
### campaign
|
|
@@ -59,15 +61,15 @@ hufi auth status
|
|
|
59
61
|
| `campaign create` | Create a new campaign (launch escrow on-chain) |
|
|
60
62
|
|
|
61
63
|
```bash
|
|
62
|
-
hufi campaign list # list active campaigns
|
|
63
|
-
hufi campaign list --status completed --chain-id 1 # completed on Ethereum
|
|
64
|
-
hufi campaign get --chain-id 137 --address 0x... # campaign details
|
|
65
|
-
hufi campaign join --address 0x... # join (chain-id defaults to 137)
|
|
66
|
-
hufi campaign status --address 0x... # check status
|
|
67
|
-
hufi campaign progress --address 0x... # your progress
|
|
68
|
-
hufi campaign progress --address 0x... --watch # live updates (polling)
|
|
69
|
-
hufi campaign progress --address 0x... --watch --interval 3000
|
|
70
|
-
hufi campaign leaderboard --address 0x... # leaderboard
|
|
64
|
+
hufi-cli campaign list # list active campaigns
|
|
65
|
+
hufi-cli campaign list --status completed --chain-id 1 # completed on Ethereum
|
|
66
|
+
hufi-cli campaign get --chain-id 137 --address 0x... # campaign details
|
|
67
|
+
hufi-cli campaign join --address 0x... # join (chain-id defaults to 137)
|
|
68
|
+
hufi-cli campaign status --address 0x... # check status
|
|
69
|
+
hufi-cli campaign progress --address 0x... # your progress
|
|
70
|
+
hufi-cli campaign progress --address 0x... --watch # live updates (polling)
|
|
71
|
+
hufi-cli campaign progress --address 0x... --watch --interval 3000
|
|
72
|
+
hufi-cli campaign leaderboard --address 0x... # leaderboard
|
|
71
73
|
```
|
|
72
74
|
|
|
73
75
|
`campaign list` and `campaign get` print exact campaign timestamps and round token balances for human-readable text output.
|
|
@@ -80,21 +82,21 @@ Before broadcasting, the CLI validates the campaign type-specific target, checks
|
|
|
80
82
|
|
|
81
83
|
```bash
|
|
82
84
|
# Market Making
|
|
83
|
-
hufi campaign create \
|
|
85
|
+
hufi-cli campaign create \
|
|
84
86
|
--type market_making --exchange mexc --symbol HMT/USDT \
|
|
85
87
|
--start-date 2026-04-01 --end-date 2026-05-01 \
|
|
86
88
|
--fund-token USDT --fund-amount 10000 \
|
|
87
89
|
--daily-volume-target 50000
|
|
88
90
|
|
|
89
91
|
# Holding
|
|
90
|
-
hufi campaign create \
|
|
92
|
+
hufi-cli campaign create \
|
|
91
93
|
--type holding --exchange mexc --symbol HMT \
|
|
92
94
|
--start-date 2026-04-01 --end-date 2026-05-01 \
|
|
93
95
|
--fund-token USDT --fund-amount 5000 \
|
|
94
96
|
--daily-balance-target 1000
|
|
95
97
|
|
|
96
98
|
# Threshold
|
|
97
|
-
hufi campaign create \
|
|
99
|
+
hufi-cli campaign create \
|
|
98
100
|
--type threshold --exchange mexc --symbol HMT \
|
|
99
101
|
--start-date 2026-04-01 --end-date 2026-05-01 \
|
|
100
102
|
--fund-token USDT --fund-amount 5000 \
|
|
@@ -113,16 +115,16 @@ Running `campaign status/join/progress/leaderboard` without `-a` shows help.
|
|
|
113
115
|
| `exchange revalidate` | Revalidate an exchange API key |
|
|
114
116
|
|
|
115
117
|
```bash
|
|
116
|
-
hufi exchange register --name mexc --api-key <key> --secret-key <secret>
|
|
117
|
-
hufi exchange register --name bitmart --api-key <key> --secret-key <secret> --bitmart-memo <memo>
|
|
118
|
-
hufi exchange list
|
|
119
|
-
hufi exchange revalidate mexc
|
|
120
|
-
hufi exchange delete mexc
|
|
118
|
+
hufi-cli exchange register --name mexc --api-key <key> --secret-key <secret>
|
|
119
|
+
hufi-cli exchange register --name bitmart --api-key <key> --secret-key <secret> --bitmart-memo <memo>
|
|
120
|
+
hufi-cli exchange list
|
|
121
|
+
hufi-cli exchange revalidate mexc
|
|
122
|
+
hufi-cli exchange delete mexc
|
|
121
123
|
```
|
|
122
124
|
|
|
123
125
|
`exchange register` expects the CCXT exchange name in `--name` and accepts `--bitmart-memo` for Bitmart accounts that require an extra memo value.
|
|
124
126
|
|
|
125
|
-
You must run `hufi auth login` before `exchange register`, `exchange list`, `exchange delete`, or `exchange revalidate`.
|
|
127
|
+
You must run `hufi-cli auth login` before `exchange register`, `exchange list`, `exchange delete`, or `exchange revalidate`.
|
|
126
128
|
|
|
127
129
|
### staking
|
|
128
130
|
|
|
@@ -135,12 +137,12 @@ You must run `hufi auth login` before `exchange register`, `exchange list`, `exc
|
|
|
135
137
|
| `staking withdraw` | Withdraw unlocked tokens after lock period |
|
|
136
138
|
|
|
137
139
|
```bash
|
|
138
|
-
hufi staking deposit # show address QR code
|
|
139
|
-
hufi staking status # check your staking
|
|
140
|
-
hufi staking status --address 0x... # check another address
|
|
141
|
-
hufi staking stake 1000 # stake 1000 HMT
|
|
142
|
-
hufi staking unstake 500 # unstake 500 HMT
|
|
143
|
-
hufi staking withdraw # withdraw unlocked tokens
|
|
140
|
+
hufi-cli staking deposit # show address QR code
|
|
141
|
+
hufi-cli staking status # check your staking
|
|
142
|
+
hufi-cli staking status --address 0x... # check another address
|
|
143
|
+
hufi-cli staking stake 1000 # stake 1000 HMT
|
|
144
|
+
hufi-cli staking unstake 500 # unstake 500 HMT
|
|
145
|
+
hufi-cli staking withdraw # withdraw unlocked tokens
|
|
144
146
|
```
|
|
145
147
|
|
|
146
148
|
Supports Polygon (chain 137) and Ethereum (chain 1). Staking contract: `0x01D1...07F1D` on Polygon.
|
|
@@ -150,10 +152,10 @@ Supports Polygon (chain 137) and Ethereum (chain 1). Staking contract: `0x01D1..
|
|
|
150
152
|
Portfolio overview — staking, active campaigns, and progress in one view.
|
|
151
153
|
|
|
152
154
|
```bash
|
|
153
|
-
hufi dashboard # full overview
|
|
154
|
-
hufi dashboard --json # machine output
|
|
155
|
-
hufi dashboard --export csv # export active campaign rows as CSV
|
|
156
|
-
hufi dashboard --export json
|
|
155
|
+
hufi-cli dashboard # full overview
|
|
156
|
+
hufi-cli dashboard --json # machine output
|
|
157
|
+
hufi-cli dashboard --export csv # export active campaign rows as CSV
|
|
158
|
+
hufi-cli dashboard --export json
|
|
157
159
|
```
|
|
158
160
|
|
|
159
161
|
## Global Options
|
|
@@ -199,3 +201,7 @@ bun run typecheck # type check
|
|
|
199
201
|
|---------|-----|
|
|
200
202
|
| Recording Oracle | https://ro.hu.finance |
|
|
201
203
|
| Campaign Launcher | https://cl.hu.finance |
|
|
204
|
+
|
|
205
|
+
## License
|
|
206
|
+
|
|
207
|
+
This project is released under the [DO WHAT THE F*** YOU WANT TO PUBLIC LICENSE v2](http://www.wtfpl.net/about/). Do whatever you want with it.
|
package/dist/cli.js
CHANGED
|
@@ -22901,6 +22901,20 @@ function validateConfig(config) {
|
|
|
22901
22901
|
if (config.address !== undefined && !isEvmAddress(config.address)) {
|
|
22902
22902
|
issues.push("address must be a valid 0x-prefixed EVM address");
|
|
22903
22903
|
}
|
|
22904
|
+
if (config.rpcUrls !== undefined) {
|
|
22905
|
+
if (typeof config.rpcUrls !== "object" || config.rpcUrls === null || Array.isArray(config.rpcUrls)) {
|
|
22906
|
+
issues.push("rpcUrls must be an object mapping chain IDs to RPC URLs");
|
|
22907
|
+
} else {
|
|
22908
|
+
for (const [chainId, url] of Object.entries(config.rpcUrls)) {
|
|
22909
|
+
if (!/^\d+$/.test(chainId)) {
|
|
22910
|
+
issues.push(`rpcUrls key '${chainId}' must be a numeric chain ID`);
|
|
22911
|
+
}
|
|
22912
|
+
if (typeof url !== "string" || !isHttpUrl(url)) {
|
|
22913
|
+
issues.push(`rpcUrls.${chainId} must be a valid http/https URL`);
|
|
22914
|
+
}
|
|
22915
|
+
}
|
|
22916
|
+
}
|
|
22917
|
+
}
|
|
22904
22918
|
return {
|
|
22905
22919
|
valid: issues.length === 0,
|
|
22906
22920
|
issues
|
|
@@ -22928,7 +22942,7 @@ function createAuthCommand() {
|
|
|
22928
22942
|
auth.command("login").description("Authenticate with Recording Oracle using a private key").option("-k, --private-key <key>", "EVM private key (uses saved key if not provided)").option("-u, --api-url <url>", "Recording Oracle API URL").option("--json", "Output as JSON").action(async (opts) => {
|
|
22929
22943
|
const privateKey = opts.privateKey ?? loadKey();
|
|
22930
22944
|
if (!privateKey) {
|
|
22931
|
-
printText("No private key provided. Run: hufi auth login -k <key> or hufi auth generate");
|
|
22945
|
+
printText("No private key provided. Run: hufi-cli auth login -k <key> or hufi-cli auth generate");
|
|
22932
22946
|
process.exit(1);
|
|
22933
22947
|
}
|
|
22934
22948
|
const config = loadConfig();
|
|
@@ -22945,7 +22959,8 @@ function createAuthCommand() {
|
|
|
22945
22959
|
printJson({ address: result.address, accessToken: result.accessToken });
|
|
22946
22960
|
} else {
|
|
22947
22961
|
printText(`Authenticated as ${result.address}`);
|
|
22948
|
-
printText(`
|
|
22962
|
+
printText(`Private key loaded from ${getKeyPath()}`);
|
|
22963
|
+
printText(`Tokens saved to ${getConfigPath()}`);
|
|
22949
22964
|
}
|
|
22950
22965
|
} catch (err) {
|
|
22951
22966
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -22994,7 +23009,7 @@ function createAuthCommand() {
|
|
|
22994
23009
|
printText(`Authenticated as ${status.address}`);
|
|
22995
23010
|
printText(`API: ${status.apiUrl}`);
|
|
22996
23011
|
} else {
|
|
22997
|
-
printText("Not authenticated. Run: hufi auth login
|
|
23012
|
+
printText("Not authenticated. Run: hufi-cli auth login -k <key>");
|
|
22998
23013
|
}
|
|
22999
23014
|
}
|
|
23000
23015
|
});
|
|
@@ -24741,6 +24756,14 @@ function getContracts(chainId) {
|
|
|
24741
24756
|
return c;
|
|
24742
24757
|
}
|
|
24743
24758
|
function getRpc(chainId) {
|
|
24759
|
+
const override = process.env[`HUFI_RPC_${chainId}`];
|
|
24760
|
+
if (override) {
|
|
24761
|
+
return override;
|
|
24762
|
+
}
|
|
24763
|
+
const configOverride = loadConfig().rpcUrls?.[String(chainId)];
|
|
24764
|
+
if (configOverride) {
|
|
24765
|
+
return configOverride;
|
|
24766
|
+
}
|
|
24744
24767
|
const rpcs = RPC_URLS[chainId];
|
|
24745
24768
|
if (!rpcs) {
|
|
24746
24769
|
throw new Error(`No RPC URLs for chain ${chainId}`);
|
|
@@ -25731,7 +25754,7 @@ function createDashboardCommand() {
|
|
|
25731
25754
|
|
|
25732
25755
|
// src/cli.ts
|
|
25733
25756
|
var program2 = new Command;
|
|
25734
|
-
program2.name("hufi").description("CLI tool for
|
|
25757
|
+
program2.name("hufi").description("CLI tool for Hu.fi platform").version("1.0.3").option("--config-file <path>", "Custom config file path (default: ~/.hufi-cli/config.json)").option("--key-file <path>", "Custom key file path (default: ~/.hufi-cli/key.json)").hook("preAction", (thisCommand) => {
|
|
25735
25758
|
const opts = thisCommand.opts();
|
|
25736
25759
|
if (opts.configFile) {
|
|
25737
25760
|
setConfigFile(opts.configFile);
|