@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.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": [
@@ -1332,6 +1364,11 @@ type Jbond = {
1332
1364
  "code": 6024;
1333
1365
  "name": "invalidEpoch";
1334
1366
  "msg": "Invalid epoch for this operation";
1367
+ },
1368
+ {
1369
+ "code": 6025;
1370
+ "name": "bondNotRemovable";
1371
+ "msg": "Bond is not removable";
1335
1372
  }
1336
1373
  ];
1337
1374
  "types": [
@@ -2204,6 +2241,16 @@ declare class JBondClient {
2204
2241
  * Build lock funds instruction
2205
2242
  */
2206
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>;
2207
2254
  /**
2208
2255
  * Build release funds instruction
2209
2256
  */
@@ -2384,6 +2431,10 @@ declare const CROWDFUNDING_BOND_SEED = "crowdfunding";
2384
2431
  /**
2385
2432
  * Program IDs for different environments
2386
2433
  */
2387
- declare const ENV_PROGRAM_ID: Record<string, PublicKey>;
2434
+ declare const ENV_PROGRAM_ID: {
2435
+ dev: PublicKey;
2436
+ stage: PublicKey;
2437
+ prod: PublicKey;
2438
+ };
2388
2439
 
2389
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": [
@@ -1332,6 +1364,11 @@ type Jbond = {
1332
1364
  "code": 6024;
1333
1365
  "name": "invalidEpoch";
1334
1366
  "msg": "Invalid epoch for this operation";
1367
+ },
1368
+ {
1369
+ "code": 6025;
1370
+ "name": "bondNotRemovable";
1371
+ "msg": "Bond is not removable";
1335
1372
  }
1336
1373
  ];
1337
1374
  "types": [
@@ -2204,6 +2241,16 @@ declare class JBondClient {
2204
2241
  * Build lock funds instruction
2205
2242
  */
2206
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>;
2207
2254
  /**
2208
2255
  * Build release funds instruction
2209
2256
  */
@@ -2384,6 +2431,10 @@ declare const CROWDFUNDING_BOND_SEED = "crowdfunding";
2384
2431
  /**
2385
2432
  * Program IDs for different environments
2386
2433
  */
2387
- declare const ENV_PROGRAM_ID: Record<string, PublicKey>;
2434
+ declare const ENV_PROGRAM_ID: {
2435
+ dev: PublicKey;
2436
+ stage: PublicKey;
2437
+ prod: PublicKey;
2438
+ };
2388
2439
 
2389
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: [
@@ -6087,6 +6120,11 @@ var jbond_default = {
6087
6120
  code: 6024,
6088
6121
  name: "InvalidEpoch",
6089
6122
  msg: "Invalid epoch for this operation"
6123
+ },
6124
+ {
6125
+ code: 6025,
6126
+ name: "BondNotRemovable",
6127
+ msg: "Bond is not removable"
6090
6128
  }
6091
6129
  ],
6092
6130
  types: [
@@ -6746,7 +6784,7 @@ var JBondClient = class _JBondClient {
6746
6784
  if (this.options.programId) {
6747
6785
  return this.options.programId;
6748
6786
  }
6749
- return ENV_PROGRAM_ID["prod" /* PROD */];
6787
+ return new web3_js.PublicKey(ENV_PROGRAM_ID["prod" /* PROD */]);
6750
6788
  }
6751
6789
  /**
6752
6790
  * Get the current connection.
@@ -6764,7 +6802,7 @@ var JBondClient = class _JBondClient {
6764
6802
  }
6765
6803
  this._program = null;
6766
6804
  this.debug(`Set environment to ${env} with program ID: ${envProgramId.toString()}`);
6767
- return this.configure("programId", envProgramId);
6805
+ return this.configure("programId", new web3_js.PublicKey(envProgramId));
6768
6806
  }
6769
6807
  /**
6770
6808
  * Configure a specific option.
@@ -7234,6 +7272,21 @@ var JBondClient = class _JBondClient {
7234
7272
  });
7235
7273
  return this.program.methods.bondLockFunds(solToLamports(amount)).accountsPartial(accounts).instruction();
7236
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
+ }
7237
7290
  /**
7238
7291
  * Build release funds instruction
7239
7292
  */
@@ -7320,7 +7373,7 @@ var JBondClient = class _JBondClient {
7320
7373
  const tokenAccount = splToken.getAssociatedTokenAddressSync(mint, address, true);
7321
7374
  try {
7322
7375
  const balance = await this.connection.getTokenAccountBalance(tokenAccount);
7323
- return solToLamports(balance.value.amount).toNumber();
7376
+ return Number(balance.value.amount);
7324
7377
  } catch {
7325
7378
  return 0;
7326
7379
  }