@hyperbridge/sdk 1.3.5 → 1.3.7

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.
@@ -3,17 +3,18 @@ import { join } from 'path';
3
3
  import { TextDecoder as TextDecoder$1, TextEncoder as TextEncoder$1 } from 'util';
4
4
  import { createConsola, LogLevels } from 'consola';
5
5
  import { flatten, zip, capitalize, maxBy, isNil } from 'lodash-es';
6
- import { toHex, hexToBytes, encodePacked, keccak256, encodeAbiParameters, bytesToHex, concatHex, createPublicClient, http, encodeFunctionData, erc20Abi, bytesToBigInt, pad, toBytes, maxUint256, parseUnits } from 'viem';
6
+ import { toHex, hexToBytes, encodePacked, keccak256, encodeAbiParameters, bytesToHex, concatHex, createPublicClient, http, encodeFunctionData, erc20Abi, bytesToBigInt, pad, toBytes, maxUint256, formatUnits, parseUnits } from 'viem';
7
7
  import mergeRace from '@async-generator/merge-race';
8
8
  import { gnosisChiado, gnosis, bscTestnet, bsc, soneium, baseSepolia, base, optimismSepolia, optimism, arbitrumSepolia, arbitrum, mainnet, sepolia } from 'viem/chains';
9
9
  import { hasWindow, isNode, env } from 'std-env';
10
- import { Vector, u8, Struct, Tuple, Enum, _void, u64, u32, Option, bool, u128 } from 'scale-ts';
10
+ import { Vector, u8, Struct, Tuple, Enum, _void, u64, u32, Option, bool, u128, Bytes } from 'scale-ts';
11
11
  import { match } from 'ts-pattern';
12
12
  import { WsProvider, ApiPromise } from '@polkadot/api';
13
13
  import { RpcWebSocketClient } from 'rpc-websocket-client';
14
- import { keccakAsU8a, decodeAddress, xxhashAsU8a } from '@polkadot/util-crypto';
14
+ import { keccakAsU8a, decodeAddress, keccakAsHex, xxhashAsU8a } from '@polkadot/util-crypto';
15
15
  import { GraphQLClient } from 'graphql-request';
16
- import { u8aToHex } from '@polkadot/util';
16
+ import { Decimal } from 'decimal.js';
17
+ import { hexToU8a, u8aToHex } from '@polkadot/util';
17
18
 
18
19
  var __defProp = Object.defineProperty;
19
20
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -3933,6 +3934,10 @@ var GetRequest = Struct({
3933
3934
  * Substrate Keys
3934
3935
  */
3935
3936
  keys: Vector(Vector(u8)),
3937
+ /*
3938
+ * The height of the state machine
3939
+ */
3940
+ height: u64,
3936
3941
  /*
3937
3942
  * Some application-specific metadata relating to this request
3938
3943
  */
@@ -4059,6 +4064,24 @@ var TimeoutMessage = Enum({
4059
4064
  requests: Vector(Request)
4060
4065
  })
4061
4066
  });
4067
+ var GetRequestsWithProof = Struct({
4068
+ /*
4069
+ * Requests to be fetched
4070
+ */
4071
+ requests: Vector(GetRequest),
4072
+ /*
4073
+ * Membership batch proof for these requests
4074
+ */
4075
+ source: Proof,
4076
+ /*
4077
+ * Storage proof for these responses
4078
+ */
4079
+ response: Proof,
4080
+ /*
4081
+ * Signer information. Ideally should be their account identifier
4082
+ */
4083
+ signer: Vector(u8)
4084
+ });
4062
4085
  var Message = Enum({
4063
4086
  /*
4064
4087
  * A consensus update message
@@ -4807,6 +4830,8 @@ var EvmChain = class {
4807
4830
  ]
4808
4831
  });
4809
4832
  return encoded2;
4833
+ }).with({ kind: "GetRequest" }, (message2) => {
4834
+ throw new Error("GetResponse is not yet supported on Substrate chains");
4810
4835
  }).exhaustive();
4811
4836
  return encoded;
4812
4837
  }
@@ -5122,8 +5147,13 @@ var SubstrateChain = class {
5122
5147
  async submitUnsigned(message) {
5123
5148
  if (!this.api) throw new Error("API not initialized");
5124
5149
  const { api } = this;
5125
- const args = hexToBytes(this.encode(message)).slice(2);
5126
- const tx = api.tx.ismp.handleUnsigned(args);
5150
+ const args = encodeISMPMessage(message);
5151
+ let tx;
5152
+ if (message.kind === "GetRequest") {
5153
+ tx = api.tx.stateCoprocessor.handleUnsigned(args);
5154
+ } else {
5155
+ tx = api.tx.ismp.handleUnsigned(args);
5156
+ }
5127
5157
  return new Promise((resolve, reject) => {
5128
5158
  let unsub = () => {
5129
5159
  };
@@ -5266,6 +5296,18 @@ function convertIPostRequestToCodec(request) {
5266
5296
  }
5267
5297
  };
5268
5298
  }
5299
+ function convertIGetRequestToCodec(request) {
5300
+ return {
5301
+ source: convertStateMachineIdToEnum(request.source),
5302
+ dest: convertStateMachineIdToEnum(request.dest),
5303
+ from: Array.from(hexToBytes(request.from)),
5304
+ nonce: request.nonce,
5305
+ keys: request.keys.map((key) => Array.from(hexToBytes(key))),
5306
+ context: Array.from(hexToBytes(request.context)),
5307
+ timeoutTimestamp: request.timeoutTimestamp,
5308
+ height: request.height
5309
+ };
5310
+ }
5269
5311
  function encodeISMPMessage(message) {
5270
5312
  try {
5271
5313
  return match(message).with({ kind: "PostRequest" }, (message2) => {
@@ -5292,6 +5334,31 @@ function encodeISMPMessage(message) {
5292
5334
  ]);
5293
5335
  }).with({ kind: "GetResponse" }, (message2) => {
5294
5336
  throw new Error("GetResponse is not yet supported on Substrate chains");
5337
+ }).with({ kind: "GetRequest" }, (message2) => {
5338
+ return GetRequestsWithProof.enc({
5339
+ requests: message2.requests.map((request) => convertIGetRequestToCodec(request)),
5340
+ source: {
5341
+ height: {
5342
+ height: message2.source.height,
5343
+ id: {
5344
+ consensusStateId: Array.from(toBytes(message2.source.consensusStateId)),
5345
+ id: convertStateMachineIdToEnum(message2.source.stateMachine)
5346
+ }
5347
+ },
5348
+ proof: Array.from(hexToBytes(message2.source.proof))
5349
+ },
5350
+ response: {
5351
+ height: {
5352
+ height: message2.response.height,
5353
+ id: {
5354
+ consensusStateId: Array.from(toBytes(message2.response.consensusStateId)),
5355
+ id: convertStateMachineIdToEnum(message2.response.stateMachine)
5356
+ }
5357
+ },
5358
+ proof: Array.from(hexToBytes(message2.response.proof))
5359
+ },
5360
+ signer: Array.from(hexToBytes(message2.signer))
5361
+ });
5295
5362
  }).with({ kind: "TimeoutPostRequest" }, (message2) => {
5296
5363
  return Vector(Message).enc([
5297
5364
  {
@@ -5460,33 +5527,6 @@ query StateMachineUpdatesByTimestamp($statemachineId: String!, $commitmentTimest
5460
5527
  }
5461
5528
  }
5462
5529
  `;
5463
- var ASSET_TELEPORTED_BY_PARAMS = `
5464
- query AssetTeleportedByParams($from: String!, $to: String!, $dest: String!, $blockNumber: Int!) {
5465
- assetTeleporteds(
5466
- filter: {
5467
- and: [
5468
- { from: { equalTo: $from } }
5469
- { to: { equalTo: $to } }
5470
- { dest: { includes: $dest } }
5471
- { blockNumber: { greaterThanOrEqualTo: $blockNumber } }
5472
- ]
5473
- }
5474
- orderBy: CREATED_AT_DESC
5475
- first: 1
5476
- ) {
5477
- nodes {
5478
- id
5479
- from
5480
- to
5481
- amount
5482
- dest
5483
- commitment
5484
- createdAt
5485
- blockNumber
5486
- }
5487
- }
5488
- }
5489
- `;
5490
5530
  var GET_RESPONSE_BY_REQUEST_ID = `
5491
5531
  query GetResponseByRequestId($requestId: String!) {
5492
5532
  getResponses(filter: {requestId: {equalTo: $requestId}}) {
@@ -6919,24 +6959,6 @@ var IndexerClient = class {
6919
6959
  }
6920
6960
  }
6921
6961
  }
6922
- /**
6923
- * Query for asset teleported events by sender, recipient, and destination chain
6924
- * @param from - The sender address
6925
- * @param to - The recipient address
6926
- * @param dest - The destination chain ID
6927
- * @returns The asset teleported event if found, undefined otherwise
6928
- */
6929
- async queryAssetTeleported(from, to, dest, blockNumber) {
6930
- const response = await this.withRetry(
6931
- () => this.client.request(ASSET_TELEPORTED_BY_PARAMS, {
6932
- from,
6933
- to,
6934
- dest,
6935
- blockNumber
6936
- })
6937
- );
6938
- return response.assetTeleporteds.nodes[0];
6939
- }
6940
6962
  /**
6941
6963
  * Executes an async operation with exponential backoff retry
6942
6964
  * @param operation - Async function to execute
@@ -11488,8 +11510,6 @@ var UNISWAP_V4_QUOTER_ABI = [
11488
11510
  inputs: [{ name: "revertData", type: "bytes", internalType: "bytes" }]
11489
11511
  }
11490
11512
  ];
11491
-
11492
- // src/protocols/intents.ts
11493
11513
  var IntentGateway = class {
11494
11514
  /**
11495
11515
  * Creates a new IntentGateway instance for cross-chain operations.
@@ -11575,6 +11595,7 @@ var IntentGateway = class {
11575
11595
  }))
11576
11596
  ];
11577
11597
  let destChainFillGas = 0n;
11598
+ let filledWithNativeToken = false;
11578
11599
  try {
11579
11600
  let protocolFeeInNativeToken = await this.quoteNative(postRequest, relayerFeeInDestFeeToken);
11580
11601
  protocolFeeInNativeToken = protocolFeeInNativeToken + protocolFeeInNativeToken * 50n / 10000n;
@@ -11587,6 +11608,7 @@ var IntentGateway = class {
11587
11608
  value: totalEthValue + protocolFeeInNativeToken,
11588
11609
  stateOverride: stateOverrides
11589
11610
  });
11611
+ filledWithNativeToken = true;
11590
11612
  } catch {
11591
11613
  console.warn(
11592
11614
  `Could not estimate gas for fill order with native token as fees for chain ${order.destChain}, now trying with fee token as fees`
@@ -11628,18 +11650,18 @@ var IntentGateway = class {
11628
11650
  sourceChainFeeTokenDecimals
11629
11651
  );
11630
11652
  const protocolFeeInSourceFeeToken = adjustFeeDecimals(
11631
- // Following baseIsmpModule.sol, the protocol fee is added to the relayer fee
11632
- await this.dest.quote(postRequest) + relayerFeeInDestFeeToken,
11653
+ await this.dest.quote(postRequest),
11633
11654
  destChainFeeTokenDecimals,
11634
11655
  sourceChainFeeTokenDecimals
11635
11656
  );
11636
- const totalEstimate = fillGasInSourceFeeToken + protocolFeeInSourceFeeToken + relayerFeeInSourceFeeToken;
11637
- const SWAP_OPERATIONS_BPS = 3500n;
11638
- const swapOperationsInFeeToken = totalEstimate * SWAP_OPERATIONS_BPS / 10000n;
11639
- const totalFeeTokenAmount = totalEstimate + swapOperationsInFeeToken;
11640
- const totalNativeTokenAmount = await this.convertFeeTokenToNative(totalFeeTokenAmount, "source");
11657
+ let totalEstimateInSourceFeeToken = fillGasInSourceFeeToken + protocolFeeInSourceFeeToken + relayerFeeInSourceFeeToken;
11658
+ if (!filledWithNativeToken) {
11659
+ totalEstimateInSourceFeeToken = totalEstimateInSourceFeeToken + totalEstimateInSourceFeeToken * 200n / 10000n;
11660
+ }
11661
+ let totalNativeTokenAmount = await this.convertFeeTokenToNative(totalEstimateInSourceFeeToken, "source");
11662
+ totalNativeTokenAmount = totalNativeTokenAmount + totalNativeTokenAmount * 200n / 10000n;
11641
11663
  return {
11642
- feeTokenAmount: totalFeeTokenAmount,
11664
+ feeTokenAmount: totalEstimateInSourceFeeToken,
11643
11665
  nativeTokenAmount: totalNativeTokenAmount,
11644
11666
  postRequestCalldata
11645
11667
  };
@@ -11649,8 +11671,7 @@ var IntentGateway = class {
11649
11671
  * Uses USD pricing to convert between fee token amounts and native token costs.
11650
11672
  *
11651
11673
  * @param feeTokenAmount - The amount in fee token (DAI)
11652
- * @param publicClient - The client for the chain to get native token info
11653
- * @param feeTokenDecimals - The decimal places of the fee token
11674
+ * @param getQuoteIn - Whether to use "source" or "dest" chain for the conversion
11654
11675
  * @returns The fee token amount converted to native token amount
11655
11676
  * @private
11656
11677
  */
@@ -11659,22 +11680,33 @@ var IntentGateway = class {
11659
11680
  const evmChainID = `EVM-${client.chain?.id}`;
11660
11681
  const wethAsset = this[getQuoteIn].config.getWrappedNativeAssetWithDecimals(evmChainID).asset;
11661
11682
  const feeToken = await this[getQuoteIn].getFeeTokenWithDecimals();
11662
- const { amountOut } = await this.findBestProtocolWithAmountIn(
11663
- getQuoteIn,
11664
- feeToken.address,
11665
- wethAsset,
11666
- feeTokenAmount,
11667
- "v2"
11668
- );
11669
- return amountOut;
11683
+ try {
11684
+ const { amountOut } = await this.findBestProtocolWithAmountIn(
11685
+ getQuoteIn,
11686
+ feeToken.address,
11687
+ wethAsset,
11688
+ feeTokenAmount,
11689
+ "v2"
11690
+ );
11691
+ if (amountOut === 0n) {
11692
+ throw new Error();
11693
+ }
11694
+ return amountOut;
11695
+ } catch {
11696
+ const nativeCurrency = client.chain?.nativeCurrency;
11697
+ const chainId = client.chain?.id;
11698
+ const feeTokenAmountDecimal = new Decimal(formatUnits(feeTokenAmount, feeToken.decimals));
11699
+ const nativeTokenPriceUsd = new Decimal(await fetchPrice(nativeCurrency?.symbol, chainId));
11700
+ const totalCostInNativeToken = feeTokenAmountDecimal.dividedBy(nativeTokenPriceUsd);
11701
+ return parseUnits(totalCostInNativeToken.toFixed(nativeCurrency?.decimals), nativeCurrency?.decimals);
11702
+ }
11670
11703
  }
11671
11704
  /**
11672
11705
  * Converts gas costs to the equivalent amount in the fee token (DAI).
11673
11706
  * Uses USD pricing to convert between native token gas costs and fee token amounts.
11674
11707
  *
11675
11708
  * @param gasEstimate - The estimated gas units
11676
- * @param publicClient - The client for the chain to get gas prices
11677
- * @param targetDecimals - The decimal places of the target fee token
11709
+ * @param gasEstimateIn - Whether to use "source" or "dest" chain for the conversion
11678
11710
  * @returns The gas cost converted to fee token amount
11679
11711
  * @private
11680
11712
  */
@@ -11685,15 +11717,36 @@ var IntentGateway = class {
11685
11717
  const evmChainID = `EVM-${client.chain?.id}`;
11686
11718
  const wethAddr = this[gasEstimateIn].config.getWrappedNativeAssetWithDecimals(evmChainID).asset;
11687
11719
  const feeToken = await this[gasEstimateIn].getFeeTokenWithDecimals();
11688
- const { amountOut } = await this.findBestProtocolWithAmountIn(
11689
- gasEstimateIn,
11690
- wethAddr,
11691
- feeToken.address,
11692
- gasCostInWei,
11693
- "v2"
11694
- );
11695
- return amountOut;
11720
+ try {
11721
+ const { amountOut } = await this.findBestProtocolWithAmountIn(
11722
+ gasEstimateIn,
11723
+ wethAddr,
11724
+ feeToken.address,
11725
+ gasCostInWei,
11726
+ "v2"
11727
+ );
11728
+ if (amountOut === 0n) {
11729
+ throw new Error();
11730
+ }
11731
+ return amountOut;
11732
+ } catch {
11733
+ const nativeCurrency = client.chain?.nativeCurrency;
11734
+ const chainId = client.chain?.id;
11735
+ const gasCostInToken = new Decimal(formatUnits(gasCostInWei, nativeCurrency?.decimals));
11736
+ const tokenPriceUsd = await fetchPrice(nativeCurrency?.symbol, chainId);
11737
+ const gasCostUsd = gasCostInToken.times(tokenPriceUsd);
11738
+ const feeTokenPriceUsd = new Decimal(1);
11739
+ const gasCostInFeeToken = gasCostUsd.dividedBy(feeTokenPriceUsd);
11740
+ return parseUnits(gasCostInFeeToken.toFixed(feeToken.decimals), feeToken.decimals);
11741
+ }
11696
11742
  }
11743
+ /**
11744
+ * Gets a quote for the native token cost of dispatching a post request.
11745
+ *
11746
+ * @param postRequest - The post request to quote
11747
+ * @param fee - The fee amount in fee token
11748
+ * @returns The native token amount required
11749
+ */
11697
11750
  async quoteNative(postRequest, fee) {
11698
11751
  const dispatchPost = {
11699
11752
  dest: toHex(postRequest.dest),
@@ -11715,7 +11768,7 @@ var IntentGateway = class {
11715
11768
  * Finds the best Uniswap protocol (V2, V3, or V4) for swapping tokens given a desired output amount.
11716
11769
  * Compares liquidity and pricing across different protocols and fee tiers.
11717
11770
  *
11718
- * @param chain - The chain identifier where the swap will occur
11771
+ * @param getQuoteIn - Whether to use "source" or "dest" chain for the swap
11719
11772
  * @param tokenIn - The address of the input token
11720
11773
  * @param tokenOut - The address of the output token
11721
11774
  * @param amountOut - The desired output amount
@@ -11880,10 +11933,11 @@ var IntentGateway = class {
11880
11933
  * Finds the best Uniswap protocol (V2, V3, or V4) for swapping tokens given an input amount.
11881
11934
  * Compares liquidity and pricing across different protocols and fee tiers.
11882
11935
  *
11883
- * @param chain - The chain identifier where the swap will occur
11936
+ * @param getQuoteIn - Whether to use "source" or "dest" chain for the swap
11884
11937
  * @param tokenIn - The address of the input token
11885
11938
  * @param tokenOut - The address of the output token
11886
11939
  * @param amountIn - The input amount to swap
11940
+ * @param selectedProtocol - Optional specific protocol to use ("v2", "v3", or "v4")
11887
11941
  * @returns Object containing the best protocol, expected output amount, and fee tier (for V3/V4)
11888
11942
  */
11889
11943
  async findBestProtocolWithAmountIn(getQuoteIn, tokenIn, tokenOut, amountIn, selectedProtocol) {
@@ -12259,24 +12313,30 @@ function readIsmpCommitmentHash(events) {
12259
12313
  }
12260
12314
  }
12261
12315
  }
12316
+ var MultiAccount = Struct({
12317
+ substrate_account: Bytes(32),
12318
+ evm_account: Bytes(20),
12319
+ dest_state_machine: StateMachine,
12320
+ timeout: u64,
12321
+ account_nonce: u64
12322
+ });
12262
12323
  var DECIMALS = 10;
12263
12324
  async function teleportDot(param_) {
12264
- const { relayApi, hyperbridge, who, options, xcmGatewayParams: params, indexerClient, pollInterval = 2e3 } = param_;
12265
- const destination = {
12266
- V3: {
12267
- parents: 0,
12268
- interior: {
12269
- X1: {
12270
- Parachain: params.paraId
12271
- }
12272
- }
12273
- }
12274
- };
12325
+ const { sourceApi, sourceIsAssetHub, who, options, xcmGatewayParams: params } = param_;
12326
+ let { nonce: accountNonce } = await sourceApi.query.system.account(who);
12327
+ let encoded_message = MultiAccount.enc({
12328
+ substrate_account: decodeAddress(who),
12329
+ evm_account: hexToU8a(params.recipient),
12330
+ dest_state_machine: { tag: "Evm", value: params.destination },
12331
+ timeout: params.timeout,
12332
+ account_nonce: accountNonce
12333
+ });
12334
+ let message_id = keccakAsHex(encoded_message);
12275
12335
  const beneficiary = {
12276
12336
  V3: {
12277
12337
  parents: 0,
12278
12338
  interior: {
12279
- X3: [
12339
+ X4: [
12280
12340
  {
12281
12341
  AccountId32: {
12282
12342
  id: u8aToHex(decodeAddress(who)),
@@ -12295,37 +12355,89 @@ async function teleportDot(param_) {
12295
12355
  },
12296
12356
  {
12297
12357
  GeneralIndex: params.timeout
12358
+ },
12359
+ {
12360
+ GeneralIndex: accountNonce
12298
12361
  }
12299
12362
  ]
12300
12363
  }
12301
12364
  }
12302
12365
  };
12303
- const assets2 = {
12304
- V3: [
12305
- {
12306
- id: {
12307
- Concrete: {
12308
- parents: 0,
12309
- interior: "Here"
12366
+ let assets2;
12367
+ let destination;
12368
+ if (sourceIsAssetHub) {
12369
+ destination = {
12370
+ V3: {
12371
+ parents: 1,
12372
+ interior: {
12373
+ X1: {
12374
+ Parachain: params.paraId
12310
12375
  }
12311
- },
12312
- fun: {
12313
- Fungible: parseUnits(params.amount.toString(), DECIMALS)
12314
12376
  }
12315
12377
  }
12316
- ]
12317
- };
12378
+ };
12379
+ assets2 = {
12380
+ V3: [
12381
+ {
12382
+ id: {
12383
+ Concrete: {
12384
+ parents: 1,
12385
+ interior: "Here"
12386
+ }
12387
+ },
12388
+ fun: {
12389
+ Fungible: parseUnits(params.amount.toString(), DECIMALS)
12390
+ }
12391
+ }
12392
+ ]
12393
+ };
12394
+ } else {
12395
+ destination = {
12396
+ V3: {
12397
+ parents: 0,
12398
+ interior: {
12399
+ X1: {
12400
+ Parachain: params.paraId
12401
+ }
12402
+ }
12403
+ }
12404
+ };
12405
+ assets2 = {
12406
+ V3: [
12407
+ {
12408
+ id: {
12409
+ Concrete: {
12410
+ parents: 0,
12411
+ interior: "Here"
12412
+ }
12413
+ },
12414
+ fun: {
12415
+ Fungible: parseUnits(params.amount.toString(), DECIMALS)
12416
+ }
12417
+ }
12418
+ ]
12419
+ };
12420
+ }
12318
12421
  const feeAssetItem = 0;
12319
12422
  const weightLimit = "Unlimited";
12320
- const tx = relayApi.tx.xcmPallet.limitedReserveTransferAssets(
12321
- destination,
12322
- beneficiary,
12323
- assets2,
12324
- feeAssetItem,
12325
- weightLimit
12326
- );
12327
- const finalized_hash = await hyperbridge.rpc.chain.getFinalizedHead();
12328
- const hyperbridgeBlock = (await hyperbridge.rpc.chain.getHeader(finalized_hash)).number.toNumber();
12423
+ let tx;
12424
+ if (sourceIsAssetHub) {
12425
+ tx = sourceApi.tx.polkadotXcm.limitedReserveTransferAssets(
12426
+ destination,
12427
+ beneficiary,
12428
+ assets2,
12429
+ feeAssetItem,
12430
+ weightLimit
12431
+ );
12432
+ } else {
12433
+ tx = sourceApi.tx.xcmPallet.limitedReserveTransferAssets(
12434
+ destination,
12435
+ beneficiary,
12436
+ assets2,
12437
+ feeAssetItem,
12438
+ weightLimit
12439
+ );
12440
+ }
12329
12441
  let closed = false;
12330
12442
  let unsubscribe;
12331
12443
  const stream = new ReadableStream(
@@ -12347,44 +12459,14 @@ async function teleportDot(param_) {
12347
12459
  if (status.isReady) {
12348
12460
  controller.enqueue({
12349
12461
  kind: "Ready",
12350
- transaction_hash: txHash.toHex()
12462
+ transaction_hash: txHash.toHex(),
12463
+ message_id
12351
12464
  });
12352
12465
  } else if (status.isInBlock || status.isFinalized) {
12353
- const decodedWho = u8aToHex(decodeAddress(who, false));
12354
- let assetTeleported = void 0;
12355
- let attempts = 0;
12356
- const maxAttempts = Math.ceil(3e5 / pollInterval);
12357
- if (!indexerClient) {
12358
- controller.enqueue({
12359
- kind: "Error",
12360
- error: "IndexerClient is required but not provided"
12361
- });
12362
- return;
12363
- }
12364
- while (!assetTeleported && attempts < maxAttempts) {
12365
- await sleep(pollInterval);
12366
- assetTeleported = await indexerClient.queryAssetTeleported(
12367
- decodedWho,
12368
- params.recipient.toLowerCase(),
12369
- params.destination.toString(),
12370
- hyperbridgeBlock
12371
- );
12372
- attempts++;
12373
- }
12374
- if (!assetTeleported) {
12375
- controller.enqueue({
12376
- kind: "Error",
12377
- error: "Failed to locate AssetTeleported event in the indexer after maximum attempts"
12378
- });
12379
- return;
12380
- }
12381
- const commitment = assetTeleported.commitment;
12382
- const blockNumber = BigInt(assetTeleported.blockNumber);
12383
12466
  controller.enqueue({
12384
12467
  kind: "Finalized",
12385
12468
  transaction_hash: txHash.toHex(),
12386
- block_number: blockNumber,
12387
- commitment
12469
+ message_id
12388
12470
  });
12389
12471
  closed = true;
12390
12472
  unsubscribe?.();