@jpool/bond-cli 1.7.0-next.1 → 1.7.0-next.2
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 +54 -4
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -6148,10 +6148,9 @@ function parseCollateralType(input) {
|
|
|
6148
6148
|
}
|
|
6149
6149
|
|
|
6150
6150
|
// package.json
|
|
6151
|
-
var version = "1.7.0-next.
|
|
6151
|
+
var version = "1.7.0-next.2";
|
|
6152
6152
|
|
|
6153
6153
|
// src/cli.ts
|
|
6154
|
-
process.env.CLUSTER = "https://mainnet.helius-rpc.com/?api-key=e7029c83-db93-4397-b540-114b2111e9f5";
|
|
6155
6154
|
var log = {
|
|
6156
6155
|
success: (...text) => console.log(source_default.green(...text)),
|
|
6157
6156
|
warn: (...text) => console.log(source_default.yellow(...text)),
|
|
@@ -6161,7 +6160,7 @@ var log = {
|
|
|
6161
6160
|
`)),
|
|
6162
6161
|
json: (data, color) => console.log(source_default[color ?? "magenta"](JSON.stringify(data, null, 2)))
|
|
6163
6162
|
};
|
|
6164
|
-
import_commander.program.name("jbond").description("CLI to interact with the JPool Bond program").version(process.env.VERSION ?? version).option("-c, --cluster <cluster>", "Solana cluster (mainnet-beta, devnet, testnet) or RPC URL [env:CLUSTER]", process.env.CLUSTER ?? "mainnet-beta").option("-k, --keypair <path>", "Path to Solana keypair file [env:CLI_SOLANA_KEYPAIR] (default: ~/.config/solana/id.json)").option("-b, --bond <name>", "Bond name [env:JBOND_BOND]", process.env.JBOND_BOND).option("-t, --bond-type <type>", "Bond type: standard|crowdfunding", "standard").hook("preAction", async (command) => {
|
|
6163
|
+
import_commander.program.name("jbond").description("CLI to interact with the JPool Bond program").version(process.env.VERSION ?? version).option("-c, --cluster <cluster>", "Solana cluster (mainnet-beta, devnet, testnet) or RPC URL [env:CLUSTER]", process.env.CLUSTER ?? "mainnet-beta").option("-e, --env <env>", "JBond program environment: dev | prod [env:JBOND_ENV]", process.env.JBOND_ENV || "prod").option("-k, --keypair <path>", "Path to Solana keypair file [env:CLI_SOLANA_KEYPAIR] (default: ~/.config/solana/id.json)").option("-b, --bond <name>", "Bond name [env:JBOND_BOND]", process.env.JBOND_BOND).option("-t, --bond-type <type>", "Bond type: standard|crowdfunding", "standard").hook("preAction", async (command) => {
|
|
6165
6164
|
const opts = command.opts();
|
|
6166
6165
|
const { provider, client } = initContext(opts);
|
|
6167
6166
|
log.json({
|
|
@@ -6312,6 +6311,23 @@ bond.command("balances").description("Show total collateral balances for bond").
|
|
|
6312
6311
|
throw new Error(`Failed to get bond balances: ${error2}`);
|
|
6313
6312
|
}
|
|
6314
6313
|
});
|
|
6314
|
+
bond.command("remove").description("Remove bond state").action(async () => {
|
|
6315
|
+
const spinner = ora("Removing bond state").start();
|
|
6316
|
+
const { client, keypair } = useContext();
|
|
6317
|
+
const bondType = getBondType();
|
|
6318
|
+
const bondName = getBondName();
|
|
6319
|
+
try {
|
|
6320
|
+
const tx = await client.bondRemove({ bondType, name: bondName, authority: keypair.publicKey });
|
|
6321
|
+
spinner.succeed("Bond state removed");
|
|
6322
|
+
log.json({
|
|
6323
|
+
name: bondName,
|
|
6324
|
+
transaction: tx
|
|
6325
|
+
});
|
|
6326
|
+
} catch (error2) {
|
|
6327
|
+
spinner.fail("Failed to remove bond state");
|
|
6328
|
+
throw error2;
|
|
6329
|
+
}
|
|
6330
|
+
});
|
|
6315
6331
|
var validator = import_commander.program.command("validator").description("Manage validator bonds");
|
|
6316
6332
|
validator.command("register <vote>").description("Register validator and create bond account").action(async (vote) => {
|
|
6317
6333
|
const spinner = ora("Registering validator").start();
|
|
@@ -6449,7 +6465,8 @@ validator.command("info <vote>").description("Show validator bond account inform
|
|
|
6449
6465
|
createdAt: bond2.createdAt,
|
|
6450
6466
|
creator: bond2.creator,
|
|
6451
6467
|
currentEpochLocked: bond2.locked,
|
|
6452
|
-
|
|
6468
|
+
pendingUnlock: bond2.pendingUnlock,
|
|
6469
|
+
pendingUnlockEpoch: bond2.pendingUnlockEpoch
|
|
6453
6470
|
});
|
|
6454
6471
|
} catch (error2) {
|
|
6455
6472
|
throw new Error(`Failed to get validator info: ${error2}`);
|
|
@@ -6528,6 +6545,39 @@ validator.command("lock-funds <vote> <amount>").description("Lock funds in valid
|
|
|
6528
6545
|
throw error2;
|
|
6529
6546
|
}
|
|
6530
6547
|
});
|
|
6548
|
+
validator.command("close <vote>").description("Close validator bond account and reclaim funds").option("-r, --receiver <pubkey>", "Rent receiver address (defaults to signer)").action(async (vote, opts) => {
|
|
6549
|
+
const spinner = ora("Closing validator bond").start();
|
|
6550
|
+
const { client, keypair } = useContext();
|
|
6551
|
+
const bondType = getBondType();
|
|
6552
|
+
const bondName = getBondName();
|
|
6553
|
+
try {
|
|
6554
|
+
const voteAccount = new import_web33.PublicKey(vote);
|
|
6555
|
+
const rentReceiver = opts.receiver ? new import_web33.PublicKey(opts.receiver) : keypair.publicKey;
|
|
6556
|
+
const bond2 = await client.getValidatorBond(bondType, bondName, voteAccount);
|
|
6557
|
+
if (!bond2) {
|
|
6558
|
+
throw new Error("Validator bond account not found");
|
|
6559
|
+
}
|
|
6560
|
+
if (bond2.locked.toNumber() > 0 || bond2.pendingUnlock.toNumber() > 0) {
|
|
6561
|
+
throw new Error("Cannot close: funds are still locked or pending unlock");
|
|
6562
|
+
}
|
|
6563
|
+
const tx = await client.closeValidatorBond({
|
|
6564
|
+
bondType,
|
|
6565
|
+
name: bondName,
|
|
6566
|
+
voteAccount,
|
|
6567
|
+
rentReceiver,
|
|
6568
|
+
authority: keypair.publicKey
|
|
6569
|
+
});
|
|
6570
|
+
spinner.succeed("Validator bond closed");
|
|
6571
|
+
log.json({
|
|
6572
|
+
voteAccount: vote,
|
|
6573
|
+
rentReceiver: rentReceiver.toString(),
|
|
6574
|
+
transaction: tx
|
|
6575
|
+
});
|
|
6576
|
+
} catch (error2) {
|
|
6577
|
+
spinner.fail("Failed to close validator bond");
|
|
6578
|
+
throw error2;
|
|
6579
|
+
}
|
|
6580
|
+
});
|
|
6531
6581
|
var session = import_commander.program.command("session").description("Manage bond sessions");
|
|
6532
6582
|
session.command("start <duration>").description("Start a bond session").action(async (duration) => {
|
|
6533
6583
|
const spinner = ora("Starting bond session").start();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jpool/bond-cli",
|
|
3
|
-
"version": "1.7.0-next.
|
|
3
|
+
"version": "1.7.0-next.2",
|
|
4
4
|
"description": "JBond CLI for interacting with the Solana program",
|
|
5
5
|
"main": "./dist/cli.js",
|
|
6
6
|
"bin": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"commander": "^14.0.1",
|
|
17
17
|
"dotenv": "^17.2.3",
|
|
18
18
|
"ora": "^9.0.0",
|
|
19
|
-
"@jpool/bond-sdk": "0.11.0-next.
|
|
19
|
+
"@jpool/bond-sdk": "0.11.0-next.22"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"tsup": "^8.5.0",
|