@hyperbridge/sdk 1.3.18 → 1.3.20

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.
@@ -1747,6 +1747,10 @@ declare const RESPONSE_RECEIPTS_SLOT = 3n;
1747
1747
  * Slot index for state commitment map
1748
1748
  */
1749
1749
  declare const STATE_COMMITMENTS_SLOT = 5n;
1750
+ declare function requestCommitmentKey(key: Hex): {
1751
+ slot1: Hex;
1752
+ slot2: Hex;
1753
+ };
1750
1754
  /**
1751
1755
  * Derives the storage slot for a specific field in the StateCommitment struct
1752
1756
  *
@@ -3095,4 +3099,4 @@ declare const coingeckoIds: {
3095
3099
  "EVM-130": string;
3096
3100
  };
3097
3101
 
3098
- export { ADDRESS_ZERO, type AllStatusKey, type AssetTeleported, type AssetTeleportedResponse, type BlockMetadata, type CancelOptions, type ChainConfig, ChainConfigService, type ChainId, Chains, type ClientConfig, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DUMMY_PRIVATE_KEY, type DecodedOrderPlacedLog, type DispatchGet, type DispatchPost, ERC20Method, type EstimateGasCallData, EvmChain, type EvmChainParams, type ExecutionResult, type FillOptions, type FillerConfig, type GetRequestResponse, type GetRequestWithStatus, type GetResponseByRequestIdResponse, type GetResponseStorageValues, type HexString, type HostParams, HyperClientStatus, type HyperbridgeTxEvents, type IChain, type IConfig, type IEvmConfig, type IGetRequest, type IGetRequestMessage, type IGetResponse, type IGetResponseMessage, type IHyperbridgeConfig, type IIsmpMessage, type IMessage, type IPostRequest, type IPostResponse, type IProof, type IRequestMessage, type ISubstrateConfig, type ITimeoutPostRequestMessage, IndexerClient, type IndexerQueryClient, IntentGateway, type IntentGatewayParams, type IsmpRequest, type NewDeployment, type Order, type OrderResponse, OrderStatus, type OrderStatusMetadata, type OrderWithStatus, type Params, type PaymentInfo, type PostRequestStatus, type PostRequestTimeoutStatus, type PostRequestWithStatus, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, type RequestBody, type RequestCommitment, RequestKind, type RequestResponse, RequestStatus, type RequestStatusKey, type RequestStatusWithMetadata, type ResponseCommitmentWithValues, type RetryConfig, STATE_COMMITMENTS_SLOT, type StateMachineHeight, type StateMachineIdParams, type StateMachineResponse, type StateMachineUpdate, SubstrateChain, type SubstrateChainParams, TeleportStatus, TimeoutStatus, type TimeoutStatusKey, type TokenGatewayAssetTeleportedResponse, type TokenGatewayAssetTeleportedWithStatus, type TokenInfo, type TokenPrice, type TokenPricesResponse, type TokenRegistry, type TokenRegistryResponse, WrappedNativeDecimals, type XcmGatewayParams, __test, addresses, adjustFeeDecimals, assets, bytes20ToBytes32, bytes32ToBytes20, chainIds, coingeckoIds, consensusStateIds, constructRedeemEscrowRequestBody, convertStateIdToStateMachineId, convertStateMachineIdToEnum, createQueryClient, createRpcUrls, encodeISMPMessage, estimateGasForPost, fetchPrice, generateRootWithProof, getChain, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, hexToString, orderCommitment, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, teleport, teleportDot, viemChains };
3102
+ export { ADDRESS_ZERO, type AllStatusKey, type AssetTeleported, type AssetTeleportedResponse, type BlockMetadata, type CancelOptions, type ChainConfig, ChainConfigService, type ChainId, Chains, type ClientConfig, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DUMMY_PRIVATE_KEY, type DecodedOrderPlacedLog, type DispatchGet, type DispatchPost, ERC20Method, type EstimateGasCallData, EvmChain, type EvmChainParams, type ExecutionResult, type FillOptions, type FillerConfig, type GetRequestResponse, type GetRequestWithStatus, type GetResponseByRequestIdResponse, type GetResponseStorageValues, type HexString, type HostParams, HyperClientStatus, type HyperbridgeTxEvents, type IChain, type IConfig, type IEvmConfig, type IGetRequest, type IGetRequestMessage, type IGetResponse, type IGetResponseMessage, type IHyperbridgeConfig, type IIsmpMessage, type IMessage, type IPostRequest, type IPostResponse, type IProof, type IRequestMessage, type ISubstrateConfig, type ITimeoutPostRequestMessage, IndexerClient, type IndexerQueryClient, IntentGateway, type IntentGatewayParams, type IsmpRequest, type NewDeployment, type Order, type OrderResponse, OrderStatus, type OrderStatusMetadata, type OrderWithStatus, type Params, type PaymentInfo, type PostRequestStatus, type PostRequestTimeoutStatus, type PostRequestWithStatus, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, type RequestBody, type RequestCommitment, RequestKind, type RequestResponse, RequestStatus, type RequestStatusKey, type RequestStatusWithMetadata, type ResponseCommitmentWithValues, type RetryConfig, STATE_COMMITMENTS_SLOT, type StateMachineHeight, type StateMachineIdParams, type StateMachineResponse, type StateMachineUpdate, SubstrateChain, type SubstrateChainParams, TeleportStatus, TimeoutStatus, type TimeoutStatusKey, type TokenGatewayAssetTeleportedResponse, type TokenGatewayAssetTeleportedWithStatus, type TokenInfo, type TokenPrice, type TokenPricesResponse, type TokenRegistry, type TokenRegistryResponse, WrappedNativeDecimals, type XcmGatewayParams, __test, addresses, adjustFeeDecimals, assets, bytes20ToBytes32, bytes32ToBytes20, chainIds, coingeckoIds, consensusStateIds, constructRedeemEscrowRequestBody, convertStateIdToStateMachineId, convertStateMachineIdToEnum, createQueryClient, createRpcUrls, encodeISMPMessage, estimateGasForPost, fetchPrice, generateRootWithProof, getChain, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, hexToString, orderCommitment, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, requestCommitmentKey, teleport, teleportDot, viemChains };
@@ -5660,7 +5660,7 @@ var EvmChain = class {
5660
5660
  * @returns {Promise<HexString>} The proof.
5661
5661
  */
5662
5662
  async queryProof(message, counterparty, at) {
5663
- const commitmentKeys = "Requests" in message ? message.Requests.map((key) => requestCommitmentKey(key)) : message.Responses.map((key) => responseCommitmentKey(key));
5663
+ const commitmentKeys = "Requests" in message ? message.Requests.map((key) => requestCommitmentKey(key).slot1) : message.Responses.map((key) => responseCommitmentKey(key));
5664
5664
  const config = {
5665
5665
  address: this.params.host,
5666
5666
  storageKeys: commitmentKeys
@@ -5702,7 +5702,7 @@ var EvmChain = class {
5702
5702
  const encoded = EvmStateProof.enc({
5703
5703
  contractProof: proof.accountProof.map((item) => Array.from(hexToBytes(item))),
5704
5704
  storageProof: [
5705
- [Array.from(hexToBytes(this.params.host)), flattenedProof.map((item) => Array.from(hexToBytes(item)))]
5705
+ [Array.from(hexToBytes(config.address)), flattenedProof.map((item) => Array.from(hexToBytes(item)))]
5706
5706
  ]
5707
5707
  });
5708
5708
  return toHex(encoded);
@@ -6061,7 +6061,10 @@ function requestCommitmentKey(key) {
6061
6061
  const slot = REQUEST_COMMITMENTS_SLOT;
6062
6062
  const mappedKey = deriveMapKey(keyBytes, slot);
6063
6063
  const number = bytesToBigInt(hexToBytes(mappedKey)) + 1n;
6064
- return pad(`0x${number.toString(16)}`, { size: 32 });
6064
+ return {
6065
+ slot1: pad(`0x${number.toString(16)}`, { size: 32 }),
6066
+ slot2: mappedKey
6067
+ };
6065
6068
  }
6066
6069
  function responseCommitmentKey(key) {
6067
6070
  const keyBytes = hexToBytes(key);
@@ -12470,77 +12473,73 @@ var IntentGateway = class {
12470
12473
  const commitment = getRequestCommitment({ ...getRequest, keys: [...getRequest.keys] });
12471
12474
  const sourceStatusStream = indexerClient.getRequestStatusStream(commitment);
12472
12475
  for await (const statusUpdate of sourceStatusStream) {
12473
- if (statusUpdate.status === RequestStatus.SOURCE_FINALIZED) {
12474
- let sourceHeight = BigInt(statusUpdate.metadata.blockNumber);
12475
- let proof;
12476
- const checkIfAlreadyDelivered = async () => {
12477
- const currentStatus = await indexerClient.queryGetRequestWithStatus(commitment);
12478
- return currentStatus?.statuses.some(
12479
- (status) => status.status === RequestStatus.HYPERBRIDGE_DELIVERED
12480
- ) ?? false;
12481
- };
12482
- while (true) {
12483
- try {
12484
- proof = await this.source.queryProof(
12485
- { Requests: [commitment] },
12486
- hyperbridgeConfig.stateMachineId,
12487
- sourceHeight
12488
- );
12489
- break;
12490
- } catch {
12491
- const failedHeight = sourceHeight;
12492
- while (sourceHeight <= failedHeight) {
12493
- if (await checkIfAlreadyDelivered()) {
12494
- break;
12495
- }
12496
- const nextHeight = await retryPromise(
12497
- () => hyperbridge.latestStateMachineHeight({
12498
- stateId: parseStateMachineId(sourceStateMachine).stateId,
12499
- consensusStateId: sourceConsensusStateId
12500
- }),
12501
- {
12502
- maxRetries: 5,
12503
- backoffMs: 5e3,
12504
- logMessage: "Failed to fetch latest state machine height (post-source-proof failure)"
12505
- }
12506
- );
12507
- if (nextHeight <= failedHeight) {
12508
- await sleep(1e4);
12509
- continue;
12510
- }
12511
- sourceHeight = nextHeight;
12512
- }
12476
+ yield statusUpdate;
12477
+ if (statusUpdate.status !== RequestStatus.SOURCE_FINALIZED) {
12478
+ continue;
12479
+ }
12480
+ let sourceHeight = BigInt(statusUpdate.metadata.blockNumber);
12481
+ let proof;
12482
+ const checkIfAlreadyDelivered = async () => {
12483
+ const currentStatus = await indexerClient.queryGetRequestWithStatus(commitment);
12484
+ return currentStatus?.statuses.some((status) => status.status === RequestStatus.HYPERBRIDGE_DELIVERED) ?? false;
12485
+ };
12486
+ const { slot1, slot2 } = requestCommitmentKey(commitment);
12487
+ while (true) {
12488
+ try {
12489
+ proof = await this.source.queryStateProof(sourceHeight, [slot1, slot2]);
12490
+ break;
12491
+ } catch {
12492
+ const failedHeight = sourceHeight;
12493
+ while (sourceHeight <= failedHeight) {
12513
12494
  if (await checkIfAlreadyDelivered()) {
12514
12495
  break;
12515
12496
  }
12516
- }
12517
- }
12518
- if (proof) {
12519
- const sourceIProof = {
12520
- height: sourceHeight,
12521
- stateMachine: sourceStateMachine,
12522
- consensusStateId: sourceConsensusStateId,
12523
- proof
12524
- };
12525
- yield { status: "SOURCE_PROOF_RECEIVED", data: sourceIProof };
12526
- const getRequestMessage = {
12527
- kind: "GetRequest",
12528
- requests: [getRequest],
12529
- source: sourceIProof,
12530
- response: destIProof,
12531
- signer: pad("0x")
12532
- };
12533
- await waitForChallengePeriod(hyperbridge, {
12534
- height: sourceHeight,
12535
- id: {
12536
- stateId: parseStateMachineId(sourceStateMachine).stateId,
12537
- consensusStateId: sourceConsensusStateId
12497
+ const nextHeight = await retryPromise(
12498
+ () => hyperbridge.latestStateMachineHeight({
12499
+ stateId: parseStateMachineId(sourceStateMachine).stateId,
12500
+ consensusStateId: sourceConsensusStateId
12501
+ }),
12502
+ {
12503
+ maxRetries: 5,
12504
+ backoffMs: 5e3,
12505
+ logMessage: "Failed to fetch latest state machine height (post-source-proof failure)"
12506
+ }
12507
+ );
12508
+ if (nextHeight <= failedHeight) {
12509
+ await sleep(1e4);
12510
+ continue;
12538
12511
  }
12539
- });
12540
- await this.submitAndConfirmReceipt(hyperbridge, commitment, getRequestMessage);
12512
+ sourceHeight = nextHeight;
12513
+ }
12514
+ if (await checkIfAlreadyDelivered()) {
12515
+ break;
12516
+ }
12541
12517
  }
12542
12518
  }
12543
- yield statusUpdate;
12519
+ if (proof) {
12520
+ const sourceIProof = {
12521
+ height: sourceHeight,
12522
+ stateMachine: sourceStateMachine,
12523
+ consensusStateId: sourceConsensusStateId,
12524
+ proof
12525
+ };
12526
+ yield { status: "SOURCE_PROOF_RECEIVED", data: sourceIProof };
12527
+ const getRequestMessage = {
12528
+ kind: "GetRequest",
12529
+ requests: [getRequest],
12530
+ source: sourceIProof,
12531
+ response: destIProof,
12532
+ signer: pad("0x")
12533
+ };
12534
+ await waitForChallengePeriod(hyperbridge, {
12535
+ height: sourceHeight,
12536
+ id: {
12537
+ stateId: parseStateMachineId(sourceStateMachine).stateId,
12538
+ consensusStateId: sourceConsensusStateId
12539
+ }
12540
+ });
12541
+ await this.submitAndConfirmReceipt(hyperbridge, commitment, getRequestMessage);
12542
+ }
12544
12543
  }
12545
12544
  }
12546
12545
  /**
@@ -12914,6 +12913,6 @@ async function teleportDot(param_) {
12914
12913
  return stream;
12915
12914
  }
12916
12915
 
12917
- export { ADDRESS_ZERO, ChainConfigService, Chains, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DUMMY_PRIVATE_KEY, ERC20Method, EvmChain, HyperClientStatus, IndexerClient, IntentGateway, OrderStatus, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, RequestKind, RequestStatus, STATE_COMMITMENTS_SLOT, SubstrateChain, TeleportStatus, TimeoutStatus, WrappedNativeDecimals, __test, addresses, adjustFeeDecimals, assets, bytes20ToBytes32, bytes32ToBytes20, chainIds, coingeckoIds, consensusStateIds, constructRedeemEscrowRequestBody, convertStateIdToStateMachineId, convertStateMachineIdToEnum, createQueryClient, createRpcUrls, encodeISMPMessage, estimateGasForPost, fetchPrice, generateRootWithProof, getChain, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, hexToString, orderCommitment, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, teleport, teleportDot, viemChains };
12916
+ export { ADDRESS_ZERO, ChainConfigService, Chains, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DUMMY_PRIVATE_KEY, ERC20Method, EvmChain, HyperClientStatus, IndexerClient, IntentGateway, OrderStatus, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, RequestKind, RequestStatus, STATE_COMMITMENTS_SLOT, SubstrateChain, TeleportStatus, TimeoutStatus, WrappedNativeDecimals, __test, addresses, adjustFeeDecimals, assets, bytes20ToBytes32, bytes32ToBytes20, chainIds, coingeckoIds, consensusStateIds, constructRedeemEscrowRequestBody, convertStateIdToStateMachineId, convertStateMachineIdToEnum, createQueryClient, createRpcUrls, encodeISMPMessage, estimateGasForPost, fetchPrice, generateRootWithProof, getChain, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, hexToString, orderCommitment, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, requestCommitmentKey, teleport, teleportDot, viemChains };
12918
12917
  //# sourceMappingURL=index.js.map
12919
12918
  //# sourceMappingURL=index.js.map