@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.mjs CHANGED
@@ -6762,11 +6762,22 @@ var JBondClient = class _JBondClient {
6762
6762
  (vb) => this.getValidatorBondBalance(state.bondType, state.name, vb.voteAccount).then((v) => v ?? 0)
6763
6763
  )
6764
6764
  );
6765
- const totalCollected = balances.reduce((sum, v) => sum + v, 0);
6766
- bondStates.push([state, totalCollected]);
6765
+ const bondStateStats = {
6766
+ totalCollected: balances.reduce((sum, v) => sum + v, 0),
6767
+ status: await this.getBondStateSessionStatus(state)
6768
+ };
6769
+ bondStates.push([state, bondStateStats]);
6767
6770
  }
6768
6771
  return bondStates;
6769
6772
  }
6773
+ async getBondStateSessionStatus(bondState) {
6774
+ const now = Math.floor(Date.now() / 1e3);
6775
+ if (bondState.sessionFinishTs.toNumber() > now) {
6776
+ return 0 /* Live */;
6777
+ } else {
6778
+ return 1 /* Finished */;
6779
+ }
6780
+ }
6770
6781
  async getValidatorBondsByState(bondType, bondName) {
6771
6782
  const validatorBonds = [];
6772
6783
  const bondStatePda = this.pda.bondState(bondType, bondName)[0];