@jpool/bond-cli 1.2.0-next.2 → 1.2.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.
Files changed (3) hide show
  1. package/README.md +7 -36
  2. package/dist/cli.js +46 -177
  3. package/package.json +15 -15
package/README.md CHANGED
@@ -52,7 +52,7 @@ Example:
52
52
  Add additional collateral to an existing validator bond.
53
53
 
54
54
  ```bash
55
- pnpm jbond topup <vote-account> <amount> -k <path>
55
+ pnpm jbond topup-collateral <vote-account> <amount> -k <path>
56
56
 
57
57
  Arguments:
58
58
  vote-account Vote account public key
@@ -63,15 +63,15 @@ Options:
63
63
  -c, --cluster <CLUSTER_NAME> Solana cluster(devnet or mainnet-beta)
64
64
 
65
65
  Example:
66
- pnpm jbond topup 686JcEJ98r8fMtUiVuKiz4WRoBpJ2Sm9zMhdc2b6H4bu 50 -c mainnet-beta
66
+ pnpm jbond topup-collateral 686JcEJ98r8fMtUiVuKiz4WRoBpJ2Sm9zMhdc2b6H4bu 50 -c mainnet-beta
67
67
  ```
68
68
 
69
69
  ### Withdraw Collateral
70
70
 
71
- Withdraw collateral from a validator bond account to a specified destination address.
71
+ Withdraw collateral from validator bond account.
72
72
 
73
73
  ```bash
74
- pnpm jbond withdraw <vote-account> <destination> <amount> [options]
74
+ pnpm jbond withdraw-collateral <vote-account> <destination> <amount> [options]
75
75
 
76
76
  Arguments:
77
77
  vote-account Vote account public key
@@ -83,42 +83,13 @@ Options:
83
83
  -c, --cluster <CLUSTER_NAME> Solana cluster(devnet or mainnet-beta)
84
84
 
85
85
  Example:
86
- pnpm jbond withdraw 686JcEJ98r8fMtUiVuKiz4WRoBpJ2Sm9zMhdc2b6H4bu 3K2coMGaZhrSkyF52wUBUXBeRBRpGLnmB3znzLRKjgiP 25 -c mainnet-beta
86
+ pnpm jbond withdraw-collateral 686JcEJ98r8fMtUiVuKiz4WRoBpJ2Sm9zMhdc2b6H4bu 3K2coMGaZhrSkyF52wUBUXBeRBRpGLnmB3znzLRKjgiP 25 -c mainnet-beta
87
87
  ```
88
88
 
89
89
  **Requirements**:
90
90
 
91
91
  Only the validator identity or withdrawal authority can execute withdrawals. The validator bond account must have sufficient collateral
92
92
 
93
- ### Set Withdrawal Authority
94
-
95
- Set or update the withdrawal authority for a validator bond account. This allows delegating withdrawal permissions to another address.
96
-
97
- ```bash
98
- pnpm jbond set-withdraw-authority <vote-account> [options]
99
-
100
- Arguments:
101
- vote-account Vote account public key
102
-
103
- Options:
104
- -k, --keypair <path> Path to keypair file (default: ~/.config/solana/id.json)
105
- -w, --new-authority <pubkey> New withdrawal authority (omit to remove authority)
106
- -c, --cluster <CLUSTER_NAME> Solana cluster(devnet or mainnet-beta)
107
-
108
- Examples:
109
- # Set a withdrawal authority
110
- pnpm jbond set-withdraw-authority 686JcEJ98r8fMtUiVuKiz4WRoBpJ2Sm9zMhdc2b6H4bu -w 9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin -c mainnet-beta
111
-
112
- # Remove withdrawal authority (revert to identity-only)
113
- pnpm jbond set-withdraw-authority 686JcEJ98r8fMtUiVuKiz4WRoBpJ2Sm9zMhdc2b6H4bu -c mainnet-beta
114
- ```
115
-
116
- **Requirements**:
117
-
118
- - Only the validator identity can set or update the withdrawal authority
119
- - When a withdrawal authority is set, only that authority (or validator identity) can withdraw collateral
120
- - Omitting the `--new-authority` option removes the withdrawal authority, reverting to identity-only withdrawals
121
-
122
93
  ### Claim Compensation
123
94
 
124
95
  Claim compensation from a validator's collateral to the reserve (authority only).
@@ -224,7 +195,7 @@ pnpm jbond register-validator GHRvDXj9BfACkJ9CoLWbpi2UkMVti9DwXJGsaFT9XDcD 100
224
195
  pnpm jbond validator-info GHRvDXj9BfACkJ9CoLWbpi2UkMVti9DwXJGsaFT9XDcD -c mainnet-beta
225
196
 
226
197
  # 4. Top up with additional 50 SOL
227
- pnpm jbond topup GHRvDXj9BfACkJ9CoLWbpi2UkMVti9DwXJGsaFT9XDcD 50 -c mainnet-beta
198
+ pnpm jbond topup-collateral GHRvDXj9BfACkJ9CoLWbpi2UkMVti9DwXJGsaFT9XDcD 50 -c mainnet-beta
228
199
  ```
229
200
 
230
201
  ### Authority Operations
@@ -260,4 +231,4 @@ Common errors and solutions:
260
231
  ### `Account already in use`
261
232
 
262
233
  - The validator is already registered
263
- - Use `topup` to add more funds instead
234
+ - Use `topup-collateral` to add more funds instead
package/dist/cli.js CHANGED
@@ -5,10 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
8
  var __copyProps = (to, from, except, desc) => {
13
9
  if (from && typeof from === "object" || typeof from === "function") {
14
10
  for (let key of __getOwnPropNames(from))
@@ -25,14 +21,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
21
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
22
  mod
27
23
  ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
24
 
30
25
  // src/cli.ts
31
- var cli_exports = {};
32
- __export(cli_exports, {
33
- parseCollateralType: () => parseCollateralType
34
- });
35
- module.exports = __toCommonJS(cli_exports);
36
26
  var import_web32 = require("@solana/web3.js");
37
27
  var import_chalk = __toESM(require("chalk"));
38
28
  var import_commander = require("commander");
@@ -91,10 +81,10 @@ function resolveKeypair(path) {
91
81
  }
92
82
 
93
83
  // package.json
94
- var version = "1.2.0-next.1";
84
+ var version = "1.1.1";
95
85
 
96
86
  // src/cli.ts
97
- import_commander.program.name("jbond").description("CLI to interact with the JPool Bond program").version(process.env.VERSION ?? version).allowExcessArguments(false).option("-c, --cluster <CLUSTER>", "Solana cluster or RPC URL").option("-k, --keypair <KEYPAIR>", "Filepath to Solana keypair").option("-b, --bond-type <TYPE>", "Bond type: performance | crowdfunding", "performance").option("-n , --bond-name <name>", "Bond name").hook("preAction", async (command) => {
87
+ import_commander.program.name("jbond").description("CLI to interact with the JPool Bond program").version(process.env.VERSION ?? version).allowExcessArguments(false).option("-c, --cluster <CLUSTER>", "Solana cluster or RPC URL").option("-k, --keypair <KEYPAIR>", "Filepath to Solana keypair").hook("preAction", async (command) => {
98
88
  const opts = command.opts();
99
89
  const { provider, client } = initContext(opts);
100
90
  console.log(import_chalk.default.dim(`# Version: ${command.version()}`));
@@ -105,32 +95,35 @@ import_commander.program.name("jbond").description("CLI to interact with the JPo
105
95
  }).hook("postAction", (_c) => {
106
96
  process.exit();
107
97
  });
108
- import_commander.program.command("global-initialize").description("Initialize global state").option("-w, --authority <pubkey>", "Authority (defaults to signer)").action(async (opts) => {
109
- const spinner = (0, import_ora.default)("Initializing global state...").start();
98
+ import_commander.program.command("info").description("Get global state information").action(async () => {
110
99
  const { client, provider } = useContext();
111
100
  try {
112
- const authority = opts.authority ? new import_web32.PublicKey(opts.authority) : provider.wallet.publicKey;
113
- const tx = await client.globalInitialize({ authority });
114
- spinner.succeed(import_chalk.default.green("Global state initialized successfully!"));
115
- console.log(import_chalk.default.gray(`Transaction: ${tx}`));
116
- console.log(import_chalk.default.gray(`Authority: ${authority.toString()}`));
101
+ const state = await client.getGlobalState();
102
+ if (!state) {
103
+ console.log(import_chalk.default.yellow("Global state not initialized"));
104
+ return;
105
+ }
106
+ console.log(import_chalk.default.cyan("Global State Information:"));
107
+ console.log(import_chalk.default.white(` Authority: ${state.authority}`));
108
+ console.log(import_chalk.default.white(` Reserve: ${state.reserve}`));
109
+ console.log(import_chalk.default.white(` Total Validators: ${state.totalValidators}`));
110
+ console.log(import_chalk.default.white(` Total Compensation Amount: ${state.totalCompensationAmount.toString()}`));
111
+ const epochInfo = await provider.connection.getEpochInfo();
112
+ console.log(import_chalk.default.white(` Current Epoch: ${epochInfo.epoch}`));
117
113
  } catch (error) {
118
- spinner.fail(import_chalk.default.red(`Failed to initialize global state: ${error}`));
114
+ console.error(import_chalk.default.red(`Failed to get global state info: ${error}`));
119
115
  process.exit(1);
120
116
  }
121
117
  });
122
- import_commander.program.command("initialize").description("Initialize specific bond project").requiredOption("-r, --reserve <address>", "Reserve vault address").requiredOption("-t, --collateral <type>", "Collateral type (sol | tokenMint:<address> | stakeAccount)").option("-w, --claim-authority <pubkey>", "Claim authority (defaults to signer)").action(async (opts) => {
123
- const spinner = (0, import_ora.default)("Initializing bond project...").start();
118
+ import_commander.program.command("initialize").description("Initialize the global state and reserve vault").requiredOption("-r, --reserve <address>", "Reserve vault address").option("-w, --claim-authority <pubkey>", "Claim authority (defaults to signer)").action(async (opts) => {
119
+ const spinner = (0, import_ora.default)("Initializing global state...").start();
124
120
  const { client } = useContext();
125
121
  const reserve = new import_web32.PublicKey(opts.reserve);
126
122
  const authority = opts.claimAuthority ? new import_web32.PublicKey(opts.claimAuthority) : void 0;
127
- const bondType = parseBondType(import_commander.program.opts().bondType);
128
- const collateralType = parseCollateralType(opts.collateral);
129
- const bondName = import_commander.program.opts().bondName;
130
- console.log(import_chalk.default.gray(`Collateral Type: ${JSON.stringify(collateralType)}`));
131
123
  try {
132
- await client.bondInitialize({ bondType, name: bondName, authority, collateralType, reserve });
124
+ const tx = await client.initialize({ reserve, authority });
133
125
  spinner.succeed(import_chalk.default.green(`Bond program initialized successfully!`));
126
+ console.log(import_chalk.default.gray(`Transaction: ${tx}`));
134
127
  console.log(import_chalk.default.gray(`Reserve address: ${reserve.toString()}`));
135
128
  } catch (error) {
136
129
  spinner.fail(import_chalk.default.red(`Failed to initialize bond program: ${error}`));
@@ -139,46 +132,37 @@ import_commander.program.command("initialize").description("Initialize specific
139
132
  import_commander.program.command("register-validator").description("Register validator and fund initial collateral").argument("<vote-account>", "Vote account public key").argument("<amount>", "Initial collateral amount in SOL").action(async (voteAccountStr, amount) => {
140
133
  const spinner = (0, import_ora.default)("Registering validator...").start();
141
134
  const { keypair, client } = useContext();
142
- const bondType = parseBondType(import_commander.program.opts().bondType);
143
- const bondName = import_commander.program.opts().bondName;
144
135
  try {
145
136
  const voteAccount = new import_web32.PublicKey(voteAccountStr);
146
137
  const initialCollateral = Number.parseFloat(amount);
147
- if (Number.isNaN(initialCollateral) || initialCollateral < 0) {
138
+ if (Number.isNaN(initialCollateral) || initialCollateral <= 0) {
148
139
  throw new Error("Invalid collateral amount");
149
140
  }
150
- await client.registerValidator({
151
- bondType,
152
- name: bondName,
141
+ const tx = await client.registerValidator({
153
142
  voteAccount,
143
+ initialCollateral,
154
144
  identity: keypair.publicKey
155
145
  });
156
146
  spinner.succeed(import_chalk.default.green(`Validator registered successfully!`));
157
- console.log(import_chalk.default.gray(`Initial collateral (ignored by register): ${initialCollateral} SOL`));
147
+ console.log(import_chalk.default.gray(`Transaction: ${tx}`));
148
+ console.log(import_chalk.default.gray(`Initial collateral: ${initialCollateral} SOL`));
158
149
  console.log(import_chalk.default.gray(`Validator: ${keypair.publicKey.toString()}`));
159
150
  console.log(import_chalk.default.gray(`Vote Account: ${voteAccountStr}`));
160
151
  } catch (error) {
161
152
  spinner.fail(import_chalk.default.red(`Failed to register validator: ${error}`));
162
153
  }
163
154
  });
164
- import_commander.program.command("topup").description("Top up collateral for validator bond account").argument("<vote-account>", "Vote account public key").argument("<amount>", "Amount to top up in SOL").action(async (voteAccountStr, amount) => {
155
+ import_commander.program.command("topup-collateral").description("Top up collateral for existing validator").argument("<vote-account>", "Vote account public key").argument("<amount>", "Amount to top up in SOL").action(async (voteAccountStr, amount) => {
165
156
  const spinner = (0, import_ora.default)("Topping up collateral...").start();
166
157
  const { client } = useContext();
167
- const bondType = parseBondType(import_commander.program.opts().bondType);
168
- const bondName = import_commander.program.opts().bondName;
169
158
  try {
170
159
  const voteAccount = new import_web32.PublicKey(voteAccountStr);
171
160
  const topUpAmount = Number.parseFloat(amount);
172
161
  if (Number.isNaN(topUpAmount) || topUpAmount <= 0) {
173
162
  throw new Error("Invalid top-up amount");
174
163
  }
175
- const signature = await client.topUpCollateral({
176
- bondType,
177
- name: bondName,
178
- voteAccount,
179
- collateral: { amount: topUpAmount }
180
- });
181
- spinner.succeed(import_chalk.default.green(`Collateral topped up successfully for bond type ${import_commander.program.opts().bondType}!`));
164
+ const signature = await client.topUpCollateral({ voteAccount, amount: topUpAmount });
165
+ spinner.succeed(import_chalk.default.green(`Collateral topped up successfully!`));
182
166
  console.log(import_chalk.default.gray(`Signature: ${signature}`));
183
167
  console.log(import_chalk.default.gray(`Top-up amount: ${topUpAmount} SOL`));
184
168
  } catch (error) {
@@ -186,11 +170,9 @@ import_commander.program.command("topup").description("Top up collateral for val
186
170
  process.exit(1);
187
171
  }
188
172
  });
189
- import_commander.program.command("withdraw").description("Withdraw collateral from validator bond account").argument("<vote-account>", "Vote account public key").argument("<destination>", "Destination address for withdrawn funds").argument("<amount>", "Amount to withdraw in SOL").action(async (voteAccountStr, destinationStr, amount) => {
173
+ import_commander.program.command("withdraw-collateral").description("Withdraw collateral from validator bond account").argument("<vote-account>", "Vote account public key").argument("<destination>", "Destination address for withdrawn funds").argument("<amount>", "Amount to withdraw in SOL").action(async (voteAccountStr, destinationStr, amount) => {
190
174
  const spinner = (0, import_ora.default)("Withdrawing collateral...").start();
191
175
  const { client } = useContext();
192
- const bondType = parseBondType(import_commander.program.opts().bondType);
193
- const bondName = import_commander.program.opts().bondName;
194
176
  try {
195
177
  const voteAccount = new import_web32.PublicKey(voteAccountStr);
196
178
  const destination = new import_web32.PublicKey(destinationStr);
@@ -198,17 +180,11 @@ import_commander.program.command("withdraw").description("Withdraw collateral fr
198
180
  if (Number.isNaN(withdrawAmount) || withdrawAmount <= 0) {
199
181
  throw new Error("Invalid withdrawal amount");
200
182
  }
201
- const bond = await client.getValidatorBond(bondType, bondName, voteAccount);
202
- if (!bond) {
183
+ const bondAccount = await client.getValidatorBond(voteAccount);
184
+ if (!bondAccount) {
203
185
  throw new Error("Validator bond account not found");
204
186
  }
205
- const tx = await client.withdrawCollateral({
206
- bondType,
207
- name: bondName,
208
- voteAccount,
209
- destination,
210
- withdraw: { amount: withdrawAmount }
211
- });
187
+ const tx = await client.withdrawCollateral({ voteAccount, destination, amount: withdrawAmount });
212
188
  spinner.succeed(import_chalk.default.green(`Collateral withdrawn successfully!`));
213
189
  console.log(import_chalk.default.gray(`Transaction: ${tx}`));
214
190
  console.log(import_chalk.default.gray(`Amount withdrawn: ${withdrawAmount} SOL`));
@@ -221,8 +197,6 @@ import_commander.program.command("withdraw").description("Withdraw collateral fr
221
197
  import_commander.program.command("claim-compensation").description("Claim compensation from validator to reserve").argument("<vote-account>", "Vote account public key").argument("<amount>", "Amount to withdraw in SOL").action(async (voteAccountStr, amount) => {
222
198
  const spinner = (0, import_ora.default)("Claiming compensation...").start();
223
199
  const { client } = useContext();
224
- const bondType = parseBondType(import_commander.program.opts().bondType);
225
- const bondName = import_commander.program.opts().bondName;
226
200
  try {
227
201
  const voteAccount = new import_web32.PublicKey(voteAccountStr);
228
202
  const withdrawAmount = Number.parseFloat(amount);
@@ -230,12 +204,8 @@ import_commander.program.command("claim-compensation").description("Claim compen
230
204
  throw new Error("Invalid withdrawal amount");
231
205
  }
232
206
  const tx = await client.claimCompensation({
233
- bondType,
234
- name: bondName,
235
207
  voteAccount,
236
- claim: {
237
- amount: withdrawAmount
238
- }
208
+ amount: withdrawAmount
239
209
  });
240
210
  spinner.succeed(import_chalk.default.green(`Compensation withdrawn successfully!`));
241
211
  console.log(import_chalk.default.gray(`Transaction: ${tx}`));
@@ -247,31 +217,31 @@ import_commander.program.command("claim-compensation").description("Claim compen
247
217
  });
248
218
  import_commander.program.command("validator-info").description("Get validator bond account information").argument("<vote-account>", "Vote account public key").option("-v, --validator <pubkey>", "Validator public key (optional, defaults to current keypair)").action(async (voteAccountStr) => {
249
219
  const { client } = useContext();
250
- const bondType = parseBondType(import_commander.program.opts().bondType);
251
- const bondName = import_commander.program.opts().bondName;
252
220
  try {
253
221
  const voteAccount = new import_web32.PublicKey(voteAccountStr);
254
- const [validatorBondAddress] = client.pda.validatorBond(bondType, bondName, voteAccount);
222
+ const [validatorBondAddress] = client.pda.validatorBond(voteAccount);
255
223
  console.log(import_chalk.default.gray(`Validator Bond Address: ${validatorBondAddress.toString()}`));
256
- const bond = await client.getValidatorBond(bondType, bondName, voteAccount);
257
- if (!bond) {
224
+ const state = await client.getValidatorBond(
225
+ voteAccount
226
+ );
227
+ if (!state) {
258
228
  console.log(import_chalk.default.yellow("Validator bond account not found"));
259
229
  return;
260
230
  }
261
231
  console.log(import_chalk.default.cyan("\nValidator Bond Account Information:"));
262
- console.log(import_chalk.default.white(` Validator: ${bond.identity}`));
263
- console.log(import_chalk.default.white(` Vote Account: ${bond.voteAccount}`));
264
- if (bond.withdrawalAuthority) {
265
- console.log(import_chalk.default.white(` Withdrawal Authority: ${bond.withdrawalAuthority}`));
232
+ console.log(import_chalk.default.white(` Validator: ${state.identity}`));
233
+ console.log(import_chalk.default.white(` Vote Account: ${state.voteAccount}`));
234
+ if (state.withdrawalAuthority) {
235
+ console.log(import_chalk.default.white(` Withdrawal Authority: ${state.withdrawalAuthority}`));
266
236
  } else {
267
237
  console.log(import_chalk.default.white(` Withdrawal Authority: Not set (identity only)`));
268
238
  }
269
239
  console.log(
270
240
  import_chalk.default.white(
271
- ` Active: ${bond.isActive ? import_chalk.default.green("Yes") : import_chalk.default.red("No")}`
241
+ ` Active: ${state.isActive ? import_chalk.default.green("Yes") : import_chalk.default.red("No")}`
272
242
  )
273
243
  );
274
- console.log(import_chalk.default.white(` Created At: ${bond.createdAt}`));
244
+ console.log(import_chalk.default.white(` Created At: ${state.createdAt}`));
275
245
  } catch (error) {
276
246
  console.error(import_chalk.default.red(`Failed to get validator info: ${error}`));
277
247
  process.exit(1);
@@ -280,11 +250,9 @@ import_commander.program.command("validator-info").description("Get validator bo
280
250
  import_commander.program.command("set-withdraw-authority").description("Set or update withdrawal authority for validator bond").argument("<vote-account>", "Vote account public key").option("-w, --new-authority <pubkey>", "New withdrawal authority (omit to remove authority)").action(async (voteAccountStr, options) => {
281
251
  const spinner = (0, import_ora.default)("Setting withdrawal authority...").start();
282
252
  const { client, keypair } = useContext();
283
- const bondType = parseBondType(import_commander.program.opts().bondType);
284
- const bondName = import_commander.program.opts().bondName;
285
253
  try {
286
254
  const voteAccount = new import_web32.PublicKey(voteAccountStr);
287
- const bondAccount = await client.getValidatorBond(bondType, bondName, voteAccount);
255
+ const bondAccount = await client.getValidatorBond(voteAccount);
288
256
  if (!bondAccount) {
289
257
  throw new Error("Validator bond account not found");
290
258
  }
@@ -293,8 +261,6 @@ import_commander.program.command("set-withdraw-authority").description("Set or u
293
261
  }
294
262
  const newWithdrawAuthority = options.newAuthority ? new import_web32.PublicKey(options.newAuthority) : null;
295
263
  const tx = await client.setWithdrawAuthority({
296
- bondType,
297
- name: bondName,
298
264
  voteAccount,
299
265
  newWithdrawAuthority
300
266
  });
@@ -313,17 +279,13 @@ import_commander.program.command("set-withdraw-authority").description("Set or u
313
279
  import_commander.program.command("configure").description("Update program configuration (authority and/or reserve)").option("-a, --new-authority <pubkey>", "New authority address").option("-r, --new-reserve <pubkey>", "New reserve address").action(async (opts) => {
314
280
  const spinner = (0, import_ora.default)("Updating program configuration...").start();
315
281
  const { client } = useContext();
316
- const bondType = parseBondType(import_commander.program.opts().bondType);
317
- const bondName = import_commander.program.opts().bondName;
318
282
  try {
319
283
  if (!opts.newAuthority && !opts.newReserve) {
320
284
  throw new Error("At least one of --new-authority or --new-reserve must be provided");
321
285
  }
322
286
  const newAuthority = opts.newAuthority ? new import_web32.PublicKey(opts.newAuthority) : void 0;
323
287
  const newReserve = opts.newReserve ? new import_web32.PublicKey(opts.newReserve) : void 0;
324
- const tx = await client.bondConfigure({
325
- bondType,
326
- name: bondName,
288
+ const tx = await client.configure({
327
289
  newAuthority,
328
290
  newReserve
329
291
  });
@@ -340,65 +302,6 @@ import_commander.program.command("configure").description("Update program config
340
302
  process.exit(1);
341
303
  }
342
304
  });
343
- import_commander.program.command("get-bond-state").description("Get bond state information").action(async () => {
344
- const { client } = useContext();
345
- const bondType = parseBondType(import_commander.program.opts().bondType);
346
- const bondName = import_commander.program.opts().bondName;
347
- try {
348
- const state = await client.getBondState(bondType, bondName);
349
- if (!state) {
350
- console.log(import_chalk.default.yellow("Bond state not found"));
351
- return;
352
- }
353
- console.log(import_chalk.default.cyan("====== Bond State: ======\n"));
354
- console.log(import_chalk.default.white(JSON.stringify(state, null, 2)));
355
- } catch (error) {
356
- console.error(import_chalk.default.red(`Failed to get bond state info: ${error}`));
357
- process.exit(1);
358
- }
359
- });
360
- import_commander.program.command("start-bond").description("Start bond command").requiredOption("-d, --duration <seconds>", "Bond session duration in seconds").action(async (opts) => {
361
- const spinner = (0, import_ora.default)("Starting bond...").start();
362
- const { client } = useContext();
363
- const bondType = parseBondType(import_commander.program.opts().bondType);
364
- const bondName = import_commander.program.opts().bondName;
365
- const duration = Number.parseInt(opts.duration, 10);
366
- try {
367
- const tx = await client.bondStart({ bondType, name: bondName, duration_secs: duration });
368
- spinner.succeed(import_chalk.default.green(`Bond started successfully!`));
369
- console.log(import_chalk.default.gray(`Transaction: ${tx}`));
370
- } catch (error) {
371
- spinner.fail(import_chalk.default.red(`Failed to start bond: ${error}`));
372
- process.exit(1);
373
- }
374
- });
375
- import_commander.program.command("finish-bond").description("Finish bond command").action(async () => {
376
- const spinner = (0, import_ora.default)("Finishing bond...").start();
377
- const { client } = useContext();
378
- const bondType = parseBondType(import_commander.program.opts().bondType);
379
- const bondName = import_commander.program.opts().bondName;
380
- try {
381
- const tx = await client.bondFinish({ bondType, name: bondName });
382
- spinner.succeed(import_chalk.default.green(`Bond finished successfully!`));
383
- console.log(import_chalk.default.gray(`Transaction: ${tx}`));
384
- } catch (error) {
385
- spinner.fail(import_chalk.default.red(`Failed to finish bond: ${error}`));
386
- process.exit(1);
387
- }
388
- });
389
- import_commander.program.command("get-collateral-type").description("Get bond collateral type").action(async () => {
390
- const { client } = useContext();
391
- const bondType = parseBondType(import_commander.program.opts().bondType);
392
- const bondName = import_commander.program.opts().bondName;
393
- try {
394
- const collateralType = await client.getBondCollateralType(bondType, bondName);
395
- console.log(import_chalk.default.cyan("Collateral Type:"));
396
- console.log(import_chalk.default.white(JSON.stringify(collateralType, null, 2)));
397
- } catch (error) {
398
- console.error(import_chalk.default.red(`Failed to get collateral type: ${error}`));
399
- process.exit(1);
400
- }
401
- });
402
305
  import_commander.program.command("*", { isDefault: true, hidden: true }).allowExcessArguments(true).action(() => {
403
306
  import_commander.program.help();
404
307
  });
@@ -411,37 +314,3 @@ import_commander.program.parseAsync().catch((e) => {
411
314
  }
412
315
  process.exit();
413
316
  });
414
- function parseBondType(t) {
415
- const x = (t || "").toLowerCase();
416
- if (x === "crowdfunding") {
417
- return { crowdfunding: {} };
418
- }
419
- if (x === "performance") {
420
- return { performance: {} };
421
- }
422
- console.error(import_chalk.default.red(`Invalid bond type: ${t}`));
423
- process.exit(1);
424
- }
425
- function parseCollateralType(input) {
426
- if (input === "sol") {
427
- return { native: {} };
428
- } else if (input.startsWith("tokenMint:")) {
429
- const parts = input.split(":");
430
- if (parts.length !== 2) {
431
- throw new Error("Invalid tokenMint format. Use tokenMint:<address>");
432
- }
433
- return { token: [new import_web32.PublicKey(parts[1])] };
434
- } else if (input.startsWith("stakeAccount:")) {
435
- const parts = input.split(":");
436
- if (parts.length !== 2) {
437
- throw new Error("Invalid stakeAccount format. Use stakeAccount:<address>");
438
- }
439
- return { stakeAccount: {} };
440
- } else {
441
- throw new Error("Unsupported collateral type. Use sol, tokenMint:<address>, or stakeAccount:<address>");
442
- }
443
- }
444
- // Annotate the CommonJS export names for ESM import in node:
445
- 0 && (module.exports = {
446
- parseCollateralType
447
- });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jpool/bond-cli",
3
- "version": "1.2.0-next.2",
3
+ "version": "1.2.1",
4
4
  "description": "JBond CLI for interacting with the Solana program",
5
5
  "main": "./dist/cli.js",
6
6
  "bin": {
@@ -9,19 +9,9 @@
9
9
  "files": [
10
10
  "dist"
11
11
  ],
12
- "scripts": {
13
- "build": "tsup",
14
- "dev": "tsup --watch",
15
- "release": "release-it",
16
- "release:ci": "release-it --ci -VV",
17
- "release:dry": "release-it --ci --dry-run",
18
- "release:pre": "release-it --preRelease=next -VV",
19
- "release:pre:dry": "release-it --preRelease=next --dry-run --ci",
20
- "postinstall": "npm run build"
21
- },
22
12
  "dependencies": {
23
13
  "@coral-xyz/anchor": "^0.31.1",
24
- "@jpool/bond-sdk": "workspace:",
14
+ "@jpool/bond-sdk": "^0.9.0",
25
15
  "@solana/web3.js": "^1.98.4",
26
16
  "chalk": "^5.6.2",
27
17
  "commander": "^14.0.1",
@@ -29,7 +19,17 @@
29
19
  "ora": "^9.0.0"
30
20
  },
31
21
  "devDependencies": {
32
- "release-it-config": "workspace:",
33
- "tsup": "^8.5.0"
22
+ "tsup": "^8.5.0",
23
+ "release-it-config": "0.0.1"
24
+ },
25
+ "scripts": {
26
+ "build": "tsup",
27
+ "dev": "tsup --watch",
28
+ "release": "release-it",
29
+ "release:ci": "release-it --ci -VV",
30
+ "release:dry": "release-it --ci --dry-run",
31
+ "release:pre": "release-it --preRelease=next -VV",
32
+ "release:pre:dry": "release-it --preRelease=next --dry-run --ci",
33
+ "postinstall": "npm run build"
34
34
  }
35
- }
35
+ }