@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.
@@ -1191,7 +1191,10 @@ declare class SubstrateChain implements IChain {
1191
1191
  */
1192
1192
  latestStateMachineHeight(stateMachineId: StateMachineIdParams): Promise<bigint>;
1193
1193
  /**
1194
- * Get the state machine update time for a given state machine height.
1194
+ * Get the state machine update time for a given state machine height. Reads the
1195
+ * `BoundedStateMachineUpdateTime` map in pallet-ismp directly, so the height is either
1196
+ * still retained on-chain or it has been evicted — there's no intermediate RPC to
1197
+ * reinterpret the absence.
1195
1198
  * @param {StateMachineHeight} stateMachineHeight - The state machine height.
1196
1199
  * @returns {Promise<bigint>} The statemachine update time in seconds.
1197
1200
  */
@@ -1191,7 +1191,10 @@ declare class SubstrateChain implements IChain {
1191
1191
  */
1192
1192
  latestStateMachineHeight(stateMachineId: StateMachineIdParams): Promise<bigint>;
1193
1193
  /**
1194
- * Get the state machine update time for a given state machine height.
1194
+ * Get the state machine update time for a given state machine height. Reads the
1195
+ * `BoundedStateMachineUpdateTime` map in pallet-ismp directly, so the height is either
1196
+ * still retained on-chain or it has been evicted — there's no intermediate RPC to
1197
+ * reinterpret the absence.
1195
1198
  * @param {StateMachineHeight} stateMachineHeight - The state machine height.
1196
1199
  * @returns {Promise<bigint>} The statemachine update time in seconds.
1197
1200
  */
@@ -7402,29 +7402,28 @@ var SubstrateChain = class _SubstrateChain {
7402
7402
  return BigInt(latestHeight);
7403
7403
  }
7404
7404
  /**
7405
- * Get the state machine update time for a given state machine height.
7405
+ * Get the state machine update time for a given state machine height. Reads the
7406
+ * `BoundedStateMachineUpdateTime` map in pallet-ismp directly, so the height is either
7407
+ * still retained on-chain or it has been evicted — there's no intermediate RPC to
7408
+ * reinterpret the absence.
7406
7409
  * @param {StateMachineHeight} stateMachineHeight - The state machine height.
7407
7410
  * @returns {Promise<bigint>} The statemachine update time in seconds.
7408
7411
  */
7409
7412
  async stateMachineUpdateTime(stateMachineHeight) {
7410
- const state_id = convertStateIdToStateMachineId(stateMachineHeight.id.stateId);
7411
- const stateMachineId = {
7412
- state_id,
7413
- consensus_state_id: stateMachineHeight.id.consensusStateId
7414
- };
7415
- const payload = {
7416
- id: stateMachineId,
7417
- height: Number(stateMachineHeight.height)
7413
+ if (!this.api) throw new Error("API not initialized");
7414
+ const id = {
7415
+ stateId: stateMachineHeight.id.stateId,
7416
+ // on-chain StateMachineId encodes consensusStateId as [u8; 4]
7417
+ consensusStateId: viem.toHex(viem.toBytes(stateMachineHeight.id.consensusStateId))
7418
7418
  };
7419
- try {
7420
- const updateTime = await this.rpcClient.call("ismp_queryStateMachineUpdateTime", [payload]);
7421
- return BigInt(updateTime);
7422
- } catch (error) {
7423
- if (MissingConsensusUpdateTimeError.isError(error)) {
7424
- throw new MissingConsensusUpdateTimeError(MISSING_CONSENSUS_UPDATE_TIME_MESSAGE, { cause: error });
7425
- }
7426
- throw error;
7419
+ const updateTime = await this.api.query.ismp.boundedStateMachineUpdateTime(
7420
+ id,
7421
+ Number(stateMachineHeight.height)
7422
+ );
7423
+ if (updateTime.isNone) {
7424
+ throw new MissingConsensusUpdateTimeError(MISSING_CONSENSUS_UPDATE_TIME_MESSAGE);
7427
7425
  }
7426
+ return BigInt(updateTime.unwrap().toString());
7428
7427
  }
7429
7428
  /**
7430
7429
  * Get the challenge period for a given state machine id.