@jpool/bond-sdk 0.11.0-next.20 → 0.11.0-next.22

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
@@ -4579,6 +4579,7 @@ var STANDARD_BOND_SEED = "standard";
4579
4579
  var CROWDFUNDING_BOND_SEED = "crowdfunding";
4580
4580
  var ENV_PROGRAM_ID = {
4581
4581
  ["dev" /* DEV */]: new PublicKey("Fo17edWRJewZNTRibgx9iTfjywCW6dzS81VwBLmPFVq1"),
4582
+ ["stage" /* STAGE */]: new PublicKey("BondQ7KqZreTcW2UbeTNDcLCJQ3aXAtLn2Fm6ftaJDU"),
4582
4583
  ["prod" /* PROD */]: new PublicKey("BondQ7KqZreTcW2UbeTNDcLCJQ3aXAtLn2Fm6ftaJDU")
4583
4584
  };
4584
4585
  var { bs58 } = utils.bytes;
@@ -4743,7 +4744,7 @@ var jbond_default = {
4743
4744
  address: "Fo17edWRJewZNTRibgx9iTfjywCW6dzS81VwBLmPFVq1",
4744
4745
  metadata: {
4745
4746
  name: "jbond",
4746
- version: "0.2.1",
4747
+ version: "0.2.2",
4747
4748
  spec: "0.1.0",
4748
4749
  description: "Jpool Bond Program"
4749
4750
  },
@@ -5712,6 +5713,38 @@ var jbond_default = {
5712
5713
  ],
5713
5714
  args: []
5714
5715
  },
5716
+ {
5717
+ name: "migrate_validator_bond",
5718
+ docs: [
5719
+ "migrate validator bond from legacy format to new format"
5720
+ ],
5721
+ discriminator: [
5722
+ 214,
5723
+ 114,
5724
+ 65,
5725
+ 138,
5726
+ 248,
5727
+ 45,
5728
+ 186,
5729
+ 229
5730
+ ],
5731
+ accounts: [
5732
+ {
5733
+ name: "validator_bond",
5734
+ writable: true
5735
+ },
5736
+ {
5737
+ name: "authority",
5738
+ writable: true,
5739
+ signer: true
5740
+ },
5741
+ {
5742
+ name: "system_program",
5743
+ address: "11111111111111111111111111111111"
5744
+ }
5745
+ ],
5746
+ args: []
5747
+ },
5715
5748
  {
5716
5749
  name: "session_finish",
5717
5750
  docs: [
@@ -6061,6 +6094,11 @@ var jbond_default = {
6061
6094
  code: 6024,
6062
6095
  name: "InvalidEpoch",
6063
6096
  msg: "Invalid epoch for this operation"
6097
+ },
6098
+ {
6099
+ code: 6025,
6100
+ name: "BondNotRemovable",
6101
+ msg: "Bond is not removable"
6064
6102
  }
6065
6103
  ],
6066
6104
  types: [
@@ -6712,7 +6750,7 @@ var JBondClient = class _JBondClient {
6712
6750
  if (this.options.programId) {
6713
6751
  return this.options.programId;
6714
6752
  }
6715
- return ENV_PROGRAM_ID["prod" /* PROD */];
6753
+ return new PublicKey(ENV_PROGRAM_ID["prod" /* PROD */]);
6716
6754
  }
6717
6755
  /**
6718
6756
  * Get the current connection.
@@ -6730,7 +6768,7 @@ var JBondClient = class _JBondClient {
6730
6768
  }
6731
6769
  this._program = null;
6732
6770
  this.debug(`Set environment to ${env} with program ID: ${envProgramId.toString()}`);
6733
- return this.configure("programId", envProgramId);
6771
+ return this.configure("programId", new PublicKey(envProgramId));
6734
6772
  }
6735
6773
  /**
6736
6774
  * Configure a specific option.
@@ -7200,6 +7238,21 @@ var JBondClient = class _JBondClient {
7200
7238
  });
7201
7239
  return this.program.methods.bondLockFunds(solToLamports(amount)).accountsPartial(accounts).instruction();
7202
7240
  }
7241
+ async migrateValidatorBond(props) {
7242
+ const ix = await this.getMigrateValidatorBondIx(props);
7243
+ return this.provider.sendAndConfirm?.(new Transaction().add(ix));
7244
+ }
7245
+ async getMigrateValidatorBondIx(props) {
7246
+ const { bondType, name, voteAccount } = props;
7247
+ const [bondState] = this.pda.bondState(bondType, name);
7248
+ const [validatorBond] = this.pda.validatorBond(bondType, name, voteAccount);
7249
+ const accounts = {
7250
+ bondState,
7251
+ validatorBond,
7252
+ systemProgram: PublicKey.default
7253
+ };
7254
+ return this.program.methods.migrateValidatorBond().accountsPartial(accounts).instruction();
7255
+ }
7203
7256
  /**
7204
7257
  * Build release funds instruction
7205
7258
  */
@@ -7286,7 +7339,7 @@ var JBondClient = class _JBondClient {
7286
7339
  const tokenAccount = getAssociatedTokenAddressSync(mint, address, true);
7287
7340
  try {
7288
7341
  const balance = await this.connection.getTokenAccountBalance(tokenAccount);
7289
- return solToLamports(balance.value.amount).toNumber();
7342
+ return Number(balance.value.amount);
7290
7343
  } catch {
7291
7344
  return 0;
7292
7345
  }