@hyperbridge/sdk 2.6.0 → 2.6.1

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.
@@ -1736,7 +1736,10 @@ declare class SubstrateChain implements IChain {
1736
1736
  */
1737
1737
  latestStateMachineHeight(stateMachineId: StateMachineIdParams): Promise<bigint>;
1738
1738
  /**
1739
- * Get the state machine update time for a given state machine height.
1739
+ * Get the state machine update time for a given state machine height. Reads the
1740
+ * `BoundedStateMachineUpdateTime` map in pallet-ismp directly, so the height is either
1741
+ * still retained on-chain or it has been evicted — there's no intermediate RPC to
1742
+ * reinterpret the absence.
1740
1743
  * @param {StateMachineHeight} stateMachineHeight - The state machine height.
1741
1744
  * @returns {Promise<bigint>} The statemachine update time in seconds.
1742
1745
  */
@@ -7441,29 +7441,28 @@ var SubstrateChain = class _SubstrateChain {
7441
7441
  return BigInt(latestHeight);
7442
7442
  }
7443
7443
  /**
7444
- * Get the state machine update time for a given state machine height.
7444
+ * Get the state machine update time for a given state machine height. Reads the
7445
+ * `BoundedStateMachineUpdateTime` map in pallet-ismp directly, so the height is either
7446
+ * still retained on-chain or it has been evicted — there's no intermediate RPC to
7447
+ * reinterpret the absence.
7445
7448
  * @param {StateMachineHeight} stateMachineHeight - The state machine height.
7446
7449
  * @returns {Promise<bigint>} The statemachine update time in seconds.
7447
7450
  */
7448
7451
  async stateMachineUpdateTime(stateMachineHeight) {
7449
- const state_id = convertStateIdToStateMachineId(stateMachineHeight.id.stateId);
7450
- const stateMachineId = {
7451
- state_id,
7452
- consensus_state_id: stateMachineHeight.id.consensusStateId
7453
- };
7454
- const payload = {
7455
- id: stateMachineId,
7456
- height: Number(stateMachineHeight.height)
7452
+ if (!this.api) throw new Error("API not initialized");
7453
+ const id = {
7454
+ stateId: stateMachineHeight.id.stateId,
7455
+ // on-chain StateMachineId encodes consensusStateId as [u8; 4]
7456
+ consensusStateId: toHex(toBytes(stateMachineHeight.id.consensusStateId))
7457
7457
  };
7458
- try {
7459
- const updateTime = await this.rpcClient.call("ismp_queryStateMachineUpdateTime", [payload]);
7460
- return BigInt(updateTime);
7461
- } catch (error) {
7462
- if (MissingConsensusUpdateTimeError.isError(error)) {
7463
- throw new MissingConsensusUpdateTimeError(MISSING_CONSENSUS_UPDATE_TIME_MESSAGE, { cause: error });
7464
- }
7465
- throw error;
7458
+ const updateTime = await this.api.query.ismp.boundedStateMachineUpdateTime(
7459
+ id,
7460
+ Number(stateMachineHeight.height)
7461
+ );
7462
+ if (updateTime.isNone) {
7463
+ throw new MissingConsensusUpdateTimeError(MISSING_CONSENSUS_UPDATE_TIME_MESSAGE);
7466
7464
  }
7465
+ return BigInt(updateTime.unwrap().toString());
7467
7466
  }
7468
7467
  /**
7469
7468
  * Get the challenge period for a given state machine id.