hufi-cli 0.5.3 → 0.5.5
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/dist/cli.js +27 -7
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -9357,7 +9357,8 @@ function keyFile() {
|
|
|
9357
9357
|
}
|
|
9358
9358
|
var DEFAULT_CONFIG = {
|
|
9359
9359
|
recordingApiUrl: "https://ro.hu.finance",
|
|
9360
|
-
launcherApiUrl: "https://cl.hu.finance"
|
|
9360
|
+
launcherApiUrl: "https://cl.hu.finance",
|
|
9361
|
+
defaultChainId: 137
|
|
9361
9362
|
};
|
|
9362
9363
|
function ensureConfigDir() {
|
|
9363
9364
|
if (!existsSync(CONFIG_DIR)) {
|
|
@@ -9402,6 +9403,9 @@ function saveKey(key, address) {
|
|
|
9402
9403
|
writeFileSync(keyFile(), JSON.stringify({ address, privateKey: key }, null, 2) + `
|
|
9403
9404
|
`);
|
|
9404
9405
|
}
|
|
9406
|
+
function getDefaultChainId() {
|
|
9407
|
+
return loadConfig().defaultChainId ?? 137;
|
|
9408
|
+
}
|
|
9405
9409
|
function loadKey() {
|
|
9406
9410
|
if (!existsSync(keyFile()))
|
|
9407
9411
|
return null;
|
|
@@ -11092,7 +11096,7 @@ function getLauncherUrl() {
|
|
|
11092
11096
|
}
|
|
11093
11097
|
function createCampaignCommand() {
|
|
11094
11098
|
const campaign = new Command("campaign").description("Campaign management commands");
|
|
11095
|
-
campaign.command("list").description("List available campaigns").option("-c, --chain-id <id>", "Chain ID", Number,
|
|
11099
|
+
campaign.command("list").description("List available campaigns").option("-c, --chain-id <id>", "Chain ID (default: from config)", Number, getDefaultChainId()).option("-s, --status <status>", "Filter by status (active, completed, cancelled, to_cancel)", "active").option("-l, --limit <n>", "Max results", Number, 20).option("--json", "Output as JSON").action(async (opts) => {
|
|
11096
11100
|
const config = loadConfig();
|
|
11097
11101
|
try {
|
|
11098
11102
|
const launcherResult = await listLauncherCampaigns(getLauncherUrl(), opts.chainId, opts.limit, opts.status);
|
|
@@ -11196,7 +11200,11 @@ function createCampaignCommand() {
|
|
|
11196
11200
|
process.exitCode = 1;
|
|
11197
11201
|
}
|
|
11198
11202
|
});
|
|
11199
|
-
campaign.command("status").description("Check campaign join status").
|
|
11203
|
+
const statusCmd = campaign.command("status").description("Check campaign join status").option("-c, --chain-id <id>", "Chain ID (default: from config)", Number, getDefaultChainId()).option("-a, --address <address>", "Campaign escrow address").option("--json", "Output as JSON").action(async (opts) => {
|
|
11204
|
+
if (!opts.address) {
|
|
11205
|
+
statusCmd.help();
|
|
11206
|
+
return;
|
|
11207
|
+
}
|
|
11200
11208
|
const { baseUrl, accessToken } = requireAuth2();
|
|
11201
11209
|
try {
|
|
11202
11210
|
const status = await checkJoinStatus(baseUrl, accessToken, opts.chainId, opts.address);
|
|
@@ -11215,7 +11223,11 @@ function createCampaignCommand() {
|
|
|
11215
11223
|
process.exitCode = 1;
|
|
11216
11224
|
}
|
|
11217
11225
|
});
|
|
11218
|
-
campaign.command("join").description("Join a campaign").
|
|
11226
|
+
const joinCmd = campaign.command("join").description("Join a campaign").option("-c, --chain-id <id>", "Chain ID (default: from config)", Number, getDefaultChainId()).option("-a, --address <address>", "Campaign escrow address").option("--json", "Output as JSON").action(async (opts) => {
|
|
11227
|
+
if (!opts.address) {
|
|
11228
|
+
joinCmd.help();
|
|
11229
|
+
return;
|
|
11230
|
+
}
|
|
11219
11231
|
const { baseUrl, accessToken } = requireAuth2();
|
|
11220
11232
|
try {
|
|
11221
11233
|
const joinStatus = await checkJoinStatus(baseUrl, accessToken, opts.chainId, opts.address);
|
|
@@ -11241,7 +11253,11 @@ function createCampaignCommand() {
|
|
|
11241
11253
|
process.exitCode = 1;
|
|
11242
11254
|
}
|
|
11243
11255
|
});
|
|
11244
|
-
campaign.command("progress").description("Check your progress in a campaign").option("-c, --chain-id <id>", "Chain ID", Number,
|
|
11256
|
+
const progressCmd = campaign.command("progress").description("Check your progress in a campaign").option("-c, --chain-id <id>", "Chain ID (default: from config)", Number, getDefaultChainId()).option("-a, --address <address>", "Campaign escrow address").option("--json", "Output as JSON").action(async (opts) => {
|
|
11257
|
+
if (!opts.address) {
|
|
11258
|
+
progressCmd.help();
|
|
11259
|
+
return;
|
|
11260
|
+
}
|
|
11245
11261
|
const { baseUrl, accessToken } = requireAuth2();
|
|
11246
11262
|
try {
|
|
11247
11263
|
const result = await getMyProgress(baseUrl, accessToken, opts.chainId, opts.address);
|
|
@@ -11263,7 +11279,11 @@ function createCampaignCommand() {
|
|
|
11263
11279
|
process.exitCode = 1;
|
|
11264
11280
|
}
|
|
11265
11281
|
});
|
|
11266
|
-
campaign.command("leaderboard").description("View campaign leaderboard").option("-c, --chain-id <id>", "Chain ID", Number,
|
|
11282
|
+
const leaderboardCmd = campaign.command("leaderboard").description("View campaign leaderboard").option("-c, --chain-id <id>", "Chain ID (default: from config)", Number, getDefaultChainId()).option("-a, --address <address>", "Campaign escrow address").option("-r, --rank-by <field>", "Rank by (rewards, current_progress)", "rewards").option("-l, --limit <n>", "Max results", Number, 20).option("--json", "Output as JSON").action(async (opts) => {
|
|
11283
|
+
if (!opts.address) {
|
|
11284
|
+
leaderboardCmd.help();
|
|
11285
|
+
return;
|
|
11286
|
+
}
|
|
11267
11287
|
try {
|
|
11268
11288
|
const baseUrl = loadConfig().recordingApiUrl.replace(/\/+$/, "");
|
|
11269
11289
|
const result = await getLeaderboard(baseUrl, opts.chainId, opts.address, opts.rankBy, opts.limit);
|
|
@@ -11292,7 +11312,7 @@ function createCampaignCommand() {
|
|
|
11292
11312
|
|
|
11293
11313
|
// src/cli.ts
|
|
11294
11314
|
var program2 = new Command;
|
|
11295
|
-
program2.name("hufi").description("CLI tool for hu.fi DeFi platform").version("0.5.
|
|
11315
|
+
program2.name("hufi").description("CLI tool for hu.fi DeFi platform").version("0.5.5").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) => {
|
|
11296
11316
|
const opts = thisCommand.opts();
|
|
11297
11317
|
if (opts.configFile) {
|
|
11298
11318
|
setConfigFile(opts.configFile);
|