@jpool/bond-sdk 0.11.0-next.21 → 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.d.mts CHANGED
@@ -14,7 +14,7 @@ type Jbond = {
14
14
  "address": "Fo17edWRJewZNTRibgx9iTfjywCW6dzS81VwBLmPFVq1";
15
15
  "metadata": {
16
16
  "name": "jbond";
17
- "version": "0.2.1";
17
+ "version": "0.2.2";
18
18
  "spec": "0.1.0";
19
19
  "description": "Jpool Bond Program";
20
20
  };
@@ -983,6 +983,38 @@ type Jbond = {
983
983
  ];
984
984
  "args": [];
985
985
  },
986
+ {
987
+ "name": "migrateValidatorBond";
988
+ "docs": [
989
+ "migrate validator bond from legacy format to new format"
990
+ ];
991
+ "discriminator": [
992
+ 214,
993
+ 114,
994
+ 65,
995
+ 138,
996
+ 248,
997
+ 45,
998
+ 186,
999
+ 229
1000
+ ];
1001
+ "accounts": [
1002
+ {
1003
+ "name": "validatorBond";
1004
+ "writable": true;
1005
+ },
1006
+ {
1007
+ "name": "authority";
1008
+ "writable": true;
1009
+ "signer": true;
1010
+ },
1011
+ {
1012
+ "name": "systemProgram";
1013
+ "address": "11111111111111111111111111111111";
1014
+ }
1015
+ ];
1016
+ "args": [];
1017
+ },
986
1018
  {
987
1019
  "name": "sessionFinish";
988
1020
  "docs": [
@@ -2209,6 +2241,16 @@ declare class JBondClient {
2209
2241
  * Build lock funds instruction
2210
2242
  */
2211
2243
  getLockFundsIx(props: BondLockFunds): Promise<TransactionInstruction>;
2244
+ migrateValidatorBond(props: {
2245
+ bondType: BondType;
2246
+ name: string;
2247
+ voteAccount: PublicKeyInitData;
2248
+ }): Promise<string | undefined>;
2249
+ getMigrateValidatorBondIx(props: {
2250
+ bondType: BondType;
2251
+ name: string;
2252
+ voteAccount: PublicKeyInitData;
2253
+ }): Promise<TransactionInstruction>;
2212
2254
  /**
2213
2255
  * Build release funds instruction
2214
2256
  */
@@ -2389,6 +2431,10 @@ declare const CROWDFUNDING_BOND_SEED = "crowdfunding";
2389
2431
  /**
2390
2432
  * Program IDs for different environments
2391
2433
  */
2392
- declare const ENV_PROGRAM_ID: Record<string, PublicKey>;
2434
+ declare const ENV_PROGRAM_ID: {
2435
+ dev: PublicKey;
2436
+ stage: PublicKey;
2437
+ prod: PublicKey;
2438
+ };
2393
2439
 
2394
2440
  export { BOND_STATE_SEED, type BondConfigureProps, type BondFinishProps, type BondInitializeProps, type BondLockFunds, type BondReleaseFunds, type BondRemoveProps, type BondStartProps, type BondState, type BondStateStats, type BondStateStatus, BondTransactionType, BondType, CROWDFUNDING_BOND_SEED, type ClaimAllProps, type ClaimProps, type CollateralType, ENV_PROGRAM_ID, type EpochHistoryItem, GLOBAL_STATE_SEED, type GetHistoryGroupedProps, type GetHistoryProps, type GlobalConfigureProps, type GlobalInitializeProps, type GlobalState, JBondClient, JBondClientEnv, type JBondClientOptions, type Jbond, NodeWallet, type RegisterValidatorProps, STANDARD_BOND_SEED, SessionStatus, type SetWithdrawAuthorityProps, type TopUpCollateralProps, type TransactionHistoryItem, VALIDATOR_BOND_SEED, type ValidatorBond, type WithdrawCollateralProps };
package/dist/index.d.ts CHANGED
@@ -14,7 +14,7 @@ type Jbond = {
14
14
  "address": "Fo17edWRJewZNTRibgx9iTfjywCW6dzS81VwBLmPFVq1";
15
15
  "metadata": {
16
16
  "name": "jbond";
17
- "version": "0.2.1";
17
+ "version": "0.2.2";
18
18
  "spec": "0.1.0";
19
19
  "description": "Jpool Bond Program";
20
20
  };
@@ -983,6 +983,38 @@ type Jbond = {
983
983
  ];
984
984
  "args": [];
985
985
  },
986
+ {
987
+ "name": "migrateValidatorBond";
988
+ "docs": [
989
+ "migrate validator bond from legacy format to new format"
990
+ ];
991
+ "discriminator": [
992
+ 214,
993
+ 114,
994
+ 65,
995
+ 138,
996
+ 248,
997
+ 45,
998
+ 186,
999
+ 229
1000
+ ];
1001
+ "accounts": [
1002
+ {
1003
+ "name": "validatorBond";
1004
+ "writable": true;
1005
+ },
1006
+ {
1007
+ "name": "authority";
1008
+ "writable": true;
1009
+ "signer": true;
1010
+ },
1011
+ {
1012
+ "name": "systemProgram";
1013
+ "address": "11111111111111111111111111111111";
1014
+ }
1015
+ ];
1016
+ "args": [];
1017
+ },
986
1018
  {
987
1019
  "name": "sessionFinish";
988
1020
  "docs": [
@@ -2209,6 +2241,16 @@ declare class JBondClient {
2209
2241
  * Build lock funds instruction
2210
2242
  */
2211
2243
  getLockFundsIx(props: BondLockFunds): Promise<TransactionInstruction>;
2244
+ migrateValidatorBond(props: {
2245
+ bondType: BondType;
2246
+ name: string;
2247
+ voteAccount: PublicKeyInitData;
2248
+ }): Promise<string | undefined>;
2249
+ getMigrateValidatorBondIx(props: {
2250
+ bondType: BondType;
2251
+ name: string;
2252
+ voteAccount: PublicKeyInitData;
2253
+ }): Promise<TransactionInstruction>;
2212
2254
  /**
2213
2255
  * Build release funds instruction
2214
2256
  */
@@ -2389,6 +2431,10 @@ declare const CROWDFUNDING_BOND_SEED = "crowdfunding";
2389
2431
  /**
2390
2432
  * Program IDs for different environments
2391
2433
  */
2392
- declare const ENV_PROGRAM_ID: Record<string, PublicKey>;
2434
+ declare const ENV_PROGRAM_ID: {
2435
+ dev: PublicKey;
2436
+ stage: PublicKey;
2437
+ prod: PublicKey;
2438
+ };
2393
2439
 
2394
2440
  export { BOND_STATE_SEED, type BondConfigureProps, type BondFinishProps, type BondInitializeProps, type BondLockFunds, type BondReleaseFunds, type BondRemoveProps, type BondStartProps, type BondState, type BondStateStats, type BondStateStatus, BondTransactionType, BondType, CROWDFUNDING_BOND_SEED, type ClaimAllProps, type ClaimProps, type CollateralType, ENV_PROGRAM_ID, type EpochHistoryItem, GLOBAL_STATE_SEED, type GetHistoryGroupedProps, type GetHistoryProps, type GlobalConfigureProps, type GlobalInitializeProps, type GlobalState, JBondClient, JBondClientEnv, type JBondClientOptions, type Jbond, NodeWallet, type RegisterValidatorProps, STANDARD_BOND_SEED, SessionStatus, type SetWithdrawAuthorityProps, type TopUpCollateralProps, type TransactionHistoryItem, VALIDATOR_BOND_SEED, type ValidatorBond, type WithdrawCollateralProps };
package/dist/index.js CHANGED
@@ -4602,6 +4602,7 @@ var STANDARD_BOND_SEED = "standard";
4602
4602
  var CROWDFUNDING_BOND_SEED = "crowdfunding";
4603
4603
  var ENV_PROGRAM_ID = {
4604
4604
  ["dev" /* DEV */]: new web3_js.PublicKey("Fo17edWRJewZNTRibgx9iTfjywCW6dzS81VwBLmPFVq1"),
4605
+ ["stage" /* STAGE */]: new web3_js.PublicKey("BondQ7KqZreTcW2UbeTNDcLCJQ3aXAtLn2Fm6ftaJDU"),
4605
4606
  ["prod" /* PROD */]: new web3_js.PublicKey("BondQ7KqZreTcW2UbeTNDcLCJQ3aXAtLn2Fm6ftaJDU")
4606
4607
  };
4607
4608
 
@@ -4769,7 +4770,7 @@ var jbond_default = {
4769
4770
  address: "Fo17edWRJewZNTRibgx9iTfjywCW6dzS81VwBLmPFVq1",
4770
4771
  metadata: {
4771
4772
  name: "jbond",
4772
- version: "0.2.1",
4773
+ version: "0.2.2",
4773
4774
  spec: "0.1.0",
4774
4775
  description: "Jpool Bond Program"
4775
4776
  },
@@ -5738,6 +5739,38 @@ var jbond_default = {
5738
5739
  ],
5739
5740
  args: []
5740
5741
  },
5742
+ {
5743
+ name: "migrate_validator_bond",
5744
+ docs: [
5745
+ "migrate validator bond from legacy format to new format"
5746
+ ],
5747
+ discriminator: [
5748
+ 214,
5749
+ 114,
5750
+ 65,
5751
+ 138,
5752
+ 248,
5753
+ 45,
5754
+ 186,
5755
+ 229
5756
+ ],
5757
+ accounts: [
5758
+ {
5759
+ name: "validator_bond",
5760
+ writable: true
5761
+ },
5762
+ {
5763
+ name: "authority",
5764
+ writable: true,
5765
+ signer: true
5766
+ },
5767
+ {
5768
+ name: "system_program",
5769
+ address: "11111111111111111111111111111111"
5770
+ }
5771
+ ],
5772
+ args: []
5773
+ },
5741
5774
  {
5742
5775
  name: "session_finish",
5743
5776
  docs: [
@@ -6751,7 +6784,7 @@ var JBondClient = class _JBondClient {
6751
6784
  if (this.options.programId) {
6752
6785
  return this.options.programId;
6753
6786
  }
6754
- return ENV_PROGRAM_ID["prod" /* PROD */];
6787
+ return new web3_js.PublicKey(ENV_PROGRAM_ID["prod" /* PROD */]);
6755
6788
  }
6756
6789
  /**
6757
6790
  * Get the current connection.
@@ -6769,7 +6802,7 @@ var JBondClient = class _JBondClient {
6769
6802
  }
6770
6803
  this._program = null;
6771
6804
  this.debug(`Set environment to ${env} with program ID: ${envProgramId.toString()}`);
6772
- return this.configure("programId", envProgramId);
6805
+ return this.configure("programId", new web3_js.PublicKey(envProgramId));
6773
6806
  }
6774
6807
  /**
6775
6808
  * Configure a specific option.
@@ -7239,6 +7272,21 @@ var JBondClient = class _JBondClient {
7239
7272
  });
7240
7273
  return this.program.methods.bondLockFunds(solToLamports(amount)).accountsPartial(accounts).instruction();
7241
7274
  }
7275
+ async migrateValidatorBond(props) {
7276
+ const ix = await this.getMigrateValidatorBondIx(props);
7277
+ return this.provider.sendAndConfirm?.(new web3_js.Transaction().add(ix));
7278
+ }
7279
+ async getMigrateValidatorBondIx(props) {
7280
+ const { bondType, name, voteAccount } = props;
7281
+ const [bondState] = this.pda.bondState(bondType, name);
7282
+ const [validatorBond] = this.pda.validatorBond(bondType, name, voteAccount);
7283
+ const accounts = {
7284
+ bondState,
7285
+ validatorBond,
7286
+ systemProgram: web3_js.PublicKey.default
7287
+ };
7288
+ return this.program.methods.migrateValidatorBond().accountsPartial(accounts).instruction();
7289
+ }
7242
7290
  /**
7243
7291
  * Build release funds instruction
7244
7292
  */
@@ -7325,7 +7373,7 @@ var JBondClient = class _JBondClient {
7325
7373
  const tokenAccount = splToken.getAssociatedTokenAddressSync(mint, address, true);
7326
7374
  try {
7327
7375
  const balance = await this.connection.getTokenAccountBalance(tokenAccount);
7328
- return solToLamports(balance.value.amount).toNumber();
7376
+ return Number(balance.value.amount);
7329
7377
  } catch {
7330
7378
  return 0;
7331
7379
  }