@hyperbridge/sdk 1.7.1 → 1.8.2

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.
@@ -590,313 +590,146 @@ declare const _default: {
590
590
  }];
591
591
  };
592
592
 
593
- /**
594
- * Generates a Merkle Mountain Range (MMR) root hash and proof for a post request.
595
- *
596
- * This function takes a post request and tree size, encodes it according to the PostRequest format,
597
- * and generates both the MMR root hash and a proof. The function builds an MMR with `treeSize` leaves,
598
- * where most leaves are variations of the encoded request (XORed with their index), except for the
599
- * last leaf, which is the unmodified request. The proof is generated for this unmodified leaf.
600
- *
601
- * @param postRequest - The post request to generate the MMR root and proof for
602
- * @param treeSize - Controls how many leaves will be added to the MMR (exactly `treeSize` leaves)
603
- * @returns An object containing:
604
- * - root: The MMR root hash as a hex string
605
- * - proof: An array of hex strings representing the MMR proof for the unmodified request
606
- * - index: The index of the unmodified request in the MMR
607
- * - kIndex: The k-index of the unmodified request in the MMR
608
- * - treeSize: The number of leaves in the MMR
609
- * - mmrSize: The size of the MMR in nodes
610
- */
611
- declare function generateRootWithProof(postRequest: IPostRequest, treeSize: bigint): Promise<{
612
- root: HexString;
613
- proof: HexString[];
614
- index: bigint;
615
- kIndex: bigint;
616
- treeSize: bigint;
617
- mmrSize: bigint;
618
- }>;
619
- declare function __test(): Promise<string>;
620
-
621
- type IStateMachine = {
622
- tag: "Evm";
623
- value: number;
624
- } | {
625
- tag: "Polkadot";
626
- value: number;
627
- } | {
628
- tag: "Kusama";
629
- value: number;
630
- } | {
631
- tag: "Substrate";
632
- value: number[];
633
- } | {
634
- tag: "Tendermint";
635
- value: number[];
636
- };
637
-
638
- declare const ADDRESS_ZERO: HexString;
639
- declare const MOCK_ADDRESS: HexString;
640
- declare const DUMMY_PRIVATE_KEY: HexString;
641
- declare const DEFAULT_GRAFFITI: HexString;
642
- /**
643
- * Returns the maximum of two bigint values
644
- * @param a - First bigint value
645
- * @param b - Second bigint value
646
- * @returns The larger of the two values
647
- */
648
- declare function maxBigInt(a: bigint, b: bigint): bigint;
649
- /**
650
- * Converts a state machine ID string to a stateId object.
651
- * Handles formats like:
652
- * - "EVM-97" → { Evm: 97 }
653
- * - "SUBSTRATE-cere" → { Substrate: "0x63657265" } (hex encoded UTF-8 bytes)
654
- * - "POLKADOT-3367" → { Polkadot: 3367 }
655
- * - "KUSAMA-123" → { Kusama: 123 }
656
- *
657
- * @param stateMachineId The state machine ID string
658
- * @returns A stateId object conforming to the StateMachineIdParams interface
659
- */
660
- declare function parseStateMachineId(stateMachineId: string): {
661
- stateId: {
662
- Evm?: number;
663
- Substrate?: HexString;
664
- Polkadot?: number;
665
- Kusama?: number;
593
+ declare class ChainConfigService {
594
+ private rpcUrls;
595
+ constructor(env?: NodeJS.ProcessEnv);
596
+ private getConfig;
597
+ getChainConfig(chain: string): ChainConfig;
598
+ getIntentGatewayAddress(chain: string): HexString;
599
+ getTokenGatewayAddress(chain: string): HexString;
600
+ getHostAddress(chain: string): HexString;
601
+ getWrappedNativeAssetWithDecimals(chain: string): {
602
+ asset: HexString;
603
+ decimals: number;
666
604
  };
667
- };
668
- /**
669
- * Calculates the commitment hash for a post request.
670
- * @param post The post request to calculate the commitment hash for.
671
- * @returns The commitment hash and the encode packed data.
672
- */
673
- declare function postRequestCommitment(post: IPostRequest): {
674
- commitment: HexString;
675
- encodePacked: HexString;
676
- };
677
- declare function orderCommitment(order: Order): HexString;
678
- /** Calculates the order commitment hash */
679
- declare function orderV2Commitment(order: OrderV2): HexString;
680
- /**
681
- * Converts a bytes32 token address to bytes20 format
682
- * This removes the extra padded zeros from the address
683
- */
684
- declare function bytes32ToBytes20(bytes32Address: string): HexString;
685
- declare function bytes20ToBytes32(bytes20Address: string): HexString;
686
- declare function hexToString(hex: string): string;
687
- /**
688
- * Retries a promise-returning operation with exponential backoff.
689
- * This function will attempt to execute the operation up to maxRetries times,
690
- * with an exponential backoff delay between attempts.
691
- *
692
- * @param operation The async operation to retry
693
- * @param retryConfig Configuration object containing retry parameters
694
- * @returns Promise that resolves with the operation result or rejects with the last error
695
- */
696
- declare function retryPromise<T>(operation: () => Promise<T>, retryConfig: RetryConfig): Promise<T>;
697
- /**
698
- * Calculates the commitment hash for a get request.
699
- * @param get The get request to calculate the commitment hash for.
700
- * @returns The commitment hash.
701
- */
702
- declare function getRequestCommitment(get: IGetRequest): HexString;
703
- /**
704
- * Estimates the gas required for a post request transaction on the source chain.
705
- * This function constructs a post request, generates mock proofs, and estimates
706
- * the gas cost for executing the transaction on the source chain.
707
- */
708
- declare function estimateGasForPost(params: {
709
- postRequest: IPostRequest;
710
- sourceClient: PublicClient;
711
- hostLatestStateMachineHeight: bigint;
712
- hostAddress: HexString;
713
- }): Promise<{
714
- gas_fee: bigint;
715
- call_data: EstimateGasCallData;
716
- }>;
717
- /**
718
- * ABI-encodes a WithdrawalRequest (commitment + beneficiary + tokens).
719
- * Used as the GET-request context for cancel-from-source, and as the inner
720
- * payload (after the RequestKind prefix) for POST-based escrow operations.
721
- */
722
- declare function encodeWithdrawalRequest(order: Order | OrderV2, beneficiary: HexString): HexString;
723
- /**
724
- * Constructs the request body for a redeem escrow operation.
725
- * This function encodes the order commitment, beneficiary address, and token inputs
726
- * to match the format expected by the IntentGateway contract.
727
- */
728
- declare function constructRedeemEscrowRequestBody(order: Order | OrderV2, beneficiary: HexString): HexString;
729
- /**
730
- * Constructs the request body for a refund escrow operation (cancel from destination).
731
- * Uses RequestKind.RefundEscrow to match the IntentGatewayV2 contract's _cancelFromDest.
732
- */
733
- declare function constructRefundEscrowRequestBody(order: Order | OrderV2, beneficiary: HexString): HexString;
734
- declare function fetchPrice(identifier: string | undefined, chainId?: number, apiKey?: string): Promise<number>;
735
- /**
736
- * Fetches the current network gas price from an Etherscan-family explorer API.
737
- * Returns the ProposeGasPrice (in gwei) converted to wei as bigint.
738
- */
739
- declare function getGasPriceFromEtherscan(chainId: string, apiKey?: string): Promise<bigint>;
740
- /**
741
- * ERC20 method signatures used for storage slot detection
742
- */
743
- declare enum ERC20Method {
744
- /** ERC20 balanceOf(address) method signature */
745
- BALANCE_OF = "0x70a08231",
746
- /** ERC20 allowance(address,address) method signature */
747
- ALLOWANCE = "0xdd62ed3e"
748
- }
749
- declare enum EvmLanguage {
750
- Solidity = 0,
751
- Vyper = 1
605
+ getDaiAsset(chain: string): HexString;
606
+ getUsdtAsset(chain: string): HexString;
607
+ getUsdcAsset(chain: string): HexString;
608
+ getUsdcDecimals(chain: string): number;
609
+ getUsdtDecimals(chain: string): number;
610
+ getCNgnAsset(chain: string): HexString | undefined;
611
+ getCNgnDecimals(chain: string): number | undefined;
612
+ getExtAsset(chain: string): HexString | undefined;
613
+ getExtDecimals(chain: string): number | undefined;
614
+ getChainId(chain: string): number;
615
+ getConsensusStateId(chain: string): HexString;
616
+ getHyperbridgeChainId(): number;
617
+ getRpcUrl(chain: string): string;
618
+ getUniswapRouterV2Address(chain: string): HexString;
619
+ getUniswapV2FactoryAddress(chain: string): HexString;
620
+ getUniswapV3FactoryAddress(chain: string): HexString;
621
+ getUniversalRouterAddress(chain: string): HexString;
622
+ getUniswapV3QuoterAddress(chain: string): HexString;
623
+ getUniswapV4QuoterAddress(chain: string): HexString;
624
+ getPermit2Address(chain: string): HexString;
625
+ getSolverAccountAddress(chain: string): HexString | undefined;
626
+ getCoingeckoId(chain: string): string | undefined;
627
+ getEtherscanApiKey(): string | undefined;
628
+ getCalldispatcherAddress(chain: string): HexString;
629
+ getTokenStorageSlots(chain: string, tokenAddress: string): {
630
+ balanceSlot: number;
631
+ allowanceSlot: number;
632
+ } | undefined;
633
+ getPopularTokens(chain: string): string[];
634
+ getIntentGatewayV2Address(chain: string): HexString;
635
+ getEntryPointV08Address(chain: string): HexString;
636
+ getHyperbridgeAddress(): string;
637
+ /**
638
+ * Get the LayerZero Endpoint ID for the chain
639
+ * Used for USDT0 cross-chain transfers via LayerZero OFT
640
+ */
641
+ getLayerZeroEid(chain: string): number | undefined;
642
+ /**
643
+ * Get the USDT0 OFT contract address for the chain
644
+ * On Ethereum: OFT Adapter (locks/unlocks USDT)
645
+ * On other chains: OFT contract (mints/burns USDT0)
646
+ */
647
+ getUsdt0OftAddress(chain: string): HexString | undefined;
752
648
  }
649
+
753
650
  /**
754
- * Retrieves the storage slot for a contract call using debug_traceCall
755
- *
756
- * This function uses the Ethereum debug API to trace contract execution and identify
757
- * the storage slot accessed during the call. It's commonly used for ERC20 token state
758
- * mappings like balanceOf and allowance, but can work with any contract call that
759
- * performs SLOAD operations.
760
- *
761
- * @param client - The viem PublicClient instance connected to an RPC node with debug API enabled
762
- * @param tokenAddress - The address of the contract to trace
763
- * @param data - The full encoded function call data (method signature + encoded parameters)
764
- * @returns The storage slot as a hex string
765
- * @throws Error if the storage slot cannot be found or if debug API is not available
766
- *
767
- * @example
768
- * ```ts
769
- * import { ERC20Method, bytes20ToBytes32 } from '@hyperbridge/sdk'
770
- *
771
- * // Get balance storage slot for ERC20
772
- * const balanceData = ERC20Method.BALANCE_OF + bytes20ToBytes32(userAddress).slice(2)
773
- * const balanceSlot = await getStorageSlot(
774
- * client,
775
- * tokenAddress,
776
- * balanceData as HexString
777
- * )
778
- *
779
- * // Get allowance storage slot for ERC20
780
- * const allowanceData = ERC20Method.ALLOWANCE +
781
- * bytes20ToBytes32(ownerAddress).slice(2) +
782
- * bytes20ToBytes32(spenderAddress).slice(2)
783
- * const allowanceSlot = await getStorageSlot(
784
- * client,
785
- * tokenAddress,
786
- * allowanceData as HexString
787
- * )
788
- * ```
789
- */
790
- declare function getStorageSlot(client: PublicClient, contractAddress: HexString, data: HexString): Promise<string>;
791
- /**
792
- * Returns the storage slot for an ERC20 `balanceOf` or `allowance` call,
793
- * first checking the recorded slot cache and falling back to an RPC trace
794
- * call via `getStorageSlot` when no cached slot is available.
795
- *
796
- * @param client - The viem PublicClient to use for the RPC trace fallback
797
- * @param chain - The chain identifier (e.g. "EVM-1")
798
- * @param contractAddress - The ERC20 token contract address
799
- * @param data - The ABI-encoded call data (method selector + padded args)
800
- * @returns The storage slot as a hex string, or undefined if not found
801
- */
802
- declare function getOrFetchStorageSlot(client: PublicClient, chain: string, contractAddress: HexString, data: HexString): Promise<HexString | undefined>;
803
- /**
804
- * Adjusts fee amounts between different decimal precisions.
805
- * Handles scaling up or down based on the decimal difference.
806
- *
807
- * @param feeInFeeToken - The fee amount to adjust
808
- * @param fromDecimals - The current decimal precision
809
- * @param toDecimals - The target decimal precision
810
- * @returns The adjusted fee amount with the target decimal precision
811
- */
812
- declare function adjustDecimals(feeInFeeToken: bigint, fromDecimals: number, toDecimals: number): bigint;
813
- /**
814
- * Chains that should prefer the Etherscan API for gas price lookup
815
- */
816
- declare const USE_ETHERSCAN_CHAINS: Set<string>;
817
- /**
818
- * Testnet chains
819
- */
820
- declare const TESTNET_CHAINS: Set<string>;
821
- /**
822
- * Retrieves the calldata used to call a target contract within a transaction using debug_traceTransaction
823
- * with the callTracer. Unlike the indexer helper, this returns the calldata whether the target is called
824
- * directly by the transaction or via nested calls.
825
- *
826
- * @param client - viem PublicClient connected to an RPC node with debug API enabled
827
- * @param txHash - The transaction hash
828
- * @param targetContractAddress - The target contract address to find the call for
829
- * @returns The input (calldata) as a hex string, or null if the target is not found in the trace
830
- * @throws Error if the RPC call fails or returns an unexpected response
831
- */
832
- declare function getContractCallInput(client: PublicClient, txHash: HexString, targetContractAddress: string): Promise<HexString | null>;
833
- /**
834
- * Calculates the balance mapping location for a given slot and holder address.
835
- * This function handles the different encoding formats used by Solidity and Vyper.
836
- *
837
- * @param slot - The slot number to calculate the mapping location for.
838
- * @param holder - The address of the holder to calculate the mapping location for.
839
- * @param language - The language of the contract.
840
- * @returns The balance mapping location as a HexString.
651
+ * The default address used as fallback when no address is provided.
652
+ * This represents the zero address in EVM chains.
841
653
  */
842
- declare function calculateBalanceMappingLocation(slot: bigint, holder: string, language: EvmLanguage): HexString;
654
+ declare const DEFAULT_ADDRESS = "0x0000000000000000000000000000000000000000";
843
655
  /**
844
- * Calculates the allowance mapping location for a given slot, owner, and spender.
845
- * ERC20 allowance is a nested mapping: mapping(address owner => mapping(address spender => uint256))
846
- *
847
- * @param slot - The base slot number for the allowance mapping
848
- * @param owner - The address of the token owner (first parameter in allowance(owner, spender))
849
- * @param spender - The address approved to spend tokens (second parameter)
850
- * @param language - The language of the contract (Solidity or Vyper)
851
- * @returns The allowance mapping location as a HexString
656
+ * Parameters for an EVM chain.
852
657
  */
853
- declare function calculateAllowanceMappingLocation(slot: bigint, owner: string, spender: string, language: EvmLanguage): HexString;
854
-
855
- declare class SubstrateChain implements IChain {
856
- private readonly params;
857
- api?: ApiPromise;
858
- private rpcClient;
859
- constructor(params: ISubstrateConfig);
860
- get config(): ISubstrateConfig;
658
+ interface EvmChainParams {
861
659
  /**
862
- * Connects to the Substrate chain using the provided WebSocket URL.
660
+ * The chain ID of the EVM chain
863
661
  */
864
- connect(): Promise<void>;
662
+ chainId: number;
865
663
  /**
866
- * Disconnects the Substrate chain connection.
664
+ * The RPC URL of the EVM chain
867
665
  */
868
- disconnect(): Promise<void>;
666
+ rpcUrl: string;
869
667
  /**
870
- * Returns the storage key for a request receipt in the child trie
871
- * The request commitment is the key
872
- * @param key - The H256 hash key (as a 0x-prefixed hex string)
873
- * @returns The storage key as a hex string
668
+ * The host address of the EVM chain (IsmpHost contract address)
874
669
  */
875
- requestReceiptKey(key: HexString): HexString;
670
+ host: HexString;
876
671
  /**
877
- * Returns the storage key for a request commitment in the child trie
878
- * The request commitment is the key
879
- * @param key - The H256 hash key (as a 0x-prefixed hex string)
880
- * @returns The storage key as a hex string
672
+ * Consensus state identifier of this chain on hyperbridge
881
673
  */
882
- requestCommitmentKey(key: HexString): HexString;
674
+ consensusStateId?: string;
883
675
  /**
884
- * Queries a request commitment from the ISMP child trie storage.
885
- * @param {HexString} commitment - The commitment hash to look up.
886
- * @returns {Promise<HexString | undefined>} The commitment data if found, undefined otherwise.
676
+ * Optional ERC-4337 bundler URL for account abstraction support
677
+ */
678
+ bundlerUrl?: string;
679
+ }
680
+ /**
681
+ * Encapsulates an EVM chain.
682
+ */
683
+ declare class EvmChain implements IChain {
684
+ private readonly params;
685
+ private publicClient;
686
+ private chainConfigService;
687
+ private constructor();
688
+ /**
689
+ * Creates an `EvmChain` instance directly from a fully-specified config object.
690
+ * Use this when you already know the chain ID, host address, and other parameters.
691
+ *
692
+ * This is the only public way to construct an `EvmChain` with explicit params — the constructor is private.
693
+ *
694
+ * @param params - Full EVM chain configuration
695
+ * @returns An `EvmChain` instance
696
+ */
697
+ static fromParams(params: EvmChainParams): EvmChain;
698
+ /**
699
+ * Creates an `EvmChain` instance by auto-detecting the chain ID from the RPC endpoint
700
+ * and resolving the correct `IsmpHost` contract address for that chain.
701
+ *
702
+ * This is the only public way to construct an `EvmChain` — the constructor is private.
703
+ *
704
+ * @param rpcUrl - HTTP(S) RPC URL of the EVM node
705
+ * @param bundlerUrl - Optional ERC-4337 bundler URL for account abstraction support
706
+ * @returns A fully initialised `EvmChain` ready for use
707
+ * @throws If the chain ID returned by the RPC is not a known Hyperbridge deployment
708
+ *
709
+ * @example
710
+ * ```typescript
711
+ * const chain = await EvmChain.create("https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY")
712
+ * const chain = await EvmChain.create("https://mainnet.base.org", "https://bundler.example.com")
713
+ * ```
714
+ */
715
+ static create(rpcUrl: string, bundlerUrl?: string): Promise<EvmChain>;
716
+ get client(): PublicClient;
717
+ get host(): HexString;
718
+ get bundlerUrl(): string | undefined;
719
+ get config(): IEvmConfig;
720
+ get configService(): ChainConfigService;
721
+ /**
722
+ * Derives the key for the request receipt.
723
+ * @param {HexString} commitment - The commitment to derive the key from.
724
+ * @returns {HexString} The derived key.
887
725
  */
888
- queryRequestCommitment(commitment: HexString): Promise<HexString | undefined>;
726
+ requestReceiptKey(commitment: HexString): HexString;
889
727
  /**
890
728
  * Queries the request receipt.
891
729
  * @param {HexString} commitment - The commitment to query.
892
730
  * @returns {Promise<HexString | undefined>} The relayer address responsible for delivering the request.
893
731
  */
894
732
  queryRequestReceipt(commitment: HexString): Promise<HexString | undefined>;
895
- /**
896
- * Returns the current timestamp of the chain.
897
- * @returns {Promise<bigint>} The current timestamp.
898
- */
899
- timestamp(): Promise<bigint>;
900
733
  /**
901
734
  * Queries the proof of the commitments.
902
735
  * @param {IMessage} message - The message to query.
@@ -906,24 +739,18 @@ declare class SubstrateChain implements IChain {
906
739
  */
907
740
  queryProof(message: IMessage, counterparty: string, at?: bigint): Promise<HexString>;
908
741
  /**
909
- * Submit an unsigned ISMP transaction to the chain. Resolves when the transaction is finalized.
910
- * @param message - The message to be submitted.
911
- * @returns A promise that resolves to an object containing the transaction hash, block hash, and block number.
742
+ * Query and return the encoded storage proof for the provided keys at the given height.
743
+ * @param {bigint} at - The block height at which to query the storage proof.
744
+ * @param {HexString[]} keys - The keys for which to query the storage proof.
745
+ * @param {HexString} address - Optional contract address to fetch storage proof else default to host contract
746
+ * @returns {Promise<HexString>} The encoded storage proof.
912
747
  */
913
- submitUnsigned(message: IIsmpMessage): Promise<{
914
- transactionHash: string;
915
- blockHash: string;
916
- blockNumber: number;
917
- timestamp: number;
918
- }>;
748
+ queryStateProof(at: bigint, keys: HexString[], address?: HexString): Promise<HexString>;
919
749
  /**
920
- * Query the state proof for a given set of keys at a specific block height.
921
- * @param at The block height to query the state proof at.
922
- * @param keys The keys to query the state proof for.
923
- * @param _address - Optional address (ignored for Substrate; present for IChain compatibility).
924
- * @returns The state proof as a hexadecimal string.
750
+ * Returns the current timestamp of the chain.
751
+ * @returns {Promise<bigint>} The current timestamp.
925
752
  */
926
- queryStateProof(at: bigint, keys: HexString[], _address?: HexString): Promise<HexString>;
753
+ timestamp(): Promise<bigint>;
927
754
  /**
928
755
  * Get the latest state machine height for a given state machine ID.
929
756
  * @param {StateMachineIdParams} stateMachineId - The state machine ID.
@@ -936,6 +763,10 @@ declare class SubstrateChain implements IChain {
936
763
  * @returns {Promise<bigint>} The statemachine update time in seconds.
937
764
  */
938
765
  stateMachineUpdateTime(stateMachineHeight: StateMachineHeight): Promise<bigint>;
766
+ /**
767
+ * Retrieves the placeOrder calldata from a transaction using debug_traceTransaction.
768
+ */
769
+ getPlaceOrderCalldata(txHash: string, intentGatewayAddress: string): Promise<HexString>;
939
770
  /**
940
771
  * Get the challenge period for a given state machine id.
941
772
  * @param {StateMachineIdParams} stateMachineId - The state machine ID.
@@ -943,220 +774,437 @@ declare class SubstrateChain implements IChain {
943
774
  */
944
775
  challengePeriod(stateMachineId: StateMachineIdParams): Promise<bigint>;
945
776
  /**
946
- * Encode an ISMP calldata for a substrate chain.
947
- * @param message The ISMP message to encode.
948
- * @returns The encoded message as a hexadecimal string.
777
+ * Encodes an ISMP message for the EVM chain.
778
+ * @param {IIsmpMessage} message The ISMP message to encode.
779
+ * @returns {HexString} The encoded calldata.
949
780
  */
950
781
  encode(message: IIsmpMessage): HexString;
951
782
  /**
952
- * Returns the index of a pallet by its name, by looking up the pallets in the runtime metadata.
953
- * @param {string} name - The name of the pallet.
954
- * @returns {number} The index of the pallet.
783
+ * Calculates the fee required to send a post request to the destination chain.
784
+ * The fee is calculated based on the per-byte fee for the destination chain
785
+ * multiplied by the size of the request body.
786
+ *
787
+ * @param request - The post request to calculate the fee for
788
+ * @returns The total fee in wei required to send the post request
955
789
  */
956
- private getPalletIndex;
790
+ quote(request: IPostRequest | IGetRequest): Promise<bigint>;
791
+ quoteNative(request: IPostRequest | IGetRequest, fee: bigint): Promise<bigint>;
792
+ private getAmountsIn;
793
+ /**
794
+ * Estimates the gas required for a post request execution on this chain.
795
+ * This function generates mock proofs for the post request, creates a state override
796
+ * with the necessary overlay root, and estimates the gas cost for executing the
797
+ * handlePostRequests transaction on the handler contract.
798
+ *
799
+ * @param request - The post request to estimate gas for
800
+ * @param paraId - The ID of the parachain (Hyperbridge) that will process the request
801
+ * @returns The estimated gas amount in gas units and the generated calldata
802
+ */
803
+ estimateGas(request: IPostRequest): Promise<{
804
+ gas: bigint;
805
+ postRequestCalldata: HexString;
806
+ }>;
807
+ /**
808
+ * Gets the fee token address and decimals for the chain.
809
+ * This function gets the fee token address and decimals for the chain.
810
+ *
811
+ * @returns The fee token address and decimals
812
+ */
813
+ getFeeTokenWithDecimals(): Promise<{
814
+ address: HexString;
815
+ decimals: number;
816
+ }>;
817
+ /**
818
+ * Gets the nonce of the host.
819
+ * This function gets the nonce of the host.
820
+ *
821
+ * @returns The nonce of the host
822
+ */
823
+ getHostNonce(): Promise<bigint>;
824
+ broadcastTransaction(signedTransaction: HexString): Promise<TransactionReceipt>;
825
+ getTransactionReceipt(hash: HexString): Promise<TransactionReceipt>;
957
826
  }
958
827
  /**
959
- * Converts a state machine ID string to an enum value.
960
- * @param {string} id - The state machine ID string.
961
- * @returns {IStateMachine} The corresponding enum value.
828
+ * Factory function for creating EVM chain instances with common defaults
829
+ *
830
+ * @param chainId - The EVM chain ID
831
+ * @param host - The IsmpHost contract address
832
+ * @param options - Optional configuration overrides
833
+ * @returns A new EvmChain instance
834
+ *
835
+ * @example
836
+ * ```typescript
837
+ * // Create with minimal config
838
+ * const ethChain = createEvmChain(1, "0x87ea45..", {
839
+ * rpcUrl: "https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY"
840
+ * })
841
+ *
842
+ * // Create with custom consensus state ID
843
+ * const arbChain = createEvmChain(42161, "0x87ea42345..", {
844
+ * rpcUrl: "https://arb-mainnet.g.alchemy.com/v2/YOUR_KEY",
845
+ * consensusStateId: "ARB_CUSTOM"
846
+ * })
847
+ * ```
848
+ */
849
+ declare function createEvmChain(chainId: number, host: HexString, options: {
850
+ rpcUrl: string;
851
+ consensusStateId?: string;
852
+ }): EvmChain;
853
+ /**
854
+ * Slot for storing request commitments.
855
+ */
856
+ declare const REQUEST_COMMITMENTS_SLOT = 0n;
857
+ /**
858
+ * Slot index for response commitments map
859
+ */
860
+ declare const RESPONSE_COMMITMENTS_SLOT = 1n;
861
+ /**
862
+ * Slot index for requests receipts map
863
+ */
864
+ declare const REQUEST_RECEIPTS_SLOT = 2n;
865
+ /**
866
+ * Slot index for response receipts map
867
+ */
868
+ declare const RESPONSE_RECEIPTS_SLOT = 3n;
869
+ /**
870
+ * Slot index for state commitment map
871
+ */
872
+ declare const STATE_COMMITMENTS_SLOT = 5n;
873
+ declare function requestCommitmentKey(key: Hex): {
874
+ slot1: Hex;
875
+ slot2: Hex;
876
+ };
877
+ /**
878
+ * Derives the storage slot for a specific field in the StateCommitment struct
879
+ *
880
+ * struct StateCommitment {
881
+ * uint256 timestamp; // slot + 0
882
+ * bytes32 overlayRoot; // slot + 1
883
+ * bytes32 stateRoot; // slot + 2
884
+ * }
885
+ *
886
+ * @param stateMachineId - The state machine ID
887
+ * @param height - The block height
888
+ * @param field - The field index in the struct (0 for timestamp, 1 for overlayRoot, 2 for stateRoot)
889
+ * @returns The storage slot for the specific field
890
+ */
891
+ declare function getStateCommitmentFieldSlot(stateMachineId: bigint, height: bigint, field: 0 | 1 | 2): HexString;
892
+ declare function getStateCommitmentSlot(stateMachineId: bigint, height: bigint): HexString;
893
+
894
+ /**
895
+ * Generates a Merkle Mountain Range (MMR) root hash and proof for a post request.
896
+ *
897
+ * This function takes a post request and tree size, encodes it according to the PostRequest format,
898
+ * and generates both the MMR root hash and a proof. The function builds an MMR with `treeSize` leaves,
899
+ * where most leaves are variations of the encoded request (XORed with their index), except for the
900
+ * last leaf, which is the unmodified request. The proof is generated for this unmodified leaf.
901
+ *
902
+ * @param postRequest - The post request to generate the MMR root and proof for
903
+ * @param treeSize - Controls how many leaves will be added to the MMR (exactly `treeSize` leaves)
904
+ * @returns An object containing:
905
+ * - root: The MMR root hash as a hex string
906
+ * - proof: An array of hex strings representing the MMR proof for the unmodified request
907
+ * - index: The index of the unmodified request in the MMR
908
+ * - kIndex: The k-index of the unmodified request in the MMR
909
+ * - treeSize: The number of leaves in the MMR
910
+ * - mmrSize: The size of the MMR in nodes
911
+ */
912
+ declare function generateRootWithProof(postRequest: IPostRequest, treeSize: bigint): Promise<{
913
+ root: HexString;
914
+ proof: HexString[];
915
+ index: bigint;
916
+ kIndex: bigint;
917
+ treeSize: bigint;
918
+ mmrSize: bigint;
919
+ }>;
920
+ declare function __test(): Promise<string>;
921
+
922
+ type IStateMachine = {
923
+ tag: "Evm";
924
+ value: number;
925
+ } | {
926
+ tag: "Polkadot";
927
+ value: number;
928
+ } | {
929
+ tag: "Kusama";
930
+ value: number;
931
+ } | {
932
+ tag: "Substrate";
933
+ value: number[];
934
+ } | {
935
+ tag: "Tendermint";
936
+ value: number[];
937
+ };
938
+
939
+ declare const ADDRESS_ZERO: HexString;
940
+ declare const MOCK_ADDRESS: HexString;
941
+ declare const DUMMY_PRIVATE_KEY: HexString;
942
+ declare const DEFAULT_GRAFFITI: HexString;
943
+ /**
944
+ * Returns the maximum of two bigint values
945
+ * @param a - First bigint value
946
+ * @param b - Second bigint value
947
+ * @returns The larger of the two values
948
+ */
949
+ declare function maxBigInt(a: bigint, b: bigint): bigint;
950
+ /**
951
+ * Converts a state machine ID string to a stateId object.
952
+ * Handles formats like:
953
+ * - "EVM-97" → { Evm: 97 }
954
+ * - "SUBSTRATE-cere" → { Substrate: "0x63657265" } (hex encoded UTF-8 bytes)
955
+ * - "POLKADOT-3367" → { Polkadot: 3367 }
956
+ * - "KUSAMA-123" → { Kusama: 123 }
957
+ *
958
+ * @param stateMachineId The state machine ID string
959
+ * @returns A stateId object conforming to the StateMachineIdParams interface
960
+ */
961
+ declare function parseStateMachineId(stateMachineId: string): {
962
+ stateId: {
963
+ Evm?: number;
964
+ Substrate?: HexString;
965
+ Polkadot?: number;
966
+ Kusama?: number;
967
+ };
968
+ };
969
+ /**
970
+ * Calculates the commitment hash for a post request.
971
+ * @param post The post request to calculate the commitment hash for.
972
+ * @returns The commitment hash and the encode packed data.
973
+ */
974
+ declare function postRequestCommitment(post: IPostRequest): {
975
+ commitment: HexString;
976
+ encodePacked: HexString;
977
+ };
978
+ /**
979
+ * Converts a bytes32 token address to bytes20 format
980
+ * This removes the extra padded zeros from the address
981
+ */
982
+ declare function bytes32ToBytes20(bytes32Address: string): HexString;
983
+ declare function bytes20ToBytes32(bytes20Address: string): HexString;
984
+ declare function hexToString(hex: string): string;
985
+ /**
986
+ * Retries a promise-returning operation with exponential backoff.
987
+ * This function will attempt to execute the operation up to maxRetries times,
988
+ * with an exponential backoff delay between attempts.
989
+ *
990
+ * @param operation The async operation to retry
991
+ * @param retryConfig Configuration object containing retry parameters
992
+ * @returns Promise that resolves with the operation result or rejects with the last error
993
+ */
994
+ declare function retryPromise<T>(operation: () => Promise<T>, retryConfig: RetryConfig): Promise<T>;
995
+ /**
996
+ * Calculates the commitment hash for a get request.
997
+ * @param get The get request to calculate the commitment hash for.
998
+ * @returns The commitment hash.
962
999
  */
963
- declare function convertStateMachineIdToEnum(id: string): IStateMachine;
1000
+ declare function getRequestCommitment(get: IGetRequest): HexString;
964
1001
  /**
965
- * Converts a state machine enum representation to a string.
966
- * @param {IStateMachine} stateMachine - The state machine enum object.
967
- * @returns {string} The state machine ID string like "EVM-97" or "SUBSTRATE-cere".
1002
+ * Estimates the gas required for a post request transaction on the source chain.
1003
+ * This function constructs a post request, generates mock proofs, and estimates
1004
+ * the gas cost for executing the transaction on the source chain.
968
1005
  */
969
- declare function convertStateMachineEnumToString(stateMachine: {
970
- tag: string;
971
- value: number | number[];
972
- }): string;
1006
+ declare function estimateGasForPost(params: {
1007
+ postRequest: IPostRequest;
1008
+ sourceClient: PublicClient;
1009
+ hostLatestStateMachineHeight: bigint;
1010
+ hostAddress: HexString;
1011
+ }): Promise<{
1012
+ gas_fee: bigint;
1013
+ call_data: EstimateGasCallData;
1014
+ }>;
973
1015
  /**
974
- * Converts a stateId object back to the state_id format used by the RPC.
975
- * @param stateId - The stateId object from StateMachineIdParams
976
- * @returns The string representation like "EVM-11155111" or "SUBSTRATE-cere"
1016
+ * ABI-encodes a WithdrawalRequest (commitment + beneficiary + tokens).
1017
+ * Used as the GET-request context for cancel-from-source, and as the inner
1018
+ * payload (after the RequestKind prefix) for POST-based escrow operations.
977
1019
  */
978
- declare function convertStateIdToStateMachineId(stateId: {
979
- Evm?: number;
980
- Substrate?: HexString;
981
- Polkadot?: number;
982
- Kusama?: number;
983
- }): string;
1020
+ declare function encodeWithdrawalRequest(order: Order | Order, beneficiary: HexString): HexString;
984
1021
  /**
985
- * Converts an IGetRequest object to a codec representation.
986
- * @param {IGetRequest} request - The IGetRequest object.
987
- * @returns The codec representation of the request.
1022
+ * Constructs the request body for a redeem escrow operation.
1023
+ * This function encodes the order commitment, beneficiary address, and token inputs
1024
+ * to match the format expected by the IntentGateway contract.
988
1025
  */
989
- declare function convertIGetRequestToCodec(request: IGetRequest): {
990
- readonly source: IStateMachine;
991
- readonly dest: IStateMachine;
992
- readonly from: number[];
993
- readonly nonce: bigint;
994
- readonly keys: number[][];
995
- readonly context: number[];
996
- readonly timeoutTimestamp: bigint;
997
- readonly height: bigint;
998
- };
1026
+ declare function constructRedeemEscrowRequestBody(order: Order | Order, beneficiary: HexString): HexString;
999
1027
  /**
1000
- * Convert codec representation back to IGetRequest
1028
+ * Constructs the request body for a refund escrow operation (cancel from destination).
1029
+ * Uses RequestKind.RefundEscrow to match the IntentGatewayV2 contract's _cancelFromDest.
1001
1030
  */
1002
- declare function convertCodecToIGetRequest(codec: {
1003
- source: {
1004
- tag: string;
1005
- value: number | number[];
1006
- };
1007
- dest: {
1008
- tag: string;
1009
- value: number | number[];
1010
- };
1011
- from: number[];
1012
- nonce: bigint;
1013
- keys: number[][];
1014
- height: bigint;
1015
- context: number[];
1016
- timeoutTimestamp: bigint;
1017
- }): IGetRequest;
1031
+ declare function constructRefundEscrowRequestBody(order: Order | Order, beneficiary: HexString): HexString;
1032
+ declare function fetchPrice(identifier: string | undefined, chainId?: number, apiKey?: string): Promise<number>;
1018
1033
  /**
1019
- * Converts an IProof object to a codec representation.
1020
- * @param {IProof} proof - The IProof object.
1021
- * @returns The codec representation of the proof.
1034
+ * Fetches the current network gas price from an Etherscan-family explorer API.
1035
+ * Returns the ProposeGasPrice (in gwei) converted to wei as bigint.
1022
1036
  */
1023
- declare function convertIProofToCodec(proof: IProof): {
1024
- readonly height: {
1025
- readonly height: bigint;
1026
- readonly id: {
1027
- readonly consensusStateId: number[];
1028
- readonly id: IStateMachine;
1029
- };
1030
- };
1031
- readonly proof: number[];
1032
- };
1037
+ declare function getGasPriceFromEtherscan(chainId: string, apiKey?: string): Promise<bigint>;
1033
1038
  /**
1034
- * Converts a codec representation back to an IProof object.
1035
- * @param {any} codec - The codec representation of the proof.
1036
- * @returns {IProof} The IProof object.
1039
+ * ERC20 method signatures used for storage slot detection
1037
1040
  */
1038
- declare function convertCodecToIProof(codec: {
1039
- height: {
1040
- height: bigint;
1041
- id: {
1042
- consensusStateId: number[];
1043
- id: {
1044
- tag: string;
1045
- value: number | number[];
1046
- };
1047
- };
1048
- };
1049
- proof: number[];
1050
- }): IProof;
1051
- declare function encodeISMPMessage(message: IIsmpMessage): Uint8Array;
1052
-
1053
- declare class ChainConfigService {
1054
- private rpcUrls;
1055
- constructor(env?: NodeJS.ProcessEnv);
1056
- private getConfig;
1057
- getChainConfig(chain: string): ChainConfig;
1058
- getIntentGatewayAddress(chain: string): HexString;
1059
- getTokenGatewayAddress(chain: string): HexString;
1060
- getHostAddress(chain: string): HexString;
1061
- getWrappedNativeAssetWithDecimals(chain: string): {
1062
- asset: HexString;
1063
- decimals: number;
1064
- };
1065
- getDaiAsset(chain: string): HexString;
1066
- getUsdtAsset(chain: string): HexString;
1067
- getUsdcAsset(chain: string): HexString;
1068
- getUsdcDecimals(chain: string): number;
1069
- getUsdtDecimals(chain: string): number;
1070
- getCNgnAsset(chain: string): HexString | undefined;
1071
- getCNgnDecimals(chain: string): number | undefined;
1072
- getExtAsset(chain: string): HexString | undefined;
1073
- getExtDecimals(chain: string): number | undefined;
1074
- getChainId(chain: string): number;
1075
- getConsensusStateId(chain: string): HexString;
1076
- getHyperbridgeChainId(): number;
1077
- getRpcUrl(chain: string): string;
1078
- getUniswapRouterV2Address(chain: string): HexString;
1079
- getUniswapV2FactoryAddress(chain: string): HexString;
1080
- getUniswapV3FactoryAddress(chain: string): HexString;
1081
- getUniversalRouterAddress(chain: string): HexString;
1082
- getUniswapV3QuoterAddress(chain: string): HexString;
1083
- getUniswapV4QuoterAddress(chain: string): HexString;
1084
- getPermit2Address(chain: string): HexString;
1085
- getSolverAccountAddress(chain: string): HexString | undefined;
1086
- getCoingeckoId(chain: string): string | undefined;
1087
- getEtherscanApiKey(): string | undefined;
1088
- getCalldispatcherAddress(chain: string): HexString;
1089
- getTokenStorageSlots(chain: string, tokenAddress: string): {
1090
- balanceSlot: number;
1091
- allowanceSlot: number;
1092
- } | undefined;
1093
- getPopularTokens(chain: string): string[];
1094
- getIntentGatewayV2Address(chain: string): HexString;
1095
- getEntryPointV08Address(chain: string): HexString;
1096
- getHyperbridgeAddress(): string;
1097
- /**
1098
- * Get the LayerZero Endpoint ID for the chain
1099
- * Used for USDT0 cross-chain transfers via LayerZero OFT
1100
- */
1101
- getLayerZeroEid(chain: string): number | undefined;
1102
- /**
1103
- * Get the USDT0 OFT contract address for the chain
1104
- * On Ethereum: OFT Adapter (locks/unlocks USDT)
1105
- * On other chains: OFT contract (mints/burns USDT0)
1106
- */
1107
- getUsdt0OftAddress(chain: string): HexString | undefined;
1041
+ declare enum ERC20Method {
1042
+ /** ERC20 balanceOf(address) method signature */
1043
+ BALANCE_OF = "0x70a08231",
1044
+ /** ERC20 allowance(address,address) method signature */
1045
+ ALLOWANCE = "0xdd62ed3e"
1108
1046
  }
1109
-
1047
+ declare enum EvmLanguage {
1048
+ Solidity = 0,
1049
+ Vyper = 1
1050
+ }
1051
+ /**
1052
+ * Retrieves the storage slot for a contract call using debug_traceCall
1053
+ *
1054
+ * This function uses the Ethereum debug API to trace contract execution and identify
1055
+ * the storage slot accessed during the call. It's commonly used for ERC20 token state
1056
+ * mappings like balanceOf and allowance, but can work with any contract call that
1057
+ * performs SLOAD operations.
1058
+ *
1059
+ * @param client - The viem PublicClient instance connected to an RPC node with debug API enabled
1060
+ * @param tokenAddress - The address of the contract to trace
1061
+ * @param data - The full encoded function call data (method signature + encoded parameters)
1062
+ * @returns The storage slot as a hex string
1063
+ * @throws Error if the storage slot cannot be found or if debug API is not available
1064
+ *
1065
+ * @example
1066
+ * ```ts
1067
+ * import { ERC20Method, bytes20ToBytes32 } from '@hyperbridge/sdk'
1068
+ *
1069
+ * // Get balance storage slot for ERC20
1070
+ * const balanceData = ERC20Method.BALANCE_OF + bytes20ToBytes32(userAddress).slice(2)
1071
+ * const balanceSlot = await getStorageSlot(
1072
+ * client,
1073
+ * tokenAddress,
1074
+ * balanceData as HexString
1075
+ * )
1076
+ *
1077
+ * // Get allowance storage slot for ERC20
1078
+ * const allowanceData = ERC20Method.ALLOWANCE +
1079
+ * bytes20ToBytes32(ownerAddress).slice(2) +
1080
+ * bytes20ToBytes32(spenderAddress).slice(2)
1081
+ * const allowanceSlot = await getStorageSlot(
1082
+ * client,
1083
+ * tokenAddress,
1084
+ * allowanceData as HexString
1085
+ * )
1086
+ * ```
1087
+ */
1088
+ declare function getStorageSlot(client: PublicClient, contractAddress: HexString, data: HexString): Promise<string>;
1089
+ /**
1090
+ * Returns the storage slot for an ERC20 `balanceOf` or `allowance` call,
1091
+ * first checking the recorded slot cache and falling back to an RPC trace
1092
+ * call via `getStorageSlot` when no cached slot is available.
1093
+ *
1094
+ * @param client - The viem PublicClient to use for the RPC trace fallback
1095
+ * @param chain - The chain identifier (e.g. "EVM-1")
1096
+ * @param contractAddress - The ERC20 token contract address
1097
+ * @param data - The ABI-encoded call data (method selector + padded args)
1098
+ * @returns The storage slot as a hex string, or undefined if not found
1099
+ */
1100
+ declare function getOrFetchStorageSlot(client: PublicClient, chain: string, contractAddress: HexString, data: HexString): Promise<HexString | undefined>;
1101
+ /**
1102
+ * Adjusts fee amounts between different decimal precisions.
1103
+ * Handles scaling up or down based on the decimal difference.
1104
+ *
1105
+ * @param feeInFeeToken - The fee amount to adjust
1106
+ * @param fromDecimals - The current decimal precision
1107
+ * @param toDecimals - The target decimal precision
1108
+ * @returns The adjusted fee amount with the target decimal precision
1109
+ */
1110
+ declare function adjustDecimals(feeInFeeToken: bigint, fromDecimals: number, toDecimals: number): bigint;
1111
+ /**
1112
+ * Chains that should prefer the Etherscan API for gas price lookup
1113
+ */
1114
+ declare const USE_ETHERSCAN_CHAINS: Set<string>;
1115
+ /**
1116
+ * Testnet chains
1117
+ */
1118
+ declare const TESTNET_CHAINS: Set<string>;
1119
+ /**
1120
+ * Retrieves the calldata used to call a target contract within a transaction using debug_traceTransaction
1121
+ * with the callTracer. Unlike the indexer helper, this returns the calldata whether the target is called
1122
+ * directly by the transaction or via nested calls.
1123
+ *
1124
+ * @param client - viem PublicClient connected to an RPC node with debug API enabled
1125
+ * @param txHash - The transaction hash
1126
+ * @param targetContractAddress - The target contract address to find the call for
1127
+ * @returns The input (calldata) as a hex string, or null if the target is not found in the trace
1128
+ * @throws Error if the RPC call fails or returns an unexpected response
1129
+ */
1130
+ declare function getContractCallInput(client: PublicClient, txHash: HexString, targetContractAddress: string): Promise<HexString | null>;
1110
1131
  /**
1111
- * The default address used as fallback when no address is provided.
1112
- * This represents the zero address in EVM chains.
1132
+ * Calculates the balance mapping location for a given slot and holder address.
1133
+ * This function handles the different encoding formats used by Solidity and Vyper.
1134
+ *
1135
+ * @param slot - The slot number to calculate the mapping location for.
1136
+ * @param holder - The address of the holder to calculate the mapping location for.
1137
+ * @param language - The language of the contract.
1138
+ * @returns The balance mapping location as a HexString.
1113
1139
  */
1114
- declare const DEFAULT_ADDRESS = "0x0000000000000000000000000000000000000000";
1140
+ declare function calculateBalanceMappingLocation(slot: bigint, holder: string, language: EvmLanguage): HexString;
1115
1141
  /**
1116
- * Parameters for an EVM chain.
1142
+ * Calculates the allowance mapping location for a given slot, owner, and spender.
1143
+ * ERC20 allowance is a nested mapping: mapping(address owner => mapping(address spender => uint256))
1144
+ *
1145
+ * @param slot - The base slot number for the allowance mapping
1146
+ * @param owner - The address of the token owner (first parameter in allowance(owner, spender))
1147
+ * @param spender - The address approved to spend tokens (second parameter)
1148
+ * @param language - The language of the contract (Solidity or Vyper)
1149
+ * @returns The allowance mapping location as a HexString
1117
1150
  */
1118
- interface EvmChainParams {
1151
+ declare function calculateAllowanceMappingLocation(slot: bigint, owner: string, spender: string, language: EvmLanguage): HexString;
1152
+
1153
+ declare class SubstrateChain implements IChain {
1154
+ private readonly params;
1155
+ api?: ApiPromise;
1156
+ private rpcClient;
1157
+ private constructor();
1119
1158
  /**
1120
- * The chain ID of the EVM chain
1159
+ * Creates a `SubstrateChain` instance and immediately connects to the
1160
+ * WebSocket endpoint, returning a fully initialised chain client.
1161
+ *
1162
+ * This is the only public way to construct a `SubstrateChain` — the constructor is private.
1163
+ *
1164
+ * @param params - Substrate chain configuration (wsUrl, stateMachineId, etc.).
1165
+ * @returns A connected `SubstrateChain` instance.
1121
1166
  */
1122
- chainId: number;
1167
+ static connect(params: ISubstrateConfig): Promise<SubstrateChain>;
1168
+ get config(): ISubstrateConfig;
1123
1169
  /**
1124
- * The RPC URL of the EVM chain
1170
+ * Connects to the Substrate chain using the provided WebSocket URL.
1125
1171
  */
1126
- rpcUrl: string;
1172
+ connect(): Promise<void>;
1127
1173
  /**
1128
- * The host address of the EVM chain (IsmpHost contract address)
1174
+ * Disconnects the Substrate chain connection.
1129
1175
  */
1130
- host: HexString;
1176
+ disconnect(): Promise<void>;
1131
1177
  /**
1132
- * Consensus state identifier of this chain on hyperbridge
1178
+ * Returns the storage key for a request receipt in the child trie
1179
+ * The request commitment is the key
1180
+ * @param key - The H256 hash key (as a 0x-prefixed hex string)
1181
+ * @returns The storage key as a hex string
1133
1182
  */
1134
- consensusStateId?: string;
1135
- }
1136
- /**
1137
- * Encapsulates an EVM chain.
1138
- */
1139
- declare class EvmChain implements IChain {
1140
- private readonly params;
1141
- private publicClient;
1142
- private chainConfigService;
1143
- constructor(params: EvmChainParams);
1144
- get client(): PublicClient;
1145
- get host(): HexString;
1146
- get config(): IEvmConfig;
1147
- get configService(): ChainConfigService;
1183
+ requestReceiptKey(key: HexString): HexString;
1148
1184
  /**
1149
- * Derives the key for the request receipt.
1150
- * @param {HexString} commitment - The commitment to derive the key from.
1151
- * @returns {HexString} The derived key.
1185
+ * Returns the storage key for a request commitment in the child trie
1186
+ * The request commitment is the key
1187
+ * @param key - The H256 hash key (as a 0x-prefixed hex string)
1188
+ * @returns The storage key as a hex string
1152
1189
  */
1153
- requestReceiptKey(commitment: HexString): HexString;
1190
+ requestCommitmentKey(key: HexString): HexString;
1191
+ /**
1192
+ * Queries a request commitment from the ISMP child trie storage.
1193
+ * @param {HexString} commitment - The commitment hash to look up.
1194
+ * @returns {Promise<HexString | undefined>} The commitment data if found, undefined otherwise.
1195
+ */
1196
+ queryRequestCommitment(commitment: HexString): Promise<HexString | undefined>;
1154
1197
  /**
1155
1198
  * Queries the request receipt.
1156
1199
  * @param {HexString} commitment - The commitment to query.
1157
1200
  * @returns {Promise<HexString | undefined>} The relayer address responsible for delivering the request.
1158
1201
  */
1159
1202
  queryRequestReceipt(commitment: HexString): Promise<HexString | undefined>;
1203
+ /**
1204
+ * Returns the current timestamp of the chain.
1205
+ * @returns {Promise<bigint>} The current timestamp.
1206
+ */
1207
+ timestamp(): Promise<bigint>;
1160
1208
  /**
1161
1209
  * Queries the proof of the commitments.
1162
1210
  * @param {IMessage} message - The message to query.
@@ -1166,18 +1214,24 @@ declare class EvmChain implements IChain {
1166
1214
  */
1167
1215
  queryProof(message: IMessage, counterparty: string, at?: bigint): Promise<HexString>;
1168
1216
  /**
1169
- * Query and return the encoded storage proof for the provided keys at the given height.
1170
- * @param {bigint} at - The block height at which to query the storage proof.
1171
- * @param {HexString[]} keys - The keys for which to query the storage proof.
1172
- * @param {HexString} address - Optional contract address to fetch storage proof else default to host contract
1173
- * @returns {Promise<HexString>} The encoded storage proof.
1217
+ * Submit an unsigned ISMP transaction to the chain. Resolves when the transaction is finalized.
1218
+ * @param message - The message to be submitted.
1219
+ * @returns A promise that resolves to an object containing the transaction hash, block hash, and block number.
1174
1220
  */
1175
- queryStateProof(at: bigint, keys: HexString[], address?: HexString): Promise<HexString>;
1221
+ submitUnsigned(message: IIsmpMessage): Promise<{
1222
+ transactionHash: string;
1223
+ blockHash: string;
1224
+ blockNumber: number;
1225
+ timestamp: number;
1226
+ }>;
1176
1227
  /**
1177
- * Returns the current timestamp of the chain.
1178
- * @returns {Promise<bigint>} The current timestamp.
1228
+ * Query the state proof for a given set of keys at a specific block height.
1229
+ * @param at The block height to query the state proof at.
1230
+ * @param keys The keys to query the state proof for.
1231
+ * @param _address - Optional address (ignored for Substrate; present for IChain compatibility).
1232
+ * @returns The state proof as a hexadecimal string.
1179
1233
  */
1180
- timestamp(): Promise<bigint>;
1234
+ queryStateProof(at: bigint, keys: HexString[], _address?: HexString): Promise<HexString>;
1181
1235
  /**
1182
1236
  * Get the latest state machine height for a given state machine ID.
1183
1237
  * @param {StateMachineIdParams} stateMachineId - The state machine ID.
@@ -1190,10 +1244,6 @@ declare class EvmChain implements IChain {
1190
1244
  * @returns {Promise<bigint>} The statemachine update time in seconds.
1191
1245
  */
1192
1246
  stateMachineUpdateTime(stateMachineHeight: StateMachineHeight): Promise<bigint>;
1193
- /**
1194
- * Retrieves the placeOrder calldata from a transaction using debug_traceTransaction.
1195
- */
1196
- getPlaceOrderCalldata(txHash: string, intentGatewayAddress: string): Promise<HexString>;
1197
1247
  /**
1198
1248
  * Get the challenge period for a given state machine id.
1199
1249
  * @param {StateMachineIdParams} stateMachineId - The state machine ID.
@@ -1201,121 +1251,112 @@ declare class EvmChain implements IChain {
1201
1251
  */
1202
1252
  challengePeriod(stateMachineId: StateMachineIdParams): Promise<bigint>;
1203
1253
  /**
1204
- * Encodes an ISMP message for the EVM chain.
1205
- * @param {IIsmpMessage} message The ISMP message to encode.
1206
- * @returns {HexString} The encoded calldata.
1254
+ * Encode an ISMP calldata for a substrate chain.
1255
+ * @param message The ISMP message to encode.
1256
+ * @returns The encoded message as a hexadecimal string.
1207
1257
  */
1208
1258
  encode(message: IIsmpMessage): HexString;
1209
1259
  /**
1210
- * Calculates the fee required to send a post request to the destination chain.
1211
- * The fee is calculated based on the per-byte fee for the destination chain
1212
- * multiplied by the size of the request body.
1213
- *
1214
- * @param request - The post request to calculate the fee for
1215
- * @returns The total fee in wei required to send the post request
1216
- */
1217
- quote(request: IPostRequest | IGetRequest): Promise<bigint>;
1218
- quoteNative(request: IPostRequest | IGetRequest, fee: bigint): Promise<bigint>;
1219
- private getAmountsIn;
1220
- /**
1221
- * Estimates the gas required for a post request execution on this chain.
1222
- * This function generates mock proofs for the post request, creates a state override
1223
- * with the necessary overlay root, and estimates the gas cost for executing the
1224
- * handlePostRequests transaction on the handler contract.
1225
- *
1226
- * @param request - The post request to estimate gas for
1227
- * @param paraId - The ID of the parachain (Hyperbridge) that will process the request
1228
- * @returns The estimated gas amount in gas units and the generated calldata
1229
- */
1230
- estimateGas(request: IPostRequest): Promise<{
1231
- gas: bigint;
1232
- postRequestCalldata: HexString;
1233
- }>;
1234
- /**
1235
- * Gets the fee token address and decimals for the chain.
1236
- * This function gets the fee token address and decimals for the chain.
1237
- *
1238
- * @returns The fee token address and decimals
1239
- */
1240
- getFeeTokenWithDecimals(): Promise<{
1241
- address: HexString;
1242
- decimals: number;
1243
- }>;
1244
- /**
1245
- * Gets the nonce of the host.
1246
- * This function gets the nonce of the host.
1247
- *
1248
- * @returns The nonce of the host
1260
+ * Returns the index of a pallet by its name, by looking up the pallets in the runtime metadata.
1261
+ * @param {string} name - The name of the pallet.
1262
+ * @returns {number} The index of the pallet.
1249
1263
  */
1250
- getHostNonce(): Promise<bigint>;
1251
- broadcastTransaction(signedTransaction: HexString): Promise<TransactionReceipt>;
1264
+ private getPalletIndex;
1252
1265
  }
1253
1266
  /**
1254
- * Factory function for creating EVM chain instances with common defaults
1255
- *
1256
- * @param chainId - The EVM chain ID
1257
- * @param host - The IsmpHost contract address
1258
- * @param options - Optional configuration overrides
1259
- * @returns A new EvmChain instance
1260
- *
1261
- * @example
1262
- * ```typescript
1263
- * // Create with minimal config
1264
- * const ethChain = createEvmChain(1, "0x87ea45..", {
1265
- * rpcUrl: "https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY"
1266
- * })
1267
- *
1268
- * // Create with custom consensus state ID
1269
- * const arbChain = createEvmChain(42161, "0x87ea42345..", {
1270
- * rpcUrl: "https://arb-mainnet.g.alchemy.com/v2/YOUR_KEY",
1271
- * consensusStateId: "ARB_CUSTOM"
1272
- * })
1273
- * ```
1267
+ * Converts a state machine ID string to an enum value.
1268
+ * @param {string} id - The state machine ID string.
1269
+ * @returns {IStateMachine} The corresponding enum value.
1274
1270
  */
1275
- declare function createEvmChain(chainId: number, host: HexString, options: {
1276
- rpcUrl: string;
1277
- consensusStateId?: string;
1278
- }): EvmChain;
1271
+ declare function convertStateMachineIdToEnum(id: string): IStateMachine;
1279
1272
  /**
1280
- * Slot for storing request commitments.
1273
+ * Converts a state machine enum representation to a string.
1274
+ * @param {IStateMachine} stateMachine - The state machine enum object.
1275
+ * @returns {string} The state machine ID string like "EVM-97" or "SUBSTRATE-cere".
1281
1276
  */
1282
- declare const REQUEST_COMMITMENTS_SLOT = 0n;
1277
+ declare function convertStateMachineEnumToString(stateMachine: {
1278
+ tag: string;
1279
+ value: number | number[];
1280
+ }): string;
1283
1281
  /**
1284
- * Slot index for response commitments map
1282
+ * Converts a stateId object back to the state_id format used by the RPC.
1283
+ * @param stateId - The stateId object from StateMachineIdParams
1284
+ * @returns The string representation like "EVM-11155111" or "SUBSTRATE-cere"
1285
1285
  */
1286
- declare const RESPONSE_COMMITMENTS_SLOT = 1n;
1286
+ declare function convertStateIdToStateMachineId(stateId: {
1287
+ Evm?: number;
1288
+ Substrate?: HexString;
1289
+ Polkadot?: number;
1290
+ Kusama?: number;
1291
+ }): string;
1287
1292
  /**
1288
- * Slot index for requests receipts map
1293
+ * Converts an IGetRequest object to a codec representation.
1294
+ * @param {IGetRequest} request - The IGetRequest object.
1295
+ * @returns The codec representation of the request.
1289
1296
  */
1290
- declare const REQUEST_RECEIPTS_SLOT = 2n;
1297
+ declare function convertIGetRequestToCodec(request: IGetRequest): {
1298
+ readonly source: IStateMachine;
1299
+ readonly dest: IStateMachine;
1300
+ readonly from: number[];
1301
+ readonly nonce: bigint;
1302
+ readonly keys: number[][];
1303
+ readonly context: number[];
1304
+ readonly timeoutTimestamp: bigint;
1305
+ readonly height: bigint;
1306
+ };
1291
1307
  /**
1292
- * Slot index for response receipts map
1308
+ * Convert codec representation back to IGetRequest
1293
1309
  */
1294
- declare const RESPONSE_RECEIPTS_SLOT = 3n;
1310
+ declare function convertCodecToIGetRequest(codec: {
1311
+ source: {
1312
+ tag: string;
1313
+ value: number | number[];
1314
+ };
1315
+ dest: {
1316
+ tag: string;
1317
+ value: number | number[];
1318
+ };
1319
+ from: number[];
1320
+ nonce: bigint;
1321
+ keys: number[][];
1322
+ height: bigint;
1323
+ context: number[];
1324
+ timeoutTimestamp: bigint;
1325
+ }): IGetRequest;
1295
1326
  /**
1296
- * Slot index for state commitment map
1327
+ * Converts an IProof object to a codec representation.
1328
+ * @param {IProof} proof - The IProof object.
1329
+ * @returns The codec representation of the proof.
1297
1330
  */
1298
- declare const STATE_COMMITMENTS_SLOT = 5n;
1299
- declare function requestCommitmentKey(key: Hex): {
1300
- slot1: Hex;
1301
- slot2: Hex;
1331
+ declare function convertIProofToCodec(proof: IProof): {
1332
+ readonly height: {
1333
+ readonly height: bigint;
1334
+ readonly id: {
1335
+ readonly consensusStateId: number[];
1336
+ readonly id: IStateMachine;
1337
+ };
1338
+ };
1339
+ readonly proof: number[];
1302
1340
  };
1303
1341
  /**
1304
- * Derives the storage slot for a specific field in the StateCommitment struct
1305
- *
1306
- * struct StateCommitment {
1307
- * uint256 timestamp; // slot + 0
1308
- * bytes32 overlayRoot; // slot + 1
1309
- * bytes32 stateRoot; // slot + 2
1310
- * }
1311
- *
1312
- * @param stateMachineId - The state machine ID
1313
- * @param height - The block height
1314
- * @param field - The field index in the struct (0 for timestamp, 1 for overlayRoot, 2 for stateRoot)
1315
- * @returns The storage slot for the specific field
1342
+ * Converts a codec representation back to an IProof object.
1343
+ * @param {any} codec - The codec representation of the proof.
1344
+ * @returns {IProof} The IProof object.
1316
1345
  */
1317
- declare function getStateCommitmentFieldSlot(stateMachineId: bigint, height: bigint, field: 0 | 1 | 2): HexString;
1318
- declare function getStateCommitmentSlot(stateMachineId: bigint, height: bigint): HexString;
1346
+ declare function convertCodecToIProof(codec: {
1347
+ height: {
1348
+ height: bigint;
1349
+ id: {
1350
+ consensusStateId: number[];
1351
+ id: {
1352
+ tag: string;
1353
+ value: number | number[];
1354
+ };
1355
+ };
1356
+ };
1357
+ proof: number[];
1358
+ }): IProof;
1359
+ declare function encodeISMPMessage(message: IIsmpMessage): Uint8Array;
1319
1360
 
1320
1361
  /**
1321
1362
  * Encodes a PackedUserOperation using SCALE codec for submission to Hyperbridge.
@@ -1379,11 +1420,6 @@ declare class IntentsCoprocessor {
1379
1420
  * Supports both hex seed (without 0x prefix) and mnemonic phrases
1380
1421
  */
1381
1422
  getKeyPair(): KeyringPair;
1382
- /**
1383
- * Checks if the connected node exposes intents_* RPC methods.
1384
- * Result is cached after the first check.
1385
- */
1386
- private checkIntentsRpc;
1387
1423
  /**
1388
1424
  * Signs and sends an extrinsic, handling status updates and errors
1389
1425
  * Implements retry logic with progressive tip increases for stuck transactions
@@ -1454,7 +1490,16 @@ declare class TronChain implements IChain {
1454
1490
  private readonly params;
1455
1491
  private readonly evm;
1456
1492
  private readonly tronWebInstance;
1457
- constructor(params: TronChainParams);
1493
+ /**
1494
+ * Creates a `TronChain` instance from a fully-specified config object.
1495
+ *
1496
+ * This is the only public way to construct a `TronChain` — the constructor is private.
1497
+ *
1498
+ * @param params - Tron chain configuration
1499
+ * @returns A `TronChain` instance
1500
+ */
1501
+ static fromParams(params: TronChainParams): Promise<TronChain>;
1502
+ private constructor();
1458
1503
  /** Underlying viem public client (delegated from the internal EvmChain) */
1459
1504
  get client(): PublicClient;
1460
1505
  /** Host contract address for this chain (delegated from the internal EvmChain) */
@@ -1487,6 +1532,7 @@ declare class TronChain implements IChain {
1487
1532
  * This mirrors the behavior used in IntentGatewayV2 for Tron chains.
1488
1533
  */
1489
1534
  broadcastTransaction(signedTransaction: any): Promise<TransactionReceipt>;
1535
+ getTransactionReceipt(hash: HexString): Promise<TransactionReceipt>;
1490
1536
  /** Gets the fee token address and decimals for the chain. */
1491
1537
  getFeeTokenWithDecimals(): Promise<{
1492
1538
  address: HexString;
@@ -1651,6 +1697,7 @@ interface IChain {
1651
1697
  interface IEvmChain extends IChain {
1652
1698
  readonly configService: ChainConfigService;
1653
1699
  readonly client: PublicClient;
1700
+ readonly bundlerUrl?: string;
1654
1701
  getHostNonce(): Promise<bigint>;
1655
1702
  quoteNative(request: IPostRequest | IGetRequest, fee: bigint): Promise<bigint>;
1656
1703
  getFeeTokenWithDecimals(): Promise<{
@@ -1659,22 +1706,8 @@ interface IEvmChain extends IChain {
1659
1706
  }>;
1660
1707
  getPlaceOrderCalldata(txHash: string, intentGatewayAddress: string): Promise<HexString>;
1661
1708
  broadcastTransaction(signedTransaction: HexString): Promise<TransactionReceipt>;
1709
+ getTransactionReceipt(hash: HexString): Promise<TransactionReceipt>;
1662
1710
  }
1663
- /**
1664
- * Returns the chain interface for a given state machine identifier.
1665
- *
1666
- * - For standard EVM chains, returns an `EvmChain`.
1667
- * - For Substrate chains, returns a connected `SubstrateChain`.
1668
- * - For Tron chains (identified by chain ID), constructs a `TronChain`
1669
- * that delegates EVM behavior to an internal `EvmChain` and manages
1670
- * its own TronWeb instance using the provided RPC URL.
1671
- *
1672
- * @param chainConfig - Chain configuration
1673
- * @returns Chain interface
1674
- */
1675
- declare function getChain(chainConfig: IEvmConfig | ISubstrateConfig): Promise<IChain>;
1676
- declare function getEvmChain(chainConfig: IEvmConfig): IChain;
1677
- declare function getSubstrateChain(chainConfig: ISubstrateConfig): Promise<SubstrateChain>;
1678
1711
 
1679
1712
  type EstimateGasCallData = ContractFunctionArgs<typeof _default.ABI, "nonpayable" | "payable", "handlePostRequests">;
1680
1713
  type HexString = `0x${string}`;
@@ -2122,87 +2155,7 @@ interface TokenInfo {
2122
2155
  */
2123
2156
  amount: bigint;
2124
2157
  }
2125
- /**
2126
- * Represents payment information for an order
2127
- */
2128
- interface PaymentInfo extends TokenInfo {
2129
- /**
2130
- * The address to receive the output tokens
2131
- */
2132
- beneficiary: HexString;
2133
- }
2134
- /**
2135
- * Represents an order in the IntentGateway
2136
- */
2137
- interface Order {
2138
- /**
2139
- * The unique identifier for the order
2140
- */
2141
- id?: string;
2142
- /**
2143
- * The address of the user who is initiating the transfer
2144
- */
2145
- user: HexString;
2146
- /**
2147
- * The state machine identifier of the origin chain
2148
- */
2149
- sourceChain: string;
2150
- /**
2151
- * The state machine identifier of the destination chain
2152
- */
2153
- destChain: string;
2154
- /**
2155
- * The block number by which the order must be filled on the destination chain
2156
- */
2157
- deadline: bigint;
2158
- /**
2159
- * The nonce of the order
2160
- */
2161
- nonce: bigint;
2162
- /**
2163
- * Represents the dispatch fees associated with the IntentGateway
2164
- */
2165
- fees: bigint;
2166
- /**
2167
- * The tokens that the filler will provide
2168
- */
2169
- outputs: PaymentInfo[];
2170
- /**
2171
- * The tokens that are escrowed for the filler
2172
- */
2173
- inputs: TokenInfo[];
2174
- /**
2175
- * A bytes array to store the calls if any
2176
- */
2177
- callData: HexString;
2178
- /**
2179
- * The transaction hash of the order
2180
- */
2181
- transactionHash?: HexString;
2182
- }
2183
2158
  interface DecodedOrderPlacedLog extends Log {
2184
- eventName: string;
2185
- args: {
2186
- user: HexString;
2187
- sourceChain: Hex;
2188
- destChain: Hex;
2189
- deadline: bigint;
2190
- nonce: bigint;
2191
- fees: bigint;
2192
- outputs: Array<{
2193
- token: HexString;
2194
- amount: bigint;
2195
- beneficiary: HexString;
2196
- }>;
2197
- inputs: Array<{
2198
- token: HexString;
2199
- amount: bigint;
2200
- }>;
2201
- callData: HexString;
2202
- };
2203
- transactionHash: HexString;
2204
- }
2205
- interface DecodedOrderV2PlacedLog extends Log {
2206
2159
  eventName: string;
2207
2160
  args: {
2208
2161
  user: HexString;
@@ -2258,15 +2211,6 @@ interface DecodedPostResponseEvent extends Log {
2258
2211
  };
2259
2212
  transactionHash: HexString;
2260
2213
  }
2261
- /**
2262
- * Options for filling an order
2263
- */
2264
- interface FillOptions {
2265
- /**
2266
- * The fee paid to the relayer for processing transactions
2267
- */
2268
- relayerFee: bigint;
2269
- }
2270
2214
  /**
2271
2215
  * Options for canceling an order
2272
2216
  */
@@ -2723,20 +2667,16 @@ interface StorageFacade {
2723
2667
  set<T>(key: string, value: T): Promise<void>;
2724
2668
  delete(key: string): Promise<void>;
2725
2669
  }
2726
- interface TokenInfoV2 {
2727
- token: HexString;
2728
- amount: bigint;
2729
- }
2730
- interface PaymentInfoV2 {
2670
+ interface PaymentInfo {
2731
2671
  beneficiary: HexString;
2732
- assets: TokenInfoV2[];
2672
+ assets: TokenInfo[];
2733
2673
  call: HexString;
2734
2674
  }
2735
- interface DispatchInfoV2 {
2736
- assets: TokenInfoV2[];
2675
+ interface DispatchInfo {
2676
+ assets: TokenInfo[];
2737
2677
  call: HexString;
2738
2678
  }
2739
- interface OrderV2 {
2679
+ interface Order {
2740
2680
  id?: string;
2741
2681
  user: HexString;
2742
2682
  source: HexString;
@@ -2745,15 +2685,14 @@ interface OrderV2 {
2745
2685
  nonce: bigint;
2746
2686
  fees: bigint;
2747
2687
  session: HexString;
2748
- predispatch: DispatchInfoV2;
2749
- inputs: TokenInfoV2[];
2750
- output: PaymentInfoV2;
2751
- transactionHash?: HexString;
2688
+ predispatch: DispatchInfo;
2689
+ inputs: TokenInfo[];
2690
+ output: PaymentInfo;
2752
2691
  }
2753
- interface FillOptionsV2 {
2692
+ interface FillOptions {
2754
2693
  relayerFee: bigint;
2755
2694
  nativeDispatchFee: bigint;
2756
- outputs: TokenInfoV2[];
2695
+ outputs: TokenInfo[];
2757
2696
  }
2758
2697
  interface PackedUserOperation {
2759
2698
  sender: HexString;
@@ -2767,8 +2706,8 @@ interface PackedUserOperation {
2767
2706
  signature: HexString;
2768
2707
  }
2769
2708
  interface SubmitBidOptions {
2770
- order: OrderV2;
2771
- fillOptions: FillOptionsV2;
2709
+ order: Order;
2710
+ fillOptions: FillOptions;
2772
2711
  solverAccount: HexString;
2773
2712
  solverPrivateKey: HexString;
2774
2713
  nonce: bigint;
@@ -2781,8 +2720,8 @@ interface SubmitBidOptions {
2781
2720
  /** Pre-built ERC-7821 calldata encoding the UserOp execution (approvals + fillOrder). */
2782
2721
  callData: HexString;
2783
2722
  }
2784
- interface EstimateFillOrderV2Params {
2785
- order: OrderV2;
2723
+ interface EstimateFillOrderParams {
2724
+ order: Order;
2786
2725
  /**
2787
2726
  * Optional percentage to bump maxPriorityFeePerGas.
2788
2727
  * This is added on top of the base gasPrice.
@@ -2796,8 +2735,8 @@ interface EstimateFillOrderV2Params {
2796
2735
  */
2797
2736
  maxFeePerGasBumpPercent?: number;
2798
2737
  }
2799
- interface FillOrderEstimateV2 {
2800
- fillOptions: FillOptionsV2;
2738
+ interface FillOrderEstimate {
2739
+ fillOptions: FillOptions;
2801
2740
  callGasLimit: bigint;
2802
2741
  verificationGasLimit: bigint;
2803
2742
  preVerificationGas: bigint;
@@ -2887,13 +2826,13 @@ type IntentOrderStatusUpdate = {
2887
2826
  sessionPrivateKey: HexString;
2888
2827
  } | {
2889
2828
  status: "ORDER_PLACED";
2890
- order: OrderV2;
2891
- transactionHash: HexString;
2829
+ order: Order;
2830
+ receipt: TransactionReceipt;
2892
2831
  } | {
2893
2832
  status: "AWAITING_BIDS";
2894
2833
  commitment: HexString;
2895
- totalFilledAmount: bigint;
2896
- remainingAmount: bigint;
2834
+ totalFilledAssets: TokenInfo[];
2835
+ remainingAssets: TokenInfo[];
2897
2836
  } | {
2898
2837
  status: "BIDS_RECEIVED";
2899
2838
  commitment: HexString;
@@ -2917,28 +2856,28 @@ type IntentOrderStatusUpdate = {
2917
2856
  userOpHash: HexString;
2918
2857
  selectedSolver: HexString;
2919
2858
  transactionHash?: HexString;
2920
- totalFilledAmount: bigint;
2921
- remainingAmount: bigint;
2859
+ totalFilledAssets: TokenInfo[];
2860
+ remainingAssets: TokenInfo[];
2922
2861
  } | {
2923
2862
  status: "PARTIAL_FILL";
2924
2863
  commitment: HexString;
2925
2864
  userOpHash: HexString;
2926
2865
  selectedSolver: HexString;
2927
2866
  transactionHash?: HexString;
2928
- filledAmount?: bigint;
2929
- totalFilledAmount: bigint;
2930
- remainingAmount: bigint;
2867
+ filledAssets: TokenInfo[];
2868
+ totalFilledAssets: TokenInfo[];
2869
+ remainingAssets: TokenInfo[];
2931
2870
  } | {
2932
2871
  status: "PARTIAL_FILL_EXHAUSTED";
2933
2872
  commitment: HexString;
2934
- totalFilledAmount?: bigint;
2935
- remainingAmount?: bigint;
2873
+ totalFilledAssets?: TokenInfo[];
2874
+ remainingAssets?: TokenInfo[];
2936
2875
  error: string;
2937
2876
  } | {
2938
2877
  status: "FAILED";
2939
2878
  commitment?: HexString;
2940
- totalFilledAmount?: bigint;
2941
- remainingAmount?: bigint;
2879
+ totalFilledAssets?: TokenInfo[];
2880
+ remainingAssets?: TokenInfo[];
2942
2881
  error: string;
2943
2882
  };
2944
2883
  /** Result of selecting a bid and submitting to the bundler */
@@ -2949,16 +2888,26 @@ interface SelectBidResult {
2949
2888
  commitment: HexString;
2950
2889
  txnHash?: HexString;
2951
2890
  fillStatus?: "full" | "partial";
2952
- /** Amount filled in this user operation (best-effort, based on on-chain logs) */
2953
- filledAmount?: bigint;
2891
+ /** Assets filled in this user operation (best-effort, based on on-chain PartialFill logs) */
2892
+ filledAssets?: TokenInfo[];
2954
2893
  }
2955
2894
  /** Options for executing an intent order */
2956
2895
  interface ExecuteIntentOrderOptions {
2957
- order: OrderV2;
2896
+ order: Order;
2958
2897
  sessionPrivateKey?: HexString;
2959
2898
  minBids?: number;
2960
2899
  bidTimeoutMs?: number;
2961
2900
  pollIntervalMs?: number;
2901
+ /**
2902
+ * If set, bids are restricted to the given solver until `timeoutMs` elapses,
2903
+ * after which any solver is accepted.
2904
+ */
2905
+ solver?: {
2906
+ /** Only bids from this address (matched against userOp.sender) will be considered */
2907
+ address: HexString;
2908
+ /** After this many ms without a matching bid, execution falls back to any solver */
2909
+ timeoutMs: number;
2910
+ };
2962
2911
  }
2963
2912
  /** Type for ERC-7821 Call struct */
2964
2913
  type ERC7821Call = {
@@ -2967,29 +2916,6 @@ type ERC7821Call = {
2967
2916
  data: `0x${string}`;
2968
2917
  };
2969
2918
 
2970
- /**
2971
- * Helper function to create chain configuration from legacy config format
2972
- * This helps migrate from the old config format to the new IChain-based format
2973
- *
2974
- * @param config - Legacy configuration object (IEvmConfig, ISubstrateConfig, or IHyperbridgeConfig)
2975
- * @returns Promise resolving to chain configuration with IChain instance
2976
- */
2977
- declare function createChain(config: IEvmConfig | ISubstrateConfig | IHyperbridgeConfig): Promise<IChain>;
2978
- /**
2979
- * Helper function to create IndexerClient with legacy config format
2980
- * @deprecated Use the constructor with IChain instances directly for better performance
2981
- *
2982
- * @param config - Legacy configuration with IEvmConfig/ISubstrateConfig/IHyperbridgeConfig
2983
- * @returns Promise resolving to IndexerClient instance
2984
- */
2985
- declare function createIndexerClient(config: {
2986
- pollInterval?: number;
2987
- queryClient: IndexerQueryClient;
2988
- tracing?: boolean;
2989
- source: IEvmConfig | ISubstrateConfig;
2990
- dest: IEvmConfig | ISubstrateConfig;
2991
- hyperbridge: IHyperbridgeConfig;
2992
- }): Promise<IndexerClient>;
2993
2919
  /**
2994
2920
  * IndexerClient provides methods for interacting with the Hyperbridge indexer.
2995
2921
  *
@@ -3012,26 +2938,24 @@ declare function createIndexerClient(config: {
3012
2938
  *
3013
2939
  * @example
3014
2940
  * ```typescript
3015
- * // New approach: Create IChain instances directly
3016
- * const sourceChain = new EvmChain({
2941
+ * const sourceChain = EvmChain.fromParams({
3017
2942
  * chainId: 1,
3018
2943
  * rpcUrl: "https://eth-rpc.com",
3019
2944
  * host: "0x87ea45..",
3020
2945
  * consensusStateId: "ETH0"
3021
2946
  * })
3022
- * const destChain = new EvmChain({
2947
+ * const destChain = EvmChain.fromParams({
3023
2948
  * chainId: 42161,
3024
2949
  * rpcUrl: "https://arb-rpc.com",
3025
2950
  * host: "0x87ea42345..",
3026
2951
  * consensusStateId: "ARB0"
3027
2952
  * })
3028
- * const hyperbridgeChain = new SubstrateChain({
2953
+ * const hyperbridgeChain = await SubstrateChain.connect({
3029
2954
  * stateMachineId: "POLKADOT-3367",
3030
2955
  * wsUrl: "ws://localhost:9944",
3031
2956
  * hasher: "Keccak",
3032
2957
  * consensusStateId: "DOT0"
3033
2958
  * })
3034
- * await hyperbridgeChain.connect()
3035
2959
  *
3036
2960
  * const client = new IndexerClient({
3037
2961
  * queryClient: queryClient,
@@ -3041,29 +2965,6 @@ declare function createIndexerClient(config: {
3041
2965
  * hyperbridge: hyperbridgeChain
3042
2966
  * });
3043
2967
  *
3044
- * // Legacy approach: Use the helper function (deprecated)
3045
- * const client = await createIndexerClient({
3046
- * queryClient: queryClient,
3047
- * pollInterval: 2000,
3048
- * source: {
3049
- * stateMachineId: "EVM-1",
3050
- * consensusStateId: "ETH0",
3051
- * rpcUrl: "https://eth-rpc.com",
3052
- * host: "0x87ea45.."
3053
- * },
3054
- * dest: {
3055
- * stateMachineId: "EVM-42161",
3056
- * consensusStateId: "ETH0",
3057
- * rpcUrl: "https://arb-rpc.com",
3058
- * host: "0x87ea42345.."
3059
- * },
3060
- * hyperbridge: {
3061
- * stateMachineId: "POLKADOT-3367",
3062
- * consensusStateId: "DOT0",
3063
- * wsUrl: "ws://localhost:9944"
3064
- * }
3065
- * });
3066
- *
3067
2968
  * // Query a request status
3068
2969
  * const status = await client.queryRequestWithStatus("0x1234...");
3069
2970
  *
@@ -3598,183 +3499,6 @@ declare class Swap {
3598
3499
  private getTickSpacing;
3599
3500
  }
3600
3501
 
3601
- /**
3602
- * IntentGateway handles cross-chain intent operations between EVM chains.
3603
- * It provides functionality for estimating fill orders, finding optimal swap protocols,
3604
- * and checking order statuses across different chains.
3605
- */
3606
- declare class IntentGateway {
3607
- readonly source: EvmChain;
3608
- readonly dest: EvmChain;
3609
- readonly swap: Swap;
3610
- private readonly storage;
3611
- /**
3612
- * Optional custom IntentGateway address for the destination chain.
3613
- * If set, this address will be used when fetching destination proofs in `cancelOrder`.
3614
- * If not set, uses the default address from the chain configuration.
3615
- * This allows using different IntentGateway contract versions (e.g., old vs new contracts).
3616
- */
3617
- destIntentGatewayAddress?: HexString;
3618
- /**
3619
- * Creates a new IntentGateway instance for cross-chain operations.
3620
- * @param source - The source EVM chain
3621
- * @param dest - The destination EVM chain
3622
- * @param destIntentGatewayAddress - Optional custom IntentGateway address for the destination chain.
3623
- * If provided, this address will be used when fetching destination proofs in `cancelOrder`.
3624
- * If not provided, uses the default address from the chain configuration.
3625
- */
3626
- constructor(source: EvmChain, dest: EvmChain, destIntentGatewayAddress?: HexString);
3627
- /**
3628
- * Estimates the total cost required to fill an order, including gas fees, relayer fees,
3629
- * protocol fees, and swap operations.
3630
- *
3631
- * @param order - The order to estimate fill costs for
3632
- * @returns An object containing the estimated cost in both fee token and native token, plus the post request calldata
3633
- */
3634
- estimateFillOrder(order: Order): Promise<{
3635
- order: Order;
3636
- feeTokenAmount: bigint;
3637
- nativeTokenAmount: bigint;
3638
- postRequestCalldata: HexString;
3639
- }>;
3640
- /**
3641
- * Converts fee token amounts back to the equivalent amount in native token.
3642
- * Uses USD pricing to convert between fee token amounts and native token costs.
3643
- *
3644
- * @param feeTokenAmount - The amount in fee token (DAI)
3645
- * @param getQuoteIn - Whether to use "source" or "dest" chain for the conversion
3646
- * @param evmChainID - The EVM chain ID in format "EVM-{id}"
3647
- * @returns The fee token amount converted to native token amount
3648
- * @private
3649
- */
3650
- private convertFeeTokenToNative;
3651
- /**
3652
- * Converts gas costs to the equivalent amount in the fee token (DAI).
3653
- * Uses USD pricing to convert between native token gas costs and fee token amounts.
3654
- *
3655
- * @param gasEstimate - The estimated gas units
3656
- * @param gasEstimateIn - Whether to use "source" or "dest" chain for the conversion
3657
- * @param evmChainID - The EVM chain ID in format "EVM-{id}"
3658
- * @returns The gas cost converted to fee token amount
3659
- * @private
3660
- */
3661
- private convertGasToFeeToken;
3662
- /**
3663
- * Gets a quote for the native token cost of dispatching a post request.
3664
- *
3665
- * @param postRequest - The post request to quote
3666
- * @param fee - The fee amount in fee token
3667
- * @returns The native token amount required
3668
- */
3669
- quoteNative(postRequest: IPostRequest, fee: bigint): Promise<bigint>;
3670
- /**
3671
- * Checks if an order has been filled by verifying the commitment status on-chain.
3672
- * Reads the storage slot corresponding to the order's commitment hash.
3673
- *
3674
- * @param order - The order to check
3675
- * @returns True if the order has been filled, false otherwise
3676
- */
3677
- isOrderFilled(order: Order): Promise<boolean>;
3678
- /**
3679
- * Checks if an order has been refunded by verifying the escrowed token amounts on-chain.
3680
- * Reads the storage slots for the `_orders` mapping on the source chain (where the escrow is held).
3681
- * An order is considered refunded when all input token amounts in the `_orders` mapping are 0.
3682
- *
3683
- * @param order - The order to check
3684
- * @returns True if the order has been refunded (all token amounts are 0), false otherwise
3685
- */
3686
- isOrderRefunded(order: Order): Promise<boolean>;
3687
- private submitAndConfirmReceipt;
3688
- /**
3689
- * Returns the native token amount required to dispatch a cancellation GET request for the given order.
3690
- * Internally constructs the IGetRequest and calls quoteNative.
3691
- */
3692
- quoteCancelNative(order: Order): Promise<bigint>;
3693
- /**
3694
- * Cancels an order through the cross-chain protocol by generating and submitting proofs.
3695
- * This is an async generator function that yields status updates throughout the cancellation process.
3696
- *
3697
- * The cancellation process involves:
3698
- * 1. Fetching proof from the destination chain that the order exists
3699
- * 2. Creating a GET request to retrieve the order state
3700
- * 3. Waiting for the source chain to finalize the request
3701
- * 4. Fetching proof from the source chain
3702
- * 5. Waiting for the challenge period to complete
3703
- * 6. Submitting the request message to Hyperbridge
3704
- * 7. Monitoring until Hyperbridge finalizes the cancellation
3705
- *
3706
- * @param order - The order to cancel, containing source/dest chains, deadline, and other order details
3707
- * @param indexerClient - Client for querying the indexer and interacting with Hyperbridge
3708
- *
3709
- * @yields {CancelEvent} Status updates during the cancellation process:
3710
- * - DESTINATION_FINALIZED: Destination proof has been obtained
3711
- * - AWAITING_GET_REQUEST: Waiting for GET request to be provided
3712
- * - SOURCE_FINALIZED: Source chain has finalized the request
3713
- * - HYPERBRIDGE_DELIVERED: Hyperbridge has delivered the request
3714
- * - HYPERBRIDGE_FINALIZED: Cancellation is complete
3715
- *
3716
- * @throws {Error} If GET request is not provided when needed
3717
- *
3718
- * @example
3719
- * ```typescript
3720
- * // Using default IntentGateway address
3721
- * const intentGateway = new IntentGateway(sourceChain, destChain);
3722
- * const cancelStream = intentGateway.cancelOrder(order, indexerClient);
3723
- *
3724
- * // Using custom IntentGateway address (e.g., for old contract version)
3725
- * const intentGateway = new IntentGateway(
3726
- * sourceChain,
3727
- * destChain,
3728
- * "0xd54165e45926720b062C192a5bacEC64d5bB08DA"
3729
- * );
3730
- * const cancelStream = intentGateway.cancelOrder(order, indexerClient);
3731
- *
3732
- * // Or set it after instantiation
3733
- * const intentGateway = new IntentGateway(sourceChain, destChain);
3734
- * intentGateway.destIntentGatewayAddress = "0xd54165e45926720b062C192a5bacEC64d5bB08DA";
3735
- * const cancelStream = intentGateway.cancelOrder(order, indexerClient);
3736
- *
3737
- * for await (const event of cancelStream) {
3738
- * switch (event.status) {
3739
- * case 'SOURCE_FINALIZED':
3740
- * console.log('Source finalized at block:', event.data.metadata.blockNumber);
3741
- * break;
3742
- * case 'HYPERBRIDGE_FINALIZED':
3743
- * console.log('Cancellation complete');
3744
- * break;
3745
- * }
3746
- * }
3747
- * ```
3748
- */
3749
- cancelOrder(order: Order, indexerClient: IndexerClient): AsyncGenerator<CancelEvent$1>;
3750
- /**
3751
- * Fetches proof for the destination chain.
3752
- * @param order - The order to fetch proof for
3753
- * @param indexerClient - Client for querying the indexer
3754
- */
3755
- private fetchDestinationProof;
3756
- }
3757
- interface CancelEventMap {
3758
- DESTINATION_FINALIZED: {
3759
- proof: IProof;
3760
- };
3761
- AWAITING_GET_REQUEST: undefined;
3762
- SOURCE_FINALIZED: {
3763
- metadata: {
3764
- blockNumber: number;
3765
- };
3766
- };
3767
- HYPERBRIDGE_DELIVERED: RequestStatusWithMetadata;
3768
- HYPERBRIDGE_FINALIZED: RequestStatusWithMetadata;
3769
- SOURCE_PROOF_RECEIVED: IProof;
3770
- }
3771
- type CancelEvent$1 = {
3772
- [K in keyof CancelEventMap]: {
3773
- status: K;
3774
- data: CancelEventMap[K];
3775
- };
3776
- }[keyof CancelEventMap];
3777
-
3778
3502
  type StorageDriverKey = "node" | "localstorage" | "indexeddb" | "memory";
3779
3503
  interface CancellationStorageOptions {
3780
3504
  env?: StorageDriverKey;
@@ -3987,10 +3711,10 @@ interface BundlerGasEstimate {
3987
3711
  *
3988
3712
  * - `DESTINATION_FINALIZED` – a state proof from the destination chain is ready.
3989
3713
  * - `AWAITING_CANCEL_TRANSACTION` – the caller must sign and submit the cancel tx.
3714
+ * - `CANCEL_STARTED` – the cancel transaction was confirmed on-chain.
3990
3715
  * - `SOURCE_FINALIZED` – the cancel request has been finalised on the source chain.
3991
3716
  * - `HYPERBRIDGE_DELIVERED` – the cancel message has been delivered to Hyperbridge.
3992
3717
  * - `HYPERBRIDGE_FINALIZED` – the cancel message has been finalised on Hyperbridge.
3993
- * - `SOURCE_PROOF_RECEIVED` – a proof of the source-chain state has been received.
3994
3718
  * - `CANCELLATION_COMPLETE` – the escrow has been refunded; cancellation is done.
3995
3719
  */
3996
3720
  type CancelEvent = {
@@ -4001,6 +3725,9 @@ type CancelEvent = {
4001
3725
  data: HexString;
4002
3726
  to: HexString;
4003
3727
  value: bigint;
3728
+ } | {
3729
+ status: "CANCEL_STARTED";
3730
+ receipt: TransactionReceipt;
4004
3731
  } | {
4005
3732
  status: "SOURCE_FINALIZED";
4006
3733
  metadata: Extract<RequestStatusWithMetadata, {
@@ -4016,9 +3743,6 @@ type CancelEvent = {
4016
3743
  metadata: Extract<RequestStatusWithMetadata, {
4017
3744
  status: "HYPERBRIDGE_FINALIZED";
4018
3745
  }>["metadata"];
4019
- } | {
4020
- status: "SOURCE_PROOF_RECEIVED";
4021
- proof: IProof;
4022
3746
  } | {
4023
3747
  status: "CANCELLATION_COMPLETE";
4024
3748
  blockNumber: number;
@@ -4032,7 +3756,7 @@ type CancelEvent = {
4032
3756
  * reference to this object so they can share fee-token caches, storage
4033
3757
  * adapters, and chain clients without duplicating initialisation logic.
4034
3758
  */
4035
- interface IntentsV2Context {
3759
+ interface IntentGatewayContext {
4036
3760
  /** EVM chain on which orders are placed and escrowed. */
4037
3761
  source: IEvmChain;
4038
3762
  /** EVM chain on which solvers fill orders and receive outputs. */
@@ -4068,7 +3792,7 @@ interface IntentsV2Context {
4068
3792
  /**
4069
3793
  * High-level facade for the IntentGatewayV2 protocol.
4070
3794
  *
4071
- * `IntentsV2` orchestrates the complete lifecycle of an intent-based
3795
+ * `IntentGateway` orchestrates the complete lifecycle of an intent-based
4072
3796
  * cross-chain swap:
4073
3797
  * - **Order placement** — encodes and yields `placeOrder` calldata; caller
4074
3798
  * signs and submits the transaction.
@@ -4084,9 +3808,9 @@ interface IntentsV2Context {
4084
3808
  * {@link OrderExecutor}, {@link OrderCanceller}, {@link BidManager},
4085
3809
  * {@link GasEstimator}, {@link OrderStatusChecker}, and {@link CryptoUtils}.
4086
3810
  *
4087
- * Use `IntentsV2.create()` to obtain an initialised instance.
3811
+ * Use `IntentGateway.create()` to obtain an initialised instance.
4088
3812
  */
4089
- declare class IntentsV2 {
3813
+ declare class IntentGateway {
4090
3814
  /** EVM chain on which orders are placed and escrowed. */
4091
3815
  readonly source: IEvmChain;
4092
3816
  /** EVM chain on which solvers fill orders and deliver outputs. */
@@ -4112,7 +3836,7 @@ declare class IntentsV2 {
4112
3836
  /** Estimates gas costs for filling an order and converts them to fee-token amounts. */
4113
3837
  private readonly gasEstimator;
4114
3838
  /**
4115
- * Private constructor — use {@link IntentsV2.create} instead.
3839
+ * Private constructor — use {@link IntentGateway.create} instead.
4116
3840
  *
4117
3841
  * Initialises all sub-modules and the shared context, including storage
4118
3842
  * adapters, fee-token and solver-code caches, and the DEX-quote utility.
@@ -4120,28 +3844,29 @@ declare class IntentsV2 {
4120
3844
  * @param source - Source chain client.
4121
3845
  * @param dest - Destination chain client.
4122
3846
  * @param intentsCoprocessor - Optional coprocessor for bid fetching.
4123
- * @param bundlerUrl - Optional ERC-4337 bundler endpoint URL.
4124
3847
  */
4125
3848
  private constructor();
4126
3849
  /**
4127
- * Creates an initialized IntentsV2 instance.
3850
+ * Creates an initialized IntentGateway instance.
4128
3851
  *
4129
3852
  * Fetches the fee tokens for both chains and optionally caches the solver
4130
3853
  * account bytecode before returning, so the instance is ready for use
4131
3854
  * without additional warm-up calls.
4132
3855
  *
3856
+ * The ERC-4337 bundler URL is read from `dest.bundlerUrl`, set when constructing
3857
+ * the destination chain via {@link EvmChain.create} or {@link EvmChainParams.bundlerUrl}.
3858
+ *
4133
3859
  * @param source - Source chain for order placement
4134
3860
  * @param dest - Destination chain for order fulfillment
4135
3861
  * @param intentsCoprocessor - Optional coprocessor for bid fetching and order execution
4136
- * @param bundlerUrl - Optional ERC-4337 bundler URL for gas estimation and UserOp submission
4137
- * @returns Initialized IntentsV2 instance
3862
+ * @returns Initialized IntentGateway instance
4138
3863
  */
4139
- static create(source: IEvmChain, dest: IEvmChain, intentsCoprocessor?: IntentsCoprocessor, bundlerUrl?: string): Promise<IntentsV2>;
3864
+ static create(source: IEvmChain, dest: IEvmChain, intentsCoprocessor?: IntentsCoprocessor): Promise<IntentGateway>;
4140
3865
  /**
4141
3866
  * Pre-warms the fee-token cache for both chains and attempts to load the
4142
3867
  * solver account bytecode into the solver-code cache.
4143
3868
  *
4144
- * Called automatically by {@link IntentsV2.create}; not intended for direct use.
3869
+ * Called automatically by {@link IntentGateway.create}; not intended for direct use.
4145
3870
  */
4146
3871
  private init;
4147
3872
  /**
@@ -4172,12 +3897,16 @@ declare class IntentsV2 {
4172
3897
  * @throws If the `placeOrder` generator behaves unexpectedly, or if gas
4173
3898
  * estimation returns zero.
4174
3899
  */
4175
- execute(order: OrderV2, graffiti?: HexString, options?: {
3900
+ execute(order: Order, graffiti?: HexString, options?: {
4176
3901
  maxPriorityFeePerGasBumpPercent?: number;
4177
3902
  maxFeePerGasBumpPercent?: number;
4178
3903
  minBids?: number;
4179
3904
  bidTimeoutMs?: number;
4180
3905
  pollIntervalMs?: number;
3906
+ solver?: {
3907
+ address: HexString;
3908
+ timeoutMs: number;
3909
+ };
4181
3910
  }): AsyncGenerator<IntentOrderStatusUpdate, void, HexString>;
4182
3911
  /**
4183
3912
  * Quotes the native token cost for cancelling an order.
@@ -4185,11 +3914,11 @@ declare class IntentsV2 {
4185
3914
  * Delegates to {@link OrderCanceller.quoteCancelNative}.
4186
3915
  *
4187
3916
  * @param order - The order to quote cancellation for.
4188
- * @param from - Chain side that initiates the cancel (`"source"` or `"dest"`).
4189
- * Defaults to `"source"`.
3917
+ * @param fromDest - If `true`, quotes the destination-initiated cancellation fee.
3918
+ * Defaults to `false` (source-side cancellation).
4190
3919
  * @returns The native token amount required to submit the cancel transaction.
4191
3920
  */
4192
- quoteCancelNative(order: OrderV2, from?: "source" | "dest"): Promise<bigint>;
3921
+ quoteCancelNative(order: Order, fromDest?: boolean): Promise<bigint>;
4193
3922
  /**
4194
3923
  * Async generator that cancels an order and streams status events until
4195
3924
  * cancellation is complete.
@@ -4198,10 +3927,11 @@ declare class IntentsV2 {
4198
3927
  *
4199
3928
  * @param order - The order to cancel.
4200
3929
  * @param indexerClient - Indexer client used for ISMP request status streaming.
4201
- * @param from - Chain side that initiates the cancel. Defaults to `"source"`.
3930
+ * @param fromDest - If `true`, initiates cancellation from the destination chain.
3931
+ * Defaults to `false` (source-side cancellation).
4202
3932
  * @yields {@link CancelEvent} objects describing each cancellation stage.
4203
3933
  */
4204
- cancelOrder(order: OrderV2, indexerClient: IndexerClient, from?: "source" | "dest"): AsyncGenerator<CancelEvent>;
3934
+ cancelOrder(order: Order, indexerClient: IndexerClient, fromDest?: boolean): AsyncGenerator<CancelEvent>;
4205
3935
  /**
4206
3936
  * Constructs a signed `PackedUserOperation` for a solver to submit as a bid.
4207
3937
  *
@@ -4225,18 +3955,18 @@ declare class IntentsV2 {
4225
3955
  * @returns A {@link SelectBidResult} with the submitted UserOperation, hashes,
4226
3956
  * and fill status.
4227
3957
  */
4228
- selectBid(order: OrderV2, bids: FillerBid[], sessionPrivateKey?: HexString): Promise<SelectBidResult>;
3958
+ selectBid(order: Order, bids: FillerBid[], sessionPrivateKey?: HexString): Promise<SelectBidResult>;
4229
3959
  /**
4230
3960
  * Estimates the gas cost for filling the given order, returning individual
4231
3961
  * gas components and fee-token-denominated totals.
4232
3962
  *
4233
- * Delegates to {@link GasEstimator.estimateFillOrderV2}.
3963
+ * Delegates to {@link GasEstimator.estimateFillOrder}.
4234
3964
  *
4235
3965
  * @param params - Estimation parameters including the order and optional
4236
3966
  * gas-price bump percentages.
4237
- * @returns A {@link FillOrderEstimateV2} with all gas components.
3967
+ * @returns A {@link FillOrderEstimate} with all gas components.
4238
3968
  */
4239
- estimateFillOrderV2(params: EstimateFillOrderV2Params): Promise<FillOrderEstimateV2>;
3969
+ estimateFillOrder(params: EstimateFillOrderParams): Promise<FillOrderEstimate>;
4240
3970
  /**
4241
3971
  * Encodes a list of calls into ERC-7821 `execute` calldata using
4242
3972
  * single-batch mode.
@@ -4265,7 +3995,7 @@ declare class IntentsV2 {
4265
3995
  * @returns `true` if the order's commitment slot on the destination chain is
4266
3996
  * non-zero (i.e. `fillOrder` has been called successfully).
4267
3997
  */
4268
- isOrderFilled(order: OrderV2): Promise<boolean>;
3998
+ isOrderFilled(order: Order): Promise<boolean>;
4269
3999
  /**
4270
4000
  * Checks whether all escrowed inputs for an order have been refunded on the
4271
4001
  * source chain.
@@ -4276,7 +4006,7 @@ declare class IntentsV2 {
4276
4006
  * @returns `true` if every input token's escrowed amount has been zeroed out
4277
4007
  * in the `_orders` mapping on the source chain.
4278
4008
  */
4279
- isOrderRefunded(order: OrderV2): Promise<boolean>;
4009
+ isOrderRefunded(order: Order): Promise<boolean>;
4280
4010
  }
4281
4011
 
4282
4012
  /**
@@ -4291,7 +4021,7 @@ declare class OrderStatusChecker {
4291
4021
  * @param ctx - Shared IntentsV2 context providing the source and destination
4292
4022
  * chain clients and config service.
4293
4023
  */
4294
- constructor(ctx: IntentsV2Context);
4024
+ constructor(ctx: IntentGatewayContext);
4295
4025
  /**
4296
4026
  * Checks if a V2 order has been filled by reading the commitment storage slot on the destination chain.
4297
4027
  *
@@ -4302,7 +4032,7 @@ declare class OrderStatusChecker {
4302
4032
  * @param order - The V2 order to check. `order.id` is used as the commitment; if not set it is computed.
4303
4033
  * @returns True if the order has been filled on the destination chain, false otherwise.
4304
4034
  */
4305
- isOrderFilled(order: OrderV2): Promise<boolean>;
4035
+ isOrderFilled(order: Order): Promise<boolean>;
4306
4036
  /**
4307
4037
  * Checks if a V2 order has been refunded by reading the `_orders` mapping on the source chain.
4308
4038
  *
@@ -4313,7 +4043,7 @@ declare class OrderStatusChecker {
4313
4043
  * @param order - The V2 order to check. `order.id` is used as the commitment; if not set it is computed.
4314
4044
  * @returns True if all escrowed inputs have been returned to the user on the source chain, false otherwise.
4315
4045
  */
4316
- isOrderRefunded(order: OrderV2): Promise<boolean>;
4046
+ isOrderRefunded(order: Order): Promise<boolean>;
4317
4047
  }
4318
4048
 
4319
4049
  /**
@@ -4348,10 +4078,10 @@ declare function encodeERC7821ExecuteBatch(calls: ERC7821Call[]): HexString;
4348
4078
  */
4349
4079
  declare function fetchSourceProof(commitment: HexString, source: IEvmChain, sourceStateMachine: string, sourceConsensusStateId: string, sourceHeight: bigint): Promise<IProof>;
4350
4080
  /**
4351
- * Strips SDK-only fields from an {@link OrderV2} and normalises all fields to
4081
+ * Strips SDK-only fields from an {@link Order} and normalises all fields to
4352
4082
  * the encoding the IntentGatewayV2 contract ABI expects:
4353
4083
  *
4354
- * - `id` and `transactionHash` are removed (not part of the on-chain struct).
4084
+ * - `id` is removed (not part of the on-chain struct).
4355
4085
  * - `source` and `destination` are hex-encoded if currently plain string
4356
4086
  * state-machine IDs.
4357
4087
  * - `inputs[i].token`, `output.beneficiary`, `output.assets[i].token`, and
@@ -4361,9 +4091,20 @@ declare function fetchSourceProof(commitment: HexString, source: IEvmChain, sour
4361
4091
  * these fields back to `address`. Values already at 32 bytes are unchanged.
4362
4092
  *
4363
4093
  * @param order - The SDK-level order to transform.
4364
- * @returns A contract-compatible order struct without `id` or `transactionHash`.
4094
+ * @returns A contract-compatible order struct without `id`.
4095
+ */
4096
+ declare function transformOrderForContract(order: Order): Omit<Order, "id">;
4097
+ /**
4098
+ * Calculates the commitment hash for an order by ABI-encoding the
4099
+ * contract-normalised form of the order and hashing it.
4100
+ *
4101
+ * Calls `transformOrderForContract` before encoding to ensure all address
4102
+ * fields are padded to 32 bytes and SDK-only fields are stripped.
4103
+ *
4104
+ * @param order - The SDK-level order to hash.
4105
+ * @returns The keccak256 commitment hash.
4365
4106
  */
4366
- declare function transformOrderForContract(order: OrderV2): Omit<OrderV2, "id" | "transactionHash">;
4107
+ declare function orderCommitment(order: Order): HexString;
4367
4108
 
4368
4109
  /**
4369
4110
  * EIP-712 type hash for the `SelectSolver` struct.
@@ -8106,13 +7847,68 @@ declare enum Chains {
8106
7847
  MAINNET = "EVM-1",
8107
7848
  BSC_MAINNET = "EVM-56",
8108
7849
  ARBITRUM_MAINNET = "EVM-42161",
7850
+ ARBITRUM_SEPOLIA = "EVM-421614",
8109
7851
  BASE_MAINNET = "EVM-8453",
7852
+ BASE_SEPOLIA = "EVM-84532",
7853
+ OPTIMISM_MAINNET = "EVM-10",
7854
+ OPTIMISM_SEPOLIA = "EVM-11155420",
7855
+ GNOSIS_MAINNET = "EVM-100",
7856
+ SONEIUM_MAINNET = "EVM-1868",
8110
7857
  POLYGON_MAINNET = "EVM-137",
8111
7858
  UNICHAIN_MAINNET = "EVM-130",
8112
7859
  POLYGON_AMOY = "EVM-80002",
7860
+ POLKADOT_ASSET_HUB_PASEO = "EVM-420420417",
8113
7861
  TRON_MAINNET = "EVM-728126428",
8114
7862
  TRON_NILE = "EVM-3448148188"
8115
7863
  }
7864
+ /** Polkadot Asset Hub Paseo testnet (chain ID 420420417) — not in viem/chains */
7865
+ declare const polkadotAssetHubPaseo: {
7866
+ blockExplorers: {
7867
+ readonly default: {
7868
+ readonly name: "Routescan";
7869
+ readonly url: "https://polkadot.testnet.routescan.io";
7870
+ };
7871
+ };
7872
+ blockTime?: number | undefined | undefined;
7873
+ contracts?: {
7874
+ [x: string]: viem.ChainContract | {
7875
+ [sourceId: number]: viem.ChainContract | undefined;
7876
+ } | undefined;
7877
+ ensRegistry?: viem.ChainContract | undefined;
7878
+ ensUniversalResolver?: viem.ChainContract | undefined;
7879
+ multicall3?: viem.ChainContract | undefined;
7880
+ erc6492Verifier?: viem.ChainContract | undefined;
7881
+ } | undefined;
7882
+ ensTlds?: readonly string[] | undefined;
7883
+ id: 420420417;
7884
+ name: "Polkadot Asset Hub (Paseo)";
7885
+ nativeCurrency: {
7886
+ readonly name: "PAS";
7887
+ readonly symbol: "PAS";
7888
+ readonly decimals: 10;
7889
+ };
7890
+ experimental_preconfirmationTime?: number | undefined | undefined;
7891
+ rpcUrls: {
7892
+ readonly default: {
7893
+ readonly http: readonly ["https://testnet-asset-hub-eth-rpc.polkadot.io"];
7894
+ };
7895
+ };
7896
+ sourceId?: number | undefined | undefined;
7897
+ testnet?: boolean | undefined | undefined;
7898
+ custom?: Record<string, unknown> | undefined;
7899
+ extendSchema?: Record<string, unknown> | undefined;
7900
+ fees?: viem.ChainFees<undefined> | undefined;
7901
+ formatters?: undefined;
7902
+ prepareTransactionRequest?: ((args: viem.PrepareTransactionRequestParameters, options: {
7903
+ phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
7904
+ }) => Promise<viem.PrepareTransactionRequestParameters>) | [fn: ((args: viem.PrepareTransactionRequestParameters, options: {
7905
+ phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
7906
+ }) => Promise<viem.PrepareTransactionRequestParameters>) | undefined, options: {
7907
+ runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
7908
+ }] | undefined;
7909
+ serializers?: viem.ChainSerializers<undefined, viem.TransactionSerializable> | undefined;
7910
+ verifyHash?: ((client: viem.Client, parameters: viem.VerifyHashActionParameters) => Promise<viem.VerifyHashActionReturnType>) | undefined;
7911
+ };
8116
7912
  /** Tron Nile Testnet (chain ID 3448148188) — not in viem/chains */
8117
7913
  declare const tronNile: {
8118
7914
  blockExplorers: {
@@ -8233,4 +8029,4 @@ declare const getChainId: (stateMachineId: string) => number | undefined;
8233
8029
  declare const getViemChain: (chainId: number) => Chain | undefined;
8234
8030
  declare const hyperbridgeAddress = "";
8235
8031
 
8236
- export { ADDRESS_ZERO, type AllStatusKey, type AssetTeleported, type AssetTeleportedResponse, type BidStorageEntry, type BidSubmissionResult, type BlockMetadata, type BundlerGasEstimate, BundlerMethod, type CancelEvent, 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, ABI as EvmHostABI, 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, ABI$1 as IntentGatewayV2ABI, IntentOrderStatus, type IntentOrderStatusKey, 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 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 };
8032
+ export { ADDRESS_ZERO, type AllStatusKey, type AssetTeleported, type AssetTeleportedResponse, type BidStorageEntry, type BidSubmissionResult, type BlockMetadata, type BundlerGasEstimate, BundlerMethod, type CancelEvent, type CancelOptions, type ChainConfig, type ChainConfigData, ChainConfigService, Chains, type ClientConfig, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DOMAIN_TYPEHASH, DUMMY_PRIVATE_KEY, type DecodedOrderPlacedLog, type DecodedPostRequestEvent, type DecodedPostResponseEvent, type DispatchGet, type DispatchInfo, type DispatchPost, ERC20Method, type ERC7821Call, ERC7821_BATCH_MODE, type EstimateFillOrderParams, type EstimateGasCallData, EvmChain, type EvmChainParams, ABI as EvmHostABI, EvmLanguage, type ExecuteIntentOrderOptions, type ExecutionResult, type FillOptions, type FillOrderEstimate, 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 IntentGatewayContext, type IntentGatewayParams, ABI$1 as IntentGatewayV2ABI, IntentOrderStatus, type IntentOrderStatusKey, type IntentOrderStatusUpdate, IntentsCoprocessor, type IsmpRequest, MOCK_ADDRESS, type NewDeployment, ORDER_V2_PARAM_TYPE, type Order, type OrderResponse, OrderStatus, OrderStatusChecker, type OrderStatusMetadata, type OrderWithStatus, PACKED_USEROP_TYPEHASH, PLACE_ORDER_SELECTOR, type PackedUserOperation, type Params, type PaymentInfo, 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 TokenPrice, type TokenPricesResponse, 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, createEvmChain, createQueryClient, decodeUserOpScale, encodeERC7821ExecuteBatch, encodeISMPMessage, encodeUserOpScale, encodeWithdrawalRequest, estimateGasForPost, fetchPrice, fetchSourceProof, generateRootWithProof, getChainId, getConfigByStateMachineId, getContractCallInput, getGasPriceFromEtherscan, getOrFetchStorageSlot, getOrderPlacedFromTx, getPostRequestEventFromTx, getPostResponseEventFromTx, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, getViemChain, hexToString, hyperbridgeAddress, maxBigInt, orderCommitment, parseStateMachineId, polkadotAssetHubPaseo, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, requestCommitmentKey, retryPromise, teleport, teleportDot, transformOrderForContract, tronChainIds, tronNile };