@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 };
@@ -1,6 +1,6 @@
1
1
  import { createConsola, LogLevels } from 'consola';
2
2
  import { flatten, zip, capitalize, maxBy, isNil } from 'lodash-es';
3
- 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';
3
+ 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';
4
4
  import mergeRace from '@async-generator/merge-race';
5
5
  import { polygonAmoy, unichain, polygon, base, arbitrum, bsc, mainnet, sepolia, gnosisChiado, bscTestnet, tron, gnosis, soneium, baseSepolia, optimismSepolia, optimism, arbitrumSepolia } from 'viem/chains';
6
6
  import { TronWeb } from 'tronweb';
@@ -439,11 +439,13 @@ var chainConfigs = {
439
439
  WETH: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
440
440
  DAI: "0x6b175474e89094c44da98b954eedeac495271d0f",
441
441
  USDC: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
442
- USDT: "0xdac17f958d2ee523a2206206994597c13d831ec7"
442
+ USDT: "0xdac17f958d2ee523a2206206994597c13d831ec7",
443
+ cNGN: "0x17CDB2a01e7a34CbB3DD4b83260B05d0274C8dab"
443
444
  },
444
445
  tokenDecimals: {
445
446
  USDC: 6,
446
- USDT: 6
447
+ USDT: 6,
448
+ cNGN: 6
447
449
  },
448
450
  tokenStorageSlots: {
449
451
  USDT: { balanceSlot: 2, allowanceSlot: 5 },
@@ -596,11 +598,13 @@ var chainConfigs = {
596
598
  DAI: "0x50c5725949a6f0c72e6c4a641f24049a917db0cb",
597
599
  USDC: "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
598
600
  USDT: "0xfde4c96c8593536e31f229ea8f37b2ada2699bb2",
599
- EXT: "0x0e668E5127087e236578893a0e01E41837A28469"
601
+ EXT: "0x0e668E5127087e236578893a0e01E41837A28469",
602
+ cNGN: "0x46C85152bFe9f96829aA94755D9f915F9B10EF5F"
600
603
  },
601
604
  tokenDecimals: {
602
605
  USDC: 6,
603
606
  USDT: 6,
607
+ cNGN: 6,
604
608
  EXT: 18
605
609
  },
606
610
  tokenStorageSlots: {
@@ -648,12 +652,14 @@ var chainConfigs = {
648
652
  DAI: "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063",
649
653
  USDC: "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",
650
654
  USDT: "0xc2132d05d31c914a87c6611c10748aeb04b58e8f",
651
- EXT: "0x7C8c11ADb8EF7cd3CFa718008Ea048445C6E7209"
655
+ EXT: "0x7C8c11ADb8EF7cd3CFa718008Ea048445C6E7209",
656
+ cNGN: "0x52828daa48C1a9A06F37500882b42daf0bE04C3B"
652
657
  },
653
658
  tokenDecimals: {
654
659
  USDC: 6,
655
660
  USDT: 6,
656
- EXT: 18
661
+ EXT: 18,
662
+ cNGN: 6
657
663
  },
658
664
  tokenStorageSlots: {
659
665
  USDT: { balanceSlot: 0, allowanceSlot: 1 },
@@ -16359,13 +16365,11 @@ var GasEstimator = class {
16359
16365
  const { order } = params;
16360
16366
  const solverPrivateKey = generatePrivateKey();
16361
16367
  const solverAccountAddress = privateKeyToAddress(solverPrivateKey);
16362
- const sourceStateMachineId = isHex(order.source) ? hexToString$1(order.source) : order.source;
16368
+ const souceStateMachineId = isHex(order.source) ? hexToString$1(order.source) : order.source;
16363
16369
  const destStateMachineId = isHex(order.destination) ? hexToString$1(order.destination) : order.destination;
16364
16370
  const intentGatewayV2Address = this.ctx.dest.configService.getIntentGatewayV2Address(destStateMachineId);
16365
16371
  const entryPointAddress = this.ctx.dest.configService.getEntryPointV08Address(destStateMachineId);
16366
- const chainId = BigInt(
16367
- this.ctx.dest.client.chain?.id ?? Number.parseInt(this.ctx.dest.config.stateMachineId.split("-")[1])
16368
- );
16372
+ const chainId = BigInt(Number.parseInt(destStateMachineId.split("-")[1]));
16369
16373
  const totalEthValue = order.output.assets.filter((output) => bytes32ToBytes20(output.token) === ADDRESS_ZERO).reduce((sum, output) => sum + output.amount, 0n);
16370
16374
  const sourceFeeToken = await getFeeToken(this.ctx, this.ctx.source.config.stateMachineId, this.ctx.source);
16371
16375
  const destFeeToken = await getFeeToken(this.ctx, this.ctx.dest.config.stateMachineId, this.ctx.dest);
@@ -16382,7 +16386,7 @@ var GasEstimator = class {
16382
16386
  intentGatewayV2Address,
16383
16387
  entryPointAddress
16384
16388
  });
16385
- const isSameChain = order.source === destStateMachineId;
16389
+ const isSameChain = souceStateMachineId === destStateMachineId;
16386
16390
  let postRequestFeeInDestFeeToken = 0n;
16387
16391
  let protocolFeeInNativeToken = 0n;
16388
16392
  if (!isSameChain) {
@@ -16391,7 +16395,7 @@ var GasEstimator = class {
16391
16395
  this.ctx,
16392
16396
  postRequestGas,
16393
16397
  "source",
16394
- sourceStateMachineId
16398
+ souceStateMachineId
16395
16399
  );
16396
16400
  postRequestFeeInDestFeeToken = adjustDecimals(
16397
16401
  postRequestFeeInSourceFeeToken,
@@ -16400,12 +16404,12 @@ var GasEstimator = class {
16400
16404
  );
16401
16405
  const postRequest = {
16402
16406
  source: destStateMachineId,
16403
- dest: order.source,
16407
+ dest: souceStateMachineId,
16404
16408
  body: constructRedeemEscrowRequestBody({ ...order, id: orderV2Commitment(order) }, MOCK_ADDRESS),
16405
16409
  timeoutTimestamp: 0n,
16406
16410
  nonce: await this.ctx.source.getHostNonce(),
16407
16411
  from: this.ctx.source.configService.getIntentGatewayV2Address(destStateMachineId),
16408
- to: this.ctx.source.configService.getIntentGatewayV2Address(sourceStateMachineId)
16412
+ to: this.ctx.source.configService.getIntentGatewayV2Address(souceStateMachineId)
16409
16413
  };
16410
16414
  protocolFeeInNativeToken = await this.quoteNative(postRequest, postRequestFeeInDestFeeToken).catch(
16411
16415
  () => this.ctx.dest.quoteNative(postRequest, postRequestFeeInDestFeeToken).catch(() => 0n)
@@ -16482,7 +16486,7 @@ var GasEstimator = class {
16482
16486
  BundlerMethod.ETH_ESTIMATE_USER_OPERATION_GAS,
16483
16487
  [bundlerUserOp, entryPointAddress, bundlerStateOverrides]
16484
16488
  );
16485
- callGasLimit = BigInt(gasEstimate.callGasLimit) * 105n / 100n;
16489
+ callGasLimit = BigInt(gasEstimate.callGasLimit) * 130n / 100n;
16486
16490
  verificationGasLimit = BigInt(gasEstimate.verificationGasLimit) * 105n / 100n;
16487
16491
  preVerificationGas = BigInt(gasEstimate.preVerificationGas) * 105n / 100n;
16488
16492
  if (this.ctx.bundlerUrl?.toLowerCase().includes("pimlico.io")) {
@@ -16495,8 +16499,8 @@ var GasEstimator = class {
16495
16499
  if (level) {
16496
16500
  const pimMaxFeePerGas = BigInt(level.maxFeePerGas);
16497
16501
  const pimMaxPriorityFeePerGas = BigInt(level.maxPriorityFeePerGas);
16498
- maxFeePerGas = pimMaxFeePerGas;
16499
- maxPriorityFeePerGas = pimMaxPriorityFeePerGas;
16502
+ maxFeePerGas = pimMaxFeePerGas + pimMaxFeePerGas * BigInt(maxFeeBumpPercent) / 100n;
16503
+ maxPriorityFeePerGas = pimMaxPriorityFeePerGas + pimMaxPriorityFeePerGas * BigInt(priorityFeeBumpPercent) / 100n;
16500
16504
  }
16501
16505
  } catch (e) {
16502
16506
  console.warn("Pimlico gas price fetch failed, using default gas price:", e);
@@ -16656,6 +16660,66 @@ var GasEstimator = class {
16656
16660
  });
16657
16661
  }
16658
16662
  };
16663
+ var OrderStatusChecker = class {
16664
+ constructor(ctx) {
16665
+ this.ctx = ctx;
16666
+ }
16667
+ /**
16668
+ * Checks if a V2 order has been filled by reading the commitment storage slot on the destination chain.
16669
+ *
16670
+ * Reads the storage slot returned by `calculateCommitmentSlotHash` on the IntentGatewayV2 contract.
16671
+ * A non-zero value at that slot means the solver has called `fillOrder` and the order is complete
16672
+ * from the user's perspective (the beneficiary has received their tokens).
16673
+ *
16674
+ * @param order - The V2 order to check. `order.id` is used as the commitment; if not set it is computed.
16675
+ * @returns True if the order has been filled on the destination chain, false otherwise.
16676
+ */
16677
+ async isOrderFilled(order) {
16678
+ const commitment = order.id ?? orderV2Commitment(order);
16679
+ const destStateMachineId = isHex(order.destination) ? hexToString$1(order.destination) : order.destination;
16680
+ const intentGatewayV2Address = this.ctx.dest.configService.getIntentGatewayV2Address(destStateMachineId);
16681
+ const filledSlot = await this.ctx.dest.client.readContract({
16682
+ abi: ABI3,
16683
+ address: intentGatewayV2Address,
16684
+ functionName: "calculateCommitmentSlotHash",
16685
+ args: [commitment]
16686
+ });
16687
+ const filledStatus = await this.ctx.dest.client.getStorageAt({
16688
+ address: intentGatewayV2Address,
16689
+ slot: filledSlot
16690
+ });
16691
+ return filledStatus !== "0x0000000000000000000000000000000000000000000000000000000000000000";
16692
+ }
16693
+ /**
16694
+ * Checks if a V2 order has been refunded by reading the `_orders` mapping on the source chain.
16695
+ *
16696
+ * Calls `_orders(commitment, tokenAddress)` for each input token. When the order is placed the
16697
+ * escrowed amounts are stored there. After a successful refund the contract zeroes them out.
16698
+ * An order is considered refunded when all escrowed input amounts have been returned (i.e. are 0).
16699
+ *
16700
+ * @param order - The V2 order to check. `order.id` is used as the commitment; if not set it is computed.
16701
+ * @returns True if all escrowed inputs have been returned to the user on the source chain, false otherwise.
16702
+ */
16703
+ async isOrderRefunded(order) {
16704
+ if (!order.inputs || order.inputs.length === 0) return false;
16705
+ const commitment = order.id ?? orderV2Commitment(order);
16706
+ const sourceStateMachineId = isHex(order.source) ? hexToString$1(order.source) : order.source;
16707
+ const intentGatewayV2Address = this.ctx.source.configService.getIntentGatewayV2Address(sourceStateMachineId);
16708
+ for (const input of order.inputs) {
16709
+ const tokenAddress = bytes32ToBytes20(input.token);
16710
+ const escrowedAmount = await this.ctx.source.client.readContract({
16711
+ abi: ABI3,
16712
+ address: intentGatewayV2Address,
16713
+ functionName: "_orders",
16714
+ args: [commitment, tokenAddress]
16715
+ });
16716
+ if (escrowedAmount !== 0n) {
16717
+ return false;
16718
+ }
16719
+ }
16720
+ return true;
16721
+ }
16722
+ };
16659
16723
 
16660
16724
  // src/protocols/intentsV2/IntentsV2.ts
16661
16725
  var IntentsV2 = class _IntentsV2 {
@@ -16668,6 +16732,7 @@ var IntentsV2 = class _IntentsV2 {
16668
16732
  orderPlacer;
16669
16733
  orderExecutor;
16670
16734
  orderCanceller;
16735
+ orderStatusChecker;
16671
16736
  bidManager;
16672
16737
  gasEstimator;
16673
16738
  constructor(source, dest, intentsCoprocessor, bundlerUrl) {
@@ -16697,6 +16762,7 @@ var IntentsV2 = class _IntentsV2 {
16697
16762
  this.orderPlacer = new OrderPlacer(this.ctx);
16698
16763
  this.orderExecutor = new OrderExecutor(this.ctx, bidManager);
16699
16764
  this.orderCanceller = new OrderCanceller(this.ctx);
16765
+ this.orderStatusChecker = new OrderStatusChecker(this.ctx);
16700
16766
  this.bidManager = bidManager;
16701
16767
  this.gasEstimator = gasEstimator;
16702
16768
  this._crypto = crypto;
@@ -16792,6 +16858,12 @@ var IntentsV2 = class _IntentsV2 {
16792
16858
  decodeERC7821Execute(callData) {
16793
16859
  return this._crypto.decodeERC7821Execute(callData);
16794
16860
  }
16861
+ async isOrderFilled(order) {
16862
+ return this.orderStatusChecker.isOrderFilled(order);
16863
+ }
16864
+ async isOrderRefunded(order) {
16865
+ return this.orderStatusChecker.isOrderRefunded(order);
16866
+ }
16795
16867
  };
16796
16868
  var TokenGateway = class {
16797
16869
  source;
@@ -17243,6 +17315,6 @@ async function teleportDot(param_) {
17243
17315
  return stream;
17244
17316
  }
17245
17317
 
17246
- 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 };
17318
+ 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 };
17247
17319
  //# sourceMappingURL=index.js.map
17248
17320
  //# sourceMappingURL=index.js.map