@jpool/bond-sdk 0.9.0-next.7 → 0.9.0-next.8
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 +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +13 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1534,7 +1534,7 @@ type BondType = IdlTypes<Jbond>['bondType'];
|
|
|
1534
1534
|
type CollateralType = IdlTypes<Jbond>['collateralType'];
|
|
1535
1535
|
type BondStateStats = {
|
|
1536
1536
|
totalCollected: number;
|
|
1537
|
-
|
|
1537
|
+
status: SessionStatus;
|
|
1538
1538
|
};
|
|
1539
1539
|
declare const bondTypeToSeed: {
|
|
1540
1540
|
performance: Seeds;
|
|
@@ -1823,7 +1823,8 @@ declare class JBondClient {
|
|
|
1823
1823
|
/**
|
|
1824
1824
|
* Get all bond states with total collected collateral
|
|
1825
1825
|
*/
|
|
1826
|
-
getAllBondStates(_bondType: BondType): Promise<Array<[BondState,
|
|
1826
|
+
getAllBondStates(_bondType: BondType): Promise<Array<[BondState, BondStateStats]>>;
|
|
1827
|
+
private getBondStateSessionStatus;
|
|
1827
1828
|
private getValidatorBondsByState;
|
|
1828
1829
|
/**
|
|
1829
1830
|
* Fetch validator bond data or null if not found
|
package/dist/index.d.ts
CHANGED
|
@@ -1534,7 +1534,7 @@ type BondType = IdlTypes<Jbond>['bondType'];
|
|
|
1534
1534
|
type CollateralType = IdlTypes<Jbond>['collateralType'];
|
|
1535
1535
|
type BondStateStats = {
|
|
1536
1536
|
totalCollected: number;
|
|
1537
|
-
|
|
1537
|
+
status: SessionStatus;
|
|
1538
1538
|
};
|
|
1539
1539
|
declare const bondTypeToSeed: {
|
|
1540
1540
|
performance: Seeds;
|
|
@@ -1823,7 +1823,8 @@ declare class JBondClient {
|
|
|
1823
1823
|
/**
|
|
1824
1824
|
* Get all bond states with total collected collateral
|
|
1825
1825
|
*/
|
|
1826
|
-
getAllBondStates(_bondType: BondType): Promise<Array<[BondState,
|
|
1826
|
+
getAllBondStates(_bondType: BondType): Promise<Array<[BondState, BondStateStats]>>;
|
|
1827
|
+
private getBondStateSessionStatus;
|
|
1827
1828
|
private getValidatorBondsByState;
|
|
1828
1829
|
/**
|
|
1829
1830
|
* Fetch validator bond data or null if not found
|
package/dist/index.js
CHANGED
|
@@ -6797,11 +6797,22 @@ var JBondClient = class _JBondClient {
|
|
|
6797
6797
|
(vb) => this.getValidatorBondBalance(state.bondType, state.name, vb.voteAccount).then((v) => v ?? 0)
|
|
6798
6798
|
)
|
|
6799
6799
|
);
|
|
6800
|
-
const
|
|
6801
|
-
|
|
6800
|
+
const bondStateStats = {
|
|
6801
|
+
totalCollected: balances.reduce((sum, v) => sum + v, 0),
|
|
6802
|
+
status: await this.getBondStateSessionStatus(state)
|
|
6803
|
+
};
|
|
6804
|
+
bondStates.push([state, bondStateStats]);
|
|
6802
6805
|
}
|
|
6803
6806
|
return bondStates;
|
|
6804
6807
|
}
|
|
6808
|
+
async getBondStateSessionStatus(bondState) {
|
|
6809
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
6810
|
+
if (bondState.sessionFinishTs.toNumber() > now) {
|
|
6811
|
+
return 0 /* Live */;
|
|
6812
|
+
} else {
|
|
6813
|
+
return 1 /* Finished */;
|
|
6814
|
+
}
|
|
6815
|
+
}
|
|
6805
6816
|
async getValidatorBondsByState(bondType, bondName) {
|
|
6806
6817
|
const validatorBonds = [];
|
|
6807
6818
|
const bondStatePda = this.pda.bondState(bondType, bondName)[0];
|