@jpool/bond-sdk 0.11.0-next.3 → 0.11.0-next.4
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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +11 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -6885,20 +6885,17 @@ var JBondClient = class _JBondClient {
|
|
|
6885
6885
|
*/
|
|
6886
6886
|
async getClaimAllCompensationsIxs(props) {
|
|
6887
6887
|
const ixs = [];
|
|
6888
|
-
const validatorBonds = await this.getBondValidatorStates(props.bondType, props.name);
|
|
6889
6888
|
const validatorBondBalances = await this.getBondStateValidatorBondBalances(
|
|
6890
6889
|
props.bondType,
|
|
6891
6890
|
props.name
|
|
6892
6891
|
);
|
|
6893
|
-
for (const
|
|
6894
|
-
|
|
6895
|
-
const validatorBondBalance = lamportsToSol(validatorBondBalances.find((vbb) => vbb.voteAccount.equals(vb.voteAccount))?.balance || 0);
|
|
6896
|
-
const amountToClaim = validatorBondBalance - (props.collateralType ? 0 : lamportsToSol(await this.validatorBondRentExempt()));
|
|
6892
|
+
for (const bond_balance of validatorBondBalances) {
|
|
6893
|
+
const amountToClaim = lamportsToSol(bond_balance.balance);
|
|
6897
6894
|
if (amountToClaim <= 0) {
|
|
6898
|
-
|
|
6895
|
+
this.debug("No balance to claim for validator:", bond_balance.voteAccount.toBase58());
|
|
6899
6896
|
continue;
|
|
6900
6897
|
}
|
|
6901
|
-
|
|
6898
|
+
this.debug("Amount to claim:", amountToClaim);
|
|
6902
6899
|
const ix = await this.getClaimIx({
|
|
6903
6900
|
bondType: props.bondType,
|
|
6904
6901
|
name: props.name,
|
|
@@ -6906,7 +6903,7 @@ var JBondClient = class _JBondClient {
|
|
|
6906
6903
|
collateralType: props.collateralType,
|
|
6907
6904
|
reserve: props.reserve,
|
|
6908
6905
|
authority: props.authority,
|
|
6909
|
-
voteAccount:
|
|
6906
|
+
voteAccount: bond_balance.voteAccount
|
|
6910
6907
|
});
|
|
6911
6908
|
ixs.push(ix);
|
|
6912
6909
|
}
|
|
@@ -6997,8 +6994,8 @@ var JBondClient = class _JBondClient {
|
|
|
6997
6994
|
if (!accountInfo) {
|
|
6998
6995
|
return 0;
|
|
6999
6996
|
}
|
|
7000
|
-
const {
|
|
7001
|
-
const rentExempt = await this.
|
|
6997
|
+
const { lamports } = accountInfo;
|
|
6998
|
+
const rentExempt = await this.validatorBondRentExempt();
|
|
7002
6999
|
return Math.max(0, lamports - rentExempt);
|
|
7003
7000
|
},
|
|
7004
7001
|
token: async (mint) => {
|
|
@@ -7015,7 +7012,7 @@ var JBondClient = class _JBondClient {
|
|
|
7015
7012
|
async getBondStateValidatorBondBalances(bondType, bondName) {
|
|
7016
7013
|
const bondState = await this.getBondState(bondType, bondName);
|
|
7017
7014
|
const collateralType = bondState.collateralType;
|
|
7018
|
-
const validatorBonds = await this.
|
|
7015
|
+
const validatorBonds = await this.getValidatorBondsForState(bondType, bondName);
|
|
7019
7016
|
if (!validatorBonds.length) {
|
|
7020
7017
|
return [];
|
|
7021
7018
|
}
|
|
@@ -7030,9 +7027,10 @@ var JBondClient = class _JBondClient {
|
|
|
7030
7027
|
native: async () => {
|
|
7031
7028
|
const addresses = validatorBonds.map((vb) => vb.publicKey);
|
|
7032
7029
|
const accountInfos = await this.connection.getMultipleAccountsInfo(addresses);
|
|
7030
|
+
const rentExempt = await this.validatorBondRentExempt();
|
|
7033
7031
|
return validatorBonds.map((vb, idx) => ({
|
|
7034
7032
|
voteAccount: vb.voteAccount,
|
|
7035
|
-
balance: accountInfos[idx]?.lamports ?? 0
|
|
7033
|
+
balance: Math.max(0, (accountInfos[idx]?.lamports ?? 0) - rentExempt)
|
|
7036
7034
|
}));
|
|
7037
7035
|
},
|
|
7038
7036
|
token: async (mint) => {
|
|
@@ -7099,7 +7097,7 @@ var JBondClient = class _JBondClient {
|
|
|
7099
7097
|
/**
|
|
7100
7098
|
* Get all validator bonds for a given bond state
|
|
7101
7099
|
*/
|
|
7102
|
-
async
|
|
7100
|
+
async getValidatorBondsForState(bondType, bondName) {
|
|
7103
7101
|
const [bondState] = this.pda.bondState(bondType, bondName);
|
|
7104
7102
|
const accounts = await this.program.account.validatorBond.all([
|
|
7105
7103
|
{
|