@hyperbridge/sdk 1.3.25 → 1.4.0

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.
@@ -1,7 +1,7 @@
1
1
  import { ConsolaInstance } from 'consola';
2
2
  import { GraphQLClient } from 'graphql-request';
3
3
  import * as viem from 'viem';
4
- import { Hex, ContractFunctionArgs, Log, PublicClient } from 'viem';
4
+ import { PublicClient, Hex, ContractFunctionArgs, Log } from 'viem';
5
5
  import { ApiPromise } from '@polkadot/api';
6
6
  import { SignerOptions } from '@polkadot/api/types';
7
7
  import { Chain } from 'viem/chains';
@@ -586,1647 +586,1703 @@ declare const _default: {
586
586
  }];
587
587
  };
588
588
 
589
- type EstimateGasCallData = ContractFunctionArgs<typeof _default.ABI, "nonpayable" | "payable", "handlePostRequests">;
590
- type HexString = `0x${string}`;
591
- interface IConfig {
592
- source: IEvmConfig | ISubstrateConfig;
593
- dest: IEvmConfig | ISubstrateConfig;
594
- hyperbridge: IHyperbridgeConfig;
595
- tracing?: boolean;
589
+ declare class ChainConfigService {
590
+ private rpcUrls;
591
+ constructor(env?: NodeJS.ProcessEnv);
592
+ getChainConfig(chain: string): ChainConfig;
593
+ getIntentGatewayAddress(chain: string): `0x${string}`;
594
+ getHostAddress(chain: string): `0x${string}`;
595
+ getWrappedNativeAssetWithDecimals(chain: string): {
596
+ asset: HexString;
597
+ decimals: number;
598
+ };
599
+ getDaiAsset(chain: string): HexString;
600
+ getUsdtAsset(chain: string): HexString;
601
+ getUsdcAsset(chain: string): HexString;
602
+ getChainId(chain: string): number;
603
+ getConsensusStateId(chain: string): HexString;
604
+ getHyperbridgeChainId(): number;
605
+ getRpcUrl(chain: string): string;
606
+ getUniswapRouterV2Address(chain: string): HexString;
607
+ getUniswapV2FactoryAddress(chain: string): HexString;
608
+ getUniversalRouterAddress(chain: string): HexString;
609
+ getUniswapV3QuoterAddress(chain: string): HexString;
610
+ getUniswapV4QuoterAddress(chain: string): HexString;
611
+ getPermit2Address(chain: string): HexString;
612
+ getCoingeckoId(chain: string): string | undefined;
613
+ getEtherscanApiKey(): string | undefined;
614
+ getCalldispatcherAddress(chain: string): HexString;
596
615
  }
597
- interface IEvmConfig {
616
+
617
+ /**
618
+ * The default address used as fallback when no address is provided.
619
+ * This represents the zero address in EVM chains.
620
+ */
621
+ declare const DEFAULT_ADDRESS = "0x0000000000000000000000000000000000000000";
622
+ /**
623
+ * Parameters for an EVM chain.
624
+ */
625
+ interface EvmChainParams {
626
+ /**
627
+ * The chain ID of the EVM chain
628
+ */
629
+ chainId: number;
630
+ /**
631
+ * The RPC URL of the EVM chain
632
+ */
598
633
  rpcUrl: string;
599
- stateMachineId: string;
600
- host: string;
601
- consensusStateId: string;
602
- }
603
- interface ISubstrateConfig {
604
- wsUrl: string;
605
- consensusStateId: string;
606
- hasher: "Keccak" | "Blake2";
607
- stateMachineId: string;
608
- }
609
- interface IHyperbridgeConfig {
610
- wsUrl: string;
611
- stateMachineId: string;
612
- consensusStateId: string;
613
- }
614
- interface IPostRequest {
615
- source: string;
616
- dest: string;
617
- from: HexString;
618
- to: HexString;
619
- nonce: bigint;
620
- body: HexString;
621
- timeoutTimestamp: bigint;
622
- }
623
- interface IGetRequest {
624
- source: string;
625
- dest: string;
626
- from: HexString;
627
- nonce: bigint;
628
- height: bigint;
629
- keys: HexString[];
630
- timeoutTimestamp: bigint;
631
- context: HexString;
632
- }
633
- interface GetResponseStorageValues {
634
- key: HexString;
635
- value: HexString;
636
- }
637
- interface IPostResponse {
638
- post: IPostRequest;
639
- response: string;
640
- timeoutTimestamp: bigint;
641
- }
642
- type IMessage = {
643
- Requests: HexString[];
644
- } | {
645
- Responses: HexString[];
646
- };
647
- type IndexerQueryClient = GraphQLClient;
648
- interface ClientConfig {
649
- pollInterval: number;
650
- queryClient: IndexerQueryClient;
651
- tracing?: boolean;
652
- source: IEvmConfig | ISubstrateConfig;
653
- dest: IEvmConfig | ISubstrateConfig;
654
- hyperbridge: IHyperbridgeConfig;
655
- }
656
- interface RetryConfig {
657
- maxRetries: number;
658
634
  /**
659
- * @description The initial backoff time in milliseconds before the first retry attempt.
635
+ * The host address of the EVM chain (IsmpHost contract address)
660
636
  */
661
- backoffMs: number;
662
- logMessage?: string;
663
- logger?: ConsolaInstance;
664
- }
665
- interface IsmpRequest {
666
- source: string;
667
- dest: string;
668
- from: string;
669
- to: string;
670
- nonce: bigint;
671
- body: string;
672
- timeoutTimestamp: bigint;
673
- storage_key?: string;
674
- }
675
- declare const RequestStatus: Readonly<{
676
- SOURCE: "SOURCE";
677
- SOURCE_FINALIZED: "SOURCE_FINALIZED";
678
- HYPERBRIDGE_DELIVERED: "HYPERBRIDGE_DELIVERED";
679
- HYPERBRIDGE_FINALIZED: "HYPERBRIDGE_FINALIZED";
680
- DESTINATION: "DESTINATION";
681
- TIMED_OUT: "TIMED_OUT";
682
- HYPERBRIDGE_TIMED_OUT: "HYPERBRIDGE_TIMED_OUT";
683
- }>;
684
- type RequestStatus = typeof RequestStatus;
685
- type RequestStatusKey = keyof typeof RequestStatus;
686
- declare const TimeoutStatus: Readonly<{
687
- PENDING_TIMEOUT: "PENDING_TIMEOUT";
688
- DESTINATION_FINALIZED_TIMEOUT: "DESTINATION_FINALIZED_TIMEOUT";
689
- HYPERBRIDGE_TIMED_OUT: "HYPERBRIDGE_TIMED_OUT";
690
- HYPERBRIDGE_FINALIZED_TIMEOUT: "HYPERBRIDGE_FINALIZED_TIMEOUT";
691
- TIMED_OUT: "TIMED_OUT";
692
- }>;
693
- type TimeoutStatus = typeof TimeoutStatus;
694
- type TimeoutStatusKey = keyof typeof TimeoutStatus;
695
- type AllStatusKey = RequestStatusKey | TimeoutStatusKey;
696
- declare enum HyperClientStatus {
697
- PENDING = "PENDING",
698
- SOURCE_FINALIZED = "SOURCE_FINALIZED",
699
- HYPERBRIDGE_FINALIZED = "HYPERBRIDGE_FINALIZED",
700
- HYPERBRIDGE_VERIFIED = "HYPERBRIDGE_VERIFIED",
701
- DESTINATION = "DESTINATION",
702
- TIMED_OUT = "TIMED_OUT",
703
- HYPERBRIDGE_TIMED_OUT = "HYPERBRIDGE_TIMED_OUT",
704
- ERROR = "ERROR"
705
- }
706
- declare enum OrderStatus {
707
- PLACED = "PLACED",
708
- FILLED = "FILLED",
709
- REDEEMED = "REDEEMED",
710
- REFUNDED = "REFUNDED"
711
- }
712
- declare enum TeleportStatus {
713
- TELEPORTED = "TELEPORTED",
714
- RECEIVED = "RECEIVED",
715
- REFUNDED = "REFUNDED"
716
- }
717
- interface TokenGatewayAssetTeleportedResponse {
718
- tokenGatewayAssetTeleporteds: {
719
- nodes: Array<{
720
- id: string;
721
- from: string;
722
- to: string;
723
- sourceChain: string;
724
- destChain: string;
725
- commitment: string;
726
- amount: string;
727
- usdValue: string;
728
- assetId: string;
729
- redeem: boolean;
730
- status: TeleportStatus;
731
- createdAt: string;
732
- blockNumber: string;
733
- blockTimestamp: string;
734
- transactionHash: string;
735
- statusMetadata: {
736
- nodes: Array<{
737
- status: TeleportStatus;
738
- chain: string;
739
- timestamp: string;
740
- blockNumber: string;
741
- blockHash: string;
742
- transactionHash: string;
743
- }>;
744
- };
745
- }>;
746
- };
637
+ host: HexString;
638
+ /**
639
+ * Consensus state identifier of this chain on hyperbridge
640
+ */
641
+ consensusStateId?: string;
747
642
  }
748
- interface TokenGatewayAssetTeleportedWithStatus {
749
- id: string;
750
- from: string;
751
- to: string;
752
- sourceChain: string;
753
- destChain: string;
754
- commitment: string;
755
- amount: bigint;
756
- usdValue: string;
757
- assetId: string;
758
- redeem: boolean;
759
- status: TeleportStatus;
760
- createdAt: Date;
761
- blockNumber: bigint;
762
- blockTimestamp: bigint;
763
- transactionHash: string;
764
- statuses: Array<{
765
- status: TeleportStatus;
766
- metadata: {
767
- blockHash: string;
768
- blockNumber: number;
769
- transactionHash: string;
770
- timestamp: bigint;
771
- };
643
+ /**
644
+ * Encapsulates an EVM chain.
645
+ */
646
+ declare class EvmChain implements IChain {
647
+ private readonly params;
648
+ private publicClient;
649
+ private chainConfigService;
650
+ constructor(params: EvmChainParams);
651
+ get client(): PublicClient;
652
+ get host(): HexString;
653
+ get config(): IEvmConfig;
654
+ get configService(): ChainConfigService;
655
+ /**
656
+ * Derives the key for the request receipt.
657
+ * @param {HexString} commitment - The commitment to derive the key from.
658
+ * @returns {HexString} The derived key.
659
+ */
660
+ requestReceiptKey(commitment: HexString): HexString;
661
+ /**
662
+ * Queries the request receipt.
663
+ * @param {HexString} commitment - The commitment to query.
664
+ * @returns {Promise<HexString | undefined>} The relayer address responsible for delivering the request.
665
+ */
666
+ queryRequestReceipt(commitment: HexString): Promise<HexString | undefined>;
667
+ /**
668
+ * Queries the proof of the commitments.
669
+ * @param {IMessage} message - The message to query.
670
+ * @param {string} counterparty - The counterparty address.
671
+ * @param {bigint} [at] - The block number to query at.
672
+ * @returns {Promise<HexString>} The proof.
673
+ */
674
+ queryProof(message: IMessage, counterparty: string, at?: bigint): Promise<HexString>;
675
+ /**
676
+ * Query and return the encoded storage proof for the provided keys at the given height.
677
+ * @param {bigint} at - The block height at which to query the storage proof.
678
+ * @param {HexString[]} keys - The keys for which to query the storage proof.
679
+ * @param {HexString} address - Optional contract address to fetch storage proof else default to host contract
680
+ * @returns {Promise<HexString>} The encoded storage proof.
681
+ */
682
+ queryStateProof(at: bigint, keys: HexString[], address?: HexString): Promise<HexString>;
683
+ /**
684
+ * Returns the current timestamp of the chain.
685
+ * @returns {Promise<bigint>} The current timestamp.
686
+ */
687
+ timestamp(): Promise<bigint>;
688
+ /**
689
+ * Get the latest state machine height for a given state machine ID.
690
+ * @param {StateMachineIdParams} stateMachineId - The state machine ID.
691
+ * @returns {Promise<bigint>} The latest state machine height.
692
+ */
693
+ latestStateMachineHeight(stateMachineId: StateMachineIdParams): Promise<bigint>;
694
+ /**
695
+ * Get the state machine update time for a given state machine height.
696
+ * @param {StateMachineHeight} stateMachineHeight - The state machine height.
697
+ * @returns {Promise<bigint>} The statemachine update time in seconds.
698
+ */
699
+ stateMachineUpdateTime(stateMachineHeight: StateMachineHeight): Promise<bigint>;
700
+ /**
701
+ * Get the challenge period for a given state machine id.
702
+ * @param {StateMachineIdParams} stateMachineId - The state machine ID.
703
+ * @returns {Promise<bigint>} The challenge period in seconds.
704
+ */
705
+ challengePeriod(stateMachineId: StateMachineIdParams): Promise<bigint>;
706
+ /**
707
+ * Encodes an ISMP message for the EVM chain.
708
+ * @param {IIsmpMessage} message The ISMP message to encode.
709
+ * @returns {HexString} The encoded calldata.
710
+ */
711
+ encode(message: IIsmpMessage): HexString;
712
+ /**
713
+ * Calculates the fee required to send a post request to the destination chain.
714
+ * The fee is calculated based on the per-byte fee for the destination chain
715
+ * multiplied by the size of the request body.
716
+ *
717
+ * @param request - The post request to calculate the fee for
718
+ * @returns The total fee in wei required to send the post request
719
+ */
720
+ quote(request: IPostRequest): Promise<bigint>;
721
+ quoteNative(request: IPostRequest, fee: bigint): Promise<bigint>;
722
+ private getAmountsIn;
723
+ /**
724
+ * Estimates the gas required for a post request execution on this chain.
725
+ * This function generates mock proofs for the post request, creates a state override
726
+ * with the necessary overlay root, and estimates the gas cost for executing the
727
+ * handlePostRequests transaction on the handler contract.
728
+ *
729
+ * @param request - The post request to estimate gas for
730
+ * @param paraId - The ID of the parachain (Hyperbridge) that will process the request
731
+ * @returns The estimated gas amount in gas units and the generated calldata
732
+ */
733
+ estimateGas(request: IPostRequest): Promise<{
734
+ gas: bigint;
735
+ postRequestCalldata: HexString;
772
736
  }>;
737
+ /**
738
+ * Gets the fee token address and decimals for the chain.
739
+ * This function gets the fee token address and decimals for the chain.
740
+ *
741
+ * @returns The fee token address and decimals
742
+ */
743
+ getFeeTokenWithDecimals(): Promise<{
744
+ address: HexString;
745
+ decimals: number;
746
+ }>;
747
+ /**
748
+ * Gets the nonce of the host.
749
+ * This function gets the nonce of the host.
750
+ *
751
+ * @returns The nonce of the host
752
+ */
753
+ getHostNonce(): Promise<bigint>;
773
754
  }
774
- interface BlockMetadata {
775
- blockHash: string;
776
- blockNumber: number;
777
- transactionHash: string;
778
- calldata?: string;
779
- timestamp?: number;
780
- }
781
- interface PostRequestStatus {
782
- status: RequestStatusKey;
783
- metadata: Partial<BlockMetadata>;
784
- }
785
- interface PostRequestTimeoutStatus {
786
- status: TimeoutStatusKey;
787
- metadata?: Partial<BlockMetadata>;
788
- }
789
- interface StateMachineUpdate {
790
- height: number;
791
- chain: string;
792
- blockHash: string;
793
- blockNumber: number;
794
- transactionHash: string;
795
- transactionIndex: number;
796
- stateMachineId: string;
797
- timestamp: number;
798
- }
799
- interface RequestResponse {
800
- requests: {
801
- nodes: Array<{
802
- source: string;
803
- dest: string;
804
- to: HexString;
805
- from: HexString;
806
- nonce: bigint;
807
- body: HexString;
808
- timeoutTimestamp: bigint;
809
- statusMetadata: {
810
- nodes: Array<{
811
- blockHash: string;
812
- blockNumber: string;
813
- timestamp: string;
814
- chain: string;
815
- status: string;
816
- transactionHash: string;
817
- }>;
818
- };
819
- }>;
820
- };
821
- }
822
- interface GetRequestResponse {
823
- getRequests: {
824
- nodes: Array<{
825
- source: string;
826
- dest: string;
827
- to: HexString;
828
- from: HexString;
829
- nonce: bigint;
830
- height: bigint;
831
- keys: HexString[];
832
- context: HexString;
833
- timeoutTimestamp: bigint;
834
- statusMetadata: {
835
- nodes: Array<{
836
- blockHash: string;
837
- blockNumber: string;
838
- timestamp: string;
839
- chain: string;
840
- status: string;
841
- transactionHash: string;
842
- }>;
843
- };
844
- }>;
845
- };
846
- }
847
- type RequestStatusWithMetadata = {
848
- status: RequestStatus["SOURCE"];
849
- metadata: {
850
- blockHash: string;
851
- blockNumber: number;
852
- transactionHash: string;
853
- timestamp?: number;
854
- };
855
- } | {
856
- status: RequestStatus["SOURCE_FINALIZED"];
857
- metadata: {
858
- blockHash: string;
859
- blockNumber: number;
860
- transactionHash: string;
861
- timestamp?: number;
862
- };
863
- } | {
864
- status: RequestStatus["HYPERBRIDGE_DELIVERED"];
865
- metadata: {
866
- blockHash: string;
867
- blockNumber: number;
868
- transactionHash: string;
869
- timestamp?: number;
870
- };
871
- } | {
872
- status: RequestStatus["HYPERBRIDGE_FINALIZED"];
873
- metadata: {
874
- calldata: Hex;
875
- blockHash: string;
876
- blockNumber: number;
877
- transactionHash: string;
878
- timestamp?: number;
879
- };
880
- } | {
881
- status: RequestStatus["DESTINATION"];
882
- metadata: {
883
- blockHash: string;
884
- blockNumber: number;
885
- transactionHash: string;
886
- timestamp?: number;
887
- };
888
- } | {
889
- status: TimeoutStatus["PENDING_TIMEOUT"];
890
- metadata: {
891
- blockHash: string;
892
- blockNumber: number;
893
- transactionHash: string;
894
- };
755
+ /**
756
+ * Factory function for creating EVM chain instances with common defaults
757
+ *
758
+ * @param chainId - The EVM chain ID
759
+ * @param host - The IsmpHost contract address
760
+ * @param options - Optional configuration overrides
761
+ * @returns A new EvmChain instance
762
+ *
763
+ * @example
764
+ * ```typescript
765
+ * // Create with minimal config
766
+ * const ethChain = createEvmChain(1, "0x87ea45..", {
767
+ * rpcUrl: "https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY"
768
+ * })
769
+ *
770
+ * // Create with custom consensus state ID
771
+ * const arbChain = createEvmChain(42161, "0x87ea42345..", {
772
+ * rpcUrl: "https://arb-mainnet.g.alchemy.com/v2/YOUR_KEY",
773
+ * consensusStateId: "ARB_CUSTOM"
774
+ * })
775
+ * ```
776
+ */
777
+ declare function createEvmChain(chainId: number, host: HexString, options: {
778
+ rpcUrl: string;
779
+ consensusStateId?: string;
780
+ }): EvmChain;
781
+ /**
782
+ * Slot for storing request commitments.
783
+ */
784
+ declare const REQUEST_COMMITMENTS_SLOT = 0n;
785
+ /**
786
+ * Slot index for response commitments map
787
+ */
788
+ declare const RESPONSE_COMMITMENTS_SLOT = 1n;
789
+ /**
790
+ * Slot index for requests receipts map
791
+ */
792
+ declare const REQUEST_RECEIPTS_SLOT = 2n;
793
+ /**
794
+ * Slot index for response receipts map
795
+ */
796
+ declare const RESPONSE_RECEIPTS_SLOT = 3n;
797
+ /**
798
+ * Slot index for state commitment map
799
+ */
800
+ declare const STATE_COMMITMENTS_SLOT = 5n;
801
+ declare function requestCommitmentKey(key: Hex): {
802
+ slot1: Hex;
803
+ slot2: Hex;
804
+ };
805
+ /**
806
+ * Derives the storage slot for a specific field in the StateCommitment struct
807
+ *
808
+ * struct StateCommitment {
809
+ * uint256 timestamp; // slot + 0
810
+ * bytes32 overlayRoot; // slot + 1
811
+ * bytes32 stateRoot; // slot + 2
812
+ * }
813
+ *
814
+ * @param stateMachineId - The state machine ID
815
+ * @param height - The block height
816
+ * @param field - The field index in the struct (0 for timestamp, 1 for overlayRoot, 2 for stateRoot)
817
+ * @returns The storage slot for the specific field
818
+ */
819
+ declare function getStateCommitmentFieldSlot(stateMachineId: bigint, height: bigint, field: 0 | 1 | 2): HexString;
820
+ declare function getStateCommitmentSlot(stateMachineId: bigint, height: bigint): HexString;
821
+
822
+ /**
823
+ * Generates a Merkle Mountain Range (MMR) root hash and proof for a post request.
824
+ *
825
+ * This function takes a post request and tree size, encodes it according to the PostRequest format,
826
+ * and generates both the MMR root hash and a proof. The function builds an MMR with `treeSize` leaves,
827
+ * where most leaves are variations of the encoded request (XORed with their index), except for the
828
+ * last leaf, which is the unmodified request. The proof is generated for this unmodified leaf.
829
+ *
830
+ * @param postRequest - The post request to generate the MMR root and proof for
831
+ * @param treeSize - Controls how many leaves will be added to the MMR (exactly `treeSize` leaves)
832
+ * @returns An object containing:
833
+ * - root: The MMR root hash as a hex string
834
+ * - proof: An array of hex strings representing the MMR proof for the unmodified request
835
+ * - index: The index of the unmodified request in the MMR
836
+ * - kIndex: The k-index of the unmodified request in the MMR
837
+ * - treeSize: The number of leaves in the MMR
838
+ * - mmrSize: The size of the MMR in nodes
839
+ */
840
+ declare function generateRootWithProof(postRequest: IPostRequest, treeSize: bigint): Promise<{
841
+ root: HexString;
842
+ proof: HexString[];
843
+ index: bigint;
844
+ kIndex: bigint;
845
+ treeSize: bigint;
846
+ mmrSize: bigint;
847
+ }>;
848
+ declare function __test(): Promise<string>;
849
+
850
+ type IStateMachine = {
851
+ tag: "Evm";
852
+ value: number;
895
853
  } | {
896
- status: TimeoutStatus["DESTINATION_FINALIZED_TIMEOUT"];
897
- metadata: {
898
- blockHash: string;
899
- blockNumber: number;
900
- transactionHash: string;
901
- timestamp?: number;
902
- };
854
+ tag: "Polkadot";
855
+ value: number;
903
856
  } | {
904
- status: TimeoutStatus["HYPERBRIDGE_TIMED_OUT"];
905
- metadata: {
906
- blockHash: string;
907
- blockNumber: number;
908
- transactionHash: string;
909
- timestamp?: number;
910
- };
857
+ tag: "Kusama";
858
+ value: number;
911
859
  } | {
912
- status: TimeoutStatus["HYPERBRIDGE_FINALIZED_TIMEOUT"];
913
- metadata: {
914
- calldata: Hex;
915
- blockHash: string;
916
- blockNumber: number;
917
- transactionHash: string;
918
- timestamp?: number;
919
- };
860
+ tag: "Substrate";
861
+ value: number[];
920
862
  } | {
921
- status: TimeoutStatus["TIMED_OUT"];
922
- metadata: {
923
- blockHash: string;
924
- blockNumber: number;
925
- transactionHash: string;
926
- timestamp?: number;
927
- };
863
+ tag: "Tendermint";
864
+ value: number[];
928
865
  };
929
- interface GenericRequestWithStatuses {
930
- source: string;
931
- dest: string;
932
- from: HexString;
933
- nonce: bigint;
934
- timeoutTimestamp: bigint;
935
- statuses: Array<RequestStatusWithMetadata>;
936
- }
937
- interface PostRequestWithStatus extends GenericRequestWithStatuses {
938
- to: HexString;
939
- body: HexString;
940
- }
941
- interface GetRequestWithStatus extends GenericRequestWithStatuses {
942
- height: bigint;
943
- keys: HexString[];
944
- context: HexString;
945
- commitment: HexString;
946
- }
947
- interface GetResponseByRequestIdResponse {
948
- getResponses: {
949
- nodes: Array<{
950
- id: string;
951
- commitment: string;
952
- responseMessage: string[];
953
- }>;
954
- };
955
- }
956
- interface ResponseCommitmentWithValues {
957
- commitment: string;
958
- values: string[];
959
- }
960
- interface RequestCommitment {
961
- requests: {
962
- nodes: Array<{
963
- id: string;
964
- commitment: string;
965
- }>;
966
- };
967
- }
968
- interface StateMachineResponse {
969
- stateMachineUpdateEvents: {
970
- nodes: {
971
- height: number;
972
- chain: string;
973
- blockHash: string;
974
- blockNumber: number;
975
- transactionHash: string;
976
- transactionIndex: number;
977
- stateMachineId: string;
978
- createdAt: string;
979
- }[];
980
- };
981
- }
982
- interface AssetTeleported {
983
- id: string;
984
- from: string;
985
- to: string;
986
- amount: bigint;
987
- dest: string;
866
+
867
+ declare const ADDRESS_ZERO: HexString;
868
+ declare const DUMMY_PRIVATE_KEY: HexString;
869
+ declare const DEFAULT_GRAFFITI: HexString;
870
+ /**
871
+ * Returns the maximum of two bigint values
872
+ * @param a - First bigint value
873
+ * @param b - Second bigint value
874
+ * @returns The larger of the two values
875
+ */
876
+ declare function maxBigInt(a: bigint, b: bigint): bigint;
877
+ /**
878
+ * Calculates the commitment hash for a post request.
879
+ * @param post The post request to calculate the commitment hash for.
880
+ * @returns The commitment hash and the encode packed data.
881
+ */
882
+ declare function postRequestCommitment(post: IPostRequest): {
988
883
  commitment: HexString;
989
- createdAt: Date;
990
- blockNumber: number;
991
- }
992
- interface AssetTeleportedResponse {
993
- assetTeleported: AssetTeleported;
994
- }
995
- interface StateMachineIdParams {
996
- stateId: {
997
- Evm?: number;
998
- Substrate?: HexString;
999
- Polkadot?: number;
1000
- Kusama?: number;
1001
- };
1002
- consensusStateId: HexString;
1003
- }
884
+ encodePacked: HexString;
885
+ };
886
+ declare function orderCommitment(order: Order): HexString;
1004
887
  /**
1005
- * Configuration for a blockchain chain
888
+ * Converts a bytes32 token address to bytes20 format
889
+ * This removes the extra padded zeros from the address
1006
890
  */
1007
- interface ChainConfig {
1008
- /**
1009
- * The unique identifier for the chain
1010
- */
1011
- chainId: number;
1012
- /**
1013
- * The RPC URL to connect to the chain
1014
- */
1015
- rpcUrl: string;
1016
- /**
1017
- * The address of the IntentGateway contract on this chain
1018
- */
1019
- intentGatewayAddress: string;
1020
- }
891
+ declare function bytes32ToBytes20(bytes32Address: string): HexString;
892
+ declare function bytes20ToBytes32(bytes20Address: string): HexString;
893
+ declare function hexToString(hex: string): string;
894
+ /**
895
+ * Retries a promise-returning operation with exponential backoff.
896
+ * This function will attempt to execute the operation up to maxRetries times,
897
+ * with an exponential backoff delay between attempts.
898
+ *
899
+ * @param operation The async operation to retry
900
+ * @param retryConfig Configuration object containing retry parameters
901
+ * @returns Promise that resolves with the operation result or rejects with the last error
902
+ */
903
+ declare function retryPromise<T>(operation: () => Promise<T>, retryConfig: RetryConfig): Promise<T>;
904
+ /**
905
+ * Calculates the commitment hash for a get request.
906
+ * @param get The get request to calculate the commitment hash for.
907
+ * @returns The commitment hash.
908
+ */
909
+ declare function getRequestCommitment(get: IGetRequest): HexString;
910
+ /**
911
+ * Estimates the gas required for a post request transaction on the source chain.
912
+ * This function constructs a post request, generates mock proofs, and estimates
913
+ * the gas cost for executing the transaction on the source chain.
914
+ */
915
+ declare function estimateGasForPost(params: {
916
+ postRequest: IPostRequest;
917
+ sourceClient: PublicClient;
918
+ hostLatestStateMachineHeight: bigint;
919
+ hostAddress: HexString;
920
+ }): Promise<{
921
+ gas_fee: bigint;
922
+ call_data: EstimateGasCallData;
923
+ }>;
1021
924
  /**
1022
- * Represents token information for an order
925
+ * Constructs the request body for a redeem escrow operation.
926
+ * This function encodes the order commitment, beneficiary address, and token inputs
927
+ * to match the format expected by the IntentGateway contract.
1023
928
  */
1024
- interface TokenInfo {
1025
- /**
1026
- * The address of the ERC20 token
1027
- * address(0) is used as a sentinel for the native token
1028
- */
1029
- token: HexString;
1030
- /**
1031
- * The amount of the token
1032
- */
1033
- amount: bigint;
1034
- }
929
+ declare function constructRedeemEscrowRequestBody(order: Order, beneficiary: HexString): HexString;
930
+ declare function fetchPrice(identifier: string, chainId?: number, apiKey?: string): Promise<number>;
1035
931
  /**
1036
- * Represents payment information for an order
932
+ * Fetches the current network gas price from an Etherscan-family explorer API.
933
+ * Returns the ProposeGasPrice (in gwei) converted to wei as bigint.
1037
934
  */
1038
- interface PaymentInfo extends TokenInfo {
1039
- /**
1040
- * The address to receive the output tokens
1041
- */
1042
- beneficiary: HexString;
1043
- }
935
+ declare function getGasPriceFromEtherscan(chainId: string, apiKey?: string): Promise<bigint>;
1044
936
  /**
1045
- * Represents an order in the IntentGateway
937
+ * ERC20 method signatures used for storage slot detection
1046
938
  */
1047
- interface Order {
1048
- /**
1049
- * The unique identifier for the order
1050
- */
1051
- id?: string;
1052
- /**
1053
- * The address of the user who is initiating the transfer
1054
- */
1055
- user: HexString;
1056
- /**
1057
- * The state machine identifier of the origin chain
1058
- */
1059
- sourceChain: string;
1060
- /**
1061
- * The state machine identifier of the destination chain
1062
- */
1063
- destChain: string;
1064
- /**
1065
- * The block number by which the order must be filled on the destination chain
1066
- */
1067
- deadline: bigint;
1068
- /**
1069
- * The nonce of the order
1070
- */
1071
- nonce: bigint;
1072
- /**
1073
- * Represents the dispatch fees associated with the IntentGateway
1074
- */
1075
- fees: bigint;
1076
- /**
1077
- * The tokens that the filler will provide
1078
- */
1079
- outputs: PaymentInfo[];
1080
- /**
1081
- * The tokens that are escrowed for the filler
1082
- */
1083
- inputs: TokenInfo[];
1084
- /**
1085
- * A bytes array to store the calls if any
1086
- */
1087
- callData: HexString;
1088
- /**
1089
- * The transaction hash of the order
1090
- */
1091
- transactionHash?: HexString;
1092
- }
1093
- interface DecodedOrderPlacedLog extends Log {
1094
- eventName: string;
1095
- args: {
1096
- user: HexString;
1097
- sourceChain: Hex;
1098
- destChain: Hex;
1099
- deadline: bigint;
1100
- nonce: bigint;
1101
- fees: bigint;
1102
- outputs: Array<{
1103
- token: HexString;
1104
- amount: bigint;
1105
- beneficiary: HexString;
1106
- }>;
1107
- inputs: Array<{
1108
- token: HexString;
1109
- amount: bigint;
1110
- }>;
1111
- callData: HexString;
1112
- };
1113
- transactionHash: HexString;
939
+ declare enum ERC20Method {
940
+ /** ERC20 balanceOf(address) method signature */
941
+ BALANCE_OF = "0x70a08231",
942
+ /** ERC20 allowance(address,address) method signature */
943
+ ALLOWANCE = "0xdd62ed3e"
1114
944
  }
1115
945
  /**
1116
- * Options for filling an order
946
+ * Retrieves the storage slot for a contract call using debug_traceCall
947
+ *
948
+ * This function uses the Ethereum debug API to trace contract execution and identify
949
+ * the storage slot accessed during the call. It's commonly used for ERC20 token state
950
+ * mappings like balanceOf and allowance, but can work with any contract call that
951
+ * performs SLOAD operations.
952
+ *
953
+ * @param client - The viem PublicClient instance connected to an RPC node with debug API enabled
954
+ * @param tokenAddress - The address of the contract to trace
955
+ * @param data - The full encoded function call data (method signature + encoded parameters)
956
+ * @returns The storage slot as a hex string
957
+ * @throws Error if the storage slot cannot be found or if debug API is not available
958
+ *
959
+ * @example
960
+ * ```ts
961
+ * import { ERC20Method, bytes20ToBytes32 } from '@hyperbridge/sdk'
962
+ *
963
+ * // Get balance storage slot for ERC20
964
+ * const balanceData = ERC20Method.BALANCE_OF + bytes20ToBytes32(userAddress).slice(2)
965
+ * const balanceSlot = await getStorageSlot(
966
+ * client,
967
+ * tokenAddress,
968
+ * balanceData as HexString
969
+ * )
970
+ *
971
+ * // Get allowance storage slot for ERC20
972
+ * const allowanceData = ERC20Method.ALLOWANCE +
973
+ * bytes20ToBytes32(ownerAddress).slice(2) +
974
+ * bytes20ToBytes32(spenderAddress).slice(2)
975
+ * const allowanceSlot = await getStorageSlot(
976
+ * client,
977
+ * tokenAddress,
978
+ * allowanceData as HexString
979
+ * )
980
+ * ```
1117
981
  */
1118
- interface FillOptions {
1119
- /**
1120
- * The fee paid to the relayer for processing transactions
1121
- */
1122
- relayerFee: bigint;
1123
- }
982
+ declare function getStorageSlot(client: PublicClient, contractAddress: HexString, data: HexString): Promise<string>;
1124
983
  /**
1125
- * Options for canceling an order
984
+ * Adjusts fee amounts between different decimal precisions.
985
+ * Handles scaling up or down based on the decimal difference.
986
+ *
987
+ * @param feeInFeeToken - The fee amount to adjust
988
+ * @param fromDecimals - The current decimal precision
989
+ * @param toDecimals - The target decimal precision
990
+ * @returns The adjusted fee amount with the target decimal precision
1126
991
  */
1127
- interface CancelOptions {
1128
- /**
1129
- * The fee paid to the relayer for processing transactions
1130
- */
1131
- relayerFee: string;
1132
- /**
1133
- * Stores the height value
1134
- */
1135
- height: string;
1136
- }
992
+ declare function adjustFeeDecimals(feeInFeeToken: bigint, fromDecimals: number, toDecimals: number): bigint;
1137
993
  /**
1138
- * Represents a new deployment of IntentGateway
994
+ * Chains that should prefer the Etherscan API for gas price lookup
1139
995
  */
1140
- interface NewDeployment {
1141
- /**
1142
- * Identifier for the state machine
1143
- */
1144
- stateMachineId: HexString;
1145
- /**
1146
- * The gateway identifier
1147
- */
1148
- gateway: HexString;
1149
- }
996
+ declare const USE_ETHERSCAN_CHAINS: Set<string>;
1150
997
  /**
1151
- * Represents the body of a request
998
+ * Testnet chains
1152
999
  */
1153
- interface RequestBody {
1154
- /**
1155
- * Represents the commitment of an order
1156
- */
1157
- commitment: HexString;
1000
+ declare const TESTNET_CHAINS: Set<string>;
1001
+
1002
+ declare class SubstrateChain implements IChain {
1003
+ private readonly params;
1004
+ api?: ApiPromise;
1005
+ private rpcClient;
1006
+ constructor(params: ISubstrateConfig);
1007
+ get config(): ISubstrateConfig;
1008
+ connect(): Promise<void>;
1158
1009
  /**
1159
- * Stores the identifier for the beneficiary
1010
+ * Disconnects the Substrate chain connection.
1160
1011
  */
1161
- beneficiary: HexString;
1012
+ disconnect(): Promise<void>;
1162
1013
  /**
1163
- * An array of token identifiers
1014
+ * Returns the storage key for a request receipt in the child trie
1015
+ * The request commitment is the key
1016
+ * @param key - The H256 hash key (as a 0x-prefixed hex string)
1017
+ * @returns The storage key as a hex string
1164
1018
  */
1165
- tokens: TokenInfo[];
1166
- }
1167
- /**
1168
- * Represents the parameters for the IntentGateway module
1169
- */
1170
- interface IntentGatewayParams {
1019
+ requestReceiptKey(key: HexString): HexString;
1171
1020
  /**
1172
- * The address of the host contract
1021
+ * Returns the storage key for a request commitment in the child trie
1022
+ * The request commitment is the key
1023
+ * @param key - The H256 hash key (as a 0x-prefixed hex string)
1024
+ * @returns The storage key as a hex string
1173
1025
  */
1174
- host: string;
1026
+ requestCommitmentKey(key: HexString): HexString;
1175
1027
  /**
1176
- * Address of the dispatcher contract responsible for handling intents
1028
+ * Queries a request commitment from the ISMP child trie storage.
1029
+ * @param {HexString} commitment - The commitment hash to look up.
1030
+ * @returns {Promise<HexString | undefined>} The commitment data if found, undefined otherwise.
1177
1031
  */
1178
- dispatcher: string;
1179
- }
1180
- /**
1181
- * Enum representing the different kinds of incoming requests
1182
- */
1183
- declare enum RequestKind {
1032
+ queryRequestCommitment(commitment: HexString): Promise<HexString | undefined>;
1184
1033
  /**
1185
- * Identifies a request for redeeming an escrow
1034
+ * Queries the request receipt.
1035
+ * @param {HexString} commitment - The commitment to query.
1036
+ * @returns {Promise<HexString | undefined>} The relayer address responsible for delivering the request.
1186
1037
  */
1187
- RedeemEscrow = 0,
1038
+ queryRequestReceipt(commitment: HexString): Promise<HexString | undefined>;
1188
1039
  /**
1189
- * Identifies a request for recording new contract deployments
1040
+ * Returns the current timestamp of the chain.
1041
+ * @returns {Promise<bigint>} The current timestamp.
1190
1042
  */
1191
- NewDeployment = 1,
1043
+ timestamp(): Promise<bigint>;
1192
1044
  /**
1193
- * Identifies a request for updating parameters
1045
+ * Queries the proof of the commitments.
1046
+ * @param {IMessage} message - The message to query.
1047
+ * @param {string} counterparty - The counterparty address.
1048
+ * @param {bigint} [at] - The block number to query at.
1049
+ * @returns {Promise<HexString>} The proof.
1194
1050
  */
1195
- UpdateParams = 2
1196
- }
1197
- /**
1198
- * Configuration for the IntentFiller
1199
- */
1200
- interface FillerConfig {
1051
+ queryProof(message: IMessage, counterparty: string, at?: bigint): Promise<HexString>;
1201
1052
  /**
1202
- * Policy for determining confirmation requirements
1203
- */
1204
- confirmationPolicy: {
1205
- getConfirmationBlocks: (chainId: number, amountUsd: number) => number;
1206
- };
1053
+ * Submit an unsigned ISMP transaction to the chain. Resolves when the transaction is finalized.
1054
+ * @param message - The message to be submitted.
1055
+ * @returns A promise that resolves to an object containing the transaction hash, block hash, and block number.
1056
+ */
1057
+ submitUnsigned(message: IIsmpMessage): Promise<{
1058
+ transactionHash: string;
1059
+ blockHash: string;
1060
+ blockNumber: number;
1061
+ timestamp: number;
1062
+ }>;
1207
1063
  /**
1208
- * Maximum number of orders to process concurrently
1064
+ * Query the state proof for a given set of keys at a specific block height.
1065
+ * @param at The block height to query the state proof at.
1066
+ * @param keys The keys to query the state proof for.
1067
+ * @returns The state proof as a hexadecimal string.
1209
1068
  */
1210
- maxConcurrentOrders?: number;
1069
+ queryStateProof(at: bigint, keys: HexString[]): Promise<HexString>;
1211
1070
  /**
1212
- * Minimum profitability threshold to consider filling an order
1213
- * Expressed as a percentage (e.g., 0.5 = 0.5%)
1071
+ * Get the latest state machine height for a given state machine ID.
1072
+ * @param {StateMachineIdParams} stateMachineId - The state machine ID.
1073
+ * @returns {Promise<bigint>} The latest state machine height.
1214
1074
  */
1215
- minProfitabilityThreshold?: number;
1075
+ latestStateMachineHeight(stateMachineId: StateMachineIdParams): Promise<bigint>;
1216
1076
  /**
1217
- * Gas price strategy for each chain
1218
- * Maps chainId to a gas price strategy function
1077
+ * Get the state machine update time for a given state machine height.
1078
+ * @param {StateMachineHeight} stateMachineHeight - The state machine height.
1079
+ * @returns {Promise<bigint>} The statemachine update time in seconds.
1219
1080
  */
1220
- gasPriceStrategy?: Record<string, () => Promise<string>>;
1081
+ stateMachineUpdateTime(stateMachineHeight: StateMachineHeight): Promise<bigint>;
1221
1082
  /**
1222
- * Maximum gas price willing to pay for each chain
1223
- * Maps chainId to maximum gas price in wei
1083
+ * Get the challenge period for a given state machine id.
1084
+ * @param {StateMachineIdParams} stateMachineId - The state machine ID.
1085
+ * @returns {Promise<bigint>} The challenge period in seconds.
1224
1086
  */
1225
- maxGasPrice?: Record<string, string>;
1087
+ challengePeriod(stateMachineId: StateMachineIdParams): Promise<bigint>;
1226
1088
  /**
1227
- * Retry configuration for failed transactions
1089
+ * Encode an ISMP calldata for a substrate chain.
1090
+ * @param message The ISMP message to encode.
1091
+ * @returns The encoded message as a hexadecimal string.
1228
1092
  */
1229
- retryConfig?: {
1230
- /**
1231
- * Maximum number of retry attempts
1232
- */
1233
- maxAttempts: number;
1234
- /**
1235
- * Initial delay between retries in ms
1236
- */
1237
- initialDelayMs: number;
1238
- };
1093
+ encode(message: IIsmpMessage): HexString;
1239
1094
  /**
1240
- * Configuration for the pending queue
1095
+ * Returns the index of a pallet by its name, by looking up the pallets in the runtime metadata.
1096
+ * @param {string} name - The name of the pallet.
1097
+ * @returns {number} The index of the pallet.
1241
1098
  */
1242
- pendingQueueConfig?: {
1243
- /**
1244
- * Delay in milliseconds before rechecking an order for confirmations
1245
- * Default: 30000 (30 seconds)
1246
- */
1247
- recheckDelayMs?: number;
1248
- /**
1249
- * Maximum number of times to recheck an order before giving up
1250
- * Default: 10
1251
- */
1252
- maxRechecks?: number;
1253
- };
1099
+ private getPalletIndex;
1254
1100
  }
1255
1101
  /**
1256
- * Result of an order execution attempt
1102
+ * Converts a state machine ID string to an enum value.
1103
+ * @param {string} id - The state machine ID string.
1104
+ * @returns {IStateMachine} The corresponding enum value.
1257
1105
  */
1258
- interface ExecutionResult {
1259
- /**
1260
- * Whether the execution was successful
1261
- */
1262
- success: boolean;
1106
+ declare function convertStateMachineIdToEnum(id: string): IStateMachine;
1107
+ /**
1108
+ * Converts a stateId object back to the state_id format used by the RPC.
1109
+ * @param stateId - The stateId object from StateMachineIdParams
1110
+ * @returns The string representation like "EVM-11155111" or "SUBSTRATE-cere"
1111
+ */
1112
+ declare function convertStateIdToStateMachineId(stateId: {
1113
+ Evm?: number;
1114
+ Substrate?: HexString;
1115
+ Polkadot?: number;
1116
+ Kusama?: number;
1117
+ }): string;
1118
+ declare function encodeISMPMessage(message: IIsmpMessage): Uint8Array;
1119
+
1120
+ /**
1121
+ * Type representing an ISMP message.
1122
+ */
1123
+ type IIsmpMessage = IRequestMessage | ITimeoutPostRequestMessage | IGetResponseMessage | IGetRequestMessage;
1124
+ interface IRequestMessage {
1263
1125
  /**
1264
- * The transaction hash if successful
1126
+ * The kind of message.
1265
1127
  */
1266
- txHash?: string;
1128
+ kind: "PostRequest";
1267
1129
  /**
1268
- * Error message if unsuccessful
1130
+ * The requests to be posted.
1269
1131
  */
1270
- error?: string;
1132
+ requests: IPostRequest[];
1271
1133
  /**
1272
- * Gas used by the transaction
1134
+ * The proof of the requests.
1273
1135
  */
1274
- gasUsed?: string;
1136
+ proof: IProof;
1275
1137
  /**
1276
- * Gas price used for the transaction
1138
+ * The signer of the message.
1277
1139
  */
1278
- gasPrice?: string;
1140
+ signer: HexString;
1141
+ }
1142
+ interface IGetRequestMessage {
1279
1143
  /**
1280
- * Total transaction cost in wei
1144
+ * The kind of message.
1281
1145
  */
1282
- txCost?: string;
1146
+ kind: "GetRequest";
1283
1147
  /**
1284
- * Block number when the transaction was confirmed
1148
+ * The requests to be posted.
1285
1149
  */
1286
- confirmedAtBlock?: number;
1150
+ requests: IGetRequest[];
1287
1151
  /**
1288
- * Timestamp when the transaction was confirmed
1152
+ * The proof of the requests from the source chain.
1289
1153
  */
1290
- confirmedAt?: Date;
1154
+ source: IProof;
1291
1155
  /**
1292
- * Actual profitability achieved
1156
+ * The proof of the response from the target chain
1293
1157
  */
1294
- actualProfitability?: number;
1158
+ response: IProof;
1295
1159
  /**
1296
- * Strategy used to fill the order
1160
+ * The signer of the message.
1297
1161
  */
1298
- strategyUsed?: string;
1162
+ signer: HexString;
1163
+ }
1164
+ interface IGetResponse {
1299
1165
  /**
1300
- * Any tokens exchanged during the fill process
1166
+ * The request that triggered this response.
1301
1167
  */
1302
- exchanges?: Array<{
1303
- fromToken: HexString;
1304
- toToken: HexString;
1305
- fromAmount: string;
1306
- toAmount: string;
1307
- exchangeRate: string;
1308
- }>;
1168
+ get: IGetRequest;
1309
1169
  /**
1310
- * The time it took to fill the order
1170
+ * The response message.
1311
1171
  */
1312
- processingTimeMs?: number;
1172
+ values: GetResponseStorageValues[];
1313
1173
  }
1314
- /**
1315
- * Represents a dispatch post for cross-chain communication
1316
- */
1317
- interface DispatchPost {
1174
+ interface IGetResponseMessage {
1318
1175
  /**
1319
- * Bytes representation of the destination state machine
1176
+ * The kind of message.
1320
1177
  */
1321
- dest: HexString;
1178
+ kind: "GetResponse";
1322
1179
  /**
1323
- * The destination module
1180
+ * The responses to be posted.
1324
1181
  */
1325
- to: HexString;
1182
+ responses: IGetResponse[];
1326
1183
  /**
1327
- * The request body
1184
+ * The proof of the responses.
1328
1185
  */
1329
- body: HexString;
1186
+ proof: IProof;
1330
1187
  /**
1331
- * Timeout for this request in seconds
1188
+ * The signer of the message.
1332
1189
  */
1333
- timeout: bigint;
1190
+ signer: HexString;
1191
+ }
1192
+ interface ITimeoutPostRequestMessage {
1334
1193
  /**
1335
- * The amount put up to be paid to the relayer,
1336
- * this is charged in `IIsmpHost.feeToken` to `msg.sender`
1194
+ * The kind of message.
1337
1195
  */
1338
- fee: bigint;
1196
+ kind: "TimeoutPostRequest";
1339
1197
  /**
1340
- * Who pays for this request?
1198
+ * The requests to be posted.
1341
1199
  */
1342
- payer: HexString;
1343
- }
1344
- interface DispatchGet {
1200
+ requests: IPostRequest[];
1345
1201
  /**
1346
- * Bytes representation of the destination state machine
1202
+ * The proof of the requests.
1347
1203
  */
1348
- dest: HexString;
1204
+ proof: IProof;
1205
+ }
1206
+ interface IProof {
1349
1207
  /**
1350
- * Height at which to read the state machine
1208
+ * The height of the proof.
1351
1209
  */
1352
1210
  height: bigint;
1353
1211
  /**
1354
- * Raw storage keys to fetch values from the counterparty
1355
- */
1356
- keys: HexString[];
1357
- /**
1358
- * Timeout for this request in seconds
1212
+ * The state machine identifier of the proof.
1359
1213
  */
1360
- timeout: bigint;
1214
+ stateMachine: string;
1361
1215
  /**
1362
- * The amount put up to be paid to the relayer
1216
+ * The associated consensus state identifier of the proof.
1363
1217
  */
1364
- fee: bigint;
1218
+ consensusStateId: string;
1365
1219
  /**
1366
- * Context for the request
1220
+ * The encoded storage proof
1367
1221
  */
1368
- context: HexString;
1369
- }
1370
- interface StateMachineHeight {
1371
- id: {
1372
- stateId: {
1373
- Evm?: number;
1374
- Substrate?: HexString;
1375
- Polkadot?: number;
1376
- Kusama?: number;
1377
- };
1378
- consensusStateId: HexString;
1379
- };
1380
- height: bigint;
1222
+ proof: HexString;
1381
1223
  }
1382
1224
  /**
1383
- * The EvmHost protocol parameters
1225
+ * Interface representing a chain.
1384
1226
  */
1385
- interface HostParams {
1386
- /**
1387
- * The default timeout in seconds for messages. If messages are dispatched
1388
- * with a timeout value lower than this this value will be used instead
1389
- */
1390
- defaultTimeout: bigint;
1391
- /**
1392
- * The default per byte fee
1393
- */
1394
- perByteFee: bigint;
1395
- /**
1396
- * The cost for applications to access the hyperbridge state commitment.
1397
- * They might do so because the hyperbridge state contains the verified state commitments
1398
- * for all chains and they want to directly read the state of these chains state bypassing
1399
- * the ISMP protocol entirely.
1400
- */
1401
- stateCommitmentFee: bigint;
1402
- /**
1403
- * The fee token contract address. This will typically be DAI.
1404
- * but we allow it to be configurable to prevent future regrets.
1405
- */
1406
- feeToken: HexString;
1407
- /**
1408
- * The admin account, this only has the rights to freeze, or unfreeze the bridge
1409
- */
1410
- admin: HexString;
1227
+ interface IChain {
1411
1228
  /**
1412
- * Ismp message handler contract. This performs all verification logic
1413
- * needed to validate cross-chain messages before they are dispatched to local modules
1229
+ * Returns the configuration for this chain
1414
1230
  */
1415
- handler: HexString;
1231
+ get config(): IEvmConfig | ISubstrateConfig;
1232
+ timestamp(): Promise<bigint>;
1416
1233
  /**
1417
- * The authorized host manager contract, is itself an `IIsmpModule`
1418
- * which receives governance requests from the Hyperbridge chain to either
1419
- * withdraw revenue from the host or update its protocol parameters
1234
+ * Returns the state trie key for the request-receipt storage item for the given request commitment.
1420
1235
  */
1421
- hostManager: HexString;
1236
+ requestReceiptKey(commitment: HexString): HexString;
1422
1237
  /**
1423
- * The local UniswapV2Router02 contract, used for swapping the native token to the feeToken.
1238
+ * Query and return the request-receipt for the given request commitment.
1424
1239
  */
1425
- uniswapV2: HexString;
1240
+ queryRequestReceipt(commitment: HexString): Promise<HexString | undefined>;
1426
1241
  /**
1427
- * The unstaking period of Polkadot's validators. In order to prevent long-range attacks
1242
+ * Query and return the encoded storage proof for the provided keys at the given height.
1428
1243
  */
1429
- unStakingPeriod: bigint;
1244
+ queryStateProof(at: bigint, keys: HexString[]): Promise<HexString>;
1245
+ queryProof(message: IMessage, counterparty: string, at?: bigint): Promise<HexString>;
1246
+ encode(message: IIsmpMessage): HexString;
1430
1247
  /**
1431
- * Minimum challenge period for state commitments in seconds
1248
+ * Get the latest state machine height for a given state machine ID.
1432
1249
  */
1433
- challengePeriod: bigint;
1250
+ latestStateMachineHeight(stateMachineId: StateMachineIdParams): Promise<bigint>;
1434
1251
  /**
1435
- * The consensus client contract which handles consensus proof verification
1252
+ * Get the challenge period for a given state machine ID.
1436
1253
  */
1437
- consensusClient: HexString;
1254
+ challengePeriod(stateMachineId: StateMachineIdParams): Promise<bigint>;
1438
1255
  /**
1439
- * State machines whose state commitments are accepted
1256
+ * Get the update time for a statemachine height.
1440
1257
  */
1441
- readonly stateMachines: readonly bigint[];
1258
+ stateMachineUpdateTime(stateMachineHeight: StateMachineHeight): Promise<bigint>;
1259
+ }
1260
+ /**
1261
+ * Returns the chain interface for a given state machine identifier
1262
+ * @param chainConfig - Chain configuration
1263
+ * @returns Chain interface
1264
+ */
1265
+ declare function getChain(chainConfig: IEvmConfig | ISubstrateConfig): Promise<IChain>;
1266
+
1267
+ type EstimateGasCallData = ContractFunctionArgs<typeof _default.ABI, "nonpayable" | "payable", "handlePostRequests">;
1268
+ type HexString = `0x${string}`;
1269
+ interface IConfig {
1270
+ source: IEvmConfig | ISubstrateConfig;
1271
+ dest: IEvmConfig | ISubstrateConfig;
1272
+ hyperbridge: IHyperbridgeConfig;
1273
+ tracing?: boolean;
1274
+ }
1275
+ interface IEvmConfig {
1276
+ rpcUrl: string;
1277
+ stateMachineId: string;
1278
+ host: HexString;
1279
+ consensusStateId: string;
1280
+ }
1281
+ interface ISubstrateConfig {
1282
+ wsUrl: string;
1283
+ consensusStateId: string;
1284
+ hasher: "Keccak" | "Blake2";
1285
+ stateMachineId: string;
1286
+ }
1287
+ interface IHyperbridgeConfig {
1288
+ wsUrl: string;
1289
+ stateMachineId: string;
1290
+ consensusStateId: string;
1291
+ }
1292
+ interface IPostRequest {
1293
+ source: string;
1294
+ dest: string;
1295
+ from: HexString;
1296
+ to: HexString;
1297
+ nonce: bigint;
1298
+ body: HexString;
1299
+ timeoutTimestamp: bigint;
1300
+ }
1301
+ interface IGetRequest {
1302
+ source: string;
1303
+ dest: string;
1304
+ from: HexString;
1305
+ nonce: bigint;
1306
+ height: bigint;
1307
+ keys: HexString[];
1308
+ timeoutTimestamp: bigint;
1309
+ context: HexString;
1310
+ }
1311
+ interface GetResponseStorageValues {
1312
+ key: HexString;
1313
+ value: HexString;
1314
+ }
1315
+ interface IPostResponse {
1316
+ post: IPostRequest;
1317
+ response: string;
1318
+ timeoutTimestamp: bigint;
1319
+ }
1320
+ type IMessage = {
1321
+ Requests: HexString[];
1322
+ } | {
1323
+ Responses: HexString[];
1324
+ };
1325
+ type IndexerQueryClient = GraphQLClient;
1326
+ interface ClientConfig {
1327
+ pollInterval: number;
1328
+ queryClient: IndexerQueryClient;
1329
+ tracing?: boolean;
1330
+ source: IChain;
1331
+ dest: IChain;
1332
+ hyperbridge: IChain;
1333
+ }
1334
+ interface RetryConfig {
1335
+ maxRetries: number;
1442
1336
  /**
1443
- * The state machine identifier for hyperbridge
1337
+ * @description The initial backoff time in milliseconds before the first retry attempt.
1444
1338
  */
1445
- hyperbridge: HexString;
1339
+ backoffMs: number;
1340
+ logMessage?: string;
1341
+ logger?: ConsolaInstance;
1446
1342
  }
1447
- interface OrderStatusMetadata {
1448
- status: OrderStatus;
1449
- chain: string;
1450
- timestamp: bigint;
1451
- blockNumber: string;
1452
- transactionHash: string;
1453
- filler?: string;
1343
+ interface IsmpRequest {
1344
+ source: string;
1345
+ dest: string;
1346
+ from: string;
1347
+ to: string;
1348
+ nonce: bigint;
1349
+ body: string;
1350
+ timeoutTimestamp: bigint;
1351
+ storage_key?: string;
1454
1352
  }
1455
- interface OrderWithStatus {
1353
+ declare const RequestStatus: Readonly<{
1354
+ SOURCE: "SOURCE";
1355
+ SOURCE_FINALIZED: "SOURCE_FINALIZED";
1356
+ HYPERBRIDGE_DELIVERED: "HYPERBRIDGE_DELIVERED";
1357
+ HYPERBRIDGE_FINALIZED: "HYPERBRIDGE_FINALIZED";
1358
+ DESTINATION: "DESTINATION";
1359
+ TIMED_OUT: "TIMED_OUT";
1360
+ HYPERBRIDGE_TIMED_OUT: "HYPERBRIDGE_TIMED_OUT";
1361
+ }>;
1362
+ type RequestStatus = typeof RequestStatus;
1363
+ type RequestStatusKey = keyof typeof RequestStatus;
1364
+ declare const TimeoutStatus: Readonly<{
1365
+ PENDING_TIMEOUT: "PENDING_TIMEOUT";
1366
+ DESTINATION_FINALIZED_TIMEOUT: "DESTINATION_FINALIZED_TIMEOUT";
1367
+ HYPERBRIDGE_TIMED_OUT: "HYPERBRIDGE_TIMED_OUT";
1368
+ HYPERBRIDGE_FINALIZED_TIMEOUT: "HYPERBRIDGE_FINALIZED_TIMEOUT";
1369
+ TIMED_OUT: "TIMED_OUT";
1370
+ }>;
1371
+ type TimeoutStatus = typeof TimeoutStatus;
1372
+ type TimeoutStatusKey = keyof typeof TimeoutStatus;
1373
+ type AllStatusKey = RequestStatusKey | TimeoutStatusKey;
1374
+ declare enum HyperClientStatus {
1375
+ PENDING = "PENDING",
1376
+ SOURCE_FINALIZED = "SOURCE_FINALIZED",
1377
+ HYPERBRIDGE_FINALIZED = "HYPERBRIDGE_FINALIZED",
1378
+ HYPERBRIDGE_VERIFIED = "HYPERBRIDGE_VERIFIED",
1379
+ DESTINATION = "DESTINATION",
1380
+ TIMED_OUT = "TIMED_OUT",
1381
+ HYPERBRIDGE_TIMED_OUT = "HYPERBRIDGE_TIMED_OUT",
1382
+ ERROR = "ERROR"
1383
+ }
1384
+ declare enum OrderStatus {
1385
+ PLACED = "PLACED",
1386
+ FILLED = "FILLED",
1387
+ REDEEMED = "REDEEMED",
1388
+ REFUNDED = "REFUNDED"
1389
+ }
1390
+ declare enum TeleportStatus {
1391
+ TELEPORTED = "TELEPORTED",
1392
+ RECEIVED = "RECEIVED",
1393
+ REFUNDED = "REFUNDED"
1394
+ }
1395
+ interface TokenGatewayAssetTeleportedResponse {
1396
+ tokenGatewayAssetTeleporteds: {
1397
+ nodes: Array<{
1398
+ id: string;
1399
+ from: string;
1400
+ to: string;
1401
+ sourceChain: string;
1402
+ destChain: string;
1403
+ commitment: string;
1404
+ amount: string;
1405
+ usdValue: string;
1406
+ assetId: string;
1407
+ redeem: boolean;
1408
+ status: TeleportStatus;
1409
+ createdAt: string;
1410
+ blockNumber: string;
1411
+ blockTimestamp: string;
1412
+ transactionHash: string;
1413
+ statusMetadata: {
1414
+ nodes: Array<{
1415
+ status: TeleportStatus;
1416
+ chain: string;
1417
+ timestamp: string;
1418
+ blockNumber: string;
1419
+ blockHash: string;
1420
+ transactionHash: string;
1421
+ }>;
1422
+ };
1423
+ }>;
1424
+ };
1425
+ }
1426
+ interface TokenGatewayAssetTeleportedWithStatus {
1456
1427
  id: string;
1457
- user: string;
1428
+ from: string;
1429
+ to: string;
1458
1430
  sourceChain: string;
1459
1431
  destChain: string;
1460
1432
  commitment: string;
1461
- deadline: bigint;
1462
- nonce: bigint;
1463
- fees: bigint;
1464
- inputTokens: string[];
1465
- inputAmounts: bigint[];
1466
- inputValuesUSD: string[];
1467
- inputUSD: string;
1468
- outputTokens: string[];
1469
- outputAmounts: bigint[];
1470
- outputBeneficiaries: string[];
1471
- calldata: string;
1472
- status: OrderStatus;
1433
+ amount: bigint;
1434
+ usdValue: string;
1435
+ assetId: string;
1436
+ redeem: boolean;
1437
+ status: TeleportStatus;
1473
1438
  createdAt: Date;
1474
1439
  blockNumber: bigint;
1475
1440
  blockTimestamp: bigint;
1476
1441
  transactionHash: string;
1477
1442
  statuses: Array<{
1478
- status: OrderStatus;
1443
+ status: TeleportStatus;
1479
1444
  metadata: {
1480
1445
  blockHash: string;
1481
1446
  blockNumber: number;
1482
1447
  transactionHash: string;
1483
1448
  timestamp: bigint;
1484
- filler?: string;
1485
1449
  };
1486
1450
  }>;
1487
1451
  }
1488
- interface OrderResponse {
1489
- orderPlaceds: {
1490
- nodes: Array<{
1491
- id: string;
1492
- user: string;
1493
- sourceChain: string;
1494
- destChain: string;
1495
- commitment: string;
1496
- deadline: string;
1497
- nonce: string;
1498
- fees: string;
1499
- inputTokens: string[];
1500
- inputAmounts: string[];
1501
- inputValuesUSD: string[];
1502
- inputUSD: string;
1503
- outputTokens: string[];
1504
- outputAmounts: string[];
1505
- outputBeneficiaries: string[];
1506
- calldata: string;
1507
- status: OrderStatus;
1508
- createdAt: string;
1509
- blockNumber: string;
1510
- blockTimestamp: string;
1511
- transactionHash: string;
1452
+ interface BlockMetadata {
1453
+ blockHash: string;
1454
+ blockNumber: number;
1455
+ transactionHash: string;
1456
+ calldata?: string;
1457
+ timestamp?: number;
1458
+ }
1459
+ interface PostRequestStatus {
1460
+ status: RequestStatusKey;
1461
+ metadata: Partial<BlockMetadata>;
1462
+ }
1463
+ interface PostRequestTimeoutStatus {
1464
+ status: TimeoutStatusKey;
1465
+ metadata?: Partial<BlockMetadata>;
1466
+ }
1467
+ interface StateMachineUpdate {
1468
+ height: number;
1469
+ chain: string;
1470
+ blockHash: string;
1471
+ blockNumber: number;
1472
+ transactionHash: string;
1473
+ transactionIndex: number;
1474
+ stateMachineId: string;
1475
+ timestamp: number;
1476
+ }
1477
+ interface RequestResponse {
1478
+ requests: {
1479
+ nodes: Array<{
1480
+ source: string;
1481
+ dest: string;
1482
+ to: HexString;
1483
+ from: HexString;
1484
+ nonce: bigint;
1485
+ body: HexString;
1486
+ timeoutTimestamp: bigint;
1512
1487
  statusMetadata: {
1513
1488
  nodes: Array<{
1514
- status: OrderStatus;
1515
- chain: string;
1516
- timestamp: string;
1517
- blockNumber: string;
1518
1489
  blockHash: string;
1490
+ blockNumber: string;
1491
+ timestamp: string;
1492
+ chain: string;
1493
+ status: string;
1519
1494
  transactionHash: string;
1520
- filler?: string;
1521
1495
  }>;
1522
1496
  };
1523
1497
  }>;
1524
1498
  };
1525
1499
  }
1526
- interface TokenPrice {
1527
- symbol: string;
1528
- address?: string;
1529
- currency: string;
1530
- price: string;
1531
- lastUpdatedAt: bigint;
1532
- }
1533
- interface TokenPricesResponse {
1534
- tokenPrices: {
1535
- nodes: Array<{
1536
- id: string;
1537
- symbol: string;
1538
- address: string;
1539
- currency: string;
1540
- price: string;
1541
- lastUpdatedAt: bigint;
1542
- }>;
1543
- };
1544
- }
1545
- interface TokenRegistry {
1546
- id: string;
1547
- name: string;
1548
- symbol: string;
1549
- address?: string;
1550
- updateFrequencySeconds: number;
1551
- lastUpdatedAt: bigint;
1552
- createdAt: Date;
1553
- }
1554
- interface TokenRegistryResponse {
1555
- tokenRegistries: {
1500
+ interface GetRequestResponse {
1501
+ getRequests: {
1556
1502
  nodes: Array<{
1557
- id: string;
1558
- name: string;
1559
- symbol: string;
1560
- address: string;
1561
- updateFrequencySeconds: number;
1562
- lastUpdatedAt: bigint;
1563
- createdAt: string;
1564
- }>;
1565
- };
1566
- }
1567
- /**
1568
- * Represents a complete transaction structure for swap operations
1569
- */
1570
- interface Transaction {
1571
- /**
1572
- * The address to send the transaction to (typically the Universal Router address)
1573
- */
1574
- to: HexString;
1575
- /**
1576
- * The value to send with the transaction (in wei)
1577
- */
1578
- value: bigint;
1579
- /**
1580
- * The calldata for the transaction
1581
- */
1582
- data: HexString;
1583
- }
1584
-
1585
- declare class ChainConfigService {
1586
- private rpcUrls;
1587
- constructor(env?: NodeJS.ProcessEnv);
1588
- getChainConfig(chain: string): ChainConfig;
1589
- getIntentGatewayAddress(chain: string): `0x${string}`;
1590
- getHostAddress(chain: string): `0x${string}`;
1591
- getWrappedNativeAssetWithDecimals(chain: string): {
1592
- asset: HexString;
1593
- decimals: number;
1594
- };
1595
- getDaiAsset(chain: string): HexString;
1596
- getUsdtAsset(chain: string): HexString;
1597
- getUsdcAsset(chain: string): HexString;
1598
- getChainId(chain: string): number;
1599
- getConsensusStateId(chain: string): HexString;
1600
- getHyperbridgeChainId(): number;
1601
- getRpcUrl(chain: string): string;
1602
- getUniswapRouterV2Address(chain: string): HexString;
1603
- getUniswapV2FactoryAddress(chain: string): HexString;
1604
- getUniversalRouterAddress(chain: string): HexString;
1605
- getUniswapV3QuoterAddress(chain: string): HexString;
1606
- getUniswapV4QuoterAddress(chain: string): HexString;
1607
- getPermit2Address(chain: string): HexString;
1608
- getCoingeckoId(chain: string): string | undefined;
1609
- getEtherscanApiKey(): string | undefined;
1610
- }
1611
-
1612
- /**
1613
- * The default address used as fallback when no address is provided.
1614
- * This represents the zero address in EVM chains.
1615
- */
1616
- declare const DEFAULT_ADDRESS = "0x0000000000000000000000000000000000000000";
1617
- /**
1618
- * Parameters for an EVM chain.
1619
- */
1620
- interface EvmChainParams {
1621
- /**
1622
- * The chain ID of the EVM chain.
1623
- */
1624
- chainId: number;
1625
- /**
1626
- * The host address of the EVM chain.
1627
- */
1628
- host: HexString;
1629
- /**
1630
- * The URL of the EVM chain.
1631
- */
1632
- url: string;
1633
- }
1634
- /**
1635
- * Encapsulates an EVM chain.
1636
- */
1637
- declare class EvmChain implements IChain {
1638
- private readonly params;
1639
- private publicClient;
1640
- private chainConfigService;
1641
- constructor(params: EvmChainParams);
1642
- get client(): PublicClient;
1643
- get host(): HexString;
1644
- get config(): ChainConfigService;
1645
- /**
1646
- * Derives the key for the request receipt.
1647
- * @param {HexString} commitment - The commitment to derive the key from.
1648
- * @returns {HexString} The derived key.
1649
- */
1650
- requestReceiptKey(commitment: HexString): HexString;
1651
- /**
1652
- * Queries the request receipt.
1653
- * @param {HexString} commitment - The commitment to query.
1654
- * @returns {Promise<HexString | undefined>} The relayer address responsible for delivering the request.
1655
- */
1656
- queryRequestReceipt(commitment: HexString): Promise<HexString | undefined>;
1657
- /**
1658
- * Queries the proof of the commitments.
1659
- * @param {IMessage} message - The message to query.
1660
- * @param {string} counterparty - The counterparty address.
1661
- * @param {bigint} [at] - The block number to query at.
1662
- * @returns {Promise<HexString>} The proof.
1663
- */
1664
- queryProof(message: IMessage, counterparty: string, at?: bigint): Promise<HexString>;
1665
- /**
1666
- * Query and return the encoded storage proof for the provided keys at the given height.
1667
- * @param {bigint} at - The block height at which to query the storage proof.
1668
- * @param {HexString[]} keys - The keys for which to query the storage proof.
1669
- * @param {HexString} address - Optional contract address to fetch storage proof else default to host contract
1670
- * @returns {Promise<HexString>} The encoded storage proof.
1671
- */
1672
- queryStateProof(at: bigint, keys: HexString[], address?: HexString): Promise<HexString>;
1673
- /**
1674
- * Returns the current timestamp of the chain.
1675
- * @returns {Promise<bigint>} The current timestamp.
1676
- */
1677
- timestamp(): Promise<bigint>;
1678
- /**
1679
- * Get the latest state machine height for a given state machine ID.
1680
- * @param {StateMachineIdParams} stateMachineId - The state machine ID.
1681
- * @returns {Promise<bigint>} The latest state machine height.
1682
- */
1683
- latestStateMachineHeight(stateMachineId: StateMachineIdParams): Promise<bigint>;
1684
- /**
1685
- * Get the state machine update time for a given state machine height.
1686
- * @param {StateMachineHeight} stateMachineHeight - The state machine height.
1687
- * @returns {Promise<bigint>} The statemachine update time in seconds.
1688
- */
1689
- stateMachineUpdateTime(stateMachineHeight: StateMachineHeight): Promise<bigint>;
1690
- /**
1691
- * Get the challenge period for a given state machine id.
1692
- * @param {StateMachineIdParams} stateMachineId - The state machine ID.
1693
- * @returns {Promise<bigint>} The challenge period in seconds.
1694
- */
1695
- challengePeriod(stateMachineId: StateMachineIdParams): Promise<bigint>;
1696
- /**
1697
- * Encodes an ISMP message for the EVM chain.
1698
- * @param {IIsmpMessage} message The ISMP message to encode.
1699
- * @returns {HexString} The encoded calldata.
1700
- */
1701
- encode(message: IIsmpMessage): HexString;
1702
- /**
1703
- * Calculates the fee required to send a post request to the destination chain.
1704
- * The fee is calculated based on the per-byte fee for the destination chain
1705
- * multiplied by the size of the request body.
1706
- *
1707
- * @param request - The post request to calculate the fee for
1708
- * @returns The total fee in wei required to send the post request
1709
- */
1710
- quote(request: IPostRequest): Promise<bigint>;
1711
- quoteNative(request: IPostRequest, fee: bigint): Promise<bigint>;
1712
- private getAmountsIn;
1713
- /**
1714
- * Estimates the gas required for a post request execution on this chain.
1715
- * This function generates mock proofs for the post request, creates a state override
1716
- * with the necessary overlay root, and estimates the gas cost for executing the
1717
- * handlePostRequests transaction on the handler contract.
1718
- *
1719
- * @param request - The post request to estimate gas for
1720
- * @param paraId - The ID of the parachain (Hyperbridge) that will process the request
1721
- * @returns The estimated gas amount in gas units and the generated calldata
1722
- */
1723
- estimateGas(request: IPostRequest): Promise<{
1724
- gas: bigint;
1725
- postRequestCalldata: HexString;
1726
- }>;
1727
- /**
1728
- * Gets the fee token address and decimals for the chain.
1729
- * This function gets the fee token address and decimals for the chain.
1730
- *
1731
- * @returns The fee token address and decimals
1732
- */
1733
- getFeeTokenWithDecimals(): Promise<{
1734
- address: HexString;
1735
- decimals: number;
1736
- }>;
1737
- /**
1738
- * Gets the nonce of the host.
1739
- * This function gets the nonce of the host.
1740
- *
1741
- * @returns The nonce of the host
1742
- */
1743
- getHostNonce(): Promise<bigint>;
1503
+ source: string;
1504
+ dest: string;
1505
+ to: HexString;
1506
+ from: HexString;
1507
+ nonce: bigint;
1508
+ height: bigint;
1509
+ keys: HexString[];
1510
+ context: HexString;
1511
+ timeoutTimestamp: bigint;
1512
+ statusMetadata: {
1513
+ nodes: Array<{
1514
+ blockHash: string;
1515
+ blockNumber: string;
1516
+ timestamp: string;
1517
+ chain: string;
1518
+ status: string;
1519
+ transactionHash: string;
1520
+ }>;
1521
+ };
1522
+ }>;
1523
+ };
1744
1524
  }
1745
- /**
1746
- * Slot for storing request commitments.
1747
- */
1748
- declare const REQUEST_COMMITMENTS_SLOT = 0n;
1749
- /**
1750
- * Slot index for response commitments map
1751
- */
1752
- declare const RESPONSE_COMMITMENTS_SLOT = 1n;
1753
- /**
1754
- * Slot index for requests receipts map
1755
- */
1756
- declare const REQUEST_RECEIPTS_SLOT = 2n;
1757
- /**
1758
- * Slot index for response receipts map
1759
- */
1760
- declare const RESPONSE_RECEIPTS_SLOT = 3n;
1761
- /**
1762
- * Slot index for state commitment map
1763
- */
1764
- declare const STATE_COMMITMENTS_SLOT = 5n;
1765
- declare function requestCommitmentKey(key: Hex): {
1766
- slot1: Hex;
1767
- slot2: Hex;
1768
- };
1769
- /**
1770
- * Derives the storage slot for a specific field in the StateCommitment struct
1771
- *
1772
- * struct StateCommitment {
1773
- * uint256 timestamp; // slot + 0
1774
- * bytes32 overlayRoot; // slot + 1
1775
- * bytes32 stateRoot; // slot + 2
1776
- * }
1777
- *
1778
- * @param stateMachineId - The state machine ID
1779
- * @param height - The block height
1780
- * @param field - The field index in the struct (0 for timestamp, 1 for overlayRoot, 2 for stateRoot)
1781
- * @returns The storage slot for the specific field
1782
- */
1783
- declare function getStateCommitmentFieldSlot(stateMachineId: bigint, height: bigint, field: 0 | 1 | 2): HexString;
1784
- declare function getStateCommitmentSlot(stateMachineId: bigint, height: bigint): HexString;
1785
-
1786
- /**
1787
- * Generates a Merkle Mountain Range (MMR) root hash and proof for a post request.
1788
- *
1789
- * This function takes a post request and tree size, encodes it according to the PostRequest format,
1790
- * and generates both the MMR root hash and a proof. The function builds an MMR with `treeSize` leaves,
1791
- * where most leaves are variations of the encoded request (XORed with their index), except for the
1792
- * last leaf, which is the unmodified request. The proof is generated for this unmodified leaf.
1793
- *
1794
- * @param postRequest - The post request to generate the MMR root and proof for
1795
- * @param treeSize - Controls how many leaves will be added to the MMR (exactly `treeSize` leaves)
1796
- * @returns An object containing:
1797
- * - root: The MMR root hash as a hex string
1798
- * - proof: An array of hex strings representing the MMR proof for the unmodified request
1799
- * - index: The index of the unmodified request in the MMR
1800
- * - kIndex: The k-index of the unmodified request in the MMR
1801
- * - treeSize: The number of leaves in the MMR
1802
- * - mmrSize: The size of the MMR in nodes
1803
- */
1804
- declare function generateRootWithProof(postRequest: IPostRequest, treeSize: bigint): Promise<{
1805
- root: HexString;
1806
- proof: HexString[];
1807
- index: bigint;
1808
- kIndex: bigint;
1809
- treeSize: bigint;
1810
- mmrSize: bigint;
1811
- }>;
1812
- declare function __test(): Promise<string>;
1813
-
1814
- type IStateMachine = {
1815
- tag: "Evm";
1816
- value: number;
1525
+ type RequestStatusWithMetadata = {
1526
+ status: RequestStatus["SOURCE"];
1527
+ metadata: {
1528
+ blockHash: string;
1529
+ blockNumber: number;
1530
+ transactionHash: string;
1531
+ timestamp?: number;
1532
+ };
1817
1533
  } | {
1818
- tag: "Polkadot";
1819
- value: number;
1534
+ status: RequestStatus["SOURCE_FINALIZED"];
1535
+ metadata: {
1536
+ blockHash: string;
1537
+ blockNumber: number;
1538
+ transactionHash: string;
1539
+ timestamp?: number;
1540
+ };
1820
1541
  } | {
1821
- tag: "Kusama";
1822
- value: number;
1542
+ status: RequestStatus["HYPERBRIDGE_DELIVERED"];
1543
+ metadata: {
1544
+ blockHash: string;
1545
+ blockNumber: number;
1546
+ transactionHash: string;
1547
+ timestamp?: number;
1548
+ };
1823
1549
  } | {
1824
- tag: "Substrate";
1825
- value: number[];
1550
+ status: RequestStatus["HYPERBRIDGE_FINALIZED"];
1551
+ metadata: {
1552
+ calldata: Hex;
1553
+ blockHash: string;
1554
+ blockNumber: number;
1555
+ transactionHash: string;
1556
+ timestamp?: number;
1557
+ };
1826
1558
  } | {
1827
- tag: "Tendermint";
1828
- value: number[];
1559
+ status: RequestStatus["DESTINATION"];
1560
+ metadata: {
1561
+ blockHash: string;
1562
+ blockNumber: number;
1563
+ transactionHash: string;
1564
+ timestamp?: number;
1565
+ };
1566
+ } | {
1567
+ status: TimeoutStatus["PENDING_TIMEOUT"];
1568
+ metadata: {
1569
+ blockHash: string;
1570
+ blockNumber: number;
1571
+ transactionHash: string;
1572
+ };
1573
+ } | {
1574
+ status: TimeoutStatus["DESTINATION_FINALIZED_TIMEOUT"];
1575
+ metadata: {
1576
+ blockHash: string;
1577
+ blockNumber: number;
1578
+ transactionHash: string;
1579
+ timestamp?: number;
1580
+ };
1581
+ } | {
1582
+ status: TimeoutStatus["HYPERBRIDGE_TIMED_OUT"];
1583
+ metadata: {
1584
+ blockHash: string;
1585
+ blockNumber: number;
1586
+ transactionHash: string;
1587
+ timestamp?: number;
1588
+ };
1589
+ } | {
1590
+ status: TimeoutStatus["HYPERBRIDGE_FINALIZED_TIMEOUT"];
1591
+ metadata: {
1592
+ calldata: Hex;
1593
+ blockHash: string;
1594
+ blockNumber: number;
1595
+ transactionHash: string;
1596
+ timestamp?: number;
1597
+ };
1598
+ } | {
1599
+ status: TimeoutStatus["TIMED_OUT"];
1600
+ metadata: {
1601
+ blockHash: string;
1602
+ blockNumber: number;
1603
+ transactionHash: string;
1604
+ timestamp?: number;
1605
+ };
1829
1606
  };
1830
-
1831
- declare const ADDRESS_ZERO: HexString;
1832
- declare const DUMMY_PRIVATE_KEY: HexString;
1833
- declare const DEFAULT_GRAFFITI: HexString;
1834
- /**
1835
- * Returns the maximum of two bigint values
1836
- * @param a - First bigint value
1837
- * @param b - Second bigint value
1838
- * @returns The larger of the two values
1839
- */
1840
- declare function maxBigInt(a: bigint, b: bigint): bigint;
1841
- /**
1842
- * Calculates the commitment hash for a post request.
1843
- * @param post The post request to calculate the commitment hash for.
1844
- * @returns The commitment hash and the encode packed data.
1845
- */
1846
- declare function postRequestCommitment(post: IPostRequest): {
1607
+ interface GenericRequestWithStatuses {
1608
+ source: string;
1609
+ dest: string;
1610
+ from: HexString;
1611
+ nonce: bigint;
1612
+ timeoutTimestamp: bigint;
1613
+ statuses: Array<RequestStatusWithMetadata>;
1614
+ }
1615
+ interface PostRequestWithStatus extends GenericRequestWithStatuses {
1616
+ to: HexString;
1617
+ body: HexString;
1618
+ }
1619
+ interface GetRequestWithStatus extends GenericRequestWithStatuses {
1620
+ height: bigint;
1621
+ keys: HexString[];
1622
+ context: HexString;
1847
1623
  commitment: HexString;
1848
- encodePacked: HexString;
1849
- };
1850
- declare function orderCommitment(order: Order): HexString;
1851
- /**
1852
- * Converts a bytes32 token address to bytes20 format
1853
- * This removes the extra padded zeros from the address
1854
- */
1855
- declare function bytes32ToBytes20(bytes32Address: string): HexString;
1856
- declare function bytes20ToBytes32(bytes20Address: string): HexString;
1857
- declare function hexToString(hex: string): string;
1624
+ }
1625
+ interface GetResponseByRequestIdResponse {
1626
+ getResponses: {
1627
+ nodes: Array<{
1628
+ id: string;
1629
+ commitment: string;
1630
+ responseMessage: string[];
1631
+ }>;
1632
+ };
1633
+ }
1634
+ interface ResponseCommitmentWithValues {
1635
+ commitment: string;
1636
+ values: string[];
1637
+ }
1638
+ interface RequestCommitment {
1639
+ requests: {
1640
+ nodes: Array<{
1641
+ id: string;
1642
+ commitment: string;
1643
+ }>;
1644
+ };
1645
+ }
1646
+ interface StateMachineResponse {
1647
+ stateMachineUpdateEvents: {
1648
+ nodes: {
1649
+ height: number;
1650
+ chain: string;
1651
+ blockHash: string;
1652
+ blockNumber: number;
1653
+ transactionHash: string;
1654
+ transactionIndex: number;
1655
+ stateMachineId: string;
1656
+ createdAt: string;
1657
+ }[];
1658
+ };
1659
+ }
1660
+ interface AssetTeleported {
1661
+ id: string;
1662
+ from: string;
1663
+ to: string;
1664
+ amount: bigint;
1665
+ dest: string;
1666
+ commitment: HexString;
1667
+ createdAt: Date;
1668
+ blockNumber: number;
1669
+ }
1670
+ interface AssetTeleportedResponse {
1671
+ assetTeleported: AssetTeleported;
1672
+ }
1673
+ interface StateMachineIdParams {
1674
+ stateId: {
1675
+ Evm?: number;
1676
+ Substrate?: HexString;
1677
+ Polkadot?: number;
1678
+ Kusama?: number;
1679
+ };
1680
+ consensusStateId: HexString;
1681
+ }
1858
1682
  /**
1859
- * Retries a promise-returning operation with exponential backoff.
1860
- * This function will attempt to execute the operation up to maxRetries times,
1861
- * with an exponential backoff delay between attempts.
1862
- *
1863
- * @param operation The async operation to retry
1864
- * @param retryConfig Configuration object containing retry parameters
1865
- * @returns Promise that resolves with the operation result or rejects with the last error
1683
+ * Configuration for a blockchain chain
1866
1684
  */
1867
- declare function retryPromise<T>(operation: () => Promise<T>, retryConfig: RetryConfig): Promise<T>;
1685
+ interface ChainConfig {
1686
+ /**
1687
+ * The unique identifier for the chain
1688
+ */
1689
+ chainId: number;
1690
+ /**
1691
+ * The RPC URL to connect to the chain
1692
+ */
1693
+ rpcUrl: string;
1694
+ /**
1695
+ * The address of the IntentGateway contract on this chain
1696
+ */
1697
+ intentGatewayAddress: string;
1698
+ }
1868
1699
  /**
1869
- * Calculates the commitment hash for a get request.
1870
- * @param get The get request to calculate the commitment hash for.
1871
- * @returns The commitment hash.
1700
+ * Represents token information for an order
1872
1701
  */
1873
- declare function getRequestCommitment(get: IGetRequest): HexString;
1702
+ interface TokenInfo {
1703
+ /**
1704
+ * The address of the ERC20 token
1705
+ * address(0) is used as a sentinel for the native token
1706
+ */
1707
+ token: HexString;
1708
+ /**
1709
+ * The amount of the token
1710
+ */
1711
+ amount: bigint;
1712
+ }
1874
1713
  /**
1875
- * Estimates the gas required for a post request transaction on the source chain.
1876
- * This function constructs a post request, generates mock proofs, and estimates
1877
- * the gas cost for executing the transaction on the source chain.
1714
+ * Represents payment information for an order
1878
1715
  */
1879
- declare function estimateGasForPost(params: {
1880
- postRequest: IPostRequest;
1881
- sourceClient: PublicClient;
1882
- hostLatestStateMachineHeight: bigint;
1883
- hostAddress: HexString;
1884
- }): Promise<{
1885
- gas_fee: bigint;
1886
- call_data: EstimateGasCallData;
1887
- }>;
1716
+ interface PaymentInfo extends TokenInfo {
1717
+ /**
1718
+ * The address to receive the output tokens
1719
+ */
1720
+ beneficiary: HexString;
1721
+ }
1888
1722
  /**
1889
- * Constructs the request body for a redeem escrow operation.
1890
- * This function encodes the order commitment, beneficiary address, and token inputs
1891
- * to match the format expected by the IntentGateway contract.
1723
+ * Represents an order in the IntentGateway
1892
1724
  */
1893
- declare function constructRedeemEscrowRequestBody(order: Order, beneficiary: HexString): HexString;
1894
- declare function fetchPrice(identifier: string, chainId?: number, apiKey?: string): Promise<number>;
1725
+ interface Order {
1726
+ /**
1727
+ * The unique identifier for the order
1728
+ */
1729
+ id?: string;
1730
+ /**
1731
+ * The address of the user who is initiating the transfer
1732
+ */
1733
+ user: HexString;
1734
+ /**
1735
+ * The state machine identifier of the origin chain
1736
+ */
1737
+ sourceChain: string;
1738
+ /**
1739
+ * The state machine identifier of the destination chain
1740
+ */
1741
+ destChain: string;
1742
+ /**
1743
+ * The block number by which the order must be filled on the destination chain
1744
+ */
1745
+ deadline: bigint;
1746
+ /**
1747
+ * The nonce of the order
1748
+ */
1749
+ nonce: bigint;
1750
+ /**
1751
+ * Represents the dispatch fees associated with the IntentGateway
1752
+ */
1753
+ fees: bigint;
1754
+ /**
1755
+ * The tokens that the filler will provide
1756
+ */
1757
+ outputs: PaymentInfo[];
1758
+ /**
1759
+ * The tokens that are escrowed for the filler
1760
+ */
1761
+ inputs: TokenInfo[];
1762
+ /**
1763
+ * A bytes array to store the calls if any
1764
+ */
1765
+ callData: HexString;
1766
+ /**
1767
+ * The transaction hash of the order
1768
+ */
1769
+ transactionHash?: HexString;
1770
+ }
1771
+ interface DecodedOrderPlacedLog extends Log {
1772
+ eventName: string;
1773
+ args: {
1774
+ user: HexString;
1775
+ sourceChain: Hex;
1776
+ destChain: Hex;
1777
+ deadline: bigint;
1778
+ nonce: bigint;
1779
+ fees: bigint;
1780
+ outputs: Array<{
1781
+ token: HexString;
1782
+ amount: bigint;
1783
+ beneficiary: HexString;
1784
+ }>;
1785
+ inputs: Array<{
1786
+ token: HexString;
1787
+ amount: bigint;
1788
+ }>;
1789
+ callData: HexString;
1790
+ };
1791
+ transactionHash: HexString;
1792
+ }
1895
1793
  /**
1896
- * Fetches the current network gas price from an Etherscan-family explorer API.
1897
- * Returns the ProposeGasPrice (in gwei) converted to wei as bigint.
1794
+ * Options for filling an order
1898
1795
  */
1899
- declare function getGasPriceFromEtherscan(chainId: string, apiKey?: string): Promise<bigint>;
1796
+ interface FillOptions {
1797
+ /**
1798
+ * The fee paid to the relayer for processing transactions
1799
+ */
1800
+ relayerFee: bigint;
1801
+ }
1900
1802
  /**
1901
- * ERC20 method signatures used for storage slot detection
1803
+ * Options for canceling an order
1902
1804
  */
1903
- declare enum ERC20Method {
1904
- /** ERC20 balanceOf(address) method signature */
1905
- BALANCE_OF = "0x70a08231",
1906
- /** ERC20 allowance(address,address) method signature */
1907
- ALLOWANCE = "0xdd62ed3e"
1805
+ interface CancelOptions {
1806
+ /**
1807
+ * The fee paid to the relayer for processing transactions
1808
+ */
1809
+ relayerFee: string;
1810
+ /**
1811
+ * Stores the height value
1812
+ */
1813
+ height: string;
1908
1814
  }
1909
1815
  /**
1910
- * Retrieves the storage slot for a contract call using debug_traceCall
1911
- *
1912
- * This function uses the Ethereum debug API to trace contract execution and identify
1913
- * the storage slot accessed during the call. It's commonly used for ERC20 token state
1914
- * mappings like balanceOf and allowance, but can work with any contract call that
1915
- * performs SLOAD operations.
1916
- *
1917
- * @param client - The viem PublicClient instance connected to an RPC node with debug API enabled
1918
- * @param tokenAddress - The address of the contract to trace
1919
- * @param data - The full encoded function call data (method signature + encoded parameters)
1920
- * @returns The storage slot as a hex string
1921
- * @throws Error if the storage slot cannot be found or if debug API is not available
1922
- *
1923
- * @example
1924
- * ```ts
1925
- * import { ERC20Method, bytes20ToBytes32 } from '@hyperbridge/sdk'
1926
- *
1927
- * // Get balance storage slot for ERC20
1928
- * const balanceData = ERC20Method.BALANCE_OF + bytes20ToBytes32(userAddress).slice(2)
1929
- * const balanceSlot = await getStorageSlot(
1930
- * client,
1931
- * tokenAddress,
1932
- * balanceData as HexString
1933
- * )
1934
- *
1935
- * // Get allowance storage slot for ERC20
1936
- * const allowanceData = ERC20Method.ALLOWANCE +
1937
- * bytes20ToBytes32(ownerAddress).slice(2) +
1938
- * bytes20ToBytes32(spenderAddress).slice(2)
1939
- * const allowanceSlot = await getStorageSlot(
1940
- * client,
1941
- * tokenAddress,
1942
- * allowanceData as HexString
1943
- * )
1944
- * ```
1816
+ * Represents a new deployment of IntentGateway
1945
1817
  */
1946
- declare function getStorageSlot(client: PublicClient, contractAddress: HexString, data: HexString): Promise<string>;
1818
+ interface NewDeployment {
1819
+ /**
1820
+ * Identifier for the state machine
1821
+ */
1822
+ stateMachineId: HexString;
1823
+ /**
1824
+ * The gateway identifier
1825
+ */
1826
+ gateway: HexString;
1827
+ }
1947
1828
  /**
1948
- * Adjusts fee amounts between different decimal precisions.
1949
- * Handles scaling up or down based on the decimal difference.
1950
- *
1951
- * @param feeInFeeToken - The fee amount to adjust
1952
- * @param fromDecimals - The current decimal precision
1953
- * @param toDecimals - The target decimal precision
1954
- * @returns The adjusted fee amount with the target decimal precision
1829
+ * Represents the body of a request
1955
1830
  */
1956
- declare function adjustFeeDecimals(feeInFeeToken: bigint, fromDecimals: number, toDecimals: number): bigint;
1831
+ interface RequestBody {
1832
+ /**
1833
+ * Represents the commitment of an order
1834
+ */
1835
+ commitment: HexString;
1836
+ /**
1837
+ * Stores the identifier for the beneficiary
1838
+ */
1839
+ beneficiary: HexString;
1840
+ /**
1841
+ * An array of token identifiers
1842
+ */
1843
+ tokens: TokenInfo[];
1844
+ }
1957
1845
  /**
1958
- * Chains that should prefer the Etherscan API for gas price lookup
1846
+ * Represents the parameters for the IntentGateway module
1959
1847
  */
1960
- declare const USE_ETHERSCAN_CHAINS: Set<string>;
1848
+ interface IntentGatewayParams {
1849
+ /**
1850
+ * The address of the host contract
1851
+ */
1852
+ host: string;
1853
+ /**
1854
+ * Address of the dispatcher contract responsible for handling intents
1855
+ */
1856
+ dispatcher: string;
1857
+ }
1961
1858
  /**
1962
- * Testnet chains
1859
+ * Enum representing the different kinds of incoming requests
1963
1860
  */
1964
- declare const TESTNET_CHAINS: Set<string>;
1965
-
1966
- interface SubstrateChainParams {
1967
- ws: string;
1968
- hasher: "Keccak" | "Blake2";
1861
+ declare enum RequestKind {
1862
+ /**
1863
+ * Identifies a request for redeeming an escrow
1864
+ */
1865
+ RedeemEscrow = 0,
1866
+ /**
1867
+ * Identifies a request for recording new contract deployments
1868
+ */
1869
+ NewDeployment = 1,
1870
+ /**
1871
+ * Identifies a request for updating parameters
1872
+ */
1873
+ UpdateParams = 2
1969
1874
  }
1970
- declare class SubstrateChain implements IChain {
1971
- private readonly params;
1972
- api?: ApiPromise;
1973
- private rpcClient;
1974
- constructor(params: SubstrateChainParams);
1975
- connect(): Promise<void>;
1875
+ /**
1876
+ * Configuration for the IntentFiller
1877
+ */
1878
+ interface FillerConfig {
1976
1879
  /**
1977
- * Disconnects the Substrate chain connection.
1880
+ * Policy for determining confirmation requirements
1978
1881
  */
1979
- disconnect(): Promise<void>;
1882
+ confirmationPolicy: {
1883
+ getConfirmationBlocks: (chainId: number, amountUsd: number) => number;
1884
+ };
1980
1885
  /**
1981
- * Returns the storage key for a request receipt in the child trie
1982
- * The request commitment is the key
1983
- * @param key - The H256 hash key (as a 0x-prefixed hex string)
1984
- * @returns The storage key as a hex string
1886
+ * Maximum number of orders to process concurrently
1985
1887
  */
1986
- requestReceiptKey(key: HexString): HexString;
1888
+ maxConcurrentOrders?: number;
1987
1889
  /**
1988
- * Returns the storage key for a request commitment in the child trie
1989
- * The request commitment is the key
1990
- * @param key - The H256 hash key (as a 0x-prefixed hex string)
1991
- * @returns The storage key as a hex string
1890
+ * Minimum profitability threshold to consider filling an order
1891
+ * Expressed as a percentage (e.g., 0.5 = 0.5%)
1992
1892
  */
1993
- requestCommitmentKey(key: HexString): HexString;
1893
+ minProfitabilityThreshold?: number;
1994
1894
  /**
1995
- * Queries a request commitment from the ISMP child trie storage.
1996
- * @param {HexString} commitment - The commitment hash to look up.
1997
- * @returns {Promise<HexString | undefined>} The commitment data if found, undefined otherwise.
1895
+ * Gas price strategy for each chain
1896
+ * Maps chainId to a gas price strategy function
1998
1897
  */
1999
- queryRequestCommitment(commitment: HexString): Promise<HexString | undefined>;
1898
+ gasPriceStrategy?: Record<string, () => Promise<string>>;
2000
1899
  /**
2001
- * Queries the request receipt.
2002
- * @param {HexString} commitment - The commitment to query.
2003
- * @returns {Promise<HexString | undefined>} The relayer address responsible for delivering the request.
1900
+ * Maximum gas price willing to pay for each chain
1901
+ * Maps chainId to maximum gas price in wei
2004
1902
  */
2005
- queryRequestReceipt(commitment: HexString): Promise<HexString | undefined>;
1903
+ maxGasPrice?: Record<string, string>;
2006
1904
  /**
2007
- * Returns the current timestamp of the chain.
2008
- * @returns {Promise<bigint>} The current timestamp.
1905
+ * Retry configuration for failed transactions
2009
1906
  */
2010
- timestamp(): Promise<bigint>;
1907
+ retryConfig?: {
1908
+ /**
1909
+ * Maximum number of retry attempts
1910
+ */
1911
+ maxAttempts: number;
1912
+ /**
1913
+ * Initial delay between retries in ms
1914
+ */
1915
+ initialDelayMs: number;
1916
+ };
2011
1917
  /**
2012
- * Queries the proof of the commitments.
2013
- * @param {IMessage} message - The message to query.
2014
- * @param {string} counterparty - The counterparty address.
2015
- * @param {bigint} [at] - The block number to query at.
2016
- * @returns {Promise<HexString>} The proof.
1918
+ * Configuration for the pending queue
2017
1919
  */
2018
- queryProof(message: IMessage, counterparty: string, at?: bigint): Promise<HexString>;
1920
+ pendingQueueConfig?: {
1921
+ /**
1922
+ * Delay in milliseconds before rechecking an order for confirmations
1923
+ * Default: 30000 (30 seconds)
1924
+ */
1925
+ recheckDelayMs?: number;
1926
+ /**
1927
+ * Maximum number of times to recheck an order before giving up
1928
+ * Default: 10
1929
+ */
1930
+ maxRechecks?: number;
1931
+ };
1932
+ }
1933
+ /**
1934
+ * Result of an order execution attempt
1935
+ */
1936
+ interface ExecutionResult {
2019
1937
  /**
2020
- * Submit an unsigned ISMP transaction to the chain. Resolves when the transaction is finalized.
2021
- * @param message - The message to be submitted.
2022
- * @returns A promise that resolves to an object containing the transaction hash, block hash, and block number.
1938
+ * Whether the execution was successful
2023
1939
  */
2024
- submitUnsigned(message: IIsmpMessage): Promise<{
2025
- transactionHash: string;
2026
- blockHash: string;
2027
- blockNumber: number;
2028
- timestamp: number;
2029
- }>;
1940
+ success: boolean;
2030
1941
  /**
2031
- * Query the state proof for a given set of keys at a specific block height.
2032
- * @param at The block height to query the state proof at.
2033
- * @param keys The keys to query the state proof for.
2034
- * @returns The state proof as a hexadecimal string.
1942
+ * The transaction hash if successful
2035
1943
  */
2036
- queryStateProof(at: bigint, keys: HexString[]): Promise<HexString>;
1944
+ txHash?: string;
2037
1945
  /**
2038
- * Get the latest state machine height for a given state machine ID.
2039
- * @param {StateMachineIdParams} stateMachineId - The state machine ID.
2040
- * @returns {Promise<bigint>} The latest state machine height.
1946
+ * Error message if unsuccessful
2041
1947
  */
2042
- latestStateMachineHeight(stateMachineId: StateMachineIdParams): Promise<bigint>;
1948
+ error?: string;
2043
1949
  /**
2044
- * Get the state machine update time for a given state machine height.
2045
- * @param {StateMachineHeight} stateMachineHeight - The state machine height.
2046
- * @returns {Promise<bigint>} The statemachine update time in seconds.
1950
+ * Gas used by the transaction
2047
1951
  */
2048
- stateMachineUpdateTime(stateMachineHeight: StateMachineHeight): Promise<bigint>;
1952
+ gasUsed?: string;
2049
1953
  /**
2050
- * Get the challenge period for a given state machine id.
2051
- * @param {StateMachineIdParams} stateMachineId - The state machine ID.
2052
- * @returns {Promise<bigint>} The challenge period in seconds.
1954
+ * Gas price used for the transaction
2053
1955
  */
2054
- challengePeriod(stateMachineId: StateMachineIdParams): Promise<bigint>;
1956
+ gasPrice?: string;
2055
1957
  /**
2056
- * Encode an ISMP calldata for a substrate chain.
2057
- * @param message The ISMP message to encode.
2058
- * @returns The encoded message as a hexadecimal string.
1958
+ * Total transaction cost in wei
2059
1959
  */
2060
- encode(message: IIsmpMessage): HexString;
1960
+ txCost?: string;
2061
1961
  /**
2062
- * Returns the index of a pallet by its name, by looking up the pallets in the runtime metadata.
2063
- * @param {string} name - The name of the pallet.
2064
- * @returns {number} The index of the pallet.
1962
+ * Block number when the transaction was confirmed
2065
1963
  */
2066
- private getPalletIndex;
1964
+ confirmedAtBlock?: number;
1965
+ /**
1966
+ * Timestamp when the transaction was confirmed
1967
+ */
1968
+ confirmedAt?: Date;
1969
+ /**
1970
+ * Actual profitability achieved
1971
+ */
1972
+ actualProfitability?: number;
1973
+ /**
1974
+ * Strategy used to fill the order
1975
+ */
1976
+ strategyUsed?: string;
1977
+ /**
1978
+ * Any tokens exchanged during the fill process
1979
+ */
1980
+ exchanges?: Array<{
1981
+ fromToken: HexString;
1982
+ toToken: HexString;
1983
+ fromAmount: string;
1984
+ toAmount: string;
1985
+ exchangeRate: string;
1986
+ }>;
1987
+ /**
1988
+ * The time it took to fill the order
1989
+ */
1990
+ processingTimeMs?: number;
2067
1991
  }
2068
1992
  /**
2069
- * Converts a state machine ID string to an enum value.
2070
- * @param {string} id - The state machine ID string.
2071
- * @returns {IStateMachine} The corresponding enum value.
2072
- */
2073
- declare function convertStateMachineIdToEnum(id: string): IStateMachine;
2074
- /**
2075
- * Converts a stateId object back to the state_id format used by the RPC.
2076
- * @param stateId - The stateId object from StateMachineIdParams
2077
- * @returns The string representation like "EVM-11155111" or "SUBSTRATE-cere"
2078
- */
2079
- declare function convertStateIdToStateMachineId(stateId: {
2080
- Evm?: number;
2081
- Substrate?: HexString;
2082
- Polkadot?: number;
2083
- Kusama?: number;
2084
- }): string;
2085
- declare function encodeISMPMessage(message: IIsmpMessage): Uint8Array;
2086
-
2087
- /**
2088
- * Type representing an ISMP message.
1993
+ * Represents a dispatch post for cross-chain communication
2089
1994
  */
2090
- type IIsmpMessage = IRequestMessage | ITimeoutPostRequestMessage | IGetResponseMessage | IGetRequestMessage;
2091
- interface IRequestMessage {
1995
+ interface DispatchPost {
2092
1996
  /**
2093
- * The kind of message.
1997
+ * Bytes representation of the destination state machine
2094
1998
  */
2095
- kind: "PostRequest";
1999
+ dest: HexString;
2096
2000
  /**
2097
- * The requests to be posted.
2001
+ * The destination module
2098
2002
  */
2099
- requests: IPostRequest[];
2003
+ to: HexString;
2100
2004
  /**
2101
- * The proof of the requests.
2005
+ * The request body
2102
2006
  */
2103
- proof: IProof;
2007
+ body: HexString;
2104
2008
  /**
2105
- * The signer of the message.
2009
+ * Timeout for this request in seconds
2106
2010
  */
2107
- signer: HexString;
2011
+ timeout: bigint;
2012
+ /**
2013
+ * The amount put up to be paid to the relayer,
2014
+ * this is charged in `IIsmpHost.feeToken` to `msg.sender`
2015
+ */
2016
+ fee: bigint;
2017
+ /**
2018
+ * Who pays for this request?
2019
+ */
2020
+ payer: HexString;
2108
2021
  }
2109
- interface IGetRequestMessage {
2022
+ interface DispatchGet {
2110
2023
  /**
2111
- * The kind of message.
2024
+ * Bytes representation of the destination state machine
2112
2025
  */
2113
- kind: "GetRequest";
2026
+ dest: HexString;
2114
2027
  /**
2115
- * The requests to be posted.
2028
+ * Height at which to read the state machine
2116
2029
  */
2117
- requests: IGetRequest[];
2030
+ height: bigint;
2118
2031
  /**
2119
- * The proof of the requests from the source chain.
2032
+ * Raw storage keys to fetch values from the counterparty
2120
2033
  */
2121
- source: IProof;
2034
+ keys: HexString[];
2122
2035
  /**
2123
- * The proof of the response from the target chain
2036
+ * Timeout for this request in seconds
2124
2037
  */
2125
- response: IProof;
2038
+ timeout: bigint;
2126
2039
  /**
2127
- * The signer of the message.
2040
+ * The amount put up to be paid to the relayer
2128
2041
  */
2129
- signer: HexString;
2042
+ fee: bigint;
2043
+ /**
2044
+ * Context for the request
2045
+ */
2046
+ context: HexString;
2047
+ }
2048
+ interface StateMachineHeight {
2049
+ id: {
2050
+ stateId: {
2051
+ Evm?: number;
2052
+ Substrate?: HexString;
2053
+ Polkadot?: number;
2054
+ Kusama?: number;
2055
+ };
2056
+ consensusStateId: HexString;
2057
+ };
2058
+ height: bigint;
2130
2059
  }
2131
- interface IGetResponse {
2060
+ /**
2061
+ * The EvmHost protocol parameters
2062
+ */
2063
+ interface HostParams {
2132
2064
  /**
2133
- * The request that triggered this response.
2065
+ * The default timeout in seconds for messages. If messages are dispatched
2066
+ * with a timeout value lower than this this value will be used instead
2134
2067
  */
2135
- get: IGetRequest;
2068
+ defaultTimeout: bigint;
2136
2069
  /**
2137
- * The response message.
2070
+ * The default per byte fee
2138
2071
  */
2139
- values: GetResponseStorageValues[];
2140
- }
2141
- interface IGetResponseMessage {
2072
+ perByteFee: bigint;
2142
2073
  /**
2143
- * The kind of message.
2074
+ * The cost for applications to access the hyperbridge state commitment.
2075
+ * They might do so because the hyperbridge state contains the verified state commitments
2076
+ * for all chains and they want to directly read the state of these chains state bypassing
2077
+ * the ISMP protocol entirely.
2144
2078
  */
2145
- kind: "GetResponse";
2079
+ stateCommitmentFee: bigint;
2146
2080
  /**
2147
- * The responses to be posted.
2081
+ * The fee token contract address. This will typically be DAI.
2082
+ * but we allow it to be configurable to prevent future regrets.
2148
2083
  */
2149
- responses: IGetResponse[];
2084
+ feeToken: HexString;
2150
2085
  /**
2151
- * The proof of the responses.
2086
+ * The admin account, this only has the rights to freeze, or unfreeze the bridge
2152
2087
  */
2153
- proof: IProof;
2088
+ admin: HexString;
2154
2089
  /**
2155
- * The signer of the message.
2090
+ * Ismp message handler contract. This performs all verification logic
2091
+ * needed to validate cross-chain messages before they are dispatched to local modules
2156
2092
  */
2157
- signer: HexString;
2158
- }
2159
- interface ITimeoutPostRequestMessage {
2093
+ handler: HexString;
2160
2094
  /**
2161
- * The kind of message.
2095
+ * The authorized host manager contract, is itself an `IIsmpModule`
2096
+ * which receives governance requests from the Hyperbridge chain to either
2097
+ * withdraw revenue from the host or update its protocol parameters
2162
2098
  */
2163
- kind: "TimeoutPostRequest";
2099
+ hostManager: HexString;
2164
2100
  /**
2165
- * The requests to be posted.
2101
+ * The local UniswapV2Router02 contract, used for swapping the native token to the feeToken.
2166
2102
  */
2167
- requests: IPostRequest[];
2103
+ uniswapV2: HexString;
2168
2104
  /**
2169
- * The proof of the requests.
2105
+ * The unstaking period of Polkadot's validators. In order to prevent long-range attacks
2170
2106
  */
2171
- proof: IProof;
2172
- }
2173
- interface IProof {
2107
+ unStakingPeriod: bigint;
2174
2108
  /**
2175
- * The height of the proof.
2109
+ * Minimum challenge period for state commitments in seconds
2176
2110
  */
2177
- height: bigint;
2111
+ challengePeriod: bigint;
2178
2112
  /**
2179
- * The state machine identifier of the proof.
2113
+ * The consensus client contract which handles consensus proof verification
2180
2114
  */
2181
- stateMachine: string;
2115
+ consensusClient: HexString;
2182
2116
  /**
2183
- * The associated consensus state identifier of the proof.
2117
+ * State machines whose state commitments are accepted
2184
2118
  */
2185
- consensusStateId: string;
2119
+ readonly stateMachines: readonly bigint[];
2186
2120
  /**
2187
- * The encoded storage proof
2121
+ * The state machine identifier for hyperbridge
2188
2122
  */
2189
- proof: HexString;
2123
+ hyperbridge: HexString;
2124
+ }
2125
+ interface OrderStatusMetadata {
2126
+ status: OrderStatus;
2127
+ chain: string;
2128
+ timestamp: bigint;
2129
+ blockNumber: string;
2130
+ transactionHash: string;
2131
+ filler?: string;
2132
+ }
2133
+ interface OrderWithStatus {
2134
+ id: string;
2135
+ user: string;
2136
+ sourceChain: string;
2137
+ destChain: string;
2138
+ commitment: string;
2139
+ deadline: bigint;
2140
+ nonce: bigint;
2141
+ fees: bigint;
2142
+ inputTokens: string[];
2143
+ inputAmounts: bigint[];
2144
+ inputValuesUSD: string[];
2145
+ inputUSD: string;
2146
+ outputTokens: string[];
2147
+ outputAmounts: bigint[];
2148
+ outputBeneficiaries: string[];
2149
+ calldata: string;
2150
+ status: OrderStatus;
2151
+ createdAt: Date;
2152
+ blockNumber: bigint;
2153
+ blockTimestamp: bigint;
2154
+ transactionHash: string;
2155
+ statuses: Array<{
2156
+ status: OrderStatus;
2157
+ metadata: {
2158
+ blockHash: string;
2159
+ blockNumber: number;
2160
+ transactionHash: string;
2161
+ timestamp: bigint;
2162
+ filler?: string;
2163
+ };
2164
+ }>;
2165
+ }
2166
+ interface OrderResponse {
2167
+ orderPlaceds: {
2168
+ nodes: Array<{
2169
+ id: string;
2170
+ user: string;
2171
+ sourceChain: string;
2172
+ destChain: string;
2173
+ commitment: string;
2174
+ deadline: string;
2175
+ nonce: string;
2176
+ fees: string;
2177
+ inputTokens: string[];
2178
+ inputAmounts: string[];
2179
+ inputValuesUSD: string[];
2180
+ inputUSD: string;
2181
+ outputTokens: string[];
2182
+ outputAmounts: string[];
2183
+ outputBeneficiaries: string[];
2184
+ calldata: string;
2185
+ status: OrderStatus;
2186
+ createdAt: string;
2187
+ blockNumber: string;
2188
+ blockTimestamp: string;
2189
+ transactionHash: string;
2190
+ statusMetadata: {
2191
+ nodes: Array<{
2192
+ status: OrderStatus;
2193
+ chain: string;
2194
+ timestamp: string;
2195
+ blockNumber: string;
2196
+ blockHash: string;
2197
+ transactionHash: string;
2198
+ filler?: string;
2199
+ }>;
2200
+ };
2201
+ }>;
2202
+ };
2203
+ }
2204
+ interface TokenPrice {
2205
+ symbol: string;
2206
+ address?: string;
2207
+ currency: string;
2208
+ price: string;
2209
+ lastUpdatedAt: bigint;
2210
+ }
2211
+ interface TokenPricesResponse {
2212
+ tokenPrices: {
2213
+ nodes: Array<{
2214
+ id: string;
2215
+ symbol: string;
2216
+ address: string;
2217
+ currency: string;
2218
+ price: string;
2219
+ lastUpdatedAt: bigint;
2220
+ }>;
2221
+ };
2222
+ }
2223
+ interface TokenRegistry {
2224
+ id: string;
2225
+ name: string;
2226
+ symbol: string;
2227
+ address?: string;
2228
+ updateFrequencySeconds: number;
2229
+ lastUpdatedAt: bigint;
2230
+ createdAt: Date;
2231
+ }
2232
+ interface TokenRegistryResponse {
2233
+ tokenRegistries: {
2234
+ nodes: Array<{
2235
+ id: string;
2236
+ name: string;
2237
+ symbol: string;
2238
+ address: string;
2239
+ updateFrequencySeconds: number;
2240
+ lastUpdatedAt: bigint;
2241
+ createdAt: string;
2242
+ }>;
2243
+ };
2190
2244
  }
2191
2245
  /**
2192
- * Interface representing a chain.
2246
+ * Represents a complete transaction structure for swap operations
2193
2247
  */
2194
- interface IChain {
2195
- timestamp(): Promise<bigint>;
2196
- /**
2197
- * Returns the state trie key for the request-receipt storage item for the given request commitment.
2198
- */
2199
- requestReceiptKey(commitment: HexString): HexString;
2200
- /**
2201
- * Query and return the request-receipt for the given request commitment.
2202
- */
2203
- queryRequestReceipt(commitment: HexString): Promise<HexString | undefined>;
2204
- /**
2205
- * Query and return the encoded storage proof for the provided keys at the given height.
2206
- */
2207
- queryStateProof(at: bigint, keys: HexString[]): Promise<HexString>;
2208
- queryProof(message: IMessage, counterparty: string, at?: bigint): Promise<HexString>;
2209
- encode(message: IIsmpMessage): HexString;
2248
+ interface Transaction {
2210
2249
  /**
2211
- * Get the latest state machine height for a given state machine ID.
2250
+ * The address to send the transaction to (typically the Universal Router address)
2212
2251
  */
2213
- latestStateMachineHeight(stateMachineId: StateMachineIdParams): Promise<bigint>;
2252
+ to: HexString;
2214
2253
  /**
2215
- * Get the challenge period for a given state machine ID.
2254
+ * The value to send with the transaction (in wei)
2216
2255
  */
2217
- challengePeriod(stateMachineId: StateMachineIdParams): Promise<bigint>;
2256
+ value: bigint;
2218
2257
  /**
2219
- * Get the update time for a statemachine height.
2258
+ * The calldata for the transaction
2220
2259
  */
2221
- stateMachineUpdateTime(stateMachineHeight: StateMachineHeight): Promise<bigint>;
2260
+ data: HexString;
2222
2261
  }
2262
+
2223
2263
  /**
2224
- * Returns the chain interface for a given state machine identifier
2225
- * @param chainConfig - Chain configuration
2226
- * @returns Chain interface
2264
+ * Helper function to create chain configuration from legacy config format
2265
+ * This helps migrate from the old config format to the new IChain-based format
2266
+ *
2267
+ * @param config - Legacy configuration object (IEvmConfig, ISubstrateConfig, or IHyperbridgeConfig)
2268
+ * @returns Promise resolving to chain configuration with IChain instance
2227
2269
  */
2228
- declare function getChain(chainConfig: IEvmConfig | ISubstrateConfig): Promise<IChain>;
2229
-
2270
+ declare function createChain(config: IEvmConfig | ISubstrateConfig | IHyperbridgeConfig): Promise<IChain>;
2271
+ /**
2272
+ * Helper function to create IndexerClient with legacy config format
2273
+ * @deprecated Use the constructor with IChain instances directly for better performance
2274
+ *
2275
+ * @param config - Legacy configuration with IEvmConfig/ISubstrateConfig/IHyperbridgeConfig
2276
+ * @returns Promise resolving to IndexerClient instance
2277
+ */
2278
+ declare function createIndexerClient(config: {
2279
+ pollInterval?: number;
2280
+ queryClient: IndexerQueryClient;
2281
+ tracing?: boolean;
2282
+ source: IEvmConfig | ISubstrateConfig;
2283
+ dest: IEvmConfig | ISubstrateConfig;
2284
+ hyperbridge: IHyperbridgeConfig;
2285
+ }): Promise<IndexerClient>;
2230
2286
  /**
2231
2287
  * IndexerClient provides methods for interacting with the Hyperbridge indexer.
2232
2288
  *
@@ -2249,24 +2305,54 @@ declare function getChain(chainConfig: IEvmConfig | ISubstrateConfig): Promise<I
2249
2305
  *
2250
2306
  * @example
2251
2307
  * ```typescript
2308
+ * // New approach: Create IChain instances directly
2309
+ * const sourceChain = new EvmChain({
2310
+ * chainId: 1,
2311
+ * rpcUrl: "https://eth-rpc.com",
2312
+ * host: "0x87ea45..",
2313
+ * consensusStateId: "ETH0"
2314
+ * })
2315
+ * const destChain = new EvmChain({
2316
+ * chainId: 42161,
2317
+ * rpcUrl: "https://arb-rpc.com",
2318
+ * host: "0x87ea42345..",
2319
+ * consensusStateId: "ARB0"
2320
+ * })
2321
+ * const hyperbridgeChain = new SubstrateChain({
2322
+ * stateMachineId: "POLKADOT-3367",
2323
+ * wsUrl: "ws://localhost:9944",
2324
+ * hasher: "Keccak",
2325
+ * consensusStateId: "DOT0"
2326
+ * })
2327
+ * await hyperbridgeChain.connect()
2328
+ *
2252
2329
  * const client = new IndexerClient({
2253
- * url: "https://indexer.hyperbridge.xyz/graphql",
2330
+ * queryClient: queryClient,
2331
+ * pollInterval: 2000,
2332
+ * source: sourceChain,
2333
+ * dest: destChain,
2334
+ * hyperbridge: hyperbridgeChain
2335
+ * });
2336
+ *
2337
+ * // Legacy approach: Use the helper function (deprecated)
2338
+ * const client = await createIndexerClient({
2339
+ * queryClient: queryClient,
2254
2340
  * pollInterval: 2000,
2255
2341
  * source: {
2256
- * stateMachineId: "EVM-1",
2257
- * consensusStateId: "ETH0"
2258
- * rpcUrl: "",
2259
- * host: "0x87ea45..",
2260
- * },
2342
+ * stateMachineId: "EVM-1",
2343
+ * consensusStateId: "ETH0",
2344
+ * rpcUrl: "https://eth-rpc.com",
2345
+ * host: "0x87ea45.."
2346
+ * },
2261
2347
  * dest: {
2262
- * stateMachineId: "EVM-42161",
2263
- * consensusStateId: "ETH0"
2264
- * rpcUrl: "",
2265
- * host: "0x87ea42345..",
2266
- * },
2348
+ * stateMachineId: "EVM-42161",
2349
+ * consensusStateId: "ETH0",
2350
+ * rpcUrl: "https://arb-rpc.com",
2351
+ * host: "0x87ea42345.."
2352
+ * },
2267
2353
  * hyperbridge: {
2268
2354
  * stateMachineId: "POLKADOT-3367",
2269
- * consensusStateId: "DOT0"
2355
+ * consensusStateId: "DOT0",
2270
2356
  * wsUrl: "ws://localhost:9944"
2271
2357
  * }
2272
2358
  * });
@@ -2300,6 +2386,18 @@ declare class IndexerClient {
2300
2386
  * Creates a new IndexerClient instance
2301
2387
  */
2302
2388
  constructor(config: PartialClientConfig);
2389
+ /**
2390
+ * Get the source chain instance
2391
+ */
2392
+ get source(): IChain;
2393
+ /**
2394
+ * Get the destination chain instance
2395
+ */
2396
+ get dest(): IChain;
2397
+ /**
2398
+ * Get the hyperbridge chain instance
2399
+ */
2400
+ get hyperbridge(): IChain;
2303
2401
  /**
2304
2402
  * Query for a single state machine update event greater than or equal to the given height.
2305
2403
  * @params statemachineId - ID of the state machine
@@ -2798,6 +2896,13 @@ declare class IntentGateway {
2798
2896
  fee?: number;
2799
2897
  transactions?: Transaction[];
2800
2898
  }>;
2899
+ createMultiHopSwapThroughPair(dexPairAddress: HexString, tokenIn: HexString, tokenOut: HexString, amountIn: bigint, evmChainID: string, getQuoteIn: "source" | "dest", recipient: HexString, protocol?: "v2" | "v3"): Promise<{
2900
+ finalAmountOut: bigint;
2901
+ calldata: Transaction[];
2902
+ }>;
2903
+ private buildSwapPath;
2904
+ private executeSwapPath;
2905
+ private createSwapCalldata;
2801
2906
  /**
2802
2907
  * Checks if an order has been filled by verifying the commitment status on-chain.
2803
2908
  * Reads the storage slot corresponding to the order's commitment hash.
@@ -2829,7 +2934,27 @@ declare class IntentGateway {
2829
2934
  blockHash: string;
2830
2935
  blockNumber: number;
2831
2936
  transactionHash: string;
2832
- timestamp?: number;
2937
+ timestamp
2938
+ /**
2939
+ * Converts fee token amounts back to the equivalent amount in native token.
2940
+ * Uses USD pricing to convert between fee token amounts and native token costs.
2941
+ *
2942
+ * @param feeTokenAmount - The amount in fee token (DAI)
2943
+ * @param getQuoteIn - Whether to use "source" or "dest" chain for the conversion
2944
+ * @param evmChainID - The EVM chain ID in format "EVM-{id}"
2945
+ * @returns The fee token amount converted to native token amount
2946
+ * @private
2947
+ */
2948
+ ? /**
2949
+ * Converts fee token amounts back to the equivalent amount in native token.
2950
+ * Uses USD pricing to convert between fee token amounts and native token costs.
2951
+ *
2952
+ * @param feeTokenAmount - The amount in fee token (DAI)
2953
+ * @param getQuoteIn - Whether to use "source" or "dest" chain for the conversion
2954
+ * @param evmChainID - The EVM chain ID in format "EVM-{id}"
2955
+ * @returns The fee token amount converted to native token amount
2956
+ * @private
2957
+ */: number;
2833
2958
  };
2834
2959
  } | {
2835
2960
  status: RequestStatus["HYPERBRIDGE_FINALIZED"];
@@ -3229,4 +3354,4 @@ declare const coingeckoIds: {
3229
3354
  "EVM-130": string;
3230
3355
  };
3231
3356
 
3232
- export { ADDRESS_ZERO, type AllStatusKey, type AssetTeleported, type AssetTeleportedResponse, type BlockMetadata, type CancelOptions, type ChainConfig, ChainConfigService, type ChainId, Chains, type ClientConfig, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DUMMY_PRIVATE_KEY, type DecodedOrderPlacedLog, type DispatchGet, type DispatchPost, ERC20Method, type EstimateGasCallData, EvmChain, type EvmChainParams, type ExecutionResult, type FillOptions, type FillerConfig, type GetRequestResponse, type GetRequestWithStatus, type GetResponseByRequestIdResponse, type GetResponseStorageValues, type HexString, type HostParams, HyperClientStatus, type HyperbridgeTxEvents, type IChain, type IConfig, type IEvmConfig, type IGetRequest, type IGetRequestMessage, type IGetResponse, type IGetResponseMessage, type IHyperbridgeConfig, type IIsmpMessage, type IMessage, type IPostRequest, type IPostResponse, type IProof, type IRequestMessage, type ISubstrateConfig, type ITimeoutPostRequestMessage, IndexerClient, type IndexerQueryClient, IntentGateway, type IntentGatewayParams, type IsmpRequest, type NewDeployment, type Order, type OrderResponse, OrderStatus, type OrderStatusMetadata, type OrderWithStatus, type Params, type PaymentInfo, type PostRequestStatus, type PostRequestTimeoutStatus, type PostRequestWithStatus, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, type RequestBody, type RequestCommitment, RequestKind, type RequestResponse, RequestStatus, type RequestStatusKey, type RequestStatusWithMetadata, type ResponseCommitmentWithValues, type RetryConfig, STATE_COMMITMENTS_SLOT, type StateMachineHeight, type StateMachineIdParams, type StateMachineResponse, type StateMachineUpdate, SubstrateChain, type SubstrateChainParams, TESTNET_CHAINS, TeleportStatus, TimeoutStatus, type TimeoutStatusKey, type TokenGatewayAssetTeleportedResponse, type TokenGatewayAssetTeleportedWithStatus, type TokenInfo, type TokenPrice, type TokenPricesResponse, type TokenRegistry, type TokenRegistryResponse, type Transaction, USE_ETHERSCAN_CHAINS, WrappedNativeDecimals, type XcmGatewayParams, __test, addresses, adjustFeeDecimals, assets, bytes20ToBytes32, bytes32ToBytes20, chainIds, coingeckoIds, consensusStateIds, constructRedeemEscrowRequestBody, convertStateIdToStateMachineId, convertStateMachineIdToEnum, createQueryClient, createRpcUrls, encodeISMPMessage, estimateGasForPost, fetchPrice, generateRootWithProof, getChain, getGasPriceFromEtherscan, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, hexToString, maxBigInt, orderCommitment, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, requestCommitmentKey, retryPromise, teleport, teleportDot, viemChains };
3357
+ export { ADDRESS_ZERO, type AllStatusKey, type AssetTeleported, type AssetTeleportedResponse, type BlockMetadata, type CancelOptions, type ChainConfig, ChainConfigService, type ChainId, Chains, type ClientConfig, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DUMMY_PRIVATE_KEY, type DecodedOrderPlacedLog, type DispatchGet, type DispatchPost, ERC20Method, type EstimateGasCallData, EvmChain, type EvmChainParams, type ExecutionResult, type FillOptions, type FillerConfig, type GetRequestResponse, type GetRequestWithStatus, type GetResponseByRequestIdResponse, type GetResponseStorageValues, type HexString, type HostParams, HyperClientStatus, type HyperbridgeTxEvents, type IChain, type IConfig, type IEvmConfig, type IGetRequest, type IGetRequestMessage, type IGetResponse, type IGetResponseMessage, type IHyperbridgeConfig, type IIsmpMessage, type IMessage, type IPostRequest, type IPostResponse, type IProof, type IRequestMessage, type ISubstrateConfig, type ITimeoutPostRequestMessage, IndexerClient, type IndexerQueryClient, IntentGateway, type IntentGatewayParams, type IsmpRequest, type NewDeployment, type Order, type OrderResponse, OrderStatus, type OrderStatusMetadata, type OrderWithStatus, type Params, type PaymentInfo, type PostRequestStatus, type PostRequestTimeoutStatus, type PostRequestWithStatus, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, type RequestBody, type RequestCommitment, RequestKind, type RequestResponse, RequestStatus, type RequestStatusKey, type RequestStatusWithMetadata, type ResponseCommitmentWithValues, type RetryConfig, STATE_COMMITMENTS_SLOT, type StateMachineHeight, type StateMachineIdParams, type StateMachineResponse, type StateMachineUpdate, SubstrateChain, TESTNET_CHAINS, TeleportStatus, TimeoutStatus, type TimeoutStatusKey, type TokenGatewayAssetTeleportedResponse, type TokenGatewayAssetTeleportedWithStatus, type TokenInfo, type TokenPrice, type TokenPricesResponse, type TokenRegistry, type TokenRegistryResponse, type Transaction, USE_ETHERSCAN_CHAINS, WrappedNativeDecimals, type XcmGatewayParams, __test, addresses, adjustFeeDecimals, assets, bytes20ToBytes32, bytes32ToBytes20, chainIds, coingeckoIds, consensusStateIds, constructRedeemEscrowRequestBody, convertStateIdToStateMachineId, convertStateMachineIdToEnum, createChain, createEvmChain, createIndexerClient, createQueryClient, createRpcUrls, encodeISMPMessage, estimateGasForPost, fetchPrice, generateRootWithProof, getChain, getGasPriceFromEtherscan, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, hexToString, maxBigInt, orderCommitment, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, requestCommitmentKey, retryPromise, teleport, teleportDot, viemChains };