@hyperbridge/sdk 1.6.4 → 1.6.6

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.
@@ -3948,6 +3948,7 @@ declare class IntentsV2 {
3948
3948
  private readonly orderPlacer;
3949
3949
  private readonly orderExecutor;
3950
3950
  private readonly orderCanceller;
3951
+ private readonly orderStatusChecker;
3951
3952
  private readonly bidManager;
3952
3953
  private readonly gasEstimator;
3953
3954
  private constructor();
@@ -3985,6 +3986,35 @@ declare class IntentsV2 {
3985
3986
  estimateFillOrderV2(params: EstimateFillOrderV2Params): Promise<FillOrderEstimateV2>;
3986
3987
  encodeERC7821Execute(calls: ERC7821Call[]): HexString;
3987
3988
  decodeERC7821Execute(callData: HexString): ERC7821Call[] | null;
3989
+ isOrderFilled(order: OrderV2): Promise<boolean>;
3990
+ isOrderRefunded(order: OrderV2): Promise<boolean>;
3991
+ }
3992
+
3993
+ declare class OrderStatusChecker {
3994
+ private readonly ctx;
3995
+ constructor(ctx: IntentsV2Context);
3996
+ /**
3997
+ * Checks if a V2 order has been filled by reading the commitment storage slot on the destination chain.
3998
+ *
3999
+ * Reads the storage slot returned by `calculateCommitmentSlotHash` on the IntentGatewayV2 contract.
4000
+ * A non-zero value at that slot means the solver has called `fillOrder` and the order is complete
4001
+ * from the user's perspective (the beneficiary has received their tokens).
4002
+ *
4003
+ * @param order - The V2 order to check. `order.id` is used as the commitment; if not set it is computed.
4004
+ * @returns True if the order has been filled on the destination chain, false otherwise.
4005
+ */
4006
+ isOrderFilled(order: OrderV2): Promise<boolean>;
4007
+ /**
4008
+ * Checks if a V2 order has been refunded by reading the `_orders` mapping on the source chain.
4009
+ *
4010
+ * Calls `_orders(commitment, tokenAddress)` for each input token. When the order is placed the
4011
+ * escrowed amounts are stored there. After a successful refund the contract zeroes them out.
4012
+ * An order is considered refunded when all escrowed input amounts have been returned (i.e. are 0).
4013
+ *
4014
+ * @param order - The V2 order to check. `order.id` is used as the commitment; if not set it is computed.
4015
+ * @returns True if all escrowed inputs have been returned to the user on the source chain, false otherwise.
4016
+ */
4017
+ isOrderRefunded(order: OrderV2): Promise<boolean>;
3988
4018
  }
3989
4019
 
3990
4020
  /**
@@ -4461,4 +4491,4 @@ declare const getChainId: (stateMachineId: string) => number | undefined;
4461
4491
  declare const getViemChain: (chainId: number) => Chain | undefined;
4462
4492
  declare const hyperbridgeAddress = "";
4463
4493
 
4464
- export { ADDRESS_ZERO, type AllStatusKey, type AssetTeleported, type AssetTeleportedResponse, type BidStorageEntry, type BidSubmissionResult, type BlockMetadata, type BundlerGasEstimate, BundlerMethod, type CancelEvent, type CancelEventMap, type CancelOptions, type ChainConfig, type ChainConfigData, ChainConfigService, Chains, type ClientConfig, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DOMAIN_TYPEHASH, DUMMY_PRIVATE_KEY, type DecodedOrderPlacedLog, type DecodedOrderV2PlacedLog, type DecodedPostRequestEvent, type DecodedPostResponseEvent, type DispatchGet, type DispatchInfoV2, type DispatchPost, ERC20Method, type ERC7821Call, ERC7821_BATCH_MODE, type EstimateFillOrderV2Params, type EstimateGasCallData, EvmChain, type EvmChainParams, EvmLanguage, type ExecuteIntentOrderOptions, type ExecutionResult, type FillOptions, type FillOptionsV2, type FillOrderEstimateV2, type FillerBid, type FillerConfig, type GetRequestResponse, type GetRequestWithStatus, type GetResponseByRequestIdResponse, type GetResponseStorageValues, type HexString, type HostParams, HyperClientStatus, type HyperbridgeTxEvents, type IChain, type IConfig, type IEvmChain, 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, IntentOrderStatus, type IntentOrderStatusKey, type IntentOrderStatusMetadata, type IntentOrderStatusUpdate, IntentsCoprocessor, IntentsV2, type IntentsV2Context, type IsmpRequest, MOCK_ADDRESS, type NewDeployment, ORDER_V2_PARAM_TYPE, type Order, type OrderResponse, OrderStatus, type OrderStatusMetadata, type OrderV2, type OrderWithStatus, PACKED_USEROP_TYPEHASH, PLACE_ORDER_SELECTOR, type PackedUserOperation, type Params, type PaymentInfo, type PaymentInfoV2, type PostRequestStatus, type PostRequestTimeoutStatus, type PostRequestWithStatus, type QuoteNativeResult, 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, SELECT_SOLVER_TYPEHASH, STATE_COMMITMENTS_SLOT, type SelectBidResult, type SelectOptions, type StateMachineHeight, type StateMachineIdParams, type StateMachineResponse, type StateMachineUpdate, type StorageFacade, type SubmitBidOptions, SubstrateChain, Swap, TESTNET_CHAINS, type TeleportParams, TeleportStatus, TimeoutStatus, type TimeoutStatusKey, TokenGateway, type TokenGatewayAssetTeleportedResponse, type TokenGatewayAssetTeleportedWithStatus, type TokenInfo, type TokenInfoV2, type TokenPrice, type TokenPricesResponse, type TokenRegistry, type TokenRegistryResponse, type Transaction, TronChain, type TronChainParams, USE_ETHERSCAN_CHAINS, type XcmGatewayParams, __test, adjustDecimals, bytes20ToBytes32, bytes32ToBytes20, calculateAllowanceMappingLocation, calculateBalanceMappingLocation, chainConfigs, constructRedeemEscrowRequestBody, constructRefundEscrowRequestBody, convertCodecToIGetRequest, convertCodecToIProof, convertIGetRequestToCodec, convertIProofToCodec, convertStateIdToStateMachineId, convertStateMachineEnumToString, convertStateMachineIdToEnum, createChain, createEvmChain, createIndexerClient, createQueryClient, decodeUserOpScale, encodeERC7821ExecuteBatch, encodeISMPMessage, encodeUserOpScale, encodeWithdrawalRequest, estimateGasForPost, fetchPrice, fetchSourceProof, generateRootWithProof, getChain, getChainId, getConfigByStateMachineId, getContractCallInput, getEvmChain, getGasPriceFromEtherscan, getOrFetchStorageSlot, getOrderPlacedFromTx, getPostRequestEventFromTx, getPostResponseEventFromTx, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, getSubstrateChain, getViemChain, hexToString, hyperbridgeAddress, maxBigInt, orderCommitment, orderV2Commitment, parseStateMachineId, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, requestCommitmentKey, retryPromise, teleport, teleportDot, transformOrderForContract, tronChainIds, tronNile };
4494
+ export { ADDRESS_ZERO, type AllStatusKey, type AssetTeleported, type AssetTeleportedResponse, type BidStorageEntry, type BidSubmissionResult, type BlockMetadata, type BundlerGasEstimate, BundlerMethod, type CancelEvent, type CancelEventMap, type CancelOptions, type ChainConfig, type ChainConfigData, ChainConfigService, Chains, type ClientConfig, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DOMAIN_TYPEHASH, DUMMY_PRIVATE_KEY, type DecodedOrderPlacedLog, type DecodedOrderV2PlacedLog, type DecodedPostRequestEvent, type DecodedPostResponseEvent, type DispatchGet, type DispatchInfoV2, type DispatchPost, ERC20Method, type ERC7821Call, ERC7821_BATCH_MODE, type EstimateFillOrderV2Params, type EstimateGasCallData, EvmChain, type EvmChainParams, EvmLanguage, type ExecuteIntentOrderOptions, type ExecutionResult, type FillOptions, type FillOptionsV2, type FillOrderEstimateV2, type FillerBid, type FillerConfig, type GetRequestResponse, type GetRequestWithStatus, type GetResponseByRequestIdResponse, type GetResponseStorageValues, type HexString, type HostParams, HyperClientStatus, type HyperbridgeTxEvents, type IChain, type IConfig, type IEvmChain, 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, IntentOrderStatus, type IntentOrderStatusKey, type IntentOrderStatusMetadata, type IntentOrderStatusUpdate, IntentsCoprocessor, IntentsV2, type IntentsV2Context, type IsmpRequest, MOCK_ADDRESS, type NewDeployment, ORDER_V2_PARAM_TYPE, type Order, type OrderResponse, OrderStatus, OrderStatusChecker, type OrderStatusMetadata, type OrderV2, type OrderWithStatus, PACKED_USEROP_TYPEHASH, PLACE_ORDER_SELECTOR, type PackedUserOperation, type Params, type PaymentInfo, type PaymentInfoV2, type PostRequestStatus, type PostRequestTimeoutStatus, type PostRequestWithStatus, type QuoteNativeResult, 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, SELECT_SOLVER_TYPEHASH, STATE_COMMITMENTS_SLOT, type SelectBidResult, type SelectOptions, type StateMachineHeight, type StateMachineIdParams, type StateMachineResponse, type StateMachineUpdate, type StorageFacade, type SubmitBidOptions, SubstrateChain, Swap, TESTNET_CHAINS, type TeleportParams, TeleportStatus, TimeoutStatus, type TimeoutStatusKey, TokenGateway, type TokenGatewayAssetTeleportedResponse, type TokenGatewayAssetTeleportedWithStatus, type TokenInfo, type TokenInfoV2, type TokenPrice, type TokenPricesResponse, type TokenRegistry, type TokenRegistryResponse, type Transaction, TronChain, type TronChainParams, USE_ETHERSCAN_CHAINS, type XcmGatewayParams, __test, adjustDecimals, bytes20ToBytes32, bytes32ToBytes20, calculateAllowanceMappingLocation, calculateBalanceMappingLocation, chainConfigs, constructRedeemEscrowRequestBody, constructRefundEscrowRequestBody, convertCodecToIGetRequest, convertCodecToIProof, convertIGetRequestToCodec, convertIProofToCodec, convertStateIdToStateMachineId, convertStateMachineEnumToString, convertStateMachineIdToEnum, createChain, createEvmChain, createIndexerClient, createQueryClient, decodeUserOpScale, encodeERC7821ExecuteBatch, encodeISMPMessage, encodeUserOpScale, encodeWithdrawalRequest, estimateGasForPost, fetchPrice, fetchSourceProof, generateRootWithProof, getChain, getChainId, getConfigByStateMachineId, getContractCallInput, getEvmChain, getGasPriceFromEtherscan, getOrFetchStorageSlot, getOrderPlacedFromTx, getPostRequestEventFromTx, getPostResponseEventFromTx, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, getSubstrateChain, getViemChain, hexToString, hyperbridgeAddress, maxBigInt, orderCommitment, orderV2Commitment, parseStateMachineId, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, requestCommitmentKey, retryPromise, teleport, teleportDot, transformOrderForContract, tronChainIds, tronNile };
@@ -3,7 +3,7 @@ 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 { defineChain, keccak256, toHex, hexToBytes, encodePacked, encodeAbiParameters, bytesToHex, createPublicClient, http, encodeFunctionData, erc20Abi, bytesToBigInt, pad, toBytes, numberToBytes, maxUint256, parseAbiParameters, parseAbiItem, formatUnits, parseUnits, concatHex, hexToString as hexToString$1, parseEventLogs, concat, decodeFunctionData, decodeAbiParameters, isHex } from 'viem';
6
+ import { defineChain, keccak256, toHex, hexToBytes, encodePacked, encodeAbiParameters, bytesToHex, createPublicClient, http, encodeFunctionData, erc20Abi, bytesToBigInt, pad, toBytes, numberToBytes, maxUint256, parseAbiParameters, parseAbiItem, formatUnits, parseUnits, concatHex, hexToString as hexToString$1, parseEventLogs, isHex, concat, decodeFunctionData, decodeAbiParameters } from 'viem';
7
7
  import mergeRace from '@async-generator/merge-race';
8
8
  import { polygonAmoy, unichain, polygon, base, arbitrum, bsc, mainnet, sepolia, gnosisChiado, bscTestnet, tron, gnosis, soneium, baseSepolia, optimismSepolia, optimism, arbitrumSepolia } from 'viem/chains';
9
9
  import { TronWeb } from 'tronweb';
@@ -389,11 +389,13 @@ var chainConfigs = {
389
389
  WETH: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
390
390
  DAI: "0x6b175474e89094c44da98b954eedeac495271d0f",
391
391
  USDC: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
392
- USDT: "0xdac17f958d2ee523a2206206994597c13d831ec7"
392
+ USDT: "0xdac17f958d2ee523a2206206994597c13d831ec7",
393
+ cNGN: "0x17CDB2a01e7a34CbB3DD4b83260B05d0274C8dab"
393
394
  },
394
395
  tokenDecimals: {
395
396
  USDC: 6,
396
- USDT: 6
397
+ USDT: 6,
398
+ cNGN: 6
397
399
  },
398
400
  tokenStorageSlots: {
399
401
  USDT: { balanceSlot: 2, allowanceSlot: 5 },
@@ -546,11 +548,13 @@ var chainConfigs = {
546
548
  DAI: "0x50c5725949a6f0c72e6c4a641f24049a917db0cb",
547
549
  USDC: "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
548
550
  USDT: "0xfde4c96c8593536e31f229ea8f37b2ada2699bb2",
549
- EXT: "0x0e668E5127087e236578893a0e01E41837A28469"
551
+ EXT: "0x0e668E5127087e236578893a0e01E41837A28469",
552
+ cNGN: "0x46C85152bFe9f96829aA94755D9f915F9B10EF5F"
550
553
  },
551
554
  tokenDecimals: {
552
555
  USDC: 6,
553
556
  USDT: 6,
557
+ cNGN: 6,
554
558
  EXT: 18
555
559
  },
556
560
  tokenStorageSlots: {
@@ -598,12 +602,14 @@ var chainConfigs = {
598
602
  DAI: "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063",
599
603
  USDC: "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",
600
604
  USDT: "0xc2132d05d31c914a87c6611c10748aeb04b58e8f",
601
- EXT: "0x7C8c11ADb8EF7cd3CFa718008Ea048445C6E7209"
605
+ EXT: "0x7C8c11ADb8EF7cd3CFa718008Ea048445C6E7209",
606
+ cNGN: "0x52828daa48C1a9A06F37500882b42daf0bE04C3B"
602
607
  },
603
608
  tokenDecimals: {
604
609
  USDC: 6,
605
610
  USDT: 6,
606
- EXT: 18
611
+ EXT: 18,
612
+ cNGN: 6
607
613
  },
608
614
  tokenStorageSlots: {
609
615
  USDT: { balanceSlot: 0, allowanceSlot: 1 },
@@ -16299,13 +16305,11 @@ var GasEstimator = class {
16299
16305
  const { order } = params;
16300
16306
  const solverPrivateKey = generatePrivateKey();
16301
16307
  const solverAccountAddress = privateKeyToAddress(solverPrivateKey);
16302
- const sourceStateMachineId = isHex(order.source) ? hexToString$1(order.source) : order.source;
16308
+ const souceStateMachineId = isHex(order.source) ? hexToString$1(order.source) : order.source;
16303
16309
  const destStateMachineId = isHex(order.destination) ? hexToString$1(order.destination) : order.destination;
16304
16310
  const intentGatewayV2Address = this.ctx.dest.configService.getIntentGatewayV2Address(destStateMachineId);
16305
16311
  const entryPointAddress = this.ctx.dest.configService.getEntryPointV08Address(destStateMachineId);
16306
- const chainId = BigInt(
16307
- this.ctx.dest.client.chain?.id ?? Number.parseInt(this.ctx.dest.config.stateMachineId.split("-")[1])
16308
- );
16312
+ const chainId = BigInt(Number.parseInt(destStateMachineId.split("-")[1]));
16309
16313
  const totalEthValue = order.output.assets.filter((output) => bytes32ToBytes20(output.token) === ADDRESS_ZERO).reduce((sum, output) => sum + output.amount, 0n);
16310
16314
  const sourceFeeToken = await getFeeToken(this.ctx, this.ctx.source.config.stateMachineId, this.ctx.source);
16311
16315
  const destFeeToken = await getFeeToken(this.ctx, this.ctx.dest.config.stateMachineId, this.ctx.dest);
@@ -16322,7 +16326,7 @@ var GasEstimator = class {
16322
16326
  intentGatewayV2Address,
16323
16327
  entryPointAddress
16324
16328
  });
16325
- const isSameChain = order.source === destStateMachineId;
16329
+ const isSameChain = souceStateMachineId === destStateMachineId;
16326
16330
  let postRequestFeeInDestFeeToken = 0n;
16327
16331
  let protocolFeeInNativeToken = 0n;
16328
16332
  if (!isSameChain) {
@@ -16331,7 +16335,7 @@ var GasEstimator = class {
16331
16335
  this.ctx,
16332
16336
  postRequestGas,
16333
16337
  "source",
16334
- sourceStateMachineId
16338
+ souceStateMachineId
16335
16339
  );
16336
16340
  postRequestFeeInDestFeeToken = adjustDecimals(
16337
16341
  postRequestFeeInSourceFeeToken,
@@ -16340,12 +16344,12 @@ var GasEstimator = class {
16340
16344
  );
16341
16345
  const postRequest = {
16342
16346
  source: destStateMachineId,
16343
- dest: order.source,
16347
+ dest: souceStateMachineId,
16344
16348
  body: constructRedeemEscrowRequestBody({ ...order, id: orderV2Commitment(order) }, MOCK_ADDRESS),
16345
16349
  timeoutTimestamp: 0n,
16346
16350
  nonce: await this.ctx.source.getHostNonce(),
16347
16351
  from: this.ctx.source.configService.getIntentGatewayV2Address(destStateMachineId),
16348
- to: this.ctx.source.configService.getIntentGatewayV2Address(sourceStateMachineId)
16352
+ to: this.ctx.source.configService.getIntentGatewayV2Address(souceStateMachineId)
16349
16353
  };
16350
16354
  protocolFeeInNativeToken = await this.quoteNative(postRequest, postRequestFeeInDestFeeToken).catch(
16351
16355
  () => this.ctx.dest.quoteNative(postRequest, postRequestFeeInDestFeeToken).catch(() => 0n)
@@ -16422,7 +16426,7 @@ var GasEstimator = class {
16422
16426
  BundlerMethod.ETH_ESTIMATE_USER_OPERATION_GAS,
16423
16427
  [bundlerUserOp, entryPointAddress, bundlerStateOverrides]
16424
16428
  );
16425
- callGasLimit = BigInt(gasEstimate.callGasLimit) * 105n / 100n;
16429
+ callGasLimit = BigInt(gasEstimate.callGasLimit) * 130n / 100n;
16426
16430
  verificationGasLimit = BigInt(gasEstimate.verificationGasLimit) * 105n / 100n;
16427
16431
  preVerificationGas = BigInt(gasEstimate.preVerificationGas) * 105n / 100n;
16428
16432
  if (this.ctx.bundlerUrl?.toLowerCase().includes("pimlico.io")) {
@@ -16435,8 +16439,8 @@ var GasEstimator = class {
16435
16439
  if (level) {
16436
16440
  const pimMaxFeePerGas = BigInt(level.maxFeePerGas);
16437
16441
  const pimMaxPriorityFeePerGas = BigInt(level.maxPriorityFeePerGas);
16438
- maxFeePerGas = pimMaxFeePerGas;
16439
- maxPriorityFeePerGas = pimMaxPriorityFeePerGas;
16442
+ maxFeePerGas = pimMaxFeePerGas + pimMaxFeePerGas * BigInt(maxFeeBumpPercent) / 100n;
16443
+ maxPriorityFeePerGas = pimMaxPriorityFeePerGas + pimMaxPriorityFeePerGas * BigInt(priorityFeeBumpPercent) / 100n;
16440
16444
  }
16441
16445
  } catch (e) {
16442
16446
  console.warn("Pimlico gas price fetch failed, using default gas price:", e);
@@ -16596,6 +16600,66 @@ var GasEstimator = class {
16596
16600
  });
16597
16601
  }
16598
16602
  };
16603
+ var OrderStatusChecker = class {
16604
+ constructor(ctx) {
16605
+ this.ctx = ctx;
16606
+ }
16607
+ /**
16608
+ * Checks if a V2 order has been filled by reading the commitment storage slot on the destination chain.
16609
+ *
16610
+ * Reads the storage slot returned by `calculateCommitmentSlotHash` on the IntentGatewayV2 contract.
16611
+ * A non-zero value at that slot means the solver has called `fillOrder` and the order is complete
16612
+ * from the user's perspective (the beneficiary has received their tokens).
16613
+ *
16614
+ * @param order - The V2 order to check. `order.id` is used as the commitment; if not set it is computed.
16615
+ * @returns True if the order has been filled on the destination chain, false otherwise.
16616
+ */
16617
+ async isOrderFilled(order) {
16618
+ const commitment = order.id ?? orderV2Commitment(order);
16619
+ const destStateMachineId = isHex(order.destination) ? hexToString$1(order.destination) : order.destination;
16620
+ const intentGatewayV2Address = this.ctx.dest.configService.getIntentGatewayV2Address(destStateMachineId);
16621
+ const filledSlot = await this.ctx.dest.client.readContract({
16622
+ abi: ABI3,
16623
+ address: intentGatewayV2Address,
16624
+ functionName: "calculateCommitmentSlotHash",
16625
+ args: [commitment]
16626
+ });
16627
+ const filledStatus = await this.ctx.dest.client.getStorageAt({
16628
+ address: intentGatewayV2Address,
16629
+ slot: filledSlot
16630
+ });
16631
+ return filledStatus !== "0x0000000000000000000000000000000000000000000000000000000000000000";
16632
+ }
16633
+ /**
16634
+ * Checks if a V2 order has been refunded by reading the `_orders` mapping on the source chain.
16635
+ *
16636
+ * Calls `_orders(commitment, tokenAddress)` for each input token. When the order is placed the
16637
+ * escrowed amounts are stored there. After a successful refund the contract zeroes them out.
16638
+ * An order is considered refunded when all escrowed input amounts have been returned (i.e. are 0).
16639
+ *
16640
+ * @param order - The V2 order to check. `order.id` is used as the commitment; if not set it is computed.
16641
+ * @returns True if all escrowed inputs have been returned to the user on the source chain, false otherwise.
16642
+ */
16643
+ async isOrderRefunded(order) {
16644
+ if (!order.inputs || order.inputs.length === 0) return false;
16645
+ const commitment = order.id ?? orderV2Commitment(order);
16646
+ const sourceStateMachineId = isHex(order.source) ? hexToString$1(order.source) : order.source;
16647
+ const intentGatewayV2Address = this.ctx.source.configService.getIntentGatewayV2Address(sourceStateMachineId);
16648
+ for (const input of order.inputs) {
16649
+ const tokenAddress = bytes32ToBytes20(input.token);
16650
+ const escrowedAmount = await this.ctx.source.client.readContract({
16651
+ abi: ABI3,
16652
+ address: intentGatewayV2Address,
16653
+ functionName: "_orders",
16654
+ args: [commitment, tokenAddress]
16655
+ });
16656
+ if (escrowedAmount !== 0n) {
16657
+ return false;
16658
+ }
16659
+ }
16660
+ return true;
16661
+ }
16662
+ };
16599
16663
 
16600
16664
  // src/protocols/intentsV2/IntentsV2.ts
16601
16665
  var IntentsV2 = class _IntentsV2 {
@@ -16608,6 +16672,7 @@ var IntentsV2 = class _IntentsV2 {
16608
16672
  orderPlacer;
16609
16673
  orderExecutor;
16610
16674
  orderCanceller;
16675
+ orderStatusChecker;
16611
16676
  bidManager;
16612
16677
  gasEstimator;
16613
16678
  constructor(source, dest, intentsCoprocessor, bundlerUrl) {
@@ -16637,6 +16702,7 @@ var IntentsV2 = class _IntentsV2 {
16637
16702
  this.orderPlacer = new OrderPlacer(this.ctx);
16638
16703
  this.orderExecutor = new OrderExecutor(this.ctx, bidManager);
16639
16704
  this.orderCanceller = new OrderCanceller(this.ctx);
16705
+ this.orderStatusChecker = new OrderStatusChecker(this.ctx);
16640
16706
  this.bidManager = bidManager;
16641
16707
  this.gasEstimator = gasEstimator;
16642
16708
  this._crypto = crypto;
@@ -16732,6 +16798,12 @@ var IntentsV2 = class _IntentsV2 {
16732
16798
  decodeERC7821Execute(callData) {
16733
16799
  return this._crypto.decodeERC7821Execute(callData);
16734
16800
  }
16801
+ async isOrderFilled(order) {
16802
+ return this.orderStatusChecker.isOrderFilled(order);
16803
+ }
16804
+ async isOrderRefunded(order) {
16805
+ return this.orderStatusChecker.isOrderRefunded(order);
16806
+ }
16735
16807
  };
16736
16808
  var TokenGateway = class {
16737
16809
  source;
@@ -17183,6 +17255,6 @@ async function teleportDot(param_) {
17183
17255
  return stream;
17184
17256
  }
17185
17257
 
17186
- export { ADDRESS_ZERO, BundlerMethod, ChainConfigService, Chains, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DOMAIN_TYPEHASH, DUMMY_PRIVATE_KEY, ERC20Method, ERC7821_BATCH_MODE, EvmChain, EvmLanguage, HyperClientStatus, IndexerClient, IntentGateway, IntentOrderStatus, IntentsCoprocessor, IntentsV2, MOCK_ADDRESS, ORDER_V2_PARAM_TYPE, OrderStatus, PACKED_USEROP_TYPEHASH, PLACE_ORDER_SELECTOR, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, RequestKind, RequestStatus, SELECT_SOLVER_TYPEHASH, STATE_COMMITMENTS_SLOT, SubstrateChain, Swap, TESTNET_CHAINS, TeleportStatus, TimeoutStatus, TokenGateway, TronChain, USE_ETHERSCAN_CHAINS, __test, adjustDecimals, bytes20ToBytes32, bytes32ToBytes20, calculateAllowanceMappingLocation, calculateBalanceMappingLocation, chainConfigs, constructRedeemEscrowRequestBody, constructRefundEscrowRequestBody, convertCodecToIGetRequest, convertCodecToIProof, convertIGetRequestToCodec, convertIProofToCodec, convertStateIdToStateMachineId, convertStateMachineEnumToString, convertStateMachineIdToEnum, createChain, createEvmChain, createIndexerClient, createQueryClient, decodeUserOpScale, encodeERC7821ExecuteBatch, encodeISMPMessage, encodeUserOpScale, encodeWithdrawalRequest, estimateGasForPost, fetchPrice, fetchSourceProof2 as fetchSourceProof, generateRootWithProof, getChain, getChainId, getConfigByStateMachineId, getContractCallInput, getEvmChain, getGasPriceFromEtherscan, getOrFetchStorageSlot, getOrderPlacedFromTx, getPostRequestEventFromTx, getPostResponseEventFromTx, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, getSubstrateChain, getViemChain, hexToString, hyperbridgeAddress, maxBigInt, orderCommitment, orderV2Commitment, parseStateMachineId, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, requestCommitmentKey, retryPromise, teleport, teleportDot, transformOrderForContract, tronChainIds, tronNile };
17258
+ export { ADDRESS_ZERO, BundlerMethod, ChainConfigService, Chains, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DOMAIN_TYPEHASH, DUMMY_PRIVATE_KEY, ERC20Method, ERC7821_BATCH_MODE, EvmChain, EvmLanguage, HyperClientStatus, IndexerClient, IntentGateway, IntentOrderStatus, IntentsCoprocessor, IntentsV2, MOCK_ADDRESS, ORDER_V2_PARAM_TYPE, OrderStatus, OrderStatusChecker, PACKED_USEROP_TYPEHASH, PLACE_ORDER_SELECTOR, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, RequestKind, RequestStatus, SELECT_SOLVER_TYPEHASH, STATE_COMMITMENTS_SLOT, SubstrateChain, Swap, TESTNET_CHAINS, TeleportStatus, TimeoutStatus, TokenGateway, TronChain, USE_ETHERSCAN_CHAINS, __test, adjustDecimals, bytes20ToBytes32, bytes32ToBytes20, calculateAllowanceMappingLocation, calculateBalanceMappingLocation, chainConfigs, constructRedeemEscrowRequestBody, constructRefundEscrowRequestBody, convertCodecToIGetRequest, convertCodecToIProof, convertIGetRequestToCodec, convertIProofToCodec, convertStateIdToStateMachineId, convertStateMachineEnumToString, convertStateMachineIdToEnum, createChain, createEvmChain, createIndexerClient, createQueryClient, decodeUserOpScale, encodeERC7821ExecuteBatch, encodeISMPMessage, encodeUserOpScale, encodeWithdrawalRequest, estimateGasForPost, fetchPrice, fetchSourceProof2 as fetchSourceProof, generateRootWithProof, getChain, getChainId, getConfigByStateMachineId, getContractCallInput, getEvmChain, getGasPriceFromEtherscan, getOrFetchStorageSlot, getOrderPlacedFromTx, getPostRequestEventFromTx, getPostResponseEventFromTx, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, getSubstrateChain, getViemChain, hexToString, hyperbridgeAddress, maxBigInt, orderCommitment, orderV2Commitment, parseStateMachineId, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, requestCommitmentKey, retryPromise, teleport, teleportDot, transformOrderForContract, tronChainIds, tronNile };
17187
17259
  //# sourceMappingURL=index.js.map
17188
17260
  //# sourceMappingURL=index.js.map