@jpool/bond-sdk 0.11.0-next.19 → 0.11.0-next.21

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/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { utils, Program, AnchorProvider, BN } from '@coral-xyz/anchor';
1
+ import { utils, AnchorProvider, Program, BN } from '@coral-xyz/anchor';
2
2
  import { getAssociatedTokenAddressSync, ACCOUNT_SIZE, AccountLayout } from '@solana/spl-token';
3
3
  import { PublicKey, Transaction, LAMPORTS_PER_SOL } from '@solana/web3.js';
4
4
 
@@ -4546,17 +4546,14 @@ var require_bn = __commonJS({
4546
4546
 
4547
4547
  // src/client.ts
4548
4548
  var import_bn = __toESM(require_bn());
4549
- var GLOBAL_STATE_SEED = "global_state";
4550
- var BOND_STATE_SEED = "bond_state";
4551
- var VALIDATOR_BOND_SEED = "validator_bond";
4552
- var STANDARD_BOND_SEED = "standard";
4553
- var CROWDFUNDING_BOND_SEED = "crowdfunding";
4554
- var ENV_PROGRAM_ID = {
4555
- ["dev" /* DEV */]: new PublicKey("Fo17edWRJewZNTRibgx9iTfjywCW6dzS81VwBLmPFVq1"),
4556
- ["prod" /* PROD */]: new PublicKey("BondQ7KqZreTcW2UbeTNDcLCJQ3aXAtLn2Fm6ftaJDU")
4557
- };
4558
4549
 
4559
4550
  // src/types/index.ts
4551
+ var JBondClientEnv = /* @__PURE__ */ ((JBondClientEnv2) => {
4552
+ JBondClientEnv2["DEV"] = "dev";
4553
+ JBondClientEnv2["STAGE"] = "stage";
4554
+ JBondClientEnv2["PROD"] = "prod";
4555
+ return JBondClientEnv2;
4556
+ })(JBondClientEnv || {});
4560
4557
  var SessionStatus = /* @__PURE__ */ ((SessionStatus2) => {
4561
4558
  SessionStatus2[SessionStatus2["Live"] = 0] = "Live";
4562
4559
  SessionStatus2[SessionStatus2["Finished"] = 1] = "Finished";
@@ -4574,7 +4571,16 @@ var BondTransactionType = /* @__PURE__ */ ((BondTransactionType2) => {
4574
4571
  return BondTransactionType2;
4575
4572
  })(BondTransactionType || {});
4576
4573
 
4577
- // src/history.ts
4574
+ // src/constants.ts
4575
+ var GLOBAL_STATE_SEED = "global_state";
4576
+ var BOND_STATE_SEED = "bond_state";
4577
+ var VALIDATOR_BOND_SEED = "validator_bond";
4578
+ var STANDARD_BOND_SEED = "standard";
4579
+ var CROWDFUNDING_BOND_SEED = "crowdfunding";
4580
+ var ENV_PROGRAM_ID = {
4581
+ ["dev" /* DEV */]: new PublicKey("Fo17edWRJewZNTRibgx9iTfjywCW6dzS81VwBLmPFVq1"),
4582
+ ["prod" /* PROD */]: new PublicKey("BondQ7KqZreTcW2UbeTNDcLCJQ3aXAtLn2Fm6ftaJDU")
4583
+ };
4578
4584
  var { bs58 } = utils.bytes;
4579
4585
  var HistoryManager = class {
4580
4586
  constructor(client) {
@@ -6055,6 +6061,11 @@ var jbond_default = {
6055
6061
  code: 6024,
6056
6062
  name: "InvalidEpoch",
6057
6063
  msg: "Invalid epoch for this operation"
6064
+ },
6065
+ {
6066
+ code: 6025,
6067
+ name: "BondNotRemovable",
6068
+ msg: "Bond is not removable"
6058
6069
  }
6059
6070
  ],
6060
6071
  types: [
@@ -6654,20 +6665,13 @@ function getBondTypeSeed(type) {
6654
6665
  }
6655
6666
 
6656
6667
  // src/client.ts
6657
- var JBondClientEnv = /* @__PURE__ */ ((JBondClientEnv2) => {
6658
- JBondClientEnv2["DEV"] = "dev";
6659
- JBondClientEnv2["STAGE"] = "stage";
6660
- JBondClientEnv2["PROD"] = "prod";
6661
- return JBondClientEnv2;
6662
- })(JBondClientEnv || {});
6663
6668
  var JBondClient = class _JBondClient {
6664
6669
  constructor(provider, options) {
6665
6670
  this.provider = provider;
6666
6671
  this.options = options ?? {};
6667
- this.program = new Program(jbond_default, this.provider);
6668
6672
  }
6669
6673
  options;
6670
- program;
6674
+ _program = null;
6671
6675
  get history() {
6672
6676
  return new HistoryManager(this);
6673
6677
  }
@@ -6696,11 +6700,24 @@ var JBondClient = class _JBondClient {
6696
6700
  static fromKeypair(connection, keypair, options) {
6697
6701
  return _JBondClient.fromWallet(connection, new NodeWallet(keypair), options);
6698
6702
  }
6703
+ /**
6704
+ * Get or create the program instance
6705
+ */
6706
+ get program() {
6707
+ if (!this._program) {
6708
+ jbond_default.address = this.programId.toBase58();
6709
+ this._program = new Program(jbond_default, this.provider);
6710
+ }
6711
+ return this._program;
6712
+ }
6699
6713
  /**
6700
6714
  * Get the current program ID.
6701
6715
  */
6702
6716
  get programId() {
6703
- return this.options.programId ?? this.program.programId;
6717
+ if (this.options.programId) {
6718
+ return this.options.programId;
6719
+ }
6720
+ return ENV_PROGRAM_ID["prod" /* PROD */];
6704
6721
  }
6705
6722
  /**
6706
6723
  * Get the current connection.
@@ -6716,6 +6733,8 @@ var JBondClient = class _JBondClient {
6716
6733
  if (!envProgramId) {
6717
6734
  throw new Error(`Invalid environment: ${env}`);
6718
6735
  }
6736
+ this._program = null;
6737
+ this.debug(`Set environment to ${env} with program ID: ${envProgramId.toString()}`);
6719
6738
  return this.configure("programId", envProgramId);
6720
6739
  }
6721
6740
  /**