@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.d.mts CHANGED
@@ -1332,6 +1332,11 @@ type Jbond = {
1332
1332
  "code": 6024;
1333
1333
  "name": "invalidEpoch";
1334
1334
  "msg": "Invalid epoch for this operation";
1335
+ },
1336
+ {
1337
+ "code": 6025;
1338
+ "name": "bondNotRemovable";
1339
+ "msg": "Bond is not removable";
1335
1340
  }
1336
1341
  ];
1337
1342
  "types": [
@@ -1821,6 +1826,14 @@ type Jbond = {
1821
1826
  ];
1822
1827
  };
1823
1828
 
1829
+ /**
1830
+ * Enum for different client environments.
1831
+ */
1832
+ declare enum JBondClientEnv {
1833
+ DEV = "dev",
1834
+ STAGE = "stage",
1835
+ PROD = "prod"
1836
+ }
1824
1837
  type GlobalState = IdlAccounts<Jbond>['globalState'];
1825
1838
  type BondState = IdlAccounts<Jbond>['bondState'];
1826
1839
  type ValidatorBond = IdlAccounts<Jbond>['validatorBond'];
@@ -1981,7 +1994,7 @@ declare class HistoryManager {
1981
1994
  private discCache;
1982
1995
  constructor(client: JBondClient);
1983
1996
  get program(): _coral_xyz_anchor.Program<Jbond>;
1984
- get programId(): any;
1997
+ get programId(): PublicKey;
1985
1998
  get connection(): _solana_web3_js.Connection;
1986
1999
  debug(...args: any[]): void;
1987
2000
  getHistory(bondType: BondType, bondName: string, vote: PublicKeyInitData, opts?: GetHistoryOpts): Promise<TransactionHistoryItem[]>;
@@ -2005,14 +2018,6 @@ declare class NodeWallet implements Wallet {
2005
2018
  get publicKey(): PublicKey;
2006
2019
  }
2007
2020
 
2008
- /**
2009
- * Enum for different client environments.
2010
- */
2011
- declare enum JBondClientEnv {
2012
- DEV = "dev",
2013
- STAGE = "stage",
2014
- PROD = "prod"
2015
- }
2016
2021
  /**
2017
2022
  * Options for configuring the JBondClient.
2018
2023
  */
@@ -2022,7 +2027,7 @@ type JBondClientOptions = {
2022
2027
  declare class JBondClient {
2023
2028
  readonly provider: Provider;
2024
2029
  readonly options: JBondClientOptions;
2025
- readonly program: Program<Jbond>;
2030
+ private _program;
2026
2031
  constructor(provider: Provider, options?: JBondClientOptions);
2027
2032
  get history(): HistoryManager;
2028
2033
  /**
@@ -2037,10 +2042,14 @@ declare class JBondClient {
2037
2042
  * Creates an instance of `JBondClient` using the provided connection and keypair.
2038
2043
  */
2039
2044
  static fromKeypair(connection: Connection, keypair: Keypair, options?: JBondClientOptions): JBondClient;
2045
+ /**
2046
+ * Get or create the program instance
2047
+ */
2048
+ get program(): Program<Jbond>;
2040
2049
  /**
2041
2050
  * Get the current program ID.
2042
2051
  */
2043
- get programId(): any;
2052
+ get programId(): PublicKey;
2044
2053
  /**
2045
2054
  * Get the current connection.
2046
2055
  */
package/dist/index.d.ts CHANGED
@@ -1332,6 +1332,11 @@ type Jbond = {
1332
1332
  "code": 6024;
1333
1333
  "name": "invalidEpoch";
1334
1334
  "msg": "Invalid epoch for this operation";
1335
+ },
1336
+ {
1337
+ "code": 6025;
1338
+ "name": "bondNotRemovable";
1339
+ "msg": "Bond is not removable";
1335
1340
  }
1336
1341
  ];
1337
1342
  "types": [
@@ -1821,6 +1826,14 @@ type Jbond = {
1821
1826
  ];
1822
1827
  };
1823
1828
 
1829
+ /**
1830
+ * Enum for different client environments.
1831
+ */
1832
+ declare enum JBondClientEnv {
1833
+ DEV = "dev",
1834
+ STAGE = "stage",
1835
+ PROD = "prod"
1836
+ }
1824
1837
  type GlobalState = IdlAccounts<Jbond>['globalState'];
1825
1838
  type BondState = IdlAccounts<Jbond>['bondState'];
1826
1839
  type ValidatorBond = IdlAccounts<Jbond>['validatorBond'];
@@ -1981,7 +1994,7 @@ declare class HistoryManager {
1981
1994
  private discCache;
1982
1995
  constructor(client: JBondClient);
1983
1996
  get program(): _coral_xyz_anchor.Program<Jbond>;
1984
- get programId(): any;
1997
+ get programId(): PublicKey;
1985
1998
  get connection(): _solana_web3_js.Connection;
1986
1999
  debug(...args: any[]): void;
1987
2000
  getHistory(bondType: BondType, bondName: string, vote: PublicKeyInitData, opts?: GetHistoryOpts): Promise<TransactionHistoryItem[]>;
@@ -2005,14 +2018,6 @@ declare class NodeWallet implements Wallet {
2005
2018
  get publicKey(): PublicKey;
2006
2019
  }
2007
2020
 
2008
- /**
2009
- * Enum for different client environments.
2010
- */
2011
- declare enum JBondClientEnv {
2012
- DEV = "dev",
2013
- STAGE = "stage",
2014
- PROD = "prod"
2015
- }
2016
2021
  /**
2017
2022
  * Options for configuring the JBondClient.
2018
2023
  */
@@ -2022,7 +2027,7 @@ type JBondClientOptions = {
2022
2027
  declare class JBondClient {
2023
2028
  readonly provider: Provider;
2024
2029
  readonly options: JBondClientOptions;
2025
- readonly program: Program<Jbond>;
2030
+ private _program;
2026
2031
  constructor(provider: Provider, options?: JBondClientOptions);
2027
2032
  get history(): HistoryManager;
2028
2033
  /**
@@ -2037,10 +2042,14 @@ declare class JBondClient {
2037
2042
  * Creates an instance of `JBondClient` using the provided connection and keypair.
2038
2043
  */
2039
2044
  static fromKeypair(connection: Connection, keypair: Keypair, options?: JBondClientOptions): JBondClient;
2045
+ /**
2046
+ * Get or create the program instance
2047
+ */
2048
+ get program(): Program<Jbond>;
2040
2049
  /**
2041
2050
  * Get the current program ID.
2042
2051
  */
2043
- get programId(): any;
2052
+ get programId(): PublicKey;
2044
2053
  /**
2045
2054
  * Get the current connection.
2046
2055
  */
package/dist/index.js CHANGED
@@ -4568,21 +4568,15 @@ var import_bn = __toESM(require_bn());
4568
4568
 
4569
4569
  // src/constants.ts
4570
4570
  init_cjs_shims();
4571
- var GLOBAL_STATE_SEED = "global_state";
4572
- var BOND_STATE_SEED = "bond_state";
4573
- var VALIDATOR_BOND_SEED = "validator_bond";
4574
- var STANDARD_BOND_SEED = "standard";
4575
- var CROWDFUNDING_BOND_SEED = "crowdfunding";
4576
- var ENV_PROGRAM_ID = {
4577
- ["dev" /* DEV */]: new web3_js.PublicKey("Fo17edWRJewZNTRibgx9iTfjywCW6dzS81VwBLmPFVq1"),
4578
- ["prod" /* PROD */]: new web3_js.PublicKey("BondQ7KqZreTcW2UbeTNDcLCJQ3aXAtLn2Fm6ftaJDU")
4579
- };
4580
-
4581
- // src/history.ts
4582
- init_cjs_shims();
4583
4571
 
4584
4572
  // src/types/index.ts
4585
4573
  init_cjs_shims();
4574
+ var JBondClientEnv = /* @__PURE__ */ ((JBondClientEnv2) => {
4575
+ JBondClientEnv2["DEV"] = "dev";
4576
+ JBondClientEnv2["STAGE"] = "stage";
4577
+ JBondClientEnv2["PROD"] = "prod";
4578
+ return JBondClientEnv2;
4579
+ })(JBondClientEnv || {});
4586
4580
  var SessionStatus = /* @__PURE__ */ ((SessionStatus2) => {
4587
4581
  SessionStatus2[SessionStatus2["Live"] = 0] = "Live";
4588
4582
  SessionStatus2[SessionStatus2["Finished"] = 1] = "Finished";
@@ -4600,7 +4594,19 @@ var BondTransactionType = /* @__PURE__ */ ((BondTransactionType2) => {
4600
4594
  return BondTransactionType2;
4601
4595
  })(BondTransactionType || {});
4602
4596
 
4597
+ // src/constants.ts
4598
+ var GLOBAL_STATE_SEED = "global_state";
4599
+ var BOND_STATE_SEED = "bond_state";
4600
+ var VALIDATOR_BOND_SEED = "validator_bond";
4601
+ var STANDARD_BOND_SEED = "standard";
4602
+ var CROWDFUNDING_BOND_SEED = "crowdfunding";
4603
+ var ENV_PROGRAM_ID = {
4604
+ ["dev" /* DEV */]: new web3_js.PublicKey("Fo17edWRJewZNTRibgx9iTfjywCW6dzS81VwBLmPFVq1"),
4605
+ ["prod" /* PROD */]: new web3_js.PublicKey("BondQ7KqZreTcW2UbeTNDcLCJQ3aXAtLn2Fm6ftaJDU")
4606
+ };
4607
+
4603
4608
  // src/history.ts
4609
+ init_cjs_shims();
4604
4610
  var { bs58 } = anchor.utils.bytes;
4605
4611
  var HistoryManager = class {
4606
4612
  constructor(client) {
@@ -6081,6 +6087,11 @@ var jbond_default = {
6081
6087
  code: 6024,
6082
6088
  name: "InvalidEpoch",
6083
6089
  msg: "Invalid epoch for this operation"
6090
+ },
6091
+ {
6092
+ code: 6025,
6093
+ name: "BondNotRemovable",
6094
+ msg: "Bond is not removable"
6084
6095
  }
6085
6096
  ],
6086
6097
  types: [
@@ -6688,20 +6699,13 @@ function getBondTypeSeed(type) {
6688
6699
  }
6689
6700
 
6690
6701
  // src/client.ts
6691
- var JBondClientEnv = /* @__PURE__ */ ((JBondClientEnv2) => {
6692
- JBondClientEnv2["DEV"] = "dev";
6693
- JBondClientEnv2["STAGE"] = "stage";
6694
- JBondClientEnv2["PROD"] = "prod";
6695
- return JBondClientEnv2;
6696
- })(JBondClientEnv || {});
6697
6702
  var JBondClient = class _JBondClient {
6698
6703
  constructor(provider, options) {
6699
6704
  this.provider = provider;
6700
6705
  this.options = options ?? {};
6701
- this.program = new anchor.Program(jbond_default, this.provider);
6702
6706
  }
6703
6707
  options;
6704
- program;
6708
+ _program = null;
6705
6709
  get history() {
6706
6710
  return new HistoryManager(this);
6707
6711
  }
@@ -6730,11 +6734,24 @@ var JBondClient = class _JBondClient {
6730
6734
  static fromKeypair(connection, keypair, options) {
6731
6735
  return _JBondClient.fromWallet(connection, new NodeWallet(keypair), options);
6732
6736
  }
6737
+ /**
6738
+ * Get or create the program instance
6739
+ */
6740
+ get program() {
6741
+ if (!this._program) {
6742
+ jbond_default.address = this.programId.toBase58();
6743
+ this._program = new anchor.Program(jbond_default, this.provider);
6744
+ }
6745
+ return this._program;
6746
+ }
6733
6747
  /**
6734
6748
  * Get the current program ID.
6735
6749
  */
6736
6750
  get programId() {
6737
- return this.options.programId ?? this.program.programId;
6751
+ if (this.options.programId) {
6752
+ return this.options.programId;
6753
+ }
6754
+ return ENV_PROGRAM_ID["prod" /* PROD */];
6738
6755
  }
6739
6756
  /**
6740
6757
  * Get the current connection.
@@ -6750,6 +6767,8 @@ var JBondClient = class _JBondClient {
6750
6767
  if (!envProgramId) {
6751
6768
  throw new Error(`Invalid environment: ${env}`);
6752
6769
  }
6770
+ this._program = null;
6771
+ this.debug(`Set environment to ${env} with program ID: ${envProgramId.toString()}`);
6753
6772
  return this.configure("programId", envProgramId);
6754
6773
  }
6755
6774
  /**