@jpool/bond-cli 1.6.2 → 1.7.0-next.1
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 +136 -108
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -6075,7 +6075,7 @@ function initContext({ cluster, env: env2, keypair }) {
|
|
|
6075
6075
|
const connection = new import_web3.Connection(rpcUrl, opts.commitment);
|
|
6076
6076
|
const wallet = new import_anchor.Wallet(resolveKeypair(keypair));
|
|
6077
6077
|
const provider = new import_anchor.AnchorProvider(connection, wallet, opts);
|
|
6078
|
-
const client = new import_bond_sdk.JBondClient(provider).env(env2);
|
|
6078
|
+
const client = new import_bond_sdk.JBondClient(provider, { debug: true }).env(env2);
|
|
6079
6079
|
context = {
|
|
6080
6080
|
cluster: cluster || "mainnet-beta",
|
|
6081
6081
|
keypair: wallet.payer,
|
|
@@ -6146,22 +6146,12 @@ function parseCollateralType(input) {
|
|
|
6146
6146
|
}
|
|
6147
6147
|
throw new Error("Invalid collateral type. Use: native | token:<mint> | stakeAccount");
|
|
6148
6148
|
}
|
|
6149
|
-
function parseBondType(type) {
|
|
6150
|
-
const normalized = (type || "").toLowerCase();
|
|
6151
|
-
if (normalized === "crowdfunding") {
|
|
6152
|
-
return { crowdfunding: {} };
|
|
6153
|
-
}
|
|
6154
|
-
if (normalized === "standard") {
|
|
6155
|
-
return { standard: {} };
|
|
6156
|
-
}
|
|
6157
|
-
console.error(source_default.red(`Invalid bond type: ${type}`));
|
|
6158
|
-
process.exit(1);
|
|
6159
|
-
}
|
|
6160
6149
|
|
|
6161
6150
|
// package.json
|
|
6162
|
-
var version = "1.
|
|
6151
|
+
var version = "1.7.0-next.1";
|
|
6163
6152
|
|
|
6164
6153
|
// src/cli.ts
|
|
6154
|
+
process.env.CLUSTER = "https://mainnet.helius-rpc.com/?api-key=e7029c83-db93-4397-b540-114b2111e9f5";
|
|
6165
6155
|
var log = {
|
|
6166
6156
|
success: (...text) => console.log(source_default.green(...text)),
|
|
6167
6157
|
warn: (...text) => console.log(source_default.yellow(...text)),
|
|
@@ -6171,7 +6161,7 @@ var log = {
|
|
|
6171
6161
|
`)),
|
|
6172
6162
|
json: (data, color) => console.log(source_default[color ?? "magenta"](JSON.stringify(data, null, 2)))
|
|
6173
6163
|
};
|
|
6174
|
-
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", process.env.CLUSTER ?? "mainnet-beta").option("-k, --keypair <path>", "Path to Solana keypair file").option("-b, --bond <name>", "Bond name
|
|
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) => {
|
|
6175
6165
|
const opts = command.opts();
|
|
6176
6166
|
const { provider, client } = initContext(opts);
|
|
6177
6167
|
log.json({
|
|
@@ -6195,8 +6185,7 @@ import_commander.program.command("init").description("Initialize global bond pro
|
|
|
6195
6185
|
});
|
|
6196
6186
|
} catch (error2) {
|
|
6197
6187
|
spinner.fail("Failed to initialize global state");
|
|
6198
|
-
|
|
6199
|
-
process.exit(1);
|
|
6188
|
+
throw error2;
|
|
6200
6189
|
}
|
|
6201
6190
|
});
|
|
6202
6191
|
var bond = import_commander.program.command("bond").description("Manage bond projects");
|
|
@@ -6206,7 +6195,7 @@ bond.command("init <name>").description("Initialize a new bond project").option(
|
|
|
6206
6195
|
try {
|
|
6207
6196
|
const reserve = opts.reserve ? new import_web33.PublicKey(opts.reserve) : keypair.publicKey;
|
|
6208
6197
|
const authority = opts.authority ? new import_web33.PublicKey(opts.authority) : void 0;
|
|
6209
|
-
const bondType =
|
|
6198
|
+
const bondType = getBondType();
|
|
6210
6199
|
const collateralType = parseCollateralType(opts.collateral);
|
|
6211
6200
|
await client.bondInitialize({ bondType, name, authority, collateralType, reserve });
|
|
6212
6201
|
spinner.succeed("Bond initialized");
|
|
@@ -6217,14 +6206,13 @@ bond.command("init <name>").description("Initialize a new bond project").option(
|
|
|
6217
6206
|
});
|
|
6218
6207
|
} catch (error2) {
|
|
6219
6208
|
spinner.fail("Failed to initialize bond");
|
|
6220
|
-
|
|
6221
|
-
process.exit(1);
|
|
6209
|
+
throw error2;
|
|
6222
6210
|
}
|
|
6223
6211
|
});
|
|
6224
|
-
bond.command("
|
|
6212
|
+
bond.command("configure").description("Update bond configuration").option("-a, --authority <pubkey>", "New authority address").option("-r, --reserve <pubkey>", "New reserve address").action(async (opts) => {
|
|
6225
6213
|
const spinner = ora("Updating bond configuration").start();
|
|
6226
6214
|
const { client } = useContext();
|
|
6227
|
-
const bondType =
|
|
6215
|
+
const bondType = getBondType();
|
|
6228
6216
|
const bondName = getBondName();
|
|
6229
6217
|
try {
|
|
6230
6218
|
if (!opts.authority && !opts.reserve) {
|
|
@@ -6241,75 +6229,94 @@ bond.command("config").description("Update bond configuration").option("-a, --au
|
|
|
6241
6229
|
spinner.succeed("Bond configuration updated");
|
|
6242
6230
|
const details = {};
|
|
6243
6231
|
if (newAuthority) {
|
|
6244
|
-
details.
|
|
6232
|
+
details.newAuthority = newAuthority.toString();
|
|
6245
6233
|
}
|
|
6246
6234
|
if (newReserve) {
|
|
6247
|
-
details.
|
|
6235
|
+
details.newReserve = newReserve.toString();
|
|
6248
6236
|
}
|
|
6249
6237
|
details.transaction = tx;
|
|
6250
6238
|
log.json(details);
|
|
6251
6239
|
} catch (error2) {
|
|
6252
6240
|
spinner.fail("Failed to update bond configuration");
|
|
6253
|
-
|
|
6254
|
-
process.exit(1);
|
|
6241
|
+
throw error2;
|
|
6255
6242
|
}
|
|
6256
6243
|
});
|
|
6257
6244
|
bond.command("info").description("Show bond state information").action(async () => {
|
|
6258
6245
|
const { client } = useContext();
|
|
6259
|
-
const bondType =
|
|
6246
|
+
const bondType = getBondType();
|
|
6260
6247
|
const bondName = getBondName();
|
|
6261
|
-
|
|
6262
|
-
|
|
6263
|
-
|
|
6264
|
-
|
|
6265
|
-
return;
|
|
6266
|
-
}
|
|
6267
|
-
log.header("Bond State Information");
|
|
6268
|
-
log.json(state);
|
|
6269
|
-
} catch (error2) {
|
|
6270
|
-
log.error(`Failed to get bond state: ${error2}`);
|
|
6271
|
-
process.exit(1);
|
|
6248
|
+
const state = await client.getBondState(bondType, bondName);
|
|
6249
|
+
if (!state) {
|
|
6250
|
+
log.warn("Bond state not found");
|
|
6251
|
+
return;
|
|
6272
6252
|
}
|
|
6253
|
+
log.header("Bond State Information");
|
|
6254
|
+
log.json(state);
|
|
6273
6255
|
});
|
|
6274
6256
|
bond.command("list").description("List all bond states").action(async () => {
|
|
6275
6257
|
const { client } = useContext();
|
|
6276
|
-
const bondType =
|
|
6277
|
-
|
|
6278
|
-
|
|
6279
|
-
|
|
6280
|
-
|
|
6281
|
-
|
|
6282
|
-
|
|
6283
|
-
log.header(`Found ${states.length} bond state(s)
|
|
6258
|
+
const bondType = getBondType();
|
|
6259
|
+
const states = await client.getAllBondStates(bondType);
|
|
6260
|
+
if (states.length === 0) {
|
|
6261
|
+
log.warn("No bond states found");
|
|
6262
|
+
return;
|
|
6263
|
+
}
|
|
6264
|
+
log.header(`Found ${states.length} bond state(s)
|
|
6284
6265
|
`);
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
6266
|
+
states.forEach((state, index) => {
|
|
6267
|
+
log.info(`Bond ${index + 1}:`);
|
|
6268
|
+
log.json(state);
|
|
6269
|
+
console.log("");
|
|
6270
|
+
});
|
|
6271
|
+
});
|
|
6272
|
+
bond.command("claim-all").description("Claim compensations from all validator bonds to reserve").action(async () => {
|
|
6273
|
+
const spinner = ora("Claiming all compensations").start();
|
|
6274
|
+
const { client, keypair, provider } = useContext();
|
|
6275
|
+
const bondType = getBondType();
|
|
6276
|
+
const bondName = getBondName();
|
|
6277
|
+
const BATCH_SIZE = 10;
|
|
6278
|
+
try {
|
|
6279
|
+
const ix = await client.getClaimAllCompensationsIxs({
|
|
6280
|
+
bondType,
|
|
6281
|
+
name: bondName,
|
|
6282
|
+
authority: keypair.publicKey
|
|
6289
6283
|
});
|
|
6284
|
+
console.log(`Total claims to process: ${ix.length}`);
|
|
6285
|
+
for (let i = 0; i < ix.length; i += BATCH_SIZE) {
|
|
6286
|
+
const chunk = ix.slice(i, i + BATCH_SIZE);
|
|
6287
|
+
const tx = await provider.connection.sendTransaction(new import_web33.Transaction().add(...chunk), [keypair]);
|
|
6288
|
+
log.info(`Processed batch ${i / BATCH_SIZE + 1}: ${chunk.length} claims (tx: ${tx})`);
|
|
6289
|
+
}
|
|
6290
|
+
spinner.succeed("All compensations claimed");
|
|
6290
6291
|
} catch (error2) {
|
|
6291
|
-
|
|
6292
|
-
|
|
6292
|
+
spinner.fail("Failed to claim all compensations");
|
|
6293
|
+
throw error2;
|
|
6293
6294
|
}
|
|
6294
6295
|
});
|
|
6295
|
-
bond.command("
|
|
6296
|
+
bond.command("balances").description("Show total collateral balances for bond").action(async () => {
|
|
6296
6297
|
const { client } = useContext();
|
|
6297
|
-
const bondType =
|
|
6298
|
+
const bondType = getBondType();
|
|
6298
6299
|
const bondName = getBondName();
|
|
6299
6300
|
try {
|
|
6300
|
-
const
|
|
6301
|
-
log.header("Collateral
|
|
6302
|
-
log.json(
|
|
6301
|
+
const validatorBalances = await client.getBondStateValidatorBondBalances(bondType, bondName);
|
|
6302
|
+
log.header("Bond Total Validator Collateral Balance");
|
|
6303
|
+
log.json({
|
|
6304
|
+
bond: bondName,
|
|
6305
|
+
bondType,
|
|
6306
|
+
validatorBalances: validatorBalances.map((vb) => ({
|
|
6307
|
+
voteAccount: vb.voteAccount.toString(),
|
|
6308
|
+
balance: `${lamportsToSol(vb.balance)}`
|
|
6309
|
+
}))
|
|
6310
|
+
});
|
|
6303
6311
|
} catch (error2) {
|
|
6304
|
-
|
|
6305
|
-
process.exit(1);
|
|
6312
|
+
throw new Error(`Failed to get bond balances: ${error2}`);
|
|
6306
6313
|
}
|
|
6307
6314
|
});
|
|
6308
6315
|
var validator = import_commander.program.command("validator").description("Manage validator bonds");
|
|
6309
6316
|
validator.command("register <vote>").description("Register validator and create bond account").action(async (vote) => {
|
|
6310
6317
|
const spinner = ora("Registering validator").start();
|
|
6311
6318
|
const { keypair, client } = useContext();
|
|
6312
|
-
const bondType =
|
|
6319
|
+
const bondType = getBondType();
|
|
6313
6320
|
const bondName = getBondName();
|
|
6314
6321
|
try {
|
|
6315
6322
|
const voteAccount = new import_web33.PublicKey(vote);
|
|
@@ -6326,19 +6333,18 @@ validator.command("register <vote>").description("Register validator and create
|
|
|
6326
6333
|
});
|
|
6327
6334
|
} catch (error2) {
|
|
6328
6335
|
spinner.fail("Failed to register validator");
|
|
6329
|
-
|
|
6330
|
-
process.exit(1);
|
|
6336
|
+
throw error2;
|
|
6331
6337
|
}
|
|
6332
6338
|
});
|
|
6333
|
-
validator.command("topup <vote> <amount>").description("Add collateral to validator bond account").action(async (vote,
|
|
6339
|
+
validator.command("topup <vote> <amount>").description("Add collateral to validator bond account").action(async (vote, amountStr) => {
|
|
6334
6340
|
const spinner = ora("Adding collateral").start();
|
|
6335
6341
|
const { client, keypair } = useContext();
|
|
6336
|
-
const bondType =
|
|
6342
|
+
const bondType = getBondType();
|
|
6337
6343
|
const bondName = getBondName();
|
|
6338
6344
|
try {
|
|
6339
6345
|
const voteAccount = new import_web33.PublicKey(vote);
|
|
6340
|
-
const
|
|
6341
|
-
if (Number.isNaN(
|
|
6346
|
+
const amount = Number.parseFloat(amountStr);
|
|
6347
|
+
if (Number.isNaN(amount) || amount <= 0) {
|
|
6342
6348
|
throw new Error("Invalid amount: must be positive number");
|
|
6343
6349
|
}
|
|
6344
6350
|
const signature = await client.topUpCollateral({
|
|
@@ -6346,29 +6352,28 @@ validator.command("topup <vote> <amount>").description("Add collateral to valida
|
|
|
6346
6352
|
name: bondName,
|
|
6347
6353
|
identity: keypair.publicKey,
|
|
6348
6354
|
voteAccount,
|
|
6349
|
-
|
|
6355
|
+
amount
|
|
6350
6356
|
});
|
|
6351
6357
|
spinner.succeed("Collateral added");
|
|
6352
6358
|
log.json({
|
|
6353
|
-
amount: `${
|
|
6359
|
+
amount: `${amount} SOL`,
|
|
6354
6360
|
transaction: signature
|
|
6355
6361
|
});
|
|
6356
6362
|
} catch (error2) {
|
|
6357
6363
|
spinner.fail("Failed to add collateral");
|
|
6358
|
-
|
|
6359
|
-
process.exit(1);
|
|
6364
|
+
throw error2;
|
|
6360
6365
|
}
|
|
6361
6366
|
});
|
|
6362
|
-
validator.command("withdraw <vote
|
|
6367
|
+
validator.command("withdraw <vote> <amount> <destination>").description("Withdraw collateral from validator bond account").action(async (voteAccountStr, amountStr, destinationStr) => {
|
|
6363
6368
|
const spinner = ora("Withdrawing collateral").start();
|
|
6364
6369
|
const { client } = useContext();
|
|
6365
|
-
const bondType =
|
|
6370
|
+
const bondType = getBondType();
|
|
6366
6371
|
const bondName = getBondName();
|
|
6367
6372
|
try {
|
|
6368
6373
|
const voteAccount = new import_web33.PublicKey(voteAccountStr);
|
|
6369
6374
|
const destination = new import_web33.PublicKey(destinationStr);
|
|
6370
|
-
const
|
|
6371
|
-
if (Number.isNaN(
|
|
6375
|
+
const amount = Number.parseFloat(amountStr);
|
|
6376
|
+
if (Number.isNaN(amount) || amount <= 0) {
|
|
6372
6377
|
throw new Error("Invalid amount: must be positive number");
|
|
6373
6378
|
}
|
|
6374
6379
|
const bond2 = await client.getValidatorBond(bondType, bondName, voteAccount);
|
|
@@ -6380,51 +6385,49 @@ validator.command("withdraw <vote-account> <amount> <destination>").description(
|
|
|
6380
6385
|
name: bondName,
|
|
6381
6386
|
voteAccount,
|
|
6382
6387
|
destination,
|
|
6383
|
-
|
|
6388
|
+
amount
|
|
6384
6389
|
});
|
|
6385
6390
|
spinner.succeed("Collateral withdrawn");
|
|
6386
6391
|
log.json({
|
|
6387
|
-
amount: `${
|
|
6392
|
+
amount: `${amount} SOL`,
|
|
6388
6393
|
destination: destinationStr,
|
|
6389
6394
|
transaction: tx
|
|
6390
6395
|
});
|
|
6391
6396
|
} catch (error2) {
|
|
6392
6397
|
spinner.fail("Failed to withdraw collateral");
|
|
6393
|
-
|
|
6394
|
-
process.exit(1);
|
|
6398
|
+
throw error2;
|
|
6395
6399
|
}
|
|
6396
6400
|
});
|
|
6397
|
-
validator.command("claim <vote> <amount>").description("Claim collateral from validator to reserve").action(async (vote,
|
|
6401
|
+
validator.command("claim <vote> <amount>").description("Claim collateral from validator to reserve").action(async (vote, amountStr) => {
|
|
6398
6402
|
const spinner = ora("Claiming collateral").start();
|
|
6399
6403
|
const { client } = useContext();
|
|
6400
|
-
const bondType =
|
|
6404
|
+
const bondType = getBondType();
|
|
6401
6405
|
const bondName = getBondName();
|
|
6402
6406
|
try {
|
|
6403
6407
|
const voteAccount = new import_web33.PublicKey(vote);
|
|
6404
|
-
const
|
|
6405
|
-
if (Number.isNaN(
|
|
6408
|
+
const amount = Number.parseFloat(amountStr);
|
|
6409
|
+
if (Number.isNaN(amount) || amount <= 0) {
|
|
6406
6410
|
throw new Error("Invalid amount: must be positive number");
|
|
6407
6411
|
}
|
|
6408
6412
|
const tx = await client.claimCompensation({
|
|
6409
6413
|
bondType,
|
|
6410
6414
|
name: bondName,
|
|
6411
6415
|
voteAccount,
|
|
6412
|
-
|
|
6416
|
+
amount
|
|
6413
6417
|
});
|
|
6414
6418
|
spinner.succeed("Collateral claimed");
|
|
6415
6419
|
log.json({
|
|
6416
|
-
amount: `${
|
|
6420
|
+
amount: `${amount} SOL`,
|
|
6417
6421
|
transaction: tx
|
|
6418
6422
|
});
|
|
6419
6423
|
} catch (error2) {
|
|
6420
6424
|
spinner.fail("Failed to claim collateral");
|
|
6421
|
-
|
|
6422
|
-
process.exit(1);
|
|
6425
|
+
throw error2;
|
|
6423
6426
|
}
|
|
6424
6427
|
});
|
|
6425
6428
|
validator.command("info <vote>").description("Show validator bond account information").action(async (vote) => {
|
|
6426
6429
|
const { client } = useContext();
|
|
6427
|
-
const bondType =
|
|
6430
|
+
const bondType = getBondType();
|
|
6428
6431
|
const bondName = getBondName();
|
|
6429
6432
|
try {
|
|
6430
6433
|
const voteAccount = new import_web33.PublicKey(vote);
|
|
@@ -6441,19 +6444,21 @@ validator.command("info <vote>").description("Show validator bond account inform
|
|
|
6441
6444
|
validator: bond2.identity,
|
|
6442
6445
|
voteAccount: bond2.voteAccount,
|
|
6443
6446
|
balance: `${lamportsToSol(balance)} SOL`,
|
|
6447
|
+
// TODO: handle non-native collateral
|
|
6444
6448
|
authority: bond2.withdrawalAuthority || "identity only",
|
|
6445
6449
|
createdAt: bond2.createdAt,
|
|
6446
|
-
creator: bond2.creator
|
|
6450
|
+
creator: bond2.creator,
|
|
6451
|
+
currentEpochLocked: bond2.locked,
|
|
6452
|
+
nextEpochLocked: bond2.nextEpochLocked
|
|
6447
6453
|
});
|
|
6448
6454
|
} catch (error2) {
|
|
6449
|
-
|
|
6450
|
-
process.exit(1);
|
|
6455
|
+
throw new Error(`Failed to get validator info: ${error2}`);
|
|
6451
6456
|
}
|
|
6452
6457
|
});
|
|
6453
6458
|
validator.command("set-authority <vote>").description("Set withdrawal authority for validator bond").option("-a, --authority <pubkey>", "New withdrawal authority (omit to remove)").action(async (vote, opts) => {
|
|
6454
6459
|
const spinner = ora("Setting withdrawal authority").start();
|
|
6455
6460
|
const { client, keypair } = useContext();
|
|
6456
|
-
const bondType =
|
|
6461
|
+
const bondType = getBondType();
|
|
6457
6462
|
const bondName = getBondName();
|
|
6458
6463
|
try {
|
|
6459
6464
|
const voteAccount = new import_web33.PublicKey(vote);
|
|
@@ -6478,37 +6483,62 @@ validator.command("set-authority <vote>").description("Set withdrawal authority
|
|
|
6478
6483
|
});
|
|
6479
6484
|
} catch (error2) {
|
|
6480
6485
|
spinner.fail("Failed to set withdrawal authority");
|
|
6481
|
-
|
|
6482
|
-
process.exit(1);
|
|
6486
|
+
throw error2;
|
|
6483
6487
|
}
|
|
6484
6488
|
});
|
|
6485
6489
|
validator.command("history <vote>").description("Show transaction history for validator").option("-l, --limit <number>", "Number of records", "10").action(async (vote, opts) => {
|
|
6486
6490
|
const { client } = useContext();
|
|
6487
|
-
const bondType =
|
|
6491
|
+
const bondType = getBondType();
|
|
6488
6492
|
const bondName = getBondName();
|
|
6489
6493
|
const limit = Number.parseInt(opts.limit, 10);
|
|
6490
6494
|
const voteAccount = new import_web33.PublicKey(vote);
|
|
6491
6495
|
const cluster = import_commander.program.opts().cluster || "mainnet-beta";
|
|
6496
|
+
const history = await client.history.getHistory(bondType, bondName, voteAccount, { limit, cluster });
|
|
6497
|
+
log.header(`Transaction History (limit: ${limit})`);
|
|
6498
|
+
log.json(history);
|
|
6499
|
+
});
|
|
6500
|
+
validator.command("lock-funds <vote> <amount>").description("Lock funds in validator bond account (standard bonds only)").action(async (vote, amountStr) => {
|
|
6501
|
+
const spinner = ora("Locking funds").start();
|
|
6502
|
+
const { client, keypair } = useContext();
|
|
6503
|
+
const bondType = getBondType();
|
|
6504
|
+
const bondName = getBondName();
|
|
6492
6505
|
try {
|
|
6493
|
-
|
|
6494
|
-
|
|
6495
|
-
|
|
6506
|
+
if (bondType !== "standard") {
|
|
6507
|
+
throw new Error("Locking funds is only supported for standard bonds");
|
|
6508
|
+
}
|
|
6509
|
+
const voteAccount = new import_web33.PublicKey(vote);
|
|
6510
|
+
const amount = Number.parseFloat(amountStr);
|
|
6511
|
+
if (Number.isNaN(amount) || amount <= 0) {
|
|
6512
|
+
throw new Error("Invalid amount: must be positive number");
|
|
6513
|
+
}
|
|
6514
|
+
const tx = await client.lockFunds({
|
|
6515
|
+
bondType,
|
|
6516
|
+
name: bondName,
|
|
6517
|
+
voteAccount,
|
|
6518
|
+
amount,
|
|
6519
|
+
withdrawAuthority: keypair.publicKey
|
|
6520
|
+
});
|
|
6521
|
+
spinner.succeed("Funds locked");
|
|
6522
|
+
log.json({
|
|
6523
|
+
amount: `${amount} SOL`,
|
|
6524
|
+
transaction: tx
|
|
6525
|
+
});
|
|
6496
6526
|
} catch (error2) {
|
|
6497
|
-
|
|
6498
|
-
|
|
6527
|
+
spinner.fail("Failed to lock funds");
|
|
6528
|
+
throw error2;
|
|
6499
6529
|
}
|
|
6500
6530
|
});
|
|
6501
6531
|
var session = import_commander.program.command("session").description("Manage bond sessions");
|
|
6502
6532
|
session.command("start <duration>").description("Start a bond session").action(async (duration) => {
|
|
6503
6533
|
const spinner = ora("Starting bond session").start();
|
|
6504
6534
|
const { client } = useContext();
|
|
6505
|
-
const bondType =
|
|
6535
|
+
const bondType = getBondType();
|
|
6506
6536
|
const bondName = getBondName();
|
|
6507
6537
|
try {
|
|
6508
6538
|
if (Number.isNaN(duration) || duration <= 0) {
|
|
6509
6539
|
throw new Error("Invalid duration: must be positive number");
|
|
6510
6540
|
}
|
|
6511
|
-
const tx = await client.bondStart({ bondType, name: bondName,
|
|
6541
|
+
const tx = await client.bondStart({ bondType, name: bondName, duration });
|
|
6512
6542
|
spinner.succeed("Bond session started");
|
|
6513
6543
|
log.json({
|
|
6514
6544
|
duration: `${duration} seconds`,
|
|
@@ -6516,14 +6546,13 @@ session.command("start <duration>").description("Start a bond session").action(a
|
|
|
6516
6546
|
});
|
|
6517
6547
|
} catch (error2) {
|
|
6518
6548
|
spinner.fail("Failed to start bond session");
|
|
6519
|
-
|
|
6520
|
-
process.exit(1);
|
|
6549
|
+
throw error2;
|
|
6521
6550
|
}
|
|
6522
6551
|
});
|
|
6523
6552
|
session.command("finish").description("Finish current bond session").action(async () => {
|
|
6524
6553
|
const spinner = ora("Finishing bond session").start();
|
|
6525
6554
|
const { client } = useContext();
|
|
6526
|
-
const bondType =
|
|
6555
|
+
const bondType = getBondType();
|
|
6527
6556
|
const bondName = getBondName();
|
|
6528
6557
|
try {
|
|
6529
6558
|
const transaction = await client.bondFinish({ bondType, name: bondName });
|
|
@@ -6531,17 +6560,13 @@ session.command("finish").description("Finish current bond session").action(asyn
|
|
|
6531
6560
|
log.json({ transaction });
|
|
6532
6561
|
} catch (error2) {
|
|
6533
6562
|
spinner.fail("Failed to finish bond session");
|
|
6534
|
-
|
|
6535
|
-
process.exit(1);
|
|
6563
|
+
throw error2;
|
|
6536
6564
|
}
|
|
6537
6565
|
});
|
|
6538
6566
|
import_commander.program.command("*", { isDefault: true, hidden: true }).allowExcessArguments(true).action(() => import_commander.program.help());
|
|
6539
6567
|
import_commander.program.parseAsync().catch((e) => {
|
|
6540
6568
|
log.error(`
|
|
6541
6569
|
${e.message}`);
|
|
6542
|
-
if (e.logs) {
|
|
6543
|
-
log.json(e.logs, "red");
|
|
6544
|
-
}
|
|
6545
6570
|
process.exit(1);
|
|
6546
6571
|
});
|
|
6547
6572
|
function getBondName() {
|
|
@@ -6551,3 +6576,6 @@ function getBondName() {
|
|
|
6551
6576
|
}
|
|
6552
6577
|
return bond2;
|
|
6553
6578
|
}
|
|
6579
|
+
function getBondType() {
|
|
6580
|
+
return import_commander.program.opts().bondType;
|
|
6581
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jpool/bond-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0-next.1",
|
|
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.
|
|
19
|
+
"@jpool/bond-sdk": "0.11.0-next.17"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"tsup": "^8.5.0",
|