@paraspell/sdk-core 13.4.1 → 13.5.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.
Files changed (3) hide show
  1. package/dist/index.d.ts +1394 -1333
  2. package/dist/index.mjs +654 -646
  3. package/package.json +4 -4
package/dist/index.d.ts CHANGED
@@ -2,11 +2,11 @@ import * as _paraspell_sdk_common from '@paraspell/sdk-common';
2
2
  import { TSubstrateChain, TChain, Version, TRelaychain, TParachain, TLocation, TExternalChain, TJunction, Parents, TJunctions } from '@paraspell/sdk-common';
3
3
  export * from '@paraspell/sdk-common';
4
4
  import * as _paraspell_assets from '@paraspell/assets';
5
- import { TAssetInfo, WithAmount, TAsset, TCurrencyCore, TCurrencyInputWithAmount, TCurrencyInput, TAmount, TAssetWithFee, WithComplexAmount, TAssetInfoWithId } from '@paraspell/assets';
5
+ import { TAssetInfo, WithAmount, TAsset, TCurrencyInputWithAmount, TCurrencyInput, TCurrencyCore, TAmount, TAssetWithFee, WithComplexAmount, TAssetInfoWithId } from '@paraspell/assets';
6
6
  export * from '@paraspell/assets';
7
7
  import { TPallet, TAssetsPallet } from '@paraspell/pallets';
8
8
  export * from '@paraspell/pallets';
9
- import { WalletClient, formatUnits as formatUnits$1, parseUnits as parseUnits$1 } from 'viem';
9
+ import { WalletClient, TransactionSerializableEIP1559, Address, formatUnits as formatUnits$1, parseUnits as parseUnits$1 } from 'viem';
10
10
 
11
11
  type WithApi<TBase, TApi, TRes, TSigner> = TBase & {
12
12
  api: PolkadotApi<TApi, TRes, TSigner>;
@@ -113,7 +113,6 @@ declare abstract class Chain<TApi, TRes, TSigner> {
113
113
  transferLocal(options: TTransferInternalOptions<TApi, TRes, TSigner>): Promise<TRes>;
114
114
  transferLocalNativeAsset(options: TTransferLocalOptions<TApi, TRes, TSigner>): Promise<TRes>;
115
115
  transferLocalNonNativeAsset(options: TTransferLocalOptions<TApi, TRes, TSigner>): TRes;
116
- protected transferToEthereum<TApi, TRes, TSigner>(input: TPolkadotXCMTransferOptions<TApi, TRes, TSigner>, useOnlyDepositInstruction?: boolean): Promise<TRes>;
117
116
  getBalanceNative(api: PolkadotApi<TApi, TRes, TSigner>, address: string, asset: TAssetInfo): Promise<bigint>;
118
117
  getCustomCurrencyId(_asset: TAssetInfo): unknown;
119
118
  getBalanceForeign<TApi, TRes, TSigner>(api: PolkadotApi<TApi, TRes, TSigner>, address: string, asset: TAssetInfo): Promise<bigint>;
@@ -150,7 +149,6 @@ declare class AssetHubKusama<TApi, TRes, TSigner> extends Chain<TApi, TRes, TSig
150
149
 
151
150
  declare class AssetHubPolkadot<TApi, TRes, TSigner> extends Chain<TApi, TRes, TSigner> implements IPolkadotXCMTransfer<TApi, TRes, TSigner> {
152
151
  constructor(chain?: TParachain, info?: string, ecosystem?: TRelaychain, version?: Version);
153
- handleEthBridgeNativeTransfer<TApi, TRes, TSigner>(input: TPolkadotXCMTransferOptions<TApi, TRes, TSigner>): Promise<TRes>;
154
152
  transferPolkadotXCM(options: TPolkadotXCMTransferOptions<TApi, TRes, TSigner>): Promise<TRes>;
155
153
  transferLocalNonNativeAsset(options: TTransferLocalOptions<TApi, TRes, TSigner>): TRes;
156
154
  getBalanceForeign<TApi, TRes, TSigner>(api: PolkadotApi<TApi, TRes, TSigner>, address: string, asset: TAssetInfo): Promise<bigint>;
@@ -601,834 +599,114 @@ declare const TRANSACT_ORIGINS: readonly ["Native", "SovereignAccount", "Superus
601
599
  */
602
600
  declare const EXCHANGE_CHAINS: readonly ["AssetHubPolkadot", "AssetHubKusama", "AssetHubPaseo", "AssetHubWestend", "Hydration", "Karura", "Acala", "BifrostKusama", "BifrostPolkadot"];
603
601
 
604
- type TSwapConfig = {
605
- currencyTo: TCurrencyCore;
606
- exchangeChain: TParachain;
607
- };
608
- type TDryRunBaseOptions<TRes> = {
609
- tx: TRes;
610
- origin: TSubstrateChain;
611
- destination: TChain;
612
- sender: string;
613
- currency: TCurrencyInputWithAmount;
614
- version?: Version;
615
- feeAsset?: TCurrencyInput;
616
- swapConfig?: TSwapConfig;
617
- useRootOrigin?: boolean;
618
- bypassOptions?: TBypassOptions;
619
- };
620
- type TDryRunOptions<TApi, TRes, TSigner> = WithApi<TDryRunBaseOptions<TRes>, TApi, TRes, TSigner>;
621
- type TDryRunCallBaseOptions<TRes> = {
602
+ /**
603
+ * Builder class for constructing asset claim transactions.
604
+ *
605
+ * @deprecated Asset claim functionality is deprecated and will be removed in v14.
606
+ */
607
+ declare class AssetClaimBuilder<TApi, TRes, TSigner, T extends Partial<TAssetClaimOptionsBase & TBuilderInternalOptions<TSigner>> = object> {
608
+ readonly api: PolkadotApi<TApi, TRes, TSigner>;
609
+ readonly _options: T;
610
+ constructor(api: PolkadotApi<TApi, TRes, TSigner>, options?: T);
622
611
  /**
623
- * The transaction to dry-run
612
+ * Specifies the assets to be claimed.
613
+ *
614
+ * @param assets - An array of assets to claim in a multi-asset format.
615
+ * @returns An instance of Builder
624
616
  */
625
- tx: TRes;
617
+ currency(currency: TAssetClaimOptionsBase['currency']): AssetClaimBuilder<TApi, TRes, TSigner, T & {
618
+ currency: TAssetClaimOptionsBase['currency'];
619
+ }>;
626
620
  /**
627
- * The chain to dry-run on
621
+ * Sets the sender address.
622
+ *
623
+ * @param address - The sender address.
624
+ * @returns
628
625
  */
629
- chain: TSubstrateChain;
626
+ sender(sender: TSender<TSigner>): AssetClaimBuilder<TApi, TRes, TSigner, T & {
627
+ sender: string;
628
+ }>;
630
629
  /**
631
- * The destination chain
630
+ * Specifies the account address on which the assets will be claimed.
631
+ *
632
+ * @param address - The destination account address.
633
+ * @returns An instance of Builder
632
634
  */
633
- destination: TDestination;
635
+ address(address: TAddress): AssetClaimBuilder<TApi, TRes, TSigner, T & {
636
+ address: TAddress;
637
+ }>;
634
638
  /**
635
- * The address to dry-run with
639
+ * Sets the XCM version to be used for the asset claim.
640
+ *
641
+ * @param version - The XCM version.
642
+ * @returns An instance of Builder
636
643
  */
637
- address: string;
644
+ xcmVersion(version: Version): AssetClaimBuilder<TApi, TRes, TSigner, T & {
645
+ version: Version;
646
+ }>;
638
647
  /**
639
- * Whether to use the root origin
648
+ * Builds and returns the asset claim extrinsic.
649
+ *
650
+ * @returns A Promise that resolves to the asset claim extrinsic.
640
651
  */
641
- useRootOrigin?: boolean;
652
+ build(this: AssetClaimBuilder<TApi, TRes, TSigner, TAssetClaimOptionsBase>): Promise<TRes>;
653
+ signAndSubmit(this: AssetClaimBuilder<TApi, TRes, TSigner, TAssetClaimOptionsBase & TBuilderInternalOptions<TSigner>>): Promise<string>;
642
654
  /**
643
- * XCM version to use for the dry-run parameters
655
+ * Returns the API instance used by the builder.
656
+ *
657
+ * @returns The API instance.
644
658
  */
645
- version: Version;
646
- asset: WithAmount<TAssetInfo>;
647
- bypassOptions?: TBypassOptions;
648
- feeAsset?: TAssetInfo;
649
- };
650
- type TDryRunBypassOptions<TApi, TRes, TSigner> = WithApi<Omit<TDryRunCallBaseOptions<TRes>, 'useRootOrigin' | 'destination'>, TApi, TRes, TSigner>;
651
- type TDryRunCallOptions<TApi, TRes, TSigner> = WithApi<TDryRunCallBaseOptions<TRes>, TApi, TRes, TSigner>;
652
- type TDryRunXcmBaseOptions<TRes> = {
653
- originLocation: any;
659
+ getApi(): TApi;
654
660
  /**
655
- * The XCM instructions
661
+ * Disconnects the API.
662
+ *
663
+ * @returns A Promise that resolves when the API is disconnected.
656
664
  */
657
- xcm: any;
658
- /** The transaction to dry-run */
659
- tx: TRes;
665
+ disconnect(): Promise<void>;
666
+ }
667
+
668
+ declare class BatchTransactionManager<TApi, TRes, TSigner> {
669
+ transactionOptions: TBatchedTransferOptions<TApi, TRes, TSigner>[];
670
+ addTransaction(options: TBatchedTransferOptions<TApi, TRes, TSigner>): void;
671
+ isEmpty(): boolean;
672
+ buildBatch(api: PolkadotApi<TApi, TRes, TSigner>, from: TSubstrateChain, options?: TBatchOptions): Promise<TRes>;
673
+ }
674
+
675
+ /**
676
+ * A builder class for constructing Para-to-Para, Para-to-Relay, Relay-to-Para transactions and asset claims.
677
+ */
678
+ declare class GeneralBuilder<TApi, TRes, TSigner, T extends Partial<TTransferBaseOptions<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>> = object> {
679
+ readonly batchManager: BatchTransactionManager<TApi, TRes, TSigner>;
680
+ readonly api: PolkadotApi<TApi, TRes, TSigner>;
681
+ readonly _options: T;
682
+ constructor(api: PolkadotApi<TApi, TRes, TSigner>, batchManager: BatchTransactionManager<TApi, TRes, TSigner>, options?: T);
660
683
  /**
661
- * The chain to dry-run on
684
+ * Specifies the origin chain for the transaction.
685
+ *
686
+ * @param chain - The chain from which the transaction originates.
687
+ * @returns An instance of Builder
662
688
  */
663
- chain: TSubstrateChain;
689
+ from(chain: TChain): GeneralBuilder<TApi, TRes, TSigner, T & {
690
+ from: TChain;
691
+ }>;
664
692
  /**
665
- * The origin chain
693
+ * Specifies the destination chain for the transaction.
694
+ *
695
+ * @param chain - The chain to which the transaction is sent.
696
+ * @param paraIdTo - (Optional) The parachain ID of the destination chain.
697
+ * @returns An instance of Builder
666
698
  */
667
- origin: TSubstrateChain;
668
- asset: TAssetInfo;
669
- version: Version;
670
- feeAsset?: TAssetInfo;
671
- amount: bigint;
672
- originFee: bigint;
673
- };
674
- type TDryRunXcmOptions<TApi, TRes, TSigner> = WithApi<TDryRunXcmBaseOptions<TRes>, TApi, TRes, TSigner>;
675
- type TDryRunResBase = {
676
- asset: TAssetInfo;
677
- isExchange?: boolean;
678
- };
679
- type TDryRunChainSuccess = TDryRunResBase & {
680
- success: true;
681
- fee: bigint;
682
- weight?: TWeight;
683
- forwardedXcms: any;
684
- destParaId?: number;
685
- };
686
- type TDryRunChainFailure = TDryRunResBase & {
687
- success: false;
688
- failureReason: string;
689
- failureSubReason?: string;
690
- };
691
- type TDryRunChainResult = TDryRunChainSuccess | TDryRunChainFailure;
692
- type THopInfo = {
693
- chain: TChain;
694
- result: TDryRunChainResult;
695
- };
696
- type TChainEndpoint = 'origin' | 'destination' | TChain;
697
- type TDryRunResult = {
698
- failureReason?: string;
699
- failureSubReason?: string;
700
- failureChain?: TChainEndpoint;
701
- origin: TDryRunChainResult;
702
- destination?: TDryRunChainResult;
703
- hops: THopInfo[];
704
- };
705
- type TResolveHopParams<TApi, TRes, TSigner> = {
706
- api: PolkadotApi<TApi, TRes, TSigner>;
707
- tx: TRes;
708
- originChain: TSubstrateChain;
709
- currentChain: TSubstrateChain;
710
- destination: TDestination;
711
- asset: TAssetInfo;
712
- currency: TCurrencyInputWithAmount;
713
- swapConfig?: TSwapConfig;
714
- hasPassedExchange: boolean;
715
- };
716
- type HopProcessParams<TApi, TRes, TSigner> = {
717
- api: PolkadotApi<TApi, TRes, TSigner>;
718
- currentChain: TSubstrateChain;
719
- currentOrigin: TSubstrateChain;
720
- currentAsset: TAssetInfo;
721
- forwardedXcms: any;
722
- hasPassedExchange: boolean;
723
- isDestination: boolean;
724
- };
725
- type HopTraversalConfig<TApi, TRes, TSigner, THopResult> = {
726
- api: PolkadotApi<TApi, TRes, TSigner>;
727
- origin: TSubstrateChain;
728
- destination: TChain;
729
- currency: TCurrencyCore;
730
- initialForwardedXcms: any;
731
- initialDestParaId: number | undefined;
732
- swapConfig?: TSwapConfig;
733
- processHop: (params: HopProcessParams<TApi, TRes, TSigner>) => Promise<THopResult>;
734
- shouldContinue: (hopResult: THopResult) => boolean;
735
- extractNextHopData: (hopResult: THopResult) => {
736
- forwardedXcms: any;
737
- destParaId: number | undefined;
738
- };
739
- };
740
- type HopTraversalResult<THopResult> = {
741
- hops: Array<{
742
- chain: TSubstrateChain;
743
- result: THopResult;
744
- }>;
745
- destination?: THopResult;
746
- lastProcessedChain?: TSubstrateChain;
747
- };
748
- type TBypassOptions = {
749
- mintFeeAssets?: boolean;
750
- sentAssetMintMode?: 'preview' | 'bypass';
751
- };
752
- declare enum XTokensError {
753
- AssetHasNoReserve = "AssetHasNoReserve",
754
- NotCrossChainTransfer = "NotCrossChainTransfer",
755
- InvalidDest = "InvalidDest",
756
- NotCrossChainTransferableCurrency = "NotCrossChainTransferableCurrency",
757
- UnweighableMessage = "UnweighableMessage",
758
- XcmExecutionFailed = "XcmExecutionFailed",
759
- CannotReanchor = "CannotReanchor",
760
- InvalidAncestry = "InvalidAncestry",
761
- InvalidAsset = "InvalidAsset",
762
- DestinationNotInvertible = "DestinationNotInvertible",
763
- BadVersion = "BadVersion",
764
- DistinctReserveForAssetAndFee = "DistinctReserveForAssetAndFee",
765
- ZeroFee = "ZeroFee",
766
- ZeroAmount = "ZeroAmount",
767
- TooManyAssetsBeingSent = "TooManyAssetsBeingSent",
768
- AssetIndexNonExistent = "AssetIndexNonExistent",
769
- FeeNotEnough = "FeeNotEnough",
770
- NotSupportedLocation = "NotSupportedLocation",
771
- MinXcmFeeNotDefined = "MinXcmFeeNotDefined",
772
- RateLimited = "RateLimited"
773
- }
774
- declare enum PolkadotXcmError {
775
- Unreachable = "Unreachable",
776
- SendFailure = "SendFailure",
777
- Filtered = "Filtered",
778
- UnweighableMessage = "UnweighableMessage",
779
- DestinationNotInvertible = "DestinationNotInvertible",
780
- Empty = "Empty",
781
- CannotReanchor = "CannotReanchor",
782
- TooManyAssets = "TooManyAssets",
783
- InvalidOrigin = "InvalidOrigin",
784
- BadVersion = "BadVersion",
785
- BadLocation = "BadLocation",
786
- NoSubscription = "NoSubscription",
787
- AlreadySubscribed = "AlreadySubscribed",
788
- CannotCheckOutTeleport = "CannotCheckOutTeleport",
789
- LowBalance = "LowBalance",
790
- TooManyLocks = "TooManyLocks",
791
- AccountNotSovereign = "AccountNotSovereign",
792
- FeesNotMet = "FeesNotMet",
793
- LockNotFound = "LockNotFound",
794
- InUse = "InUse",
795
- REMOVED = "REMOVED",
796
- InvalidAssetUnknownReserve = "InvalidAssetUnknownReserve",
797
- InvalidAssetUnsupportedReserve = "InvalidAssetUnsupportedReserve",
798
- TooManyReserves = "TooManyReserves",
799
- LocalExecutionIncomplete = "LocalExecutionIncomplete",
800
- TooManyAuthorizedAliases = "TooManyAuthorizedAliases",
801
- ExpiresInPast = "ExpiresInPast",
802
- AliasNotFound = "AliasNotFound",
803
- LocalExecutionIncompleteWithError = "LocalExecutionIncompleteWithError"
804
- }
805
- declare enum PolkadotXcmExecutionError {
806
- Overflow = "Overflow",
807
- Unimplemented = "Unimplemented",
808
- UntrustedReserveLocation = "UntrustedReserveLocation",
809
- UntrustedTeleportLocation = "UntrustedTeleportLocation",
810
- LocationFull = "LocationFull",
811
- LocationNotInvertible = "LocationNotInvertible",
812
- BadOrigin = "BadOrigin",
813
- InvalidLocation = "InvalidLocation",
814
- AssetNotFound = "AssetNotFound",
815
- FailedToTransactAsset = "FailedToTransactAsset",
816
- NotWithdrawable = "NotWithdrawable",
817
- LocationCannotHold = "LocationCannotHold",
818
- ExceedsMaxMessageSize = "ExceedsMaxMessageSize",
819
- DestinationUnsupported = "DestinationUnsupported",
820
- Transport = "Transport",
821
- Unroutable = "Unroutable",
822
- UnknownClaim = "UnknownClaim",
823
- FailedToDecode = "FailedToDecode",
824
- MaxWeightInvalid = "MaxWeightInvalid",
825
- NotHoldingFees = "NotHoldingFees",
826
- TooExpensive = "TooExpensive",
827
- Trap = "Trap",
828
- ExpectationFalse = "ExpectationFalse",
829
- PalletNotFound = "PalletNotFound",
830
- NameMismatch = "NameMismatch",
831
- VersionIncompatible = "VersionIncompatible",
832
- HoldingWouldOverflow = "HoldingWouldOverflow",
833
- ExportError = "ExportError",
834
- ReanchorFailed = "ReanchorFailed",
835
- NoDeal = "NoDeal",
836
- FeesNotMet = "FeesNotMet",
837
- LockError = "LockError",
838
- NoPermission = "NoPermission",
839
- Unanchored = "Unanchored",
840
- NotDepositable = "NotDepositable",
841
- TooManyAssets = "TooManyAssets",
842
- UnhandledXcmVersion = "UnhandledXcmVersion",
843
- WeightLimitReached = "WeightLimitReached",
844
- Barrier = "Barrier",
845
- WeightNotComputable = "WeightNotComputable",
846
- ExceedsStackLimit = "ExceedsStackLimit"
847
- }
848
- type TModuleError = {
849
- index: string;
850
- error: string;
851
- };
852
- type TDryRunError = {
853
- failureReason: string;
854
- failureSubReason?: string;
855
- };
856
-
857
- type TXcmFeeSwapConfig = TSwapConfig & {
858
- amountOut: bigint;
859
- };
860
- type TTxFactory<TRes> = (amount?: string, relative?: boolean) => Promise<TRes>;
861
- type TGetXcmFeeBaseOptions<TRes, TDisableFallback extends boolean = boolean> = {
862
- /**
863
- * The transaction factory
864
- */
865
- buildTx: TTxFactory<TRes>;
866
- /**
867
- * The origin chain
868
- */
869
- origin: TSubstrateChain;
870
- /**
871
- * The destination chain
872
- */
873
- destination: TChain;
874
- /**
875
- * The sender address
876
- */
877
- sender: string;
878
- recipient: string;
879
- currency: WithAmount<TCurrencyCore>;
880
- version?: Version;
881
- feeAsset?: TCurrencyInput;
882
- disableFallback: TDisableFallback;
883
- swapConfig?: TXcmFeeSwapConfig;
884
- skipReverseFeeCalculation?: boolean;
885
- };
886
- type TGetXcmFeeOptions<TApi, TRes, TSigner, TDisableFallback extends boolean = boolean> = WithApi<TGetXcmFeeBaseOptions<TRes, TDisableFallback>, TApi, TRes, TSigner>;
887
- type TGetXcmFeeInternalOptions<TApi, TRes, TSigner, TDisableFallback extends boolean = boolean> = Omit<TGetXcmFeeOptions<TApi, TRes, TSigner, TDisableFallback>, 'buildTx'> & {
888
- tx: TRes;
889
- useRootOrigin: boolean;
890
- };
891
- type TGetXcmFeeBuilderOptions = {
892
- disableFallback: boolean;
893
- };
894
- type TGetOriginXcmFeeBaseOptions<TRes> = {
895
- buildTx: TTxFactory<TRes>;
896
- origin: TSubstrateChain;
897
- destination: TChain;
898
- sender: string;
899
- currency: WithAmount<TCurrencyCore>;
900
- version?: Version;
901
- feeAsset?: TCurrencyInput;
902
- disableFallback: boolean;
903
- useRootOrigin?: boolean;
904
- };
905
- type TGetOriginXcmFeeOptions<TApi, TRes, TSigner> = WithApi<TGetOriginXcmFeeBaseOptions<TRes>, TApi, TRes, TSigner>;
906
- type TGetOriginXcmFeeInternalOptions<TApi, TRes, TSigner> = Omit<TGetOriginXcmFeeOptions<TApi, TRes, TSigner>, 'buildTx'> & {
907
- tx: TRes;
908
- };
909
- type TGetFeeForDestChainBaseOptions<TRes> = {
910
- prevChain: TSubstrateChain;
911
- origin: TSubstrateChain;
912
- destination: TChain;
913
- sender: string;
914
- recipient: string;
915
- currency: WithAmount<TCurrencyCore>;
916
- forwardedXcms: any;
917
- tx: TRes;
918
- asset: TAssetInfo;
919
- version: Version;
920
- originFee: bigint;
921
- feeAsset?: TCurrencyInput;
922
- disableFallback: boolean;
923
- hasPassedExchange?: boolean;
924
- swapConfig?: TXcmFeeSwapConfig;
925
- skipReverseFeeCalculation?: boolean;
926
- };
927
- type TGetFeeForDestChainOptions<TApi, TRes, TSigner> = WithApi<TGetFeeForDestChainBaseOptions<TRes>, TApi, TRes, TSigner>;
928
- type TGetReverseTxFeeOptions<TApi, TRes, TSigner> = Omit<TGetFeeForDestChainOptions<TApi, TRes, TSigner>, 'destination' | 'disableFallback' | 'forwardedXcms' | 'asset' | 'originFee' | 'prevChain' | 'version'> & {
929
- destination: TSubstrateChain;
930
- };
931
- type TFeeType = 'dryRun' | 'paymentInfo' | 'noFeeRequired';
932
- type TXcmFeeBase$1 = {
933
- asset: TAssetInfo;
934
- weight?: TWeight;
935
- sufficient?: boolean;
936
- isExchange?: boolean;
937
- };
938
- type TXcmFeeDetailSuccess = TXcmFeeBase$1 & {
939
- fee: bigint;
940
- feeType: TFeeType;
941
- dryRunError?: string;
942
- dryRunSubError?: string;
943
- };
944
- type TXcmFeeDetailWithFallback = TXcmFeeDetailSuccess;
945
- type TXcmFeeDetailError = TXcmFeeBase$1 & {
946
- fee?: bigint;
947
- feeType?: TFeeType;
948
- dryRunError: string;
949
- dryRunSubError?: string;
950
- };
951
- type TXcmFeeDetail = TXcmFeeDetailSuccess | TXcmFeeDetailError;
952
- type TXcmFeeHopResult = {
953
- fee?: bigint;
954
- feeType?: TFeeType;
955
- sufficient?: boolean;
956
- dryRunError?: string;
957
- dryRunSubError?: string;
958
- forwardedXcms?: any;
959
- destParaId?: number;
960
- asset: TAssetInfo;
961
- };
962
- type TConditionalXcmFeeDetail<TDisableFallback extends boolean> = TDisableFallback extends false ? TXcmFeeDetailWithFallback : TXcmFeeDetail;
963
- type TDestXcmFeeDetail<TDisableFallback extends boolean> = TConditionalXcmFeeDetail<TDisableFallback> & {
964
- forwardedXcms?: any;
965
- destParaId?: number;
966
- };
967
- type TConditionalXcmFeeHopInfo<TDisableFallback extends boolean> = {
968
- chain: TChain;
969
- result: TConditionalXcmFeeDetail<TDisableFallback>;
970
- };
971
- type TXcmFeeHopInfo = {
972
- chain: TChain;
973
- result: TXcmFeeDetail;
974
- };
975
- type TGetXcmFeeResult<TDisableFallback extends boolean = boolean> = {
976
- failureReason?: string;
977
- failureChain?: TChainEndpoint;
978
- origin: TConditionalXcmFeeDetail<TDisableFallback>;
979
- destination: TConditionalXcmFeeDetail<TDisableFallback>;
980
- hops: TConditionalXcmFeeHopInfo<TDisableFallback>[];
981
- };
982
- type TPaymentInfo = {
983
- partialFee: bigint;
984
- weight: TWeight;
985
- };
986
-
987
- type TExchangeChain = (typeof EXCHANGE_CHAINS)[number];
988
- type TExchangeInput = TExchangeChain | TExchangeChain[] | undefined;
989
- type TSwapOptions<TApi, TRes, TSigner> = {
990
- currencyTo: TCurrencyCore;
991
- exchange?: TExchangeInput;
992
- slippage?: number;
993
- evmSenderAddress?: string;
994
- evmSigner?: TSigner;
995
- onStatusChange?: TStatusChangeCallback<TApi, TRes>;
996
- };
997
- type TTransactionContext<TApi, TRes> = {
998
- type: TTransactionType;
999
- api: TApi;
1000
- chain: TSubstrateChain;
1001
- tx: TRes;
1002
- };
1003
- type TTransactionType = 'TRANSFER' | 'SWAP' | 'SWAP_AND_TRANSFER';
1004
- type TSwapEventType = TTransactionType | 'SELECTING_EXCHANGE' | 'COMPLETED';
1005
- /**
1006
- * The transaction progress information.
1007
- */
1008
- type TSwapEvent<TApi, TRes> = {
1009
- /**
1010
- * Current execution phase type
1011
- */
1012
- type: TSwapEventType;
1013
- /**
1014
- * Full transaction plan for visualization
1015
- */
1016
- routerPlan?: TTransactionContext<TApi, TRes>[];
1017
- /**
1018
- * Current transaction's origin chain
1019
- */
1020
- chain?: TSubstrateChain;
1021
- /**
1022
- * Current transaction's destination chain
1023
- */
1024
- destinationChain?: TChain;
1025
- /**
1026
- * 0-based step index of current operation
1027
- */
1028
- currentStep?: number;
1029
- };
1030
- type TStatusChangeCallback<TApi, TRes> = (info: TSwapEvent<TApi, TRes>) => void;
1031
- interface TSwapBuilder<TApi, TRes, TSigner> {
1032
- from(chain: TSubstrateChain | undefined): TSwapBuilder<TApi, TRes, TSigner>;
1033
- to(chain: TChain | undefined): TSwapBuilder<TApi, TRes, TSigner>;
1034
- exchange(chain: TExchangeInput): TSwapBuilder<TApi, TRes, TSigner>;
1035
- currencyFrom(currency: TCurrencyInput): TSwapBuilder<TApi, TRes, TSigner>;
1036
- currencyTo(currency: TCurrencyInput): TSwapBuilder<TApi, TRes, TSigner>;
1037
- feeAsset(currency: TCurrencyInput | undefined): TSwapBuilder<TApi, TRes, TSigner>;
1038
- amount(amount: TAmount): TSwapBuilder<TApi, TRes, TSigner>;
1039
- recipient(address: string | undefined): TSwapBuilder<TApi, TRes, TSigner>;
1040
- sender(address: string): TSwapBuilder<TApi, TRes, TSigner>;
1041
- signer(signer: TSigner): TSwapBuilder<TApi, TRes, TSigner>;
1042
- evmSenderAddress(address: string | undefined): TSwapBuilder<TApi, TRes, TSigner>;
1043
- evmSigner(signer: TSigner | undefined): TSwapBuilder<TApi, TRes, TSigner>;
1044
- slippagePct(pct: string): TSwapBuilder<TApi, TRes, TSigner>;
1045
- onStatusChange(callback: TStatusChangeCallback<TApi, TRes>): TSwapBuilder<TApi, TRes, TSigner>;
1046
- getXcmFees<TDisableFallback extends boolean = false>(options?: TGetXcmFeeBuilderOptions & {
1047
- disableFallback: TDisableFallback;
1048
- }): Promise<TGetXcmFeeResult<TDisableFallback>>;
1049
- getTransferableAmount(): Promise<bigint>;
1050
- getMinTransferableAmount(): Promise<bigint>;
1051
- getBestAmountOut(): Promise<{
1052
- exchange: TExchangeChain;
1053
- amountOut: bigint;
1054
- }>;
1055
- dryRun(): Promise<TDryRunResult>;
1056
- build(): Promise<TTransactionContext<TApi, TRes>[]>;
1057
- signAndSubmit(): Promise<string[]>;
1058
- }
1059
- type TSwapBuilderFactory = <TApi, TRes, TSigner>(api: PolkadotApi<TApi, TRes, TSigner>) => TSwapBuilder<TApi, TRes, TSigner>;
1060
-
1061
- type TPolkadotXCMTransferOptions<TApi, TRes, TSigner> = {
1062
- api: PolkadotApi<TApi, TRes, TSigner>;
1063
- chain: TSubstrateChain;
1064
- beneficiaryLocation: TLocation;
1065
- recipient: TAddress;
1066
- asset: TAsset;
1067
- overriddenAsset?: TLocation | TAssetWithFee[];
1068
- scenario: TScenario;
1069
- assetInfo: WithAmount<TAssetInfo>;
1070
- currency: TCurrencyInputWithAmount;
1071
- feeAssetInfo?: TAssetInfo;
1072
- feeCurrency?: TCurrencyInput;
1073
- destination: TDestination;
1074
- destChain?: TChain;
1075
- paraIdTo?: number;
1076
- version: Version;
1077
- sender?: string;
1078
- ahAddress?: string;
1079
- pallet?: string;
1080
- method?: string;
1081
- transactOptions?: TTransactOptions<TRes>;
1082
- };
1083
- type TXTokensTransferOptions<TApi, TRes, TSigner> = {
1084
- api: PolkadotApi<TApi, TRes, TSigner>;
1085
- asset: WithAmount<TAssetInfo>;
1086
- recipient: TAddress;
1087
- scenario: TScenario;
1088
- origin: TSubstrateChain;
1089
- destination: TDestination;
1090
- paraIdTo?: number;
1091
- version: Version;
1092
- overriddenAsset?: TLocation | TAssetWithFee[];
1093
- pallet?: string;
1094
- method?: string;
1095
- useMultiAssetTransfer?: boolean;
1096
- };
1097
- interface IPolkadotXCMTransfer<TApi, TRes, TSigner> {
1098
- transferPolkadotXCM: (input: TPolkadotXCMTransferOptions<TApi, TRes, TSigner>) => Promise<TRes>;
1099
- }
1100
- interface IXTokensTransfer<TApi, TRes, TSigner> {
1101
- transferXTokens: (input: TXTokensTransferOptions<TApi, TRes, TSigner>) => TRes;
1102
- }
1103
- type TScenario = 'ParaToRelay' | 'ParaToPara' | 'RelayToPara';
1104
- type TAddress = string | TLocation;
1105
- type TDestination = TChain | TLocation;
1106
- type TTransferBaseOptions<TApi, TRes, TSigner> = {
1107
- /**
1108
- * The origin chain
1109
- */
1110
- from: TChain;
1111
- /**
1112
- * The destination address. A SS58 or H160 format.
1113
- */
1114
- recipient: TAddress;
1115
- /**
1116
- * The optional sender address. A SS58 or H160 format.
1117
- */
1118
- sender?: string;
1119
- /**
1120
- * The optional asset hub address. A SS58 format only.
1121
- */
1122
- ahAddress?: string;
1123
- /**
1124
- * The destination chain or XCM location
1125
- */
1126
- to: TDestination;
1127
- /**
1128
- * The currency to transfer. Either ID, symbol, location, or multi-asset
1129
- */
1130
- currency: TCurrencyInputWithAmount;
1131
- /**
1132
- * The optional fee asset. Either ID, symbol, or location
1133
- */
1134
- feeAsset?: TCurrencyInput;
1135
- /**
1136
- * The optional destination parachain ID
1137
- */
1138
- paraIdTo?: number;
1139
- /**
1140
- * The optional overrided XCM version
1141
- */
1142
- version?: Version;
1143
- /**
1144
- * The optional pallet override
1145
- */
1146
- pallet?: string;
1147
- /**
1148
- * Whether to keep the account alive after the transfer.
1149
- */
1150
- keepAlive?: boolean;
1151
- /**
1152
- * The optional pallet method override
1153
- */
1154
- method?: string;
1155
- /**
1156
- * Hex of the encoded transaction call to apply on the destination chain
1157
- */
1158
- transactOptions?: TTransactOptions<TRes>;
1159
- /**
1160
- * The optional swap options
1161
- */
1162
- swapOptions?: TSwapOptions<TApi, TRes, TSigner>;
1163
- };
1164
- /**
1165
- * Options for transferring from a parachain to another parachain or relay chain
1166
- */
1167
- type TTransferOptions<TApi, TRes, TSigner> = WithApi<TTransferBaseOptions<TApi, TRes, TSigner>, TApi, TRes, TSigner> & {
1168
- isAmountAll: boolean;
1169
- };
1170
- type TSubstrateTransferBaseOptions<TApi, TRes, TSigner> = Omit<TTransferBaseOptions<TApi, TRes, TSigner>, 'from'> & {
1171
- from: TSubstrateChain;
1172
- };
1173
- type TSubstrateTransferOptions<TApi, TRes, TSigner> = Omit<TTransferOptions<TApi, TRes, TSigner>, 'from'> & {
1174
- from: TSubstrateChain;
1175
- };
1176
- type WithRequiredSender<TBase> = Omit<TBase, 'sender'> & {
1177
- /**
1178
- * The sender address. A SS58 or H160 format.
1179
- */
1180
- sender: string;
1181
- };
1182
- type WithRequiredSwapOptions<TBase, TApi, TRes, TSigner> = Omit<TBase, 'swapOptions'> & {
1183
- swapOptions: TSwapOptions<TApi, TRes, TSigner>;
1184
- };
1185
- type TTransferOptionsWithSwap<TApi, TRes, TSigner> = WithRequiredSwapOptions<Omit<TSubstrateTransferOptions<TApi, TRes, TSigner>, 'isAmountAll'>, TApi, TRes, TSigner>;
1186
- type TTransferBaseOptionsWithSwap<TApi, TRes, TSigner> = WithRequiredSwapOptions<TTransferBaseOptions<TApi, TRes, TSigner>, TApi, TRes, TSigner>;
1187
- type TTransferBaseOptionsWithSender<TApi, TRes, TSigner> = WithRequiredSender<TTransferBaseOptions<TApi, TRes, TSigner>>;
1188
- type TSubstrateTransferBaseOptionsWithSender<TApi, TRes, TSigner> = WithRequiredSender<TSubstrateTransferBaseOptions<TApi, TRes, TSigner>>;
1189
- type TTransferInternalOptions<TApi, TRes, TSigner> = Omit<TTransferBaseOptions<TApi, TRes, TSigner>, 'from' | 'feeAsset' | 'version'> & {
1190
- api: PolkadotApi<TApi, TRes, TSigner>;
1191
- assetInfo: WithAmount<TAssetInfo>;
1192
- feeAsset?: TAssetInfo;
1193
- feeCurrency?: TCurrencyInput;
1194
- overriddenAsset?: TLocation | TAssetWithFee[];
1195
- version: Version;
1196
- isAmountAll: boolean;
1197
- };
1198
- type TTransactOrigin = (typeof TRANSACT_ORIGINS)[number];
1199
- type TTransactOptions<TRes, TWeightType = bigint> = {
1200
- call: string | TRes;
1201
- originKind?: TTransactOrigin;
1202
- maxWeight?: TWeight<TWeightType>;
1203
- };
1204
- type TSerializedExtrinsics = {
1205
- module: TPallet;
1206
- method: string;
1207
- params: Record<string, unknown>;
1208
- };
1209
- type TSerializedStateQuery = {
1210
- module: TAssetsPallet;
1211
- method: string;
1212
- params: unknown[];
1213
- };
1214
- type TSerializedRuntimeApiQuery = {
1215
- module: string;
1216
- method: string;
1217
- params: unknown[];
1218
- };
1219
- type TDestWeight = {
1220
- ref_time: bigint;
1221
- proof_size: bigint;
1222
- };
1223
- type TXTokensMethod = 'transfer' | 'transfer_multiasset' | 'transfer_multiassets';
1224
- type TPolkadotXcmMethod = 'limited_teleport_assets' | 'limited_reserve_transfer_assets' | 'reserve_transfer_assets' | 'reserve_withdraw_assets' | 'transfer_assets' | 'transfer_assets_using_type_and_then';
1225
- type TXcmPalletMethod = 'limited_teleport_assets' | 'limited_reserve_transfer_assets' | 'transfer_assets_using_type_and_then';
1226
- type TWeight<TWeightType = bigint> = {
1227
- refTime: TWeightType;
1228
- proofSize: TWeightType;
1229
- };
1230
- type TCreateBeneficiaryOptions<TApi, TRes, TSigner> = {
1231
- api: PolkadotApi<TApi, TRes, TSigner>;
1232
- address: TAddress;
1233
- version: Version;
1234
- };
1235
- type TCreateBeneficiaryXTokensOptions<TApi, TRes, TSigner> = {
1236
- api: PolkadotApi<TApi, TRes, TSigner>;
1237
- origin: TSubstrateChain;
1238
- destination: TDestination;
1239
- recipient: TAddress;
1240
- version: Version;
1241
- paraId?: number;
1242
- };
1243
- type TBridgeStatus = 'Normal' | 'Halted';
1244
- type TTransferLocalOptions<TApi, TRes, TSigner> = Omit<TTransferInternalOptions<TApi, TRes, TSigner>, 'recipient'> & {
1245
- recipient: string;
1246
- balance: bigint;
1247
- };
1248
- type TTransferFeeEstimates = {
1249
- originFee: bigint;
1250
- reserveFee: bigint;
1251
- };
1252
- type TCreateBaseTransferXcmOptions<TRes> = {
1253
- chain: TSubstrateChain;
1254
- destChain: TChain;
1255
- assetInfo: WithAmount<TAssetInfo>;
1256
- feeAssetInfo?: TAssetInfo;
1257
- fees: TTransferFeeEstimates;
1258
- recipient: string;
1259
- sender?: string;
1260
- version: Version;
1261
- useJitWithdraw?: boolean;
1262
- useFeeAssetOnHops?: boolean;
1263
- paraIdTo?: number;
1264
- transactOptions?: TTransactOptions<TRes>;
1265
- };
1266
- type TCreateTransferXcmOptions<TApi, TRes, TSigner> = WithApi<TCreateBaseTransferXcmOptions<TRes>, TApi, TRes, TSigner>;
1267
- type TCreateBaseSwapXcmOptions = {
1268
- chain?: TSubstrateChain;
1269
- exchangeChain: TExchangeChain;
1270
- destChain?: TChain;
1271
- assetInfoFrom: WithAmount<TAssetInfo>;
1272
- assetInfoTo: WithAmount<TAssetInfo>;
1273
- currencyTo: TCurrencyInput;
1274
- feeAssetInfo?: TAssetInfo;
1275
- sender: string;
1276
- recipient: string;
1277
- calculateMinAmountOut: (amountIn: bigint, assetTo?: TAssetInfo) => Promise<bigint>;
1278
- };
1279
- type TCreateSwapXcmOptions<TApi, TRes, TSigner> = WithApi<TCreateBaseSwapXcmOptions, TApi, TRes, TSigner>;
1280
- type TSwapFeeEstimates = {
1281
- originFee: bigint;
1282
- originReserveFee: bigint;
1283
- exchangeFee: bigint;
1284
- destReserveFee: bigint;
1285
- };
1286
- type TCreateSwapXcmInternalOptions<TApi, TRes, TSigner> = WithApi<TCreateBaseSwapXcmOptions, TApi, TRes, TSigner> & {
1287
- version: Version;
1288
- fees: TSwapFeeEstimates;
1289
- paraIdTo?: number;
1290
- };
1291
- type TCreateEthBridgeInstructionsOptions<TApi, TRes, TSigner> = {
1292
- api: PolkadotApi<TApi, TRes, TSigner>;
1293
- recipient: TAddress;
1294
- assetInfo: TAssetInfo;
1295
- sender: string;
1296
- ahAddress?: string;
1297
- version: Version;
1298
- };
1299
-
1300
- /** @deprecated Asset claim functionality is deprecated and will be removed in v14. */
1301
- type TAssetClaimOptionsBase = {
1302
- chain: TSubstrateChain;
1303
- currency: WithComplexAmount<TCurrencyCore> | TAsset<TAmount>[] | WithComplexAmount<TCurrencyCore>[];
1304
- address: TAddress;
1305
- version?: Version;
1306
- };
1307
- type TAssetClaimOptions<TApi, TRes, TSigner> = WithApi<TAssetClaimOptionsBase, TApi, TRes, TSigner>;
1308
- type TAssetClaimInternalOptions<TApi, TRes, TSigner> = TAssetClaimOptions<TApi, TRes, TSigner> & {
1309
- version: Version;
1310
- assets: TAsset<bigint>[];
1311
- };
1312
-
1313
- type TSetBalanceRes = {
1314
- assetStatusTx?: TSerializedExtrinsics;
1315
- balanceTx: TSerializedExtrinsics;
1316
- };
1317
- declare abstract class BaseAssetsPallet {
1318
- protected palletName: TAssetsPallet;
1319
- constructor(palletName: TAssetsPallet);
1320
- abstract mint<TApi, TRes, TSigner>(address: string, assetInfo: WithAmount<TAssetInfo>, balance: bigint, chain: TSubstrateChain, api: PolkadotApi<TApi, TRes, TSigner>): Promise<TSetBalanceRes>;
1321
- abstract getBalance<TApi, TRes, TSigner>(api: PolkadotApi<TApi, TRes, TSigner>, address: string, asset: TAssetInfo, customCurrencyId?: unknown): Promise<bigint>;
1322
- }
1323
-
1324
- /**
1325
- * Builder class for constructing asset claim transactions.
1326
- *
1327
- * @deprecated Asset claim functionality is deprecated and will be removed in v14.
1328
- */
1329
- declare class AssetClaimBuilder<TApi, TRes, TSigner, T extends Partial<TAssetClaimOptionsBase & TBuilderInternalOptions<TSigner>> = object> {
1330
- readonly api: PolkadotApi<TApi, TRes, TSigner>;
1331
- readonly _options: T;
1332
- constructor(api: PolkadotApi<TApi, TRes, TSigner>, options?: T);
1333
- /**
1334
- * Specifies the assets to be claimed.
1335
- *
1336
- * @param assets - An array of assets to claim in a multi-asset format.
1337
- * @returns An instance of Builder
1338
- */
1339
- currency(currency: TAssetClaimOptionsBase['currency']): AssetClaimBuilder<TApi, TRes, TSigner, T & {
1340
- currency: TAssetClaimOptionsBase['currency'];
1341
- }>;
1342
- /**
1343
- * Sets the sender address.
1344
- *
1345
- * @param address - The sender address.
1346
- * @returns
1347
- */
1348
- sender(sender: TSender<TSigner>): AssetClaimBuilder<TApi, TRes, TSigner, T & {
1349
- sender: string;
1350
- }>;
1351
- /**
1352
- * Specifies the account address on which the assets will be claimed.
1353
- *
1354
- * @param address - The destination account address.
1355
- * @returns An instance of Builder
1356
- */
1357
- address(address: TAddress): AssetClaimBuilder<TApi, TRes, TSigner, T & {
1358
- address: TAddress;
1359
- }>;
1360
- /**
1361
- * Sets the XCM version to be used for the asset claim.
1362
- *
1363
- * @param version - The XCM version.
1364
- * @returns An instance of Builder
1365
- */
1366
- xcmVersion(version: Version): AssetClaimBuilder<TApi, TRes, TSigner, T & {
1367
- version: Version;
1368
- }>;
1369
- /**
1370
- * Builds and returns the asset claim extrinsic.
1371
- *
1372
- * @returns A Promise that resolves to the asset claim extrinsic.
1373
- */
1374
- build(this: AssetClaimBuilder<TApi, TRes, TSigner, TAssetClaimOptionsBase>): Promise<TRes>;
1375
- signAndSubmit(this: AssetClaimBuilder<TApi, TRes, TSigner, TAssetClaimOptionsBase & TBuilderInternalOptions<TSigner>>): Promise<string>;
1376
- /**
1377
- * Returns the API instance used by the builder.
1378
- *
1379
- * @returns The API instance.
1380
- */
1381
- getApi(): TApi;
1382
- /**
1383
- * Disconnects the API.
1384
- *
1385
- * @returns A Promise that resolves when the API is disconnected.
1386
- */
1387
- disconnect(): Promise<void>;
1388
- }
1389
-
1390
- declare class BatchTransactionManager<TApi, TRes, TSigner> {
1391
- transactionOptions: TBatchedTransferOptions<TApi, TRes, TSigner>[];
1392
- addTransaction(options: TBatchedTransferOptions<TApi, TRes, TSigner>): void;
1393
- isEmpty(): boolean;
1394
- buildBatch(api: PolkadotApi<TApi, TRes, TSigner>, from: TSubstrateChain, options?: TBatchOptions): Promise<TRes>;
1395
- }
1396
-
1397
- /**
1398
- * A builder class for constructing Para-to-Para, Para-to-Relay, Relay-to-Para transactions and asset claims.
1399
- */
1400
- declare class GeneralBuilder<TApi, TRes, TSigner, T extends Partial<TTransferBaseOptions<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>> = object> {
1401
- readonly batchManager: BatchTransactionManager<TApi, TRes, TSigner>;
1402
- readonly api: PolkadotApi<TApi, TRes, TSigner>;
1403
- readonly _options: T;
1404
- constructor(api: PolkadotApi<TApi, TRes, TSigner>, batchManager: BatchTransactionManager<TApi, TRes, TSigner>, options?: T);
1405
- /**
1406
- * Specifies the origin chain for the transaction.
1407
- *
1408
- * @param chain - The chain from which the transaction originates.
1409
- * @returns An instance of Builder
1410
- */
1411
- from(chain: TChain): GeneralBuilder<TApi, TRes, TSigner, T & {
1412
- from: TChain;
1413
- }>;
1414
- /**
1415
- * Specifies the destination chain for the transaction.
1416
- *
1417
- * @param chain - The chain to which the transaction is sent.
1418
- * @param paraIdTo - (Optional) The parachain ID of the destination chain.
1419
- * @returns An instance of Builder
1420
- */
1421
- to(chain: TDestination, paraIdTo?: number): GeneralBuilder<TApi, TRes, TSigner, T & {
1422
- to: TDestination;
1423
- }>;
1424
- /**
1425
- * Initiates the process to claim assets from a specified chain.
1426
- *
1427
- * @deprecated Asset claim functionality is deprecated and will be removed in v14.
1428
- * @param chain - The chain from which to claim assets.
1429
- * @returns An instance of Builder
1430
- */
1431
- claimFrom(chain: TSubstrateChain): AssetClaimBuilder<TApi, TRes, TSigner, {
699
+ to(chain: TDestination, paraIdTo?: number): GeneralBuilder<TApi, TRes, TSigner, T & {
700
+ to: TDestination;
701
+ }>;
702
+ /**
703
+ * Initiates the process to claim assets from a specified chain.
704
+ *
705
+ * @deprecated Asset claim functionality is deprecated and will be removed in v14.
706
+ * @param chain - The chain from which to claim assets.
707
+ * @returns An instance of Builder
708
+ */
709
+ claimFrom(chain: TSubstrateChain): AssetClaimBuilder<TApi, TRes, TSigner, {
1432
710
  chain: TSubstrateChain;
1433
711
  }>;
1434
712
  /**
@@ -1497,638 +775,1388 @@ declare class GeneralBuilder<TApi, TRes, TSigner, T extends Partial<TTransferBas
1497
775
  method: string | undefined;
1498
776
  }>;
1499
777
  /**
1500
- * Optional fee asset for the transaction.
1501
- *
1502
- * @param currency - The currency to be used for the fee.
1503
- * @returns An instance of the Builder
778
+ * Optional fee asset for the transaction.
779
+ *
780
+ * @param currency - The currency to be used for the fee.
781
+ * @returns An instance of the Builder
782
+ */
783
+ feeAsset(currency: TCurrencyInput | undefined): GeneralBuilder<TApi, TRes, TSigner, T & {
784
+ feeAsset: TCurrencyInput | undefined;
785
+ }>;
786
+ /**
787
+ * Sets the hex of the encoded transaction call to apply on the destination chain
788
+ *
789
+ * @param hex - The encoded call hex or extrinsics.
790
+ * @param originKind - (Optional) The means of expressing the message origin as a dispatch origin.
791
+ * @param maxWeight - (Optional) The weight of the call. If not provided, the weight will be estimated.
792
+ * @returns An instance of the Builder.
793
+ */
794
+ transact(call: string | TRes, originKind?: TTransactOrigin, maxWeight?: TWeight): GeneralBuilder<TApi, TRes, TSigner, T & {
795
+ transactOptions: {
796
+ call: string | TRes;
797
+ originKind: "Native" | "SovereignAccount" | "Superuser" | "Xcm" | undefined;
798
+ maxWeight: TWeight | undefined;
799
+ };
800
+ }>;
801
+ /**
802
+ * Performs a token swap as part of the transfer, using the specified exchange and destination currency.
803
+ *
804
+ * @param options - The swap options.
805
+ * @returns An instance of the Builder.
806
+ */
807
+ swap(options: TSwapOptions<TApi, TRes, TSigner>): GeneralBuilder<TApi, TRes, TSigner, T & {
808
+ swapOptions: TSwapOptions<TApi, TRes, TSigner>;
809
+ }>;
810
+ /**
811
+ * Adds the transfer transaction to the batch.
812
+ *
813
+ * @returns An instance of Builder
814
+ */
815
+ addToBatch(this: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptions<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>>): GeneralBuilder<TApi, TRes, TSigner, T & {
816
+ from: TSubstrateChain;
817
+ }>;
818
+ /**
819
+ * Builds and returns the batched transaction based on the configured parameters.
820
+ *
821
+ * @param options - (Optional) Options to customize the batch transaction.
822
+ * @returns A Extrinsic representing the batched transactions.
823
+ */
824
+ buildBatch(this: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptions<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>>, options?: TBatchOptions): Promise<TRes>;
825
+ protected buildInternal<TOptions extends TTransferBaseOptions<TApi, TRes, TSigner>>(this: GeneralBuilder<TApi, TRes, TSigner, TOptions>): Promise<TBuildInternalRes<TApi, TRes, TSigner, TOptions>>;
826
+ private prepareNormalizedOptions;
827
+ /**
828
+ * Builds and returns the transfer extrinsic.
829
+ *
830
+ * @returns A Promise that resolves to the transfer extrinsic.
831
+ */
832
+ build(this: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptions<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>>): Promise<TRes>;
833
+ /**
834
+ * Builds an unsigned EIP-1559 transaction (viem `TransactionSerializableEIP1559`) for an
835
+ * EVM-compatible origin. `nonce`, `gas`, and fees are populated from the origin chain's RPC.
836
+ */
837
+ buildEvm(this: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptionsWithSender<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>>): Promise<TransactionSerializableEIP1559>;
838
+ /**
839
+ * Builds and returns multiple transfer or swap extrinsics
840
+ *
841
+ * @returns A Promise that resolves to the transfer extrinsic contexts
842
+ */
843
+ buildAll(this: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptions<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>>): Promise<TTransactionContext<TApi, TRes>[]>;
844
+ private validateBatchState;
845
+ private buildCommon;
846
+ private buildCommonAll;
847
+ private maybePerformXcmFormatCheck;
848
+ dryRun(this: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptionsWithSender<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>>): Promise<TDryRunResult>;
849
+ dryRunPreview(this: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptionsWithSender<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>>, dryRunOptions?: TDryRunPreviewOptions): Promise<TDryRunResult>;
850
+ protected createTxFactory<TOptions extends TTransferBaseOptions<TApi, TRes, TSigner>>(this: GeneralBuilder<TApi, TRes, TSigner, TOptions>): TTxFactory<TRes>;
851
+ /**
852
+ * Returns the XCM fee for the transfer using dryRun or paymentInfo function.
853
+ *
854
+ * @returns An origin and destination fee.
855
+ */
856
+ getXcmFee<TDisableFallback extends boolean = false>(this: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptionsWithSender<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>>, options?: TGetXcmFeeBuilderOptions & {
857
+ disableFallback: TDisableFallback;
858
+ }): Promise<TGetXcmFeeResult<TDisableFallback>>;
859
+ /**
860
+ * Returns the origin XCM fee for the transfer using dryRun or paymentInfo function.
861
+ *
862
+ * @returns An origin fee.
863
+ */
864
+ getOriginXcmFee<TDisableFallback extends boolean = false>(this: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptionsWithSender<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>>, options?: TGetXcmFeeBuilderOptions & {
865
+ disableFallback: TDisableFallback;
866
+ }): Promise<TXcmFeeDetailWithForwardedXcm<TDisableFallback>>;
867
+ /**
868
+ * Returns the max transferable amount for the transfer
869
+ *
870
+ * @returns The max transferable amount.
871
+ */
872
+ getTransferableAmount(this: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptionsWithSender<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>>): Promise<bigint>;
873
+ /**
874
+ * Returns the min transferable amount for the transfer
875
+ *
876
+ * @returns The min transferable amount.
877
+ */
878
+ getMinTransferableAmount(this: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptionsWithSender<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>>): Promise<bigint>;
879
+ /**
880
+ * Returns the max transferable amount for the transfer
881
+ *
882
+ * @returns The max transferable amount.
883
+ */
884
+ verifyEdOnDestination(this: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptionsWithSender<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>>): Promise<boolean>;
885
+ /**
886
+ * Returns the transfer info for the transfer
887
+ *
888
+ * @returns The transfer info.
889
+ */
890
+ getTransferInfo(this: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptionsWithSender<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>>): Promise<TTransferInfo>;
891
+ /**
892
+ * Returns the receivable amount on the destination after the transfer
893
+ *
894
+ * @returns The computed receivable amount.
895
+ * @throws \{UnableToComputeError\} Thrown when the receivable amount cannot be determined.
896
+ */
897
+ getReceivableAmount(this: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptionsWithSender<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>>): Promise<bigint>;
898
+ getBestAmountOut(this: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptionsWithSwap<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>>): Promise<{
899
+ exchange: TExchangeChain;
900
+ amountOut: bigint;
901
+ }>;
902
+ signAndSubmit(this: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptionsWithSender<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>>): Promise<string>;
903
+ signAndSubmitAll(this: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptionsWithSender<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>>): Promise<string[]>;
904
+ private executeWithEvmSigner;
905
+ private prepareEvmDispatch;
906
+ /**
907
+ * Returns the API instance used by the builder.
908
+ *
909
+ * @returns The API instance.
910
+ */
911
+ getApi(): TApi;
912
+ /**
913
+ * Disconnects the API.
914
+ *
915
+ * @returns A Promise that resolves when the API is disconnected.
916
+ */
917
+ disconnect(): Promise<void>;
918
+ }
919
+ /**
920
+ * Creates a new Builder instance.
921
+ *
922
+ * @param api - The API instance to use for building transactions. If not provided, a new instance will be created.
923
+ * @returns A new Builder instance.
924
+ */
925
+ declare const Builder: <TApi, TRes, TSigner>(api: PolkadotApi<TApi, TRes, TSigner>) => GeneralBuilder<TApi, TRes, TSigner, object>;
926
+
927
+ type TEvmTransferOptionsBase = {
928
+ from: TChain;
929
+ to: TChain;
930
+ currency: TCurrencyInputWithAmount;
931
+ recipient: string;
932
+ ahAddress?: string;
933
+ };
934
+ type TEvmTransferOptions<TApi, TRes, TSigner> = WithApi<TEvmTransferOptionsBase & {
935
+ signer: WalletClient;
936
+ }, TApi, TRes, TSigner>;
937
+ type TBuildEvmTransferOptions<TApi, TRes, TSigner> = WithApi<TEvmTransferOptionsBase & {
938
+ sender: string;
939
+ }, TApi, TRes, TSigner>;
940
+ /**
941
+ * The options for the batch builder.
942
+ */
943
+ declare enum BatchMode {
944
+ /**
945
+ * Does not commit if one of the calls in the batch fails.
946
+ */
947
+ BATCH_ALL = "BATCH_ALL",
948
+ /**
949
+ * Commits each successful call regardless if a call fails.
950
+ */
951
+ BATCH = "BATCH"
952
+ }
953
+ /**
954
+ * The options for the batch builder.
955
+ */
956
+ type TBatchOptions = {
957
+ /**
958
+ * The batch mode. Can be either:
959
+ * `BATCH_ALL` - does not commit if one of the calls in the batch fails.
960
+ * `BATCH` - commits each successful call regardless if a call fails.
961
+ */
962
+ mode: BatchMode;
963
+ };
964
+ type TDryRunPreviewOptions = {
965
+ mintFeeAssets?: boolean;
966
+ };
967
+ type TBuilderOptions<TApi> = TApi | TBuilderConfig<TApi>;
968
+ type TBuilderConfig<TApi> = Partial<{
969
+ apiOverrides: Partial<Record<TChain, TApi>>;
970
+ development: boolean;
971
+ abstractDecimals: boolean;
972
+ xcmFormatCheck: boolean;
973
+ }>;
974
+ type TCreateTxsOptions<TApi, TRes, TSigner> = Pick<TTransferOptions<TApi, TRes, TSigner>, 'api' | 'from' | 'to' | 'currency'>;
975
+ type TBatchedTransferOptions<TApi, TRes, TSigner> = Omit<TSubstrateTransferOptions<TApi, TRes, TSigner>, 'isAmountAll'> & {
976
+ builder: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptions<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>>;
977
+ };
978
+ type TBuildInternalResBase<TApi, TRes, TSigner, TOptions extends TTransferBaseOptions<TApi, TRes, TSigner> = TTransferBaseOptions<TApi, TRes, TSigner>> = {
979
+ options: TTransferOptions<TApi, TRes, TSigner> & TOptions;
980
+ };
981
+ type TBuildInternalRes<TApi, TRes, TSigner, TOptions extends TTransferBaseOptions<TApi, TRes, TSigner> = TTransferBaseOptions<TApi, TRes, TSigner>> = TBuildInternalResBase<TApi, TRes, TSigner, TOptions> & {
982
+ tx: TRes;
983
+ };
984
+ type TBuildAllInternalRes<TApi, TRes, TSigner, TOptions extends TTransferBaseOptions<TApi, TRes, TSigner> = TTransferBaseOptions<TApi, TRes, TSigner>> = TBuildInternalResBase<TApi, TRes, TSigner, TOptions> & {
985
+ txContexts: TTransactionContext<TApi, TRes>[];
986
+ };
987
+ type TSender<TSigner> = string | TSigner;
988
+ type TBuilderInternalOptions<TSigner> = {
989
+ senderSource?: TSender<TSigner> | WalletClient;
990
+ };
991
+
992
+ type TSwapConfig = {
993
+ currencyTo: TCurrencyCore;
994
+ exchangeChain: TParachain;
995
+ };
996
+ type TDryRunBaseOptions<TRes> = {
997
+ tx: TRes;
998
+ origin: TSubstrateChain;
999
+ destination: TChain;
1000
+ sender: string;
1001
+ currency: TCurrencyInputWithAmount;
1002
+ version?: Version;
1003
+ feeAsset?: TCurrencyInput;
1004
+ swapConfig?: TSwapConfig;
1005
+ useRootOrigin?: boolean;
1006
+ bypassOptions?: TBypassOptions;
1007
+ };
1008
+ type TDryRunOptions<TApi, TRes, TSigner> = WithApi<TDryRunBaseOptions<TRes>, TApi, TRes, TSigner>;
1009
+ type TDryRunCallBaseOptions<TRes> = {
1010
+ /**
1011
+ * The transaction to dry-run
1504
1012
  */
1505
- feeAsset(currency: TCurrencyInput | undefined): GeneralBuilder<TApi, TRes, TSigner, T & {
1506
- feeAsset: TCurrencyInput | undefined;
1507
- }>;
1013
+ tx: TRes;
1508
1014
  /**
1509
- * Sets the hex of the encoded transaction call to apply on the destination chain
1510
- *
1511
- * @param hex - The encoded call hex or extrinsics.
1512
- * @param originKind - (Optional) The means of expressing the message origin as a dispatch origin.
1513
- * @param maxWeight - (Optional) The weight of the call. If not provided, the weight will be estimated.
1514
- * @returns An instance of the Builder.
1015
+ * The chain to dry-run on
1515
1016
  */
1516
- transact(call: string | TRes, originKind?: TTransactOrigin, maxWeight?: TWeight): GeneralBuilder<TApi, TRes, TSigner, T & {
1517
- transactOptions: {
1518
- call: string | TRes;
1519
- originKind: "Native" | "SovereignAccount" | "Superuser" | "Xcm" | undefined;
1520
- maxWeight: TWeight | undefined;
1521
- };
1522
- }>;
1017
+ chain: TSubstrateChain;
1523
1018
  /**
1524
- * Performs a token swap as part of the transfer, using the specified exchange and destination currency.
1525
- *
1526
- * @param options - The swap options.
1527
- * @returns An instance of the Builder.
1019
+ * The destination chain
1528
1020
  */
1529
- swap(options: TSwapOptions<TApi, TRes, TSigner>): GeneralBuilder<TApi, TRes, TSigner, T & {
1530
- swapOptions: TSwapOptions<TApi, TRes, TSigner>;
1531
- }>;
1021
+ destination: TDestination;
1532
1022
  /**
1533
- * Adds the transfer transaction to the batch.
1534
- *
1535
- * @returns An instance of Builder
1023
+ * The address to dry-run with
1536
1024
  */
1537
- addToBatch(this: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptions<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>>): GeneralBuilder<TApi, TRes, TSigner, T & {
1538
- from: TSubstrateChain;
1539
- }>;
1025
+ address: string;
1540
1026
  /**
1541
- * Builds and returns the batched transaction based on the configured parameters.
1542
- *
1543
- * @param options - (Optional) Options to customize the batch transaction.
1544
- * @returns A Extrinsic representing the batched transactions.
1027
+ * Whether to use the root origin
1545
1028
  */
1546
- buildBatch(this: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptions<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>>, options?: TBatchOptions): Promise<TRes>;
1547
- protected buildInternal<TOptions extends TTransferBaseOptions<TApi, TRes, TSigner>>(this: GeneralBuilder<TApi, TRes, TSigner, TOptions>): Promise<TBuildInternalRes<TApi, TRes, TSigner, TOptions>>;
1548
- private prepareNormalizedOptions;
1029
+ useRootOrigin?: boolean;
1549
1030
  /**
1550
- * Builds and returns the transfer extrinsic.
1551
- *
1552
- * @returns A Promise that resolves to the transfer extrinsic.
1031
+ * XCM version to use for the dry-run parameters
1553
1032
  */
1554
- build(this: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptions<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>>): Promise<TRes>;
1033
+ version: Version;
1034
+ asset: WithAmount<TAssetInfo>;
1035
+ bypassOptions?: TBypassOptions;
1036
+ feeAsset?: TAssetInfo;
1037
+ };
1038
+ type TDryRunBypassOptions<TApi, TRes, TSigner> = WithApi<Omit<TDryRunCallBaseOptions<TRes>, 'useRootOrigin' | 'destination'>, TApi, TRes, TSigner>;
1039
+ type TDryRunCallOptions<TApi, TRes, TSigner> = WithApi<TDryRunCallBaseOptions<TRes>, TApi, TRes, TSigner>;
1040
+ type TDryRunXcmBaseOptions<TRes> = {
1041
+ originLocation: any;
1555
1042
  /**
1556
- * Builds and returns multiple transfer or swap extrinsics
1557
- *
1558
- * @returns A Promise that resolves to the transfer extrinsic contexts
1043
+ * The XCM instructions
1559
1044
  */
1560
- buildAll(this: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptions<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>>): Promise<TTransactionContext<TApi, TRes>[]>;
1561
- private validateBatchState;
1562
- private buildCommon;
1563
- private buildCommonAll;
1564
- private maybePerformXcmFormatCheck;
1565
- dryRun(this: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptionsWithSender<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>>): Promise<TDryRunResult>;
1566
- dryRunPreview(this: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptionsWithSender<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>>, dryRunOptions?: TDryRunPreviewOptions): Promise<TDryRunResult>;
1567
- protected createTxFactory<TOptions extends TTransferBaseOptions<TApi, TRes, TSigner>>(this: GeneralBuilder<TApi, TRes, TSigner, TOptions>): TTxFactory<TRes>;
1045
+ xcm: any;
1046
+ /** The transaction to dry-run */
1047
+ tx: TRes;
1568
1048
  /**
1569
- * Returns the XCM fee for the transfer using dryRun or paymentInfo function.
1570
- *
1571
- * @returns An origin and destination fee.
1049
+ * The chain to dry-run on
1572
1050
  */
1573
- getXcmFee<TDisableFallback extends boolean = false>(this: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptionsWithSender<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>>, options?: TGetXcmFeeBuilderOptions & {
1574
- disableFallback: TDisableFallback;
1575
- }): Promise<TGetXcmFeeResult<TDisableFallback>>;
1051
+ chain: TSubstrateChain;
1576
1052
  /**
1577
- * Returns the origin XCM fee for the transfer using dryRun or paymentInfo function.
1578
- *
1579
- * @returns An origin fee.
1053
+ * The origin chain
1580
1054
  */
1581
- getOriginXcmFee(this: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptionsWithSender<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>>, { disableFallback }?: TGetXcmFeeBuilderOptions): Promise<TXcmFeeDetail & {
1582
- forwardedXcms?: unknown;
1583
- destParaId?: number;
1055
+ origin: TSubstrateChain;
1056
+ asset: TAssetInfo;
1057
+ version: Version;
1058
+ feeAsset?: TAssetInfo;
1059
+ amount: bigint;
1060
+ originFee: bigint;
1061
+ };
1062
+ type TDryRunXcmOptions<TApi, TRes, TSigner> = WithApi<TDryRunXcmBaseOptions<TRes>, TApi, TRes, TSigner>;
1063
+ type TDryRunResBase = {
1064
+ asset: TAssetInfo;
1065
+ isExchange?: boolean;
1066
+ };
1067
+ type TDryRunChainSuccess = TDryRunResBase & {
1068
+ success: true;
1069
+ fee: bigint;
1070
+ weight?: TWeight;
1071
+ forwardedXcms: any;
1072
+ destParaId?: number;
1073
+ };
1074
+ type TDryRunChainFailure = TDryRunResBase & {
1075
+ success: false;
1076
+ failureReason: string;
1077
+ failureSubReason?: string;
1078
+ };
1079
+ type TDryRunChainResult = TDryRunChainSuccess | TDryRunChainFailure;
1080
+ type THopInfo = {
1081
+ chain: TChain;
1082
+ result: TDryRunChainResult;
1083
+ };
1084
+ type TChainEndpoint = 'origin' | 'destination' | TChain;
1085
+ type TDryRunResult = {
1086
+ failureReason?: string;
1087
+ failureSubReason?: string;
1088
+ failureChain?: TChainEndpoint;
1089
+ origin: TDryRunChainResult;
1090
+ destination?: TDryRunChainResult;
1091
+ hops: THopInfo[];
1092
+ };
1093
+ type TResolveHopParams<TApi, TRes, TSigner> = {
1094
+ api: PolkadotApi<TApi, TRes, TSigner>;
1095
+ tx: TRes;
1096
+ originChain: TSubstrateChain;
1097
+ currentChain: TSubstrateChain;
1098
+ destination: TDestination;
1099
+ asset: TAssetInfo;
1100
+ currency: TCurrencyInputWithAmount;
1101
+ swapConfig?: TSwapConfig;
1102
+ hasPassedExchange: boolean;
1103
+ };
1104
+ type HopProcessParams<TApi, TRes, TSigner> = {
1105
+ api: PolkadotApi<TApi, TRes, TSigner>;
1106
+ currentChain: TSubstrateChain;
1107
+ currentOrigin: TSubstrateChain;
1108
+ currentAsset: TAssetInfo;
1109
+ forwardedXcms: any;
1110
+ hasPassedExchange: boolean;
1111
+ isDestination: boolean;
1112
+ };
1113
+ type HopTraversalConfig<TApi, TRes, TSigner, THopResult> = {
1114
+ api: PolkadotApi<TApi, TRes, TSigner>;
1115
+ origin: TSubstrateChain;
1116
+ destination: TChain;
1117
+ currency: TCurrencyCore;
1118
+ initialForwardedXcms: any;
1119
+ initialDestParaId: number | undefined;
1120
+ swapConfig?: TSwapConfig;
1121
+ processHop: (params: HopProcessParams<TApi, TRes, TSigner>) => Promise<THopResult>;
1122
+ shouldContinue: (hopResult: THopResult) => boolean;
1123
+ extractNextHopData: (hopResult: THopResult) => {
1124
+ forwardedXcms: any;
1125
+ destParaId: number | undefined;
1126
+ };
1127
+ };
1128
+ type HopTraversalResult<THopResult> = {
1129
+ hops: Array<{
1130
+ chain: TSubstrateChain;
1131
+ result: THopResult;
1584
1132
  }>;
1133
+ destination?: THopResult;
1134
+ lastProcessedChain?: TSubstrateChain;
1135
+ };
1136
+ type TBypassOptions = {
1137
+ mintFeeAssets?: boolean;
1138
+ sentAssetMintMode?: 'preview' | 'bypass';
1139
+ };
1140
+ declare enum XTokensError {
1141
+ AssetHasNoReserve = "AssetHasNoReserve",
1142
+ NotCrossChainTransfer = "NotCrossChainTransfer",
1143
+ InvalidDest = "InvalidDest",
1144
+ NotCrossChainTransferableCurrency = "NotCrossChainTransferableCurrency",
1145
+ UnweighableMessage = "UnweighableMessage",
1146
+ XcmExecutionFailed = "XcmExecutionFailed",
1147
+ CannotReanchor = "CannotReanchor",
1148
+ InvalidAncestry = "InvalidAncestry",
1149
+ InvalidAsset = "InvalidAsset",
1150
+ DestinationNotInvertible = "DestinationNotInvertible",
1151
+ BadVersion = "BadVersion",
1152
+ DistinctReserveForAssetAndFee = "DistinctReserveForAssetAndFee",
1153
+ ZeroFee = "ZeroFee",
1154
+ ZeroAmount = "ZeroAmount",
1155
+ TooManyAssetsBeingSent = "TooManyAssetsBeingSent",
1156
+ AssetIndexNonExistent = "AssetIndexNonExistent",
1157
+ FeeNotEnough = "FeeNotEnough",
1158
+ NotSupportedLocation = "NotSupportedLocation",
1159
+ MinXcmFeeNotDefined = "MinXcmFeeNotDefined",
1160
+ RateLimited = "RateLimited"
1161
+ }
1162
+ declare enum PolkadotXcmError {
1163
+ Unreachable = "Unreachable",
1164
+ SendFailure = "SendFailure",
1165
+ Filtered = "Filtered",
1166
+ UnweighableMessage = "UnweighableMessage",
1167
+ DestinationNotInvertible = "DestinationNotInvertible",
1168
+ Empty = "Empty",
1169
+ CannotReanchor = "CannotReanchor",
1170
+ TooManyAssets = "TooManyAssets",
1171
+ InvalidOrigin = "InvalidOrigin",
1172
+ BadVersion = "BadVersion",
1173
+ BadLocation = "BadLocation",
1174
+ NoSubscription = "NoSubscription",
1175
+ AlreadySubscribed = "AlreadySubscribed",
1176
+ CannotCheckOutTeleport = "CannotCheckOutTeleport",
1177
+ LowBalance = "LowBalance",
1178
+ TooManyLocks = "TooManyLocks",
1179
+ AccountNotSovereign = "AccountNotSovereign",
1180
+ FeesNotMet = "FeesNotMet",
1181
+ LockNotFound = "LockNotFound",
1182
+ InUse = "InUse",
1183
+ REMOVED = "REMOVED",
1184
+ InvalidAssetUnknownReserve = "InvalidAssetUnknownReserve",
1185
+ InvalidAssetUnsupportedReserve = "InvalidAssetUnsupportedReserve",
1186
+ TooManyReserves = "TooManyReserves",
1187
+ LocalExecutionIncomplete = "LocalExecutionIncomplete",
1188
+ TooManyAuthorizedAliases = "TooManyAuthorizedAliases",
1189
+ ExpiresInPast = "ExpiresInPast",
1190
+ AliasNotFound = "AliasNotFound",
1191
+ LocalExecutionIncompleteWithError = "LocalExecutionIncompleteWithError"
1192
+ }
1193
+ declare enum PolkadotXcmExecutionError {
1194
+ Overflow = "Overflow",
1195
+ Unimplemented = "Unimplemented",
1196
+ UntrustedReserveLocation = "UntrustedReserveLocation",
1197
+ UntrustedTeleportLocation = "UntrustedTeleportLocation",
1198
+ LocationFull = "LocationFull",
1199
+ LocationNotInvertible = "LocationNotInvertible",
1200
+ BadOrigin = "BadOrigin",
1201
+ InvalidLocation = "InvalidLocation",
1202
+ AssetNotFound = "AssetNotFound",
1203
+ FailedToTransactAsset = "FailedToTransactAsset",
1204
+ NotWithdrawable = "NotWithdrawable",
1205
+ LocationCannotHold = "LocationCannotHold",
1206
+ ExceedsMaxMessageSize = "ExceedsMaxMessageSize",
1207
+ DestinationUnsupported = "DestinationUnsupported",
1208
+ Transport = "Transport",
1209
+ Unroutable = "Unroutable",
1210
+ UnknownClaim = "UnknownClaim",
1211
+ FailedToDecode = "FailedToDecode",
1212
+ MaxWeightInvalid = "MaxWeightInvalid",
1213
+ NotHoldingFees = "NotHoldingFees",
1214
+ TooExpensive = "TooExpensive",
1215
+ Trap = "Trap",
1216
+ ExpectationFalse = "ExpectationFalse",
1217
+ PalletNotFound = "PalletNotFound",
1218
+ NameMismatch = "NameMismatch",
1219
+ VersionIncompatible = "VersionIncompatible",
1220
+ HoldingWouldOverflow = "HoldingWouldOverflow",
1221
+ ExportError = "ExportError",
1222
+ ReanchorFailed = "ReanchorFailed",
1223
+ NoDeal = "NoDeal",
1224
+ FeesNotMet = "FeesNotMet",
1225
+ LockError = "LockError",
1226
+ NoPermission = "NoPermission",
1227
+ Unanchored = "Unanchored",
1228
+ NotDepositable = "NotDepositable",
1229
+ TooManyAssets = "TooManyAssets",
1230
+ UnhandledXcmVersion = "UnhandledXcmVersion",
1231
+ WeightLimitReached = "WeightLimitReached",
1232
+ Barrier = "Barrier",
1233
+ WeightNotComputable = "WeightNotComputable",
1234
+ ExceedsStackLimit = "ExceedsStackLimit"
1235
+ }
1236
+ type TModuleError = {
1237
+ index: string;
1238
+ error: string;
1239
+ };
1240
+ type TDryRunError = {
1241
+ failureReason: string;
1242
+ failureSubReason?: string;
1243
+ };
1244
+
1245
+ declare class AmountTooLowError extends Error {
1246
+ constructor(message?: string);
1247
+ }
1248
+
1249
+ /**
1250
+ * Error thrown when an API operation is attempted before the API has been initialized.
1251
+ */
1252
+ declare class ApiNotInitializedError extends Error {
1253
+ constructor();
1254
+ }
1255
+
1256
+ /**
1257
+ * Error thrown when a batch operation is invalid or cannot be executed.
1258
+ */
1259
+ declare class BatchValidationError extends Error {
1260
+ constructor(message: string);
1261
+ }
1262
+
1263
+ /**
1264
+ * Error thrown when the Ethereum bridge is halted.
1265
+ */
1266
+ declare class BridgeHaltedError extends Error {
1585
1267
  /**
1586
- * Returns the max transferable amount for the transfer
1587
- *
1588
- * @returns The max transferable amount.
1589
- */
1590
- getTransferableAmount(this: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptionsWithSender<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>>): Promise<bigint>;
1591
- /**
1592
- * Returns the min transferable amount for the transfer
1268
+ * Constructs a new BridgeHaltedError.
1593
1269
  *
1594
- * @returns The min transferable amount.
1270
+ * @param message - Optional custom error message.
1595
1271
  */
1596
- getMinTransferableAmount(this: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptionsWithSender<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>>): Promise<bigint>;
1272
+ constructor();
1273
+ }
1274
+
1275
+ /**
1276
+ * Error thrown when the Dry Run fails.
1277
+ */
1278
+ declare class DryRunFailedError extends Error {
1279
+ readonly reason: string;
1280
+ readonly dryRunType?: TChainEndpoint;
1597
1281
  /**
1598
- * Returns the max transferable amount for the transfer
1282
+ * Constructs a new DryRunFailedError.
1599
1283
  *
1600
- * @returns The max transferable amount.
1284
+ * @param reason - The reason why the dry run failed.
1285
+ * @param dryRunType - Optional. Specifies if the error is related to the 'origin' or 'destination' dry run.
1286
+ * @param prefix - Optional. A short sentence prepended to the message
1601
1287
  */
1602
- verifyEdOnDestination(this: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptionsWithSender<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>>): Promise<boolean>;
1288
+ constructor(reason: string, dryRunType?: TChainEndpoint, prefix?: string);
1289
+ }
1290
+
1291
+ /**
1292
+ * Error thrown when an extension is not installed.
1293
+ */
1294
+ declare class ExtensionNotInstalledError extends Error {
1603
1295
  /**
1604
- * Returns the transfer info for the transfer
1296
+ * Constructs a new ExtensionNotInstalledError.
1605
1297
  *
1606
- * @returns The transfer info.
1298
+ * @param message - The error message.
1607
1299
  */
1608
- getTransferInfo(this: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptionsWithSender<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>>): Promise<TTransferInfo>;
1300
+ constructor(message: string);
1301
+ }
1302
+
1303
+ /**
1304
+ * Error thrown when a feature or route is temporarily disabled via configuration or governance.
1305
+ */
1306
+ declare class FeatureTemporarilyDisabledError extends Error {
1307
+ constructor(message: string);
1308
+ }
1309
+
1310
+ /**
1311
+ * Error thrown when an invalid address is provided.
1312
+ */
1313
+ declare class InvalidAddressError extends Error {
1609
1314
  /**
1610
- * Returns the receivable amount on the destination after the transfer
1315
+ * Constructs a new InvalidAddressError.
1611
1316
  *
1612
- * @returns The computed receivable amount.
1613
- * @throws \{UnableToComputeError\} Thrown when the receivable amount cannot be determined.
1317
+ * @param message - The error message.
1614
1318
  */
1615
- getReceivableAmount(this: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptionsWithSender<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>>): Promise<bigint>;
1616
- getBestAmountOut(this: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptionsWithSwap<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>>): Promise<{
1617
- exchange: TExchangeChain;
1618
- amountOut: bigint;
1619
- }>;
1620
- signAndSubmit(this: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptionsWithSender<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>>): Promise<string>;
1621
- signAndSubmitAll(this: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptionsWithSender<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>>): Promise<string[]>;
1622
- private executeWithEvmSigner;
1319
+ constructor(message: string);
1320
+ }
1321
+
1322
+ /**
1323
+ * Error development mode is on and no API override is provided for a specific chain.
1324
+ */
1325
+ declare class MissingChainApiError extends Error {
1623
1326
  /**
1624
- * Returns the API instance used by the builder.
1327
+ * Constructs a new MissingChainApiError.
1625
1328
  *
1626
- * @returns The API instance.
1329
+ * @param chain - The chain for which the API is missing.
1627
1330
  */
1628
- getApi(): TApi;
1331
+ constructor(chain: TChain);
1332
+ }
1333
+
1334
+ /**
1335
+ * Error thrown when a required parameter is missing.
1336
+ */
1337
+ declare class MissingParameterError extends Error {
1338
+ constructor(parameter: string | string[], message?: string);
1339
+ }
1340
+
1341
+ /**
1342
+ * Used to inform user, that Parachain they wish to use has not yet implemented full XCM Support
1343
+ */
1344
+ declare class NoXCMSupportImplementedError extends Error {
1629
1345
  /**
1630
- * Disconnects the API.
1346
+ * Constructs a new NoXCMSupportImplementedError.
1631
1347
  *
1632
- * @returns A Promise that resolves when the API is disconnected.
1348
+ * @param chain - The chain for which XCM support is not implemented.
1633
1349
  */
1634
- disconnect(): Promise<void>;
1350
+ constructor(chain: TChain);
1635
1351
  }
1352
+
1636
1353
  /**
1637
- * Creates a new Builder instance.
1638
- *
1639
- * @param api - The API instance to use for building transactions. If not provided, a new instance will be created.
1640
- * @returns A new Builder instance.
1354
+ * Error thrown when numeric input is invalid or cannot be parsed.
1641
1355
  */
1642
- declare const Builder: <TApi, TRes, TSigner>(api: PolkadotApi<TApi, TRes, TSigner>) => GeneralBuilder<TApi, TRes, TSigner, object>;
1356
+ declare class NumberFormatError extends Error {
1357
+ constructor(message?: string);
1358
+ }
1643
1359
 
1644
- type TGetBalanceCommonOptions = {
1645
- /**
1646
- * The address of the account.
1647
- */
1648
- address: string;
1649
- /**
1650
- * The chain on which to query the balance.
1651
- */
1360
+ /**
1361
+ * Error thrown when asset or currency overrides are invalid or conflicting.
1362
+ */
1363
+ declare class OverrideConflictError extends Error {
1364
+ constructor(message: string);
1365
+ }
1366
+
1367
+ /**
1368
+ * Error thrown when no provider or RPC endpoint is available for the requested chain.
1369
+ */
1370
+ declare class ProviderUnavailableError extends Error {
1371
+ constructor(message: string);
1372
+ }
1373
+
1374
+ /**
1375
+ * Error thrown when routing or path resolution fails.
1376
+ */
1377
+ declare class RoutingResolutionError extends Error {
1378
+ constructor(message: string);
1379
+ }
1380
+
1381
+ /**
1382
+ * Error thrown when a runtime API call fails
1383
+ */
1384
+ declare class RuntimeApiError extends Error {
1385
+ constructor(message: string);
1386
+ }
1387
+
1388
+ /**
1389
+ * Error thrown when a required runtime API is not available on the target chain.
1390
+ */
1391
+ declare class RuntimeApiUnavailableError extends Error {
1392
+ constructor(chain: string, apiName: string);
1393
+ }
1394
+
1395
+ type TScenarioNotSupportedContext = {
1652
1396
  chain: TChain;
1397
+ scenario: TScenario;
1653
1398
  };
1654
1399
  /**
1655
- * Retrieves the asset balance for a given account on a specified chain.
1400
+ * Error thrown when a scenario, route, or chain capability is not supported.
1656
1401
  */
1657
- type TGetAssetBalanceOptionsBase = TGetBalanceCommonOptions & {
1402
+ declare class ScenarioNotSupportedError extends Error {
1403
+ constructor(message: string);
1404
+ constructor({ chain, scenario }: TScenarioNotSupportedContext);
1405
+ }
1406
+
1407
+ /**
1408
+ * Error thrown when a submitted transaction encounters a dispatch error on-chain.
1409
+ */
1410
+ declare class SubmitTransactionError extends Error {
1658
1411
  /**
1659
- * The resolved asset to query balance for.
1412
+ * Constructs a new SubmitTransactionError.
1413
+ *
1414
+ * @param message - The dispatch error details.
1660
1415
  */
1661
- asset: TAssetInfo;
1662
- };
1416
+ constructor(message: string);
1417
+ }
1418
+
1419
+ declare class TransferToAhNotSupported extends Error {
1420
+ constructor(message?: string);
1421
+ }
1422
+
1423
+ declare class TypeAndThenUnavailableError extends Error {
1424
+ constructor(message: string);
1425
+ }
1426
+
1663
1427
  /**
1664
- * Retrieves the currency balance for a given account on a specified chain.
1428
+ * UnableToComputeError is thrown when a computation cannot be performed.
1665
1429
  */
1666
- type TGetBalanceOptionsBase = TGetBalanceCommonOptions & {
1430
+ declare class UnableToComputeError extends Error {
1667
1431
  /**
1668
- * The currency to query.
1432
+ * Constructs a new UnableToComputeError.
1433
+ *
1434
+ * @param message - Required error message.
1669
1435
  */
1670
- currency?: TCurrencyCore;
1436
+ constructor(message: string);
1437
+ }
1438
+
1439
+ /**
1440
+ * Error thrown when an operation or parameter combination is not supported.
1441
+ */
1442
+ declare class UnsupportedOperationError extends Error {
1443
+ constructor(message: string);
1444
+ }
1445
+
1446
+ /**
1447
+ * Thrown when a validation check fails.
1448
+ */
1449
+ declare class ValidationError extends Error {
1450
+ constructor(message: string);
1451
+ }
1452
+
1453
+ type TXcmFeeSwapConfig = TSwapConfig & {
1454
+ amountOut: bigint;
1671
1455
  };
1672
- type TGetBalanceOptions<TApi, TRes, TSigner> = WithApi<TGetBalanceOptionsBase, TApi, TRes, TSigner>;
1673
- type TGetAssetBalanceOptions<TApi, TRes, TSigner> = WithApi<TGetAssetBalanceOptionsBase, TApi, TRes, TSigner>;
1674
- type TGetTransferableAmountOptionsBase<TRes> = {
1456
+ type TTxFactory<TRes> = (amount?: string, relative?: boolean) => Promise<TRes>;
1457
+ type TGetXcmFeeBaseOptions<TRes, TDisableFallback extends boolean = boolean> = {
1675
1458
  /**
1676
- * The sender address of the account.
1459
+ * The transaction factory
1677
1460
  */
1678
- sender: string;
1461
+ buildTx: TTxFactory<TRes>;
1679
1462
  /**
1680
- * The chain on which to query the balance.
1463
+ * The origin chain
1681
1464
  */
1682
1465
  origin: TSubstrateChain;
1683
1466
  /**
1684
- * The destination chain.
1467
+ * The destination chain
1685
1468
  */
1686
1469
  destination: TChain;
1687
1470
  /**
1688
- * The currency to query.
1471
+ * The sender address
1689
1472
  */
1473
+ sender: string;
1474
+ recipient: string;
1690
1475
  currency: WithAmount<TCurrencyCore>;
1691
- version: Version | undefined;
1476
+ version?: Version;
1477
+ feeAsset?: TCurrencyInput;
1478
+ disableFallback: TDisableFallback;
1479
+ swapConfig?: TXcmFeeSwapConfig;
1480
+ skipReverseFeeCalculation?: boolean;
1481
+ };
1482
+ type TGetXcmFeeOptions<TApi, TRes, TSigner, TDisableFallback extends boolean = boolean> = WithApi<TGetXcmFeeBaseOptions<TRes, TDisableFallback>, TApi, TRes, TSigner>;
1483
+ type TGetXcmFeeInternalOptions<TApi, TRes, TSigner, TDisableFallback extends boolean = boolean> = Omit<TGetXcmFeeOptions<TApi, TRes, TSigner, TDisableFallback>, 'buildTx'> & {
1484
+ tx: TRes;
1485
+ useRootOrigin: boolean;
1486
+ };
1487
+ type TGetXcmFeeBuilderOptions = {
1488
+ disableFallback: boolean;
1489
+ };
1490
+ type TGetOriginXcmFeeBaseOptions<TRes, TDisableFallback extends boolean = boolean> = {
1692
1491
  buildTx: TTxFactory<TRes>;
1492
+ origin: TSubstrateChain;
1493
+ destination: TChain;
1494
+ sender: string;
1495
+ currency: WithAmount<TCurrencyCore>;
1496
+ version?: Version;
1693
1497
  feeAsset?: TCurrencyInput;
1498
+ disableFallback: TDisableFallback;
1499
+ useRootOrigin?: boolean;
1694
1500
  };
1695
- type TGetTransferableAmountOptions<TApi, TRes, TSigner> = WithApi<TGetTransferableAmountOptionsBase<TRes>, TApi, TRes, TSigner>;
1696
- type TGetMinTransferableAmountOptions<TApi, TRes, TSigner> = WithApi<TGetTransferableAmountOptionsBase<TRes> & {
1501
+ type TGetOriginXcmFeeOptions<TApi, TRes, TSigner, TDisableFallback extends boolean = boolean> = WithApi<TGetOriginXcmFeeBaseOptions<TRes, TDisableFallback>, TApi, TRes, TSigner>;
1502
+ type TGetOriginXcmFeeInternalOptions<TApi, TRes, TSigner> = Omit<TGetOriginXcmFeeOptions<TApi, TRes, TSigner>, 'buildTx'> & {
1503
+ tx: TRes;
1504
+ };
1505
+ type TGetFeeForDestChainBaseOptions<TRes> = {
1506
+ prevChain: TSubstrateChain;
1507
+ origin: TSubstrateChain;
1508
+ destination: TChain;
1509
+ sender: string;
1697
1510
  recipient: string;
1698
- builder: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptionsWithSender<TApi, TRes, TSigner>>;
1699
- }, TApi, TRes, TSigner>;
1700
- type TVerifyEdOnDestinationOptionsBase<TRes> = {
1511
+ currency: WithAmount<TCurrencyCore>;
1512
+ forwardedXcms: any;
1513
+ tx: TRes;
1514
+ asset: TAssetInfo;
1515
+ version: Version;
1516
+ originFee: bigint;
1517
+ feeAsset?: TCurrencyInput;
1518
+ disableFallback: boolean;
1519
+ hasPassedExchange?: boolean;
1520
+ swapConfig?: TXcmFeeSwapConfig;
1521
+ skipReverseFeeCalculation?: boolean;
1522
+ };
1523
+ type TGetFeeForDestChainOptions<TApi, TRes, TSigner> = WithApi<TGetFeeForDestChainBaseOptions<TRes>, TApi, TRes, TSigner>;
1524
+ type TGetReverseTxFeeOptions<TApi, TRes, TSigner> = Omit<TGetFeeForDestChainOptions<TApi, TRes, TSigner>, 'destination' | 'disableFallback' | 'forwardedXcms' | 'asset' | 'originFee' | 'prevChain' | 'version'> & {
1525
+ destination: TSubstrateChain;
1526
+ };
1527
+ type TFeeType = 'dryRun' | 'paymentInfo' | 'noFeeRequired';
1528
+ type TXcmFeeBase$1 = {
1529
+ asset: TAssetInfo;
1530
+ weight?: TWeight;
1531
+ sufficient?: boolean;
1532
+ isExchange?: boolean;
1533
+ };
1534
+ type TXcmFeeDetailSuccess = TXcmFeeBase$1 & {
1535
+ fee: bigint;
1536
+ feeType: TFeeType;
1537
+ dryRunError?: string;
1538
+ dryRunSubError?: string;
1539
+ };
1540
+ type TXcmFeeDetailWithFallback = TXcmFeeDetailSuccess;
1541
+ type TXcmFeeDetailError = TXcmFeeBase$1 & {
1542
+ fee?: bigint;
1543
+ feeType?: TFeeType;
1544
+ dryRunError: string;
1545
+ dryRunSubError?: string;
1546
+ };
1547
+ type TXcmFeeDetail = TXcmFeeDetailSuccess | TXcmFeeDetailError;
1548
+ type TXcmFeeHopResult = {
1549
+ fee?: bigint;
1550
+ feeType?: TFeeType;
1551
+ sufficient?: boolean;
1552
+ dryRunError?: string;
1553
+ dryRunSubError?: string;
1554
+ forwardedXcms?: any;
1555
+ destParaId?: number;
1556
+ asset: TAssetInfo;
1557
+ };
1558
+ type TConditionalXcmFeeDetail<TDisableFallback extends boolean> = TDisableFallback extends false ? TXcmFeeDetailWithFallback : TXcmFeeDetail;
1559
+ type TXcmFeeDetailWithForwardedXcm<TDisableFallback extends boolean> = TConditionalXcmFeeDetail<TDisableFallback> & {
1560
+ forwardedXcms?: unknown;
1561
+ destParaId?: number;
1562
+ };
1563
+ type TConditionalXcmFeeHopInfo<TDisableFallback extends boolean> = {
1564
+ chain: TChain;
1565
+ result: TConditionalXcmFeeDetail<TDisableFallback>;
1566
+ };
1567
+ type TXcmFeeHopInfo = {
1568
+ chain: TChain;
1569
+ result: TXcmFeeDetail;
1570
+ };
1571
+ type TGetXcmFeeResult<TDisableFallback extends boolean = boolean> = {
1572
+ failureReason?: string;
1573
+ failureChain?: TChainEndpoint;
1574
+ origin: TConditionalXcmFeeDetail<TDisableFallback>;
1575
+ destination: TConditionalXcmFeeDetail<TDisableFallback>;
1576
+ hops: TConditionalXcmFeeHopInfo<TDisableFallback>[];
1577
+ };
1578
+ type TPaymentInfo = {
1579
+ partialFee: bigint;
1580
+ weight: TWeight;
1581
+ };
1582
+
1583
+ type THopTransferInfo = {
1584
+ chain: TChain;
1585
+ result: {
1586
+ xcmFee: TXcmFeeBase;
1587
+ asset: TAssetInfo;
1588
+ isExchange?: boolean;
1589
+ };
1590
+ };
1591
+ type TXcmFeeBase = {
1592
+ fee: bigint;
1593
+ asset: TAssetInfo;
1594
+ };
1595
+ type TTransferInfo = {
1596
+ chain: {
1597
+ origin: TChain;
1598
+ destination: TChain;
1599
+ ecosystem: string;
1600
+ };
1601
+ origin: {
1602
+ selectedCurrency: {
1603
+ sufficient: boolean;
1604
+ balance: bigint;
1605
+ balanceAfter: bigint;
1606
+ asset: TAssetInfo;
1607
+ };
1608
+ xcmFee: TXcmFeeBase & {
1609
+ sufficient: boolean;
1610
+ balance: bigint;
1611
+ balanceAfter: bigint;
1612
+ };
1613
+ isExchange?: boolean;
1614
+ };
1615
+ hops: THopTransferInfo[];
1616
+ destination: {
1617
+ receivedCurrency: {
1618
+ sufficient: boolean | UnableToComputeError;
1619
+ receivedAmount: bigint | UnableToComputeError;
1620
+ balance: bigint;
1621
+ balanceAfter: bigint | UnableToComputeError;
1622
+ asset: TAssetInfo;
1623
+ };
1624
+ xcmFee: TXcmFeeBase & {
1625
+ balanceAfter: bigint | UnableToComputeError;
1626
+ };
1627
+ isExchange?: boolean;
1628
+ };
1629
+ };
1630
+ type TBuildOriginInfoOptions<TApi, TRes, TSigner> = {
1631
+ api: PolkadotApi<TApi, TRes, TSigner>;
1632
+ origin: TSubstrateChain;
1633
+ sender: string;
1634
+ currency: TCurrencyCore;
1635
+ originAsset: TAssetInfo;
1636
+ amount: bigint;
1637
+ originFee: bigint;
1638
+ originFeeAsset: TAssetInfo;
1639
+ isFeeAssetAh: boolean;
1640
+ };
1641
+ type BuildHopInfoOptions<TApi, TRes, TSigner> = {
1642
+ api: PolkadotApi<TApi, TRes, TSigner>;
1643
+ chain: TChain;
1644
+ fee: bigint;
1645
+ originChain: TSubstrateChain;
1646
+ currency: TCurrencyCore;
1647
+ asset: TAssetInfo;
1648
+ sender: string;
1649
+ ahAddress?: string;
1650
+ };
1651
+ type TBuildDestInfoOptions<TApi, TRes, TSigner> = {
1652
+ api: PolkadotApi<TApi, TRes, TSigner>;
1653
+ origin: TSubstrateChain;
1654
+ destination: TChain;
1655
+ recipient: string;
1656
+ currency: WithAmount<TCurrencyCore>;
1657
+ originFee: bigint;
1658
+ isFeeAssetAh: boolean;
1659
+ destFeeDetail: TXcmFeeDetail;
1660
+ totalHopFee: bigint;
1661
+ bridgeFee?: bigint;
1662
+ };
1663
+ type TOriginFeeDetails = {
1664
+ sufficientForXCM: boolean;
1665
+ xcmFee: bigint;
1666
+ };
1667
+ type TGetTransferInfoOptionsBase<TRes> = {
1668
+ buildTx: TTxFactory<TRes>;
1669
+ origin: TSubstrateChain;
1670
+ destination: TChain;
1671
+ sender: string;
1672
+ ahAddress?: string;
1673
+ recipient: string;
1674
+ currency: WithAmount<TCurrencyCore>;
1675
+ version: Version | undefined;
1676
+ feeAsset?: TCurrencyCore;
1677
+ };
1678
+ type TGetTransferInfoOptions<TApi, TRes, TSigner> = WithApi<TGetTransferInfoOptionsBase<TRes>, TApi, TRes, TSigner>;
1679
+
1680
+ type TExchangeChain = (typeof EXCHANGE_CHAINS)[number];
1681
+ type TExchangeInput = TExchangeChain | TExchangeChain[] | undefined;
1682
+ type TSwapOptions<TApi, TRes, TSigner> = {
1683
+ currencyTo: TCurrencyCore;
1684
+ exchange?: TExchangeInput;
1685
+ slippage?: number;
1686
+ evmSenderAddress?: string;
1687
+ evmSigner?: TSigner;
1688
+ onStatusChange?: TStatusChangeCallback<TApi, TRes>;
1689
+ };
1690
+ type TTransactionContext<TApi, TRes> = {
1691
+ type: TTransactionType;
1692
+ api: TApi;
1693
+ chain: TSubstrateChain;
1694
+ tx: TRes;
1695
+ };
1696
+ type TTransactionType = 'TRANSFER' | 'SWAP' | 'SWAP_AND_TRANSFER';
1697
+ type TSwapEventType = TTransactionType | 'SELECTING_EXCHANGE' | 'COMPLETED';
1698
+ /**
1699
+ * The transaction progress information.
1700
+ */
1701
+ type TSwapEvent<TApi, TRes> = {
1702
+ /**
1703
+ * Current execution phase type
1704
+ */
1705
+ type: TSwapEventType;
1706
+ /**
1707
+ * Full transaction plan for visualization
1708
+ */
1709
+ routerPlan?: TTransactionContext<TApi, TRes>[];
1710
+ /**
1711
+ * Current transaction's origin chain
1712
+ */
1713
+ chain?: TSubstrateChain;
1714
+ /**
1715
+ * Current transaction's destination chain
1716
+ */
1717
+ destinationChain?: TChain;
1701
1718
  /**
1702
- * The origin chain.
1719
+ * 0-based step index of current operation
1703
1720
  */
1721
+ currentStep?: number;
1722
+ };
1723
+ type TStatusChangeCallback<TApi, TRes> = (info: TSwapEvent<TApi, TRes>) => void;
1724
+ interface TSwapBuilder<TApi, TRes, TSigner> {
1725
+ from(chain: TSubstrateChain | undefined): TSwapBuilder<TApi, TRes, TSigner>;
1726
+ to(chain: TChain | undefined): TSwapBuilder<TApi, TRes, TSigner>;
1727
+ exchange(chain: TExchangeInput): TSwapBuilder<TApi, TRes, TSigner>;
1728
+ currencyFrom(currency: TCurrencyInput): TSwapBuilder<TApi, TRes, TSigner>;
1729
+ currencyTo(currency: TCurrencyInput): TSwapBuilder<TApi, TRes, TSigner>;
1730
+ feeAsset(currency: TCurrencyInput | undefined): TSwapBuilder<TApi, TRes, TSigner>;
1731
+ amount(amount: TAmount): TSwapBuilder<TApi, TRes, TSigner>;
1732
+ recipient(address: string | undefined): TSwapBuilder<TApi, TRes, TSigner>;
1733
+ sender(address: string): TSwapBuilder<TApi, TRes, TSigner>;
1734
+ signer(signer: TSigner): TSwapBuilder<TApi, TRes, TSigner>;
1735
+ evmSenderAddress(address: string | undefined): TSwapBuilder<TApi, TRes, TSigner>;
1736
+ evmSigner(signer: TSigner | undefined): TSwapBuilder<TApi, TRes, TSigner>;
1737
+ slippagePct(pct: string): TSwapBuilder<TApi, TRes, TSigner>;
1738
+ onStatusChange(callback: TStatusChangeCallback<TApi, TRes>): TSwapBuilder<TApi, TRes, TSigner>;
1739
+ getXcmFees<TDisableFallback extends boolean = false>(options?: TGetXcmFeeBuilderOptions & {
1740
+ disableFallback: TDisableFallback;
1741
+ }): Promise<TGetXcmFeeResult<TDisableFallback>>;
1742
+ getOriginXcmFee<TDisableFallback extends boolean = false>(options?: TGetXcmFeeBuilderOptions & {
1743
+ disableFallback: TDisableFallback;
1744
+ }): Promise<TXcmFeeDetailWithForwardedXcm<TDisableFallback>>;
1745
+ getSwapInfo(): Promise<TTransferInfo>;
1746
+ getTransferableAmount(): Promise<bigint>;
1747
+ getMinTransferableAmount(): Promise<bigint>;
1748
+ getBestAmountOut(): Promise<{
1749
+ exchange: TExchangeChain;
1750
+ amountOut: bigint;
1751
+ }>;
1752
+ dryRun(): Promise<TDryRunResult>;
1753
+ dryRunPreview(previewOptions?: TDryRunPreviewOptions): Promise<TDryRunResult>;
1754
+ build(): Promise<TTransactionContext<TApi, TRes>[]>;
1755
+ signAndSubmit(): Promise<string[]>;
1756
+ }
1757
+ type TSwapBuilderFactory = <TApi, TRes, TSigner>(api: PolkadotApi<TApi, TRes, TSigner>) => TSwapBuilder<TApi, TRes, TSigner>;
1758
+
1759
+ type TPolkadotXCMTransferOptions<TApi, TRes, TSigner> = {
1760
+ api: PolkadotApi<TApi, TRes, TSigner>;
1761
+ chain: TSubstrateChain;
1762
+ beneficiaryLocation: TLocation;
1763
+ recipient: TAddress;
1764
+ asset: TAsset;
1765
+ overriddenAsset?: TLocation | TAssetWithFee[];
1766
+ scenario: TScenario;
1767
+ assetInfo: WithAmount<TAssetInfo>;
1768
+ currency: TCurrencyInputWithAmount;
1769
+ feeAssetInfo?: TAssetInfo;
1770
+ feeCurrency?: TCurrencyInput;
1771
+ destination: TDestination;
1772
+ destChain?: TChain;
1773
+ paraIdTo?: number;
1774
+ version: Version;
1775
+ sender?: string;
1776
+ ahAddress?: string;
1777
+ pallet?: string;
1778
+ method?: string;
1779
+ transactOptions?: TTransactOptions<TRes>;
1780
+ };
1781
+ type TXTokensTransferOptions<TApi, TRes, TSigner> = {
1782
+ api: PolkadotApi<TApi, TRes, TSigner>;
1783
+ asset: WithAmount<TAssetInfo>;
1784
+ recipient: TAddress;
1785
+ scenario: TScenario;
1704
1786
  origin: TSubstrateChain;
1787
+ destination: TDestination;
1788
+ paraIdTo?: number;
1789
+ version: Version;
1790
+ overriddenAsset?: TLocation | TAssetWithFee[];
1791
+ pallet?: string;
1792
+ method?: string;
1793
+ useMultiAssetTransfer?: boolean;
1794
+ };
1795
+ interface IPolkadotXCMTransfer<TApi, TRes, TSigner> {
1796
+ transferPolkadotXCM: (input: TPolkadotXCMTransferOptions<TApi, TRes, TSigner>) => Promise<TRes>;
1797
+ }
1798
+ interface IXTokensTransfer<TApi, TRes, TSigner> {
1799
+ transferXTokens: (input: TXTokensTransferOptions<TApi, TRes, TSigner>) => TRes;
1800
+ }
1801
+ type TScenario = 'ParaToRelay' | 'ParaToPara' | 'RelayToPara';
1802
+ type TAddress = string | TLocation;
1803
+ type TDestination = TChain | TLocation;
1804
+ type TTransferBaseOptions<TApi, TRes, TSigner> = {
1705
1805
  /**
1706
- * The destination chain.
1806
+ * The origin chain
1707
1807
  */
1708
- destination: TChain;
1808
+ from: TChain;
1709
1809
  /**
1710
- * The address of the account.
1810
+ * The destination address. A SS58 or H160 format.
1711
1811
  */
1712
- recipient: string;
1812
+ recipient: TAddress;
1713
1813
  /**
1714
- * The account of the sender.
1814
+ * The optional sender address. A SS58 or H160 format.
1715
1815
  */
1716
- sender: string;
1816
+ sender?: string;
1717
1817
  /**
1718
- * The currency to query.
1818
+ * The optional asset hub address. A SS58 format only.
1719
1819
  */
1720
- currency: WithAmount<TCurrencyCore>;
1721
- version: Version | undefined;
1722
- buildTx: TTxFactory<TRes>;
1723
- feeAsset?: TCurrencyInput;
1724
- };
1725
- type TVerifyEdOnDestinationOptions<TApi, TRes, TSigner> = WithApi<TVerifyEdOnDestinationOptionsBase<TRes>, TApi, TRes, TSigner>;
1726
-
1727
- type TEvmTransferOptionsBase = {
1728
- from: TChain;
1729
- to: TChain;
1730
- currency: TCurrencyInputWithAmount;
1731
- recipient: string;
1732
1820
  ahAddress?: string;
1733
- signer: WalletClient;
1734
- };
1735
- type TEvmTransferOptions<TApi, TRes, TSigner> = WithApi<TEvmTransferOptionsBase, TApi, TRes, TSigner>;
1736
- /**
1737
- * The options for the batch builder.
1738
- */
1739
- declare enum BatchMode {
1740
1821
  /**
1741
- * Does not commit if one of the calls in the batch fails.
1822
+ * The destination chain or XCM location
1742
1823
  */
1743
- BATCH_ALL = "BATCH_ALL",
1824
+ to: TDestination;
1744
1825
  /**
1745
- * Commits each successful call regardless if a call fails.
1826
+ * The currency to transfer. Either ID, symbol, location, or multi-asset
1746
1827
  */
1747
- BATCH = "BATCH"
1748
- }
1749
- /**
1750
- * The options for the batch builder.
1751
- */
1752
- type TBatchOptions = {
1828
+ currency: TCurrencyInputWithAmount;
1753
1829
  /**
1754
- * The batch mode. Can be either:
1755
- * `BATCH_ALL` - does not commit if one of the calls in the batch fails.
1756
- * `BATCH` - commits each successful call regardless if a call fails.
1830
+ * The optional fee asset. Either ID, symbol, or location
1757
1831
  */
1758
- mode: BatchMode;
1759
- };
1760
- type TDryRunPreviewOptions = {
1761
- mintFeeAssets?: boolean;
1762
- };
1763
- type TBuilderOptions<TApi> = TApi | TBuilderConfig<TApi>;
1764
- type TBuilderConfig<TApi> = Partial<{
1765
- apiOverrides: Partial<Record<TChain, TApi>>;
1766
- development: boolean;
1767
- abstractDecimals: boolean;
1768
- xcmFormatCheck: boolean;
1769
- }>;
1770
- type TCreateTxsOptions<TApi, TRes, TSigner> = Pick<TTransferOptions<TApi, TRes, TSigner>, 'api' | 'from' | 'to' | 'currency'>;
1771
- type TBatchedTransferOptions<TApi, TRes, TSigner> = Omit<TSubstrateTransferOptions<TApi, TRes, TSigner>, 'isAmountAll'> & {
1772
- builder: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptions<TApi, TRes, TSigner> & TBuilderInternalOptions<TSigner>>;
1773
- };
1774
- type TBuildInternalResBase<TApi, TRes, TSigner, TOptions extends TTransferBaseOptions<TApi, TRes, TSigner> = TTransferBaseOptions<TApi, TRes, TSigner>> = {
1775
- options: TTransferOptions<TApi, TRes, TSigner> & TOptions;
1776
- };
1777
- type TBuildInternalRes<TApi, TRes, TSigner, TOptions extends TTransferBaseOptions<TApi, TRes, TSigner> = TTransferBaseOptions<TApi, TRes, TSigner>> = TBuildInternalResBase<TApi, TRes, TSigner, TOptions> & {
1778
- tx: TRes;
1779
- };
1780
- type TBuildAllInternalRes<TApi, TRes, TSigner, TOptions extends TTransferBaseOptions<TApi, TRes, TSigner> = TTransferBaseOptions<TApi, TRes, TSigner>> = TBuildInternalResBase<TApi, TRes, TSigner, TOptions> & {
1781
- txContexts: TTransactionContext<TApi, TRes>[];
1782
- };
1783
- type TSender<TSigner> = string | TSigner;
1784
- type TBuilderInternalOptions<TSigner> = {
1785
- senderSource?: TSender<TSigner> | WalletClient;
1786
- };
1787
-
1788
- type TProviderEntry = {
1789
- name: string;
1790
- endpoint: string;
1791
- };
1792
- type TChainConfig = {
1793
- name: string;
1794
- info: string;
1795
- paraId: number;
1796
- providers: TProviderEntry[];
1797
- };
1798
- type TChainConfigMap = Record<TSubstrateChain, TChainConfig>;
1799
-
1800
- type OneKey<K extends string, V = unknown> = {
1801
- [P in K]: Record<P, V> & Partial<Record<Exclude<K, P>, never>> extends infer O ? {
1802
- [Q in keyof O]: O[Q];
1803
- } : never;
1804
- }[K];
1805
- type TXcmVersioned<T> = OneKey<Version, T>;
1806
- type TXcmForeignAsset = {
1807
- ForeignAsset: string | number | bigint | undefined;
1808
- };
1809
- type TForeignAssetId = {
1810
- ForeignAssetId: bigint | undefined;
1811
- };
1812
- type TForeignOrTokenAsset = TXcmForeignAsset | {
1813
- Token: string | undefined;
1814
- };
1815
- type TForeignOrNativeAsset = TXcmForeignAsset | 'Native';
1816
- type TXcmAsset = {
1817
- XCM: number | undefined;
1818
- } | {
1819
- Native: null;
1820
- };
1821
- type TNativeTokenAsset = 'NativeToken';
1822
- type TZeitgeistAsset = 'Ztg';
1823
- type TOtherReserveAsset = {
1824
- OtherReserve: string | bigint | undefined;
1825
- };
1826
- type TSelfReserveAsset = 'SelfReserve';
1827
- type TReserveAsset = TOtherReserveAsset | TSelfReserveAsset;
1828
- type TBifrostToken = {
1829
- Native: string | number;
1830
- } | {
1831
- VToken: string;
1832
- } | {
1833
- Token: string;
1834
- } | {
1835
- VSToken2: number;
1836
- } | {
1837
- VToken2: number;
1838
- } | {
1839
- Token2: number;
1840
- };
1841
- type TXTokensCurrencySelection = TXcmVersioned<TLocation | TAsset | TAsset[]> | TXcmForeignAsset | TForeignAssetId | TForeignOrTokenAsset | TXcmAsset | TOtherReserveAsset | TBifrostToken | string | bigint | number | undefined;
1842
-
1843
- declare class AmountTooLowError extends Error {
1844
- constructor(message?: string);
1845
- }
1846
-
1847
- /**
1848
- * Error thrown when an API operation is attempted before the API has been initialized.
1849
- */
1850
- declare class ApiNotInitializedError extends Error {
1851
- constructor();
1852
- }
1853
-
1854
- /**
1855
- * Error thrown when a batch operation is invalid or cannot be executed.
1856
- */
1857
- declare class BatchValidationError extends Error {
1858
- constructor(message: string);
1859
- }
1860
-
1861
- /**
1862
- * Error thrown when the Ethereum bridge is halted.
1863
- */
1864
- declare class BridgeHaltedError extends Error {
1832
+ feeAsset?: TCurrencyInput;
1865
1833
  /**
1866
- * Constructs a new BridgeHaltedError.
1867
- *
1868
- * @param message - Optional custom error message.
1834
+ * The optional destination parachain ID
1869
1835
  */
1870
- constructor();
1871
- }
1872
-
1873
- /**
1874
- * Error thrown when the Dry Run fails.
1875
- */
1876
- declare class DryRunFailedError extends Error {
1877
- readonly reason: string;
1878
- readonly dryRunType?: TChainEndpoint;
1836
+ paraIdTo?: number;
1837
+ /**
1838
+ * The optional overrided XCM version
1839
+ */
1840
+ version?: Version;
1879
1841
  /**
1880
- * Constructs a new DryRunFailedError.
1881
- *
1882
- * @param reason - The reason why the dry run failed.
1883
- * @param dryRunType - Optional. Specifies if the error is related to the 'origin' or 'destination' dry run.
1842
+ * The optional pallet override
1884
1843
  */
1885
- constructor(reason: string, dryRunType?: TChainEndpoint);
1886
- }
1887
-
1888
- /**
1889
- * Error thrown when an extension is not installed.
1890
- */
1891
- declare class ExtensionNotInstalledError extends Error {
1844
+ pallet?: string;
1892
1845
  /**
1893
- * Constructs a new ExtensionNotInstalledError.
1894
- *
1895
- * @param message - The error message.
1846
+ * Whether to keep the account alive after the transfer.
1896
1847
  */
1897
- constructor(message: string);
1898
- }
1899
-
1900
- /**
1901
- * Error thrown when a feature or route is temporarily disabled via configuration or governance.
1902
- */
1903
- declare class FeatureTemporarilyDisabledError extends Error {
1904
- constructor(message: string);
1905
- }
1906
-
1907
- /**
1908
- * Error thrown when an invalid address is provided.
1909
- */
1910
- declare class InvalidAddressError extends Error {
1848
+ keepAlive?: boolean;
1911
1849
  /**
1912
- * Constructs a new InvalidAddressError.
1913
- *
1914
- * @param message - The error message.
1850
+ * The optional pallet method override
1915
1851
  */
1916
- constructor(message: string);
1917
- }
1918
-
1919
- /**
1920
- * Error development mode is on and no API override is provided for a specific chain.
1921
- */
1922
- declare class MissingChainApiError extends Error {
1852
+ method?: string;
1923
1853
  /**
1924
- * Constructs a new MissingChainApiError.
1925
- *
1926
- * @param chain - The chain for which the API is missing.
1854
+ * Hex of the encoded transaction call to apply on the destination chain
1927
1855
  */
1928
- constructor(chain: TChain);
1929
- }
1930
-
1931
- /**
1932
- * Error thrown when a required parameter is missing.
1933
- */
1934
- declare class MissingParameterError extends Error {
1935
- constructor(parameter: string | string[], message?: string);
1936
- }
1937
-
1938
- /**
1939
- * Used to inform user, that Parachain they wish to use has not yet implemented full XCM Support
1940
- */
1941
- declare class NoXCMSupportImplementedError extends Error {
1856
+ transactOptions?: TTransactOptions<TRes>;
1942
1857
  /**
1943
- * Constructs a new NoXCMSupportImplementedError.
1944
- *
1945
- * @param chain - The chain for which XCM support is not implemented.
1858
+ * The optional swap options
1946
1859
  */
1947
- constructor(chain: TChain);
1948
- }
1949
-
1950
- /**
1951
- * Error thrown when numeric input is invalid or cannot be parsed.
1952
- */
1953
- declare class NumberFormatError extends Error {
1954
- constructor(message?: string);
1955
- }
1956
-
1957
- /**
1958
- * Error thrown when asset or currency overrides are invalid or conflicting.
1959
- */
1960
- declare class OverrideConflictError extends Error {
1961
- constructor(message: string);
1962
- }
1963
-
1964
- /**
1965
- * Error thrown when no provider or RPC endpoint is available for the requested chain.
1966
- */
1967
- declare class ProviderUnavailableError extends Error {
1968
- constructor(message: string);
1969
- }
1970
-
1860
+ swapOptions?: TSwapOptions<TApi, TRes, TSigner>;
1861
+ };
1971
1862
  /**
1972
- * Error thrown when routing or path resolution fails.
1863
+ * Options for transferring from a parachain to another parachain or relay chain
1973
1864
  */
1974
- declare class RoutingResolutionError extends Error {
1975
- constructor(message: string);
1976
- }
1865
+ type TTransferOptions<TApi, TRes, TSigner> = WithApi<TTransferBaseOptions<TApi, TRes, TSigner>, TApi, TRes, TSigner> & {
1866
+ isAmountAll: boolean;
1867
+ };
1868
+ type TSubstrateTransferBaseOptions<TApi, TRes, TSigner> = Omit<TTransferBaseOptions<TApi, TRes, TSigner>, 'from'> & {
1869
+ from: TSubstrateChain;
1870
+ };
1871
+ type TSubstrateTransferOptions<TApi, TRes, TSigner> = Omit<TTransferOptions<TApi, TRes, TSigner>, 'from'> & {
1872
+ from: TSubstrateChain;
1873
+ };
1874
+ type WithRequiredSender<TBase> = Omit<TBase, 'sender'> & {
1875
+ /**
1876
+ * The sender address. A SS58 or H160 format.
1877
+ */
1878
+ sender: string;
1879
+ };
1880
+ type WithRequiredSwapOptions<TBase, TApi, TRes, TSigner> = Omit<TBase, 'swapOptions'> & {
1881
+ swapOptions: TSwapOptions<TApi, TRes, TSigner>;
1882
+ };
1883
+ type TTransferOptionsWithSwap<TApi, TRes, TSigner> = WithRequiredSwapOptions<Omit<TSubstrateTransferOptions<TApi, TRes, TSigner>, 'isAmountAll'>, TApi, TRes, TSigner>;
1884
+ type TTransferBaseOptionsWithSwap<TApi, TRes, TSigner> = WithRequiredSwapOptions<TTransferBaseOptions<TApi, TRes, TSigner>, TApi, TRes, TSigner>;
1885
+ type TTransferBaseOptionsWithSender<TApi, TRes, TSigner> = WithRequiredSender<TTransferBaseOptions<TApi, TRes, TSigner>>;
1886
+ type TSubstrateTransferBaseOptionsWithSender<TApi, TRes, TSigner> = WithRequiredSender<TSubstrateTransferBaseOptions<TApi, TRes, TSigner>>;
1887
+ type TTransferInternalOptions<TApi, TRes, TSigner> = Omit<TTransferBaseOptions<TApi, TRes, TSigner>, 'from' | 'feeAsset' | 'version'> & {
1888
+ api: PolkadotApi<TApi, TRes, TSigner>;
1889
+ assetInfo: WithAmount<TAssetInfo>;
1890
+ feeAsset?: TAssetInfo;
1891
+ feeCurrency?: TCurrencyInput;
1892
+ overriddenAsset?: TLocation | TAssetWithFee[];
1893
+ version: Version;
1894
+ isAmountAll: boolean;
1895
+ };
1896
+ type TTransactOrigin = (typeof TRANSACT_ORIGINS)[number];
1897
+ type TTransactOptions<TRes, TWeightType = bigint> = {
1898
+ call: string | TRes;
1899
+ originKind?: TTransactOrigin;
1900
+ maxWeight?: TWeight<TWeightType>;
1901
+ };
1902
+ type TSerializedExtrinsics = {
1903
+ module: TPallet;
1904
+ method: string;
1905
+ params: Record<string, unknown>;
1906
+ };
1907
+ type TSerializedStateQuery = {
1908
+ module: TAssetsPallet;
1909
+ method: string;
1910
+ params: unknown[];
1911
+ };
1912
+ type TSerializedRuntimeApiQuery = {
1913
+ module: string;
1914
+ method: string;
1915
+ params: unknown[];
1916
+ };
1917
+ type TDestWeight = {
1918
+ ref_time: bigint;
1919
+ proof_size: bigint;
1920
+ };
1921
+ type TXTokensMethod = 'transfer' | 'transfer_multiasset' | 'transfer_multiassets';
1922
+ type TPolkadotXcmMethod = 'limited_teleport_assets' | 'limited_reserve_transfer_assets' | 'reserve_transfer_assets' | 'reserve_withdraw_assets' | 'transfer_assets' | 'transfer_assets_using_type_and_then';
1923
+ type TXcmPalletMethod = 'limited_teleport_assets' | 'limited_reserve_transfer_assets' | 'transfer_assets_using_type_and_then';
1924
+ type TWeight<TWeightType = bigint> = {
1925
+ refTime: TWeightType;
1926
+ proofSize: TWeightType;
1927
+ };
1928
+ type TCreateBeneficiaryOptions<TApi, TRes, TSigner> = {
1929
+ api: PolkadotApi<TApi, TRes, TSigner>;
1930
+ address: TAddress;
1931
+ version: Version;
1932
+ };
1933
+ type TCreateBeneficiaryXTokensOptions<TApi, TRes, TSigner> = {
1934
+ api: PolkadotApi<TApi, TRes, TSigner>;
1935
+ origin: TSubstrateChain;
1936
+ destination: TDestination;
1937
+ recipient: TAddress;
1938
+ version: Version;
1939
+ paraId?: number;
1940
+ };
1941
+ type TBridgeStatus = 'Normal' | 'Halted';
1942
+ type TTransferLocalOptions<TApi, TRes, TSigner> = Omit<TTransferInternalOptions<TApi, TRes, TSigner>, 'recipient'> & {
1943
+ recipient: string;
1944
+ balance: bigint;
1945
+ };
1946
+ type TTransferFeeEstimates = {
1947
+ originFee: bigint;
1948
+ reserveFee: bigint;
1949
+ };
1950
+ type TCreateBaseTransferXcmOptions<TRes> = {
1951
+ chain: TSubstrateChain;
1952
+ destChain: TChain;
1953
+ assetInfo: WithAmount<TAssetInfo>;
1954
+ feeAssetInfo?: TAssetInfo;
1955
+ fees: TTransferFeeEstimates;
1956
+ recipient: string;
1957
+ sender?: string;
1958
+ version: Version;
1959
+ useJitWithdraw?: boolean;
1960
+ useFeeAssetOnHops?: boolean;
1961
+ forceBuyExecution?: boolean;
1962
+ paraIdTo?: number;
1963
+ transactOptions?: TTransactOptions<TRes>;
1964
+ };
1965
+ type TCreateTransferXcmOptions<TApi, TRes, TSigner> = WithApi<TCreateBaseTransferXcmOptions<TRes>, TApi, TRes, TSigner>;
1966
+ type TCreateBaseSwapXcmOptions = {
1967
+ chain?: TSubstrateChain;
1968
+ exchangeChain: TExchangeChain;
1969
+ destChain?: TChain;
1970
+ assetInfoFrom: WithAmount<TAssetInfo>;
1971
+ assetInfoTo: WithAmount<TAssetInfo>;
1972
+ currencyTo: TCurrencyInput;
1973
+ feeAssetInfo?: TAssetInfo;
1974
+ sender: string;
1975
+ recipient: string;
1976
+ calculateMinAmountOut: (amountIn: bigint, assetTo?: TAssetInfo) => Promise<bigint>;
1977
+ };
1978
+ type TCreateSwapXcmOptions<TApi, TRes, TSigner> = WithApi<TCreateBaseSwapXcmOptions, TApi, TRes, TSigner>;
1979
+ type TSwapFeeEstimates = {
1980
+ originFee: bigint;
1981
+ originReserveFee: bigint;
1982
+ exchangeFee: bigint;
1983
+ destReserveFee: bigint;
1984
+ };
1985
+ type TCreateSwapXcmInternalOptions<TApi, TRes, TSigner> = WithApi<TCreateBaseSwapXcmOptions, TApi, TRes, TSigner> & {
1986
+ version: Version;
1987
+ fees: TSwapFeeEstimates;
1988
+ paraIdTo?: number;
1989
+ };
1990
+ type TCreateEthBridgeInstructionsOptions<TApi, TRes, TSigner> = {
1991
+ api: PolkadotApi<TApi, TRes, TSigner>;
1992
+ recipient: TAddress;
1993
+ assetInfo: TAssetInfo;
1994
+ sender: string;
1995
+ ahAddress?: string;
1996
+ version: Version;
1997
+ };
1977
1998
 
1978
- /**
1979
- * Error thrown when a runtime API call fails
1980
- */
1981
- declare class RuntimeApiError extends Error {
1982
- constructor(message: string);
1983
- }
1999
+ /** @deprecated Asset claim functionality is deprecated and will be removed in v14. */
2000
+ type TAssetClaimOptionsBase = {
2001
+ chain: TSubstrateChain;
2002
+ currency: WithComplexAmount<TCurrencyCore> | TAsset<TAmount>[] | WithComplexAmount<TCurrencyCore>[];
2003
+ address: TAddress;
2004
+ version?: Version;
2005
+ };
2006
+ type TAssetClaimOptions<TApi, TRes, TSigner> = WithApi<TAssetClaimOptionsBase, TApi, TRes, TSigner>;
2007
+ type TAssetClaimInternalOptions<TApi, TRes, TSigner> = TAssetClaimOptions<TApi, TRes, TSigner> & {
2008
+ version: Version;
2009
+ assets: TAsset<bigint>[];
2010
+ };
1984
2011
 
1985
- /**
1986
- * Error thrown when a required runtime API is not available on the target chain.
1987
- */
1988
- declare class RuntimeApiUnavailableError extends Error {
1989
- constructor(chain: string, apiName: string);
2012
+ type TSetBalanceRes = {
2013
+ assetStatusTx?: TSerializedExtrinsics;
2014
+ balanceTx: TSerializedExtrinsics;
2015
+ };
2016
+ declare abstract class BaseAssetsPallet {
2017
+ protected palletName: TAssetsPallet;
2018
+ constructor(palletName: TAssetsPallet);
2019
+ abstract mint<TApi, TRes, TSigner>(address: string, assetInfo: WithAmount<TAssetInfo>, balance: bigint, chain: TSubstrateChain, api: PolkadotApi<TApi, TRes, TSigner>): Promise<TSetBalanceRes>;
2020
+ abstract getBalance<TApi, TRes, TSigner>(api: PolkadotApi<TApi, TRes, TSigner>, address: string, asset: TAssetInfo, customCurrencyId?: unknown): Promise<bigint>;
1990
2021
  }
1991
2022
 
1992
- type TScenarioNotSupportedContext = {
2023
+ type TGetBalanceCommonOptions = {
2024
+ /**
2025
+ * The address of the account.
2026
+ */
2027
+ address: string;
2028
+ /**
2029
+ * The chain on which to query the balance.
2030
+ */
1993
2031
  chain: TChain;
1994
- scenario: TScenario;
1995
2032
  };
1996
2033
  /**
1997
- * Error thrown when a scenario, route, or chain capability is not supported.
1998
- */
1999
- declare class ScenarioNotSupportedError extends Error {
2000
- constructor(message: string);
2001
- constructor({ chain, scenario }: TScenarioNotSupportedContext);
2002
- }
2003
-
2004
- /**
2005
- * Error thrown when a submitted transaction encounters a dispatch error on-chain.
2034
+ * Retrieves the asset balance for a given account on a specified chain.
2006
2035
  */
2007
- declare class SubmitTransactionError extends Error {
2036
+ type TGetAssetBalanceOptionsBase = TGetBalanceCommonOptions & {
2008
2037
  /**
2009
- * Constructs a new SubmitTransactionError.
2010
- *
2011
- * @param message - The dispatch error details.
2038
+ * The resolved asset to query balance for.
2012
2039
  */
2013
- constructor(message: string);
2014
- }
2015
-
2016
- declare class TransferToAhNotSupported extends Error {
2017
- constructor(message?: string);
2018
- }
2019
-
2020
- declare class TypeAndThenUnavailableError extends Error {
2021
- constructor(message: string);
2022
- }
2023
-
2040
+ asset: TAssetInfo;
2041
+ };
2024
2042
  /**
2025
- * UnableToComputeError is thrown when a computation cannot be performed.
2043
+ * Retrieves the currency balance for a given account on a specified chain.
2026
2044
  */
2027
- declare class UnableToComputeError extends Error {
2045
+ type TGetBalanceOptionsBase = TGetBalanceCommonOptions & {
2028
2046
  /**
2029
- * Constructs a new UnableToComputeError.
2030
- *
2031
- * @param message - Required error message.
2047
+ * The currency to query.
2032
2048
  */
2033
- constructor(message: string);
2034
- }
2035
-
2036
- /**
2037
- * Error thrown when an operation or parameter combination is not supported.
2038
- */
2039
- declare class UnsupportedOperationError extends Error {
2040
- constructor(message: string);
2041
- }
2042
-
2043
- /**
2044
- * Thrown when a validation check fails.
2045
- */
2046
- declare class ValidationError extends Error {
2047
- constructor(message: string);
2048
- }
2049
-
2050
- type THopTransferInfo = {
2051
- chain: TChain;
2052
- result: {
2053
- xcmFee: TXcmFeeBase;
2054
- asset: TAssetInfo;
2055
- };
2056
- };
2057
- type TXcmFeeBase = {
2058
- fee: bigint;
2059
- asset: TAssetInfo;
2060
- };
2061
- type TTransferInfo = {
2062
- chain: {
2063
- origin: TChain;
2064
- destination: TChain;
2065
- ecosystem: string;
2066
- };
2067
- origin: {
2068
- selectedCurrency: {
2069
- sufficient: boolean;
2070
- balance: bigint;
2071
- balanceAfter: bigint;
2072
- asset: TAssetInfo;
2073
- };
2074
- xcmFee: TXcmFeeBase & {
2075
- sufficient: boolean;
2076
- balance: bigint;
2077
- balanceAfter: bigint;
2078
- };
2079
- };
2080
- hops: THopTransferInfo[];
2081
- destination: {
2082
- receivedCurrency: {
2083
- sufficient: boolean | UnableToComputeError;
2084
- receivedAmount: bigint | UnableToComputeError;
2085
- balance: bigint;
2086
- balanceAfter: bigint | UnableToComputeError;
2087
- asset: TAssetInfo;
2088
- };
2089
- xcmFee: TXcmFeeBase & {
2090
- balanceAfter: bigint | UnableToComputeError;
2091
- };
2092
- };
2049
+ currency?: TCurrencyCore;
2093
2050
  };
2094
- type BuildHopInfoOptions<TApi, TRes, TSigner> = {
2095
- api: PolkadotApi<TApi, TRes, TSigner>;
2096
- chain: TSubstrateChain;
2097
- fee: bigint;
2098
- originChain: TSubstrateChain;
2099
- currency: TCurrencyCore;
2100
- asset: TAssetInfo;
2051
+ type TGetBalanceOptions<TApi, TRes, TSigner> = WithApi<TGetBalanceOptionsBase, TApi, TRes, TSigner>;
2052
+ type TGetAssetBalanceOptions<TApi, TRes, TSigner> = WithApi<TGetAssetBalanceOptionsBase, TApi, TRes, TSigner>;
2053
+ type TGetTransferableAmountOptionsBase<TRes> = {
2054
+ /**
2055
+ * The sender address of the account.
2056
+ */
2101
2057
  sender: string;
2102
- ahAddress?: string;
2103
- };
2104
- type TBuildDestInfoOptions<TApi, TRes, TSigner> = {
2105
- api: PolkadotApi<TApi, TRes, TSigner>;
2058
+ /**
2059
+ * The chain on which to query the balance.
2060
+ */
2106
2061
  origin: TSubstrateChain;
2062
+ /**
2063
+ * The destination chain.
2064
+ */
2107
2065
  destination: TChain;
2108
- recipient: string;
2066
+ /**
2067
+ * The currency to query.
2068
+ */
2109
2069
  currency: WithAmount<TCurrencyCore>;
2110
- originFee: bigint;
2111
- isFeeAssetAh: boolean;
2112
- destFeeDetail: TXcmFeeDetail;
2113
- totalHopFee: bigint;
2114
- bridgeFee?: bigint;
2115
- };
2116
- type TOriginFeeDetails = {
2117
- sufficientForXCM: boolean;
2118
- xcmFee: bigint;
2119
- };
2120
- type TGetTransferInfoOptionsBase<TRes> = {
2070
+ version: Version | undefined;
2121
2071
  buildTx: TTxFactory<TRes>;
2072
+ feeAsset?: TCurrencyInput;
2073
+ };
2074
+ type TGetTransferableAmountOptions<TApi, TRes, TSigner> = WithApi<TGetTransferableAmountOptionsBase<TRes>, TApi, TRes, TSigner>;
2075
+ type TGetMinTransferableAmountOptions<TApi, TRes, TSigner> = WithApi<TGetTransferableAmountOptionsBase<TRes> & {
2076
+ recipient: string;
2077
+ builder: GeneralBuilder<TApi, TRes, TSigner, TTransferBaseOptionsWithSender<TApi, TRes, TSigner>>;
2078
+ }, TApi, TRes, TSigner>;
2079
+ type TVerifyEdOnDestinationOptionsBase<TRes> = {
2080
+ /**
2081
+ * The origin chain.
2082
+ */
2122
2083
  origin: TSubstrateChain;
2084
+ /**
2085
+ * The destination chain.
2086
+ */
2123
2087
  destination: TChain;
2124
- sender: string;
2125
- ahAddress?: string;
2088
+ /**
2089
+ * The address of the account.
2090
+ */
2126
2091
  recipient: string;
2092
+ /**
2093
+ * The account of the sender.
2094
+ */
2095
+ sender: string;
2096
+ /**
2097
+ * The currency to query.
2098
+ */
2127
2099
  currency: WithAmount<TCurrencyCore>;
2128
2100
  version: Version | undefined;
2129
- feeAsset?: TCurrencyCore;
2101
+ buildTx: TTxFactory<TRes>;
2102
+ feeAsset?: TCurrencyInput;
2130
2103
  };
2131
- type TGetTransferInfoOptions<TApi, TRes, TSigner> = WithApi<TGetTransferInfoOptionsBase<TRes>, TApi, TRes, TSigner>;
2104
+ type TVerifyEdOnDestinationOptions<TApi, TRes, TSigner> = WithApi<TVerifyEdOnDestinationOptionsBase<TRes>, TApi, TRes, TSigner>;
2105
+
2106
+ type TProviderEntry = {
2107
+ name: string;
2108
+ endpoint: string;
2109
+ };
2110
+ type TChainConfig = {
2111
+ name: string;
2112
+ info: string;
2113
+ paraId: number;
2114
+ providers: TProviderEntry[];
2115
+ };
2116
+ type TChainConfigMap = Record<TSubstrateChain, TChainConfig>;
2117
+
2118
+ type OneKey<K extends string, V = unknown> = {
2119
+ [P in K]: Record<P, V> & Partial<Record<Exclude<K, P>, never>> extends infer O ? {
2120
+ [Q in keyof O]: O[Q];
2121
+ } : never;
2122
+ }[K];
2123
+ type TXcmVersioned<T> = OneKey<Version, T>;
2124
+ type TXcmForeignAsset = {
2125
+ ForeignAsset: string | number | bigint | undefined;
2126
+ };
2127
+ type TForeignAssetId = {
2128
+ ForeignAssetId: bigint | undefined;
2129
+ };
2130
+ type TForeignOrTokenAsset = TXcmForeignAsset | {
2131
+ Token: string | undefined;
2132
+ };
2133
+ type TForeignOrNativeAsset = TXcmForeignAsset | 'Native';
2134
+ type TXcmAsset = {
2135
+ XCM: number | undefined;
2136
+ } | {
2137
+ Native: null;
2138
+ };
2139
+ type TNativeTokenAsset = 'NativeToken';
2140
+ type TZeitgeistAsset = 'Ztg';
2141
+ type TOtherReserveAsset = {
2142
+ OtherReserve: string | bigint | undefined;
2143
+ };
2144
+ type TSelfReserveAsset = 'SelfReserve';
2145
+ type TReserveAsset = TOtherReserveAsset | TSelfReserveAsset;
2146
+ type TBifrostToken = {
2147
+ Native: string | number;
2148
+ } | {
2149
+ VToken: string;
2150
+ } | {
2151
+ Token: string;
2152
+ } | {
2153
+ VSToken2: number;
2154
+ } | {
2155
+ VToken2: number;
2156
+ } | {
2157
+ Token2: number;
2158
+ };
2159
+ type TXTokensCurrencySelection = TXcmVersioned<TLocation | TAsset | TAsset[]> | TXcmForeignAsset | TForeignAssetId | TForeignOrTokenAsset | TXcmAsset | TOtherReserveAsset | TBifrostToken | string | bigint | number | undefined;
2132
2160
 
2133
2161
  type TChainWithApi<TApi, TRes, TSigner, T = TSubstrateChain> = {
2134
2162
  api: PolkadotApi<TApi, TRes, TSigner>;
@@ -2136,13 +2164,14 @@ type TChainWithApi<TApi, TRes, TSigner, T = TSubstrateChain> = {
2136
2164
  };
2137
2165
  type TTypeAndThenCallContext<TApi, TRes, TSigner> = {
2138
2166
  origin: TChainWithApi<TApi, TRes, TSigner>;
2139
- dest: TChainWithApi<TApi, TRes, TSigner>;
2167
+ dest: TChainWithApi<TApi, TRes, TSigner, TChain>;
2140
2168
  reserve: TChainWithApi<TApi, TRes, TSigner, TChain>;
2141
2169
  isSubBridge: boolean;
2142
2170
  isSnowbridge: boolean;
2143
2171
  isRelayAsset: boolean;
2144
2172
  assetInfo: WithAmount<TAssetInfo>;
2145
2173
  systemAsset: TAssetInfo;
2174
+ bridgeHopChain?: TSubstrateChain;
2146
2175
  options: TPolkadotXCMTransferOptions<TApi, TRes, TSigner>;
2147
2176
  };
2148
2177
  type TTypeAndThenFees = {
@@ -2197,13 +2226,15 @@ declare const getParaId: (chain: TChain) => number;
2197
2226
  declare const getTChain: (paraId: number, ecosystem: TRelaychain | TExternalChain) => TChain | null;
2198
2227
 
2199
2228
  interface TEvmExtension {
2200
- executeEvmTransfer: <TApi, TRes, TSigner>(options: TEvmTransferOptions<TApi, TRes, TSigner>) => Promise<string>;
2229
+ executeTransfer: <TApi, TRes, TSigner>(options: TEvmTransferOptions<TApi, TRes, TSigner>) => Promise<string>;
2230
+ buildTransfer: <TApi, TRes, TSigner>(options: TBuildEvmTransferOptions<TApi, TRes, TSigner>) => Promise<TransactionSerializableEIP1559>;
2201
2231
  }
2202
2232
  declare const registerEvmExtension: (extension: TEvmExtension | undefined) => void;
2203
2233
  declare const getEvmExtensionOrThrow: () => TEvmExtension;
2204
2234
 
2205
2235
  interface TEvmSnowbridgeExtension {
2206
- executeEvmSnowbridgeTransfer: <TApi, TRes, TSigner>(options: TEvmTransferOptions<TApi, TRes, TSigner>) => Promise<string>;
2236
+ executeTransfer: <TApi, TRes, TSigner>(options: TEvmTransferOptions<TApi, TRes, TSigner>) => Promise<string>;
2237
+ buildTransfer: <TApi, TRes, TSigner>(options: TBuildEvmTransferOptions<TApi, TRes, TSigner>) => Promise<TransactionSerializableEIP1559>;
2207
2238
  }
2208
2239
  declare const registerEvmSnowbridgeExtension: (extension: TEvmSnowbridgeExtension | undefined) => void;
2209
2240
  declare const getEvmSnowbridgeExtensionOrThrow: () => TEvmSnowbridgeExtension;
@@ -2259,10 +2290,7 @@ declare const transferMoonbeamEvm: <TApi, TRes, TSigner>(options: TEvmTransferOp
2259
2290
 
2260
2291
  declare const transferMoonbeamToEth: <TApi, TRes, TSigner>(from: TSubstrateChain, { api, to, signer, recipient, ahAddress, currency }: TEvmTransferOptions<TApi, TRes, TSigner>) => Promise<`0x${string}`>;
2261
2292
 
2262
- declare const getOriginXcmFee: <TApi, TRes, TSigner>(options: TGetOriginXcmFeeOptions<TApi, TRes, TSigner>) => Promise<TXcmFeeDetail & {
2263
- forwardedXcms?: unknown;
2264
- destParaId?: number;
2265
- }>;
2293
+ declare const getOriginXcmFee: <TApi, TRes, TSigner, TDisableFallback extends boolean = boolean>(options: TGetOriginXcmFeeOptions<TApi, TRes, TSigner, TDisableFallback>) => Promise<TXcmFeeDetailWithForwardedXcm<TDisableFallback>>;
2266
2294
 
2267
2295
  declare const getOriginXcmFeeInternal: <TApi, TRes, TSigner>({ api, tx, origin, destination, sender, disableFallback, feeAsset, currency, version, useRootOrigin }: TGetOriginXcmFeeInternalOptions<TApi, TRes, TSigner>) => Promise<TXcmFeeDetail & {
2268
2296
  forwardedXcms?: any;
@@ -2276,6 +2304,37 @@ declare const getXcmFeeOnce: <TApi, TRes, TSigner, TDisableFallback extends bool
2276
2304
 
2277
2305
  declare const getBridgeStatus: <TApi, TRes, TSigner>(api: PolkadotApi<TApi, TRes, TSigner>) => Promise<TBridgeStatus>;
2278
2306
 
2307
+ declare const aggregateHopFees: (hops: TXcmFeeHopInfo[], matchAsset: TAssetInfo) => {
2308
+ totalHopFee: bigint;
2309
+ bridgeFee?: bigint;
2310
+ };
2311
+
2312
+ declare const buildDestInfo: <TApi, TRes, TSigner>({ api, origin, destination, recipient, currency, originFee, isFeeAssetAh, destFeeDetail, totalHopFee, bridgeFee }: TBuildDestInfoOptions<TApi, TRes, TSigner>) => Promise<{
2313
+ receivedCurrency: {
2314
+ sufficient: boolean | UnableToComputeError;
2315
+ receivedAmount: bigint | UnableToComputeError;
2316
+ balance: bigint;
2317
+ balanceAfter: bigint | UnableToComputeError;
2318
+ asset: _paraspell_assets.TAssetInfo;
2319
+ };
2320
+ xcmFee: {
2321
+ fee: bigint;
2322
+ balance: bigint;
2323
+ balanceAfter: bigint;
2324
+ asset: _paraspell_assets.TAssetInfo;
2325
+ };
2326
+ }>;
2327
+
2328
+ declare const buildHopInfo: <TApi, TRes, TSigner>({ api, chain, fee, originChain, asset, currency }: BuildHopInfoOptions<TApi, TRes, TSigner>) => Promise<{
2329
+ asset: _paraspell_assets.TAssetInfo;
2330
+ xcmFee: {
2331
+ fee: bigint;
2332
+ asset: _paraspell_assets.TAssetInfo;
2333
+ };
2334
+ }>;
2335
+
2336
+ declare const buildOriginInfo: <TApi, TRes, TSigner>({ api, origin, sender, currency, originAsset, amount, originFee, originFeeAsset, isFeeAssetAh }: TBuildOriginInfoOptions<TApi, TRes, TSigner>) => Promise<TTransferInfo["origin"]>;
2337
+
2279
2338
  declare const getTransferInfo: <TApi, TRes, TSigner>({ api, buildTx, origin, destination, sender, ahAddress, recipient, currency, feeAsset, version }: TGetTransferInfoOptions<TApi, TRes, TSigner>) => Promise<TTransferInfo>;
2280
2339
 
2281
2340
  declare const getMinTransferableAmountInternal: <TApi, TRes, TSigner>({ api, origin, sender, recipient, origin: chain, destination, currency, feeAsset, buildTx, builder, version }: TGetMinTransferableAmountOptions<TApi, TRes, TSigner>) => Promise<bigint>;
@@ -2314,7 +2373,9 @@ declare const validateDestinationAddress: <TApi, TRes, TSigner>(address: TAddres
2314
2373
  declare const assertToIsString: (to: TDestination, overrideMsg?: string) => asserts to is Exclude<TDestination, TLocation>;
2315
2374
  declare const assertAddressIsString: (address: TAddress) => asserts address is Exclude<TAddress, TLocation>;
2316
2375
  declare const assertSender: (address: string | undefined) => asserts address is string;
2376
+ declare const assertEvmAddress: (address: string) => asserts address is Address;
2317
2377
  declare const assertHasId: (asset: TAssetInfo) => asserts asset is TAssetInfoWithId;
2378
+ declare const assertCurrencyCore: <T>(value: T) => asserts value is (T & TCurrencyCore) | (T & undefined);
2318
2379
  declare const assertSenderSource: <TSigner>(sender?: TSender<TSigner>) => asserts sender is TSender<TSigner>;
2319
2380
  declare const isSenderSigner: <TSigner>(sender: TSender<TSigner>) => sender is TSigner;
2320
2381
  declare const assertSwapSupport: <TApi, TRes, TSigner>(options: TSwapOptions<TApi, TRes, TSigner> | undefined) => void;
@@ -2341,7 +2402,7 @@ declare const createTxOverrideAmount: <TApi, TRes, TSigner>(options: TCreateTxsO
2341
2402
  declare const createTransferOrSwapAll: <TApi, TRes, TSigner>(options: TSubstrateTransferOptions<TApi, TRes, TSigner>) => Promise<TTransactionContext<TApi, TRes>[]>;
2342
2403
  declare const createTransferOrSwap: <TApi, TRes, TSigner>(options: TSubstrateTransferOptions<TApi, TRes, TSigner>) => Promise<TRes>;
2343
2404
 
2344
- declare const getAssetReserveChain: (chain: TSubstrateChain, assetLocation: TLocation) => TSubstrateChain;
2405
+ declare const getAssetReserveChain: (chain: TSubstrateChain, assetLocation: TLocation, resolveExternalReserve?: boolean) => TChain;
2345
2406
 
2346
2407
  declare const getChainVersion: <TApi, TRes, TSigner>(chain: TChain) => Version;
2347
2408
 
@@ -2384,7 +2445,7 @@ declare const isViemSigner: (value: unknown) => value is WalletClient;
2384
2445
  declare const createBeneficiaryLocXTokens: <TApi, TRes, TSigner>({ api, recipient, origin, destination, version, paraId }: TCreateBeneficiaryXTokensOptions<TApi, TRes, TSigner>) => TLocation;
2385
2446
  declare const createBeneficiaryLocation: <TApi, TRes, TSigner>({ api, address, version }: TCreateBeneficiaryOptions<TApi, TRes, TSigner>) => TLocation;
2386
2447
 
2387
- declare const createDestination: (version: Version, origin: TSubstrateChain, destination: TDestination, chainId?: number, junction?: TJunction, parents?: Parents) => TLocation;
2448
+ declare const createDestination: (version: Version, origin: TChain, destination: TDestination, chainId?: number, junction?: TJunction, parents?: Parents) => TLocation;
2388
2449
  declare const createVersionedDestination: (version: Version, origin: TSubstrateChain, destination: TDestination, chainId?: number, junction?: TJunction, parents?: Parents) => TXcmVersioned<TLocation>;
2389
2450
 
2390
2451
  declare const createX1Payload: (version: Version, junction: TJunction) => TJunctions;
@@ -2459,5 +2520,5 @@ declare const selectXcmVersion: (forcedVersion: Version | undefined, originVersi
2459
2520
  declare const pickCompatibleXcmVersion: (origin: TSubstrateChain, destination: TDestination, override?: Version) => Version;
2460
2521
  declare const pickRouterCompatibleXcmVersion: (origin: TSubstrateChain | undefined, exchangeChain: TSubstrateChain, destination: TChain | undefined) => Version;
2461
2522
 
2462
- export { API_TYPES, AmountTooLowError, ApiNotInitializedError, AssetClaimBuilder, BaseAssetsPallet, BatchMode, BatchValidationError, BridgeHaltedError, Builder, DEFAULT_TTL_MS, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETH_MAINNET_CHAIN_ID, ETH_TESTNET_CHAIN_ID, EXCHANGE_CHAINS, EXTENSION_MS, ExtensionNotInstalledError, FeatureTemporarilyDisabledError, GeneralBuilder, InvalidAddressError, MAX_CLIENTS, MissingChainApiError, MissingParameterError, NoXCMSupportImplementedError, NumberFormatError, OverrideConflictError, PolkadotApi, PolkadotXcmError, PolkadotXcmExecutionError, ProviderUnavailableError, RELAY_LOCATION, RoutingResolutionError, RuntimeApiError, RuntimeApiUnavailableError, ScenarioNotSupportedError, SubmitTransactionError, TRANSACT_ORIGINS, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, TypeAndThenUnavailableError, UnableToComputeError, UnsupportedOperationError, ValidationError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, applyDecimalAbstraction, assertAddressIsString, assertExtensionInstalled, assertHasId, assertNotEvmTransfer, assertSender, assertSenderSource, assertSubstrateOrigin, assertSwapSupport, assertToIsString, blake2b256, blake2b512, calcPreviewMintAmount, claimAssets, compareAddresses, computeOverridenAmount, constructTypeAndThenCall, convertBuilderConfig, convertSs58, createAsset, createAssetId, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createClientCache, createClientPoolHelpers, createCustomXcmOnDest, createDestination, createDirectExecuteXcm, createEthereumBridgeInstructions, createExecuteCall, createExecuteExchangeXcm, createSwapBuilder, createTransfer, createTransferOrSwap, createTransferOrSwapAll, createTxOverrideAmount, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createVersionedDestination, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, executeWithSwap, formatAssetIdToERC20, formatUnits, generateMessageId, getAssetBalanceInternal, getAssetReserveChain, getBalance, getBalanceInternal, getBridgeStatus, getChain, getChainConfig, getChainLocation, getChainProviders, getChainVersion, getEthErc20Balance, getEvmExtensionOrThrow, getEvmPrivateKeyHex, getEvmSnowbridgeExtensionOrThrow, getFailureInfo, getLocalTransferAmount, getMinTransferableAmount, getMinTransferableAmountInternal, getMoonbeamErc20Balance, getOriginXcmFee, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getRelayChainOf, getSwapExtensionOrThrow, getTChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeInternal, getXcmFeeOnce, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, isConfig, isSenderSigner, isViemSigner, keyFromWs, localizeLocation, maybeOverrideAsset, maybeOverrideAssets, normalizeAmount, normalizeExchange, overrideTxAmount, padFee, padValueBy, parseUnits, pickCompatibleXcmVersion, pickRouterCompatibleXcmVersion, registerEvmExtension, registerEvmSnowbridgeExtension, registerSwapExtension, resolveAssetCount, resolveDestChain, resolveModuleError, resolveParaId, resolveTransferParams, reverseTransformLocation, selectXcmVersion, sortAssets, throwUnsupportedCurrency, transferMoonbeamEvm, transferMoonbeamToEth, traverseXcmHops, validateAddress, validateAssetSpecifiers, validateCurrency, validateDestination, validateDestinationAddress, validateTransact, verifyEdOnDestination, wrapTxBypass };
2463
- export type { BuildHopInfoOptions, ClientCache, HopProcessParams, HopTraversalConfig, HopTraversalResult, IPolkadotXCMTransfer, IXTokensTransfer, OneKey, TAddress, TApiOrUrl, TApiType, TAssetClaimInternalOptions, TAssetClaimOptions, TAssetClaimOptionsBase, TBatchOptions, TBatchedTransferOptions, TBifrostToken, TBridgeStatus, TBuildAllInternalRes, TBuildDestInfoOptions, TBuildInternalRes, TBuildInternalResBase, TBuilderConfig, TBuilderInternalOptions, TBuilderOptions, TBypassOptions, TCacheItem, TChainConfig, TChainConfigMap, TChainEndpoint, TChainWithApi, TClientEntry, TClientKey, TConditionalXcmFeeDetail, TConditionalXcmFeeHopInfo, TCreateBaseSwapXcmOptions, TCreateBaseTransferXcmOptions, TCreateBeneficiaryOptions, TCreateBeneficiaryXTokensOptions, TCreateEthBridgeInstructionsOptions, TCreateSwapXcmInternalOptions, TCreateSwapXcmOptions, TCreateTransferXcmOptions, TCreateTxsOptions, TDestWeight, TDestXcmFeeDetail, TDestination, TDryRunBaseOptions, TDryRunBypassOptions, TDryRunCallBaseOptions, TDryRunCallOptions, TDryRunChainFailure, TDryRunChainResult, TDryRunChainSuccess, TDryRunError, TDryRunOptions, TDryRunPreviewOptions, TDryRunResBase, TDryRunResult, TDryRunXcmBaseOptions, TDryRunXcmOptions, TEvmExtension, TEvmSnowbridgeExtension, TEvmTransferOptions, TEvmTransferOptionsBase, TExchangeChain, TExchangeInput, TFeeType, TForeignAssetId, TForeignOrNativeAsset, TForeignOrTokenAsset, TGetAssetBalanceOptions, TGetAssetBalanceOptionsBase, TGetBalanceCommonOptions, TGetBalanceOptions, TGetBalanceOptionsBase, TGetFeeForDestChainBaseOptions, TGetFeeForDestChainOptions, TGetMinTransferableAmountOptions, TGetOriginXcmFeeBaseOptions, TGetOriginXcmFeeInternalOptions, TGetOriginXcmFeeOptions, TGetReverseTxFeeOptions, TGetTransferInfoOptions, TGetTransferInfoOptionsBase, TGetTransferableAmountOptions, TGetTransferableAmountOptionsBase, TGetXcmFeeBaseOptions, TGetXcmFeeBuilderOptions, TGetXcmFeeInternalOptions, TGetXcmFeeOptions, TGetXcmFeeResult, THopInfo, THopTransferInfo, TModuleError, TNativeTokenAsset, TOriginFeeDetails, TOtherReserveAsset, TPaymentInfo, TPolkadotXCMTransferOptions, TPolkadotXcmMethod, TProviderEntry, TReserveAsset, TResolveHopParams, TScenario, TSelfReserveAsset, TSender, TSerializedExtrinsics, TSerializedRuntimeApiQuery, TSerializedStateQuery, TSetBalanceRes, TStatusChangeCallback, TSubstrateTransferBaseOptions, TSubstrateTransferBaseOptionsWithSender, TSubstrateTransferOptions, TSwapBuilder, TSwapBuilderFactory, TSwapConfig, TSwapEvent, TSwapEventType, TSwapExtension, TSwapFeeEstimates, TSwapOptions, TTransactOptions, TTransactOrigin, TTransactionContext, TTransactionType, TTransferBaseOptions, TTransferBaseOptionsWithSender, TTransferBaseOptionsWithSwap, TTransferFeeEstimates, TTransferInfo, TTransferInternalOptions, TTransferLocalOptions, TTransferOptions, TTransferOptionsWithSwap, TTxFactory, TTypeAndThenCallContext, TTypeAndThenFees, TTypeAndThenOverrides, TUrl, TVerifyEdOnDestinationOptions, TVerifyEdOnDestinationOptionsBase, TWeight, TXTokensCurrencySelection, TXTokensMethod, TXTokensTransferOptions, TXcmAsset, TXcmFeeBase, TXcmFeeDetail, TXcmFeeDetailError, TXcmFeeDetailSuccess, TXcmFeeDetailWithFallback, TXcmFeeHopInfo, TXcmFeeHopResult, TXcmFeeSwapConfig, TXcmForeignAsset, TXcmPalletMethod, TXcmVersioned, TZeitgeistAsset, WithApi, WithRequiredSender, WithRequiredSwapOptions };
2523
+ export { API_TYPES, AmountTooLowError, ApiNotInitializedError, AssetClaimBuilder, BaseAssetsPallet, BatchMode, BatchValidationError, BridgeHaltedError, Builder, DEFAULT_TTL_MS, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETH_MAINNET_CHAIN_ID, ETH_TESTNET_CHAIN_ID, EXCHANGE_CHAINS, EXTENSION_MS, ExtensionNotInstalledError, FeatureTemporarilyDisabledError, GeneralBuilder, InvalidAddressError, MAX_CLIENTS, MissingChainApiError, MissingParameterError, NoXCMSupportImplementedError, NumberFormatError, OverrideConflictError, PolkadotApi, PolkadotXcmError, PolkadotXcmExecutionError, ProviderUnavailableError, RELAY_LOCATION, RoutingResolutionError, RuntimeApiError, RuntimeApiUnavailableError, ScenarioNotSupportedError, SubmitTransactionError, TRANSACT_ORIGINS, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, TypeAndThenUnavailableError, UnableToComputeError, UnsupportedOperationError, ValidationError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, aggregateHopFees, applyDecimalAbstraction, assertAddressIsString, assertCurrencyCore, assertEvmAddress, assertExtensionInstalled, assertHasId, assertNotEvmTransfer, assertSender, assertSenderSource, assertSubstrateOrigin, assertSwapSupport, assertToIsString, blake2b256, blake2b512, buildDestInfo, buildHopInfo, buildOriginInfo, calcPreviewMintAmount, claimAssets, compareAddresses, computeOverridenAmount, constructTypeAndThenCall, convertBuilderConfig, convertSs58, createAsset, createAssetId, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createClientCache, createClientPoolHelpers, createCustomXcmOnDest, createDestination, createDirectExecuteXcm, createEthereumBridgeInstructions, createExecuteCall, createExecuteExchangeXcm, createSwapBuilder, createTransfer, createTransferOrSwap, createTransferOrSwapAll, createTxOverrideAmount, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createVersionedDestination, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, executeWithSwap, formatAssetIdToERC20, formatUnits, generateMessageId, getAssetBalanceInternal, getAssetReserveChain, getBalance, getBalanceInternal, getBridgeStatus, getChain, getChainConfig, getChainLocation, getChainProviders, getChainVersion, getEthErc20Balance, getEvmExtensionOrThrow, getEvmPrivateKeyHex, getEvmSnowbridgeExtensionOrThrow, getFailureInfo, getLocalTransferAmount, getMinTransferableAmount, getMinTransferableAmountInternal, getMoonbeamErc20Balance, getOriginXcmFee, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getRelayChainOf, getSwapExtensionOrThrow, getTChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeInternal, getXcmFeeOnce, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, isConfig, isSenderSigner, isViemSigner, keyFromWs, localizeLocation, maybeOverrideAsset, maybeOverrideAssets, normalizeAmount, normalizeExchange, overrideTxAmount, padFee, padValueBy, parseUnits, pickCompatibleXcmVersion, pickRouterCompatibleXcmVersion, registerEvmExtension, registerEvmSnowbridgeExtension, registerSwapExtension, resolveAssetCount, resolveDestChain, resolveModuleError, resolveParaId, resolveTransferParams, reverseTransformLocation, selectXcmVersion, sortAssets, throwUnsupportedCurrency, transferMoonbeamEvm, transferMoonbeamToEth, traverseXcmHops, validateAddress, validateAssetSpecifiers, validateCurrency, validateDestination, validateDestinationAddress, validateTransact, verifyEdOnDestination, wrapTxBypass };
2524
+ export type { BuildHopInfoOptions, ClientCache, HopProcessParams, HopTraversalConfig, HopTraversalResult, IPolkadotXCMTransfer, IXTokensTransfer, OneKey, TAddress, TApiOrUrl, TApiType, TAssetClaimInternalOptions, TAssetClaimOptions, TAssetClaimOptionsBase, TBatchOptions, TBatchedTransferOptions, TBifrostToken, TBridgeStatus, TBuildAllInternalRes, TBuildDestInfoOptions, TBuildEvmTransferOptions, TBuildInternalRes, TBuildInternalResBase, TBuildOriginInfoOptions, TBuilderConfig, TBuilderInternalOptions, TBuilderOptions, TBypassOptions, TCacheItem, TChainConfig, TChainConfigMap, TChainEndpoint, TChainWithApi, TClientEntry, TClientKey, TConditionalXcmFeeDetail, TConditionalXcmFeeHopInfo, TCreateBaseSwapXcmOptions, TCreateBaseTransferXcmOptions, TCreateBeneficiaryOptions, TCreateBeneficiaryXTokensOptions, TCreateEthBridgeInstructionsOptions, TCreateSwapXcmInternalOptions, TCreateSwapXcmOptions, TCreateTransferXcmOptions, TCreateTxsOptions, TDestWeight, TDestination, TDryRunBaseOptions, TDryRunBypassOptions, TDryRunCallBaseOptions, TDryRunCallOptions, TDryRunChainFailure, TDryRunChainResult, TDryRunChainSuccess, TDryRunError, TDryRunOptions, TDryRunPreviewOptions, TDryRunResBase, TDryRunResult, TDryRunXcmBaseOptions, TDryRunXcmOptions, TEvmExtension, TEvmSnowbridgeExtension, TEvmTransferOptions, TEvmTransferOptionsBase, TExchangeChain, TExchangeInput, TFeeType, TForeignAssetId, TForeignOrNativeAsset, TForeignOrTokenAsset, TGetAssetBalanceOptions, TGetAssetBalanceOptionsBase, TGetBalanceCommonOptions, TGetBalanceOptions, TGetBalanceOptionsBase, TGetFeeForDestChainBaseOptions, TGetFeeForDestChainOptions, TGetMinTransferableAmountOptions, TGetOriginXcmFeeBaseOptions, TGetOriginXcmFeeInternalOptions, TGetOriginXcmFeeOptions, TGetReverseTxFeeOptions, TGetTransferInfoOptions, TGetTransferInfoOptionsBase, TGetTransferableAmountOptions, TGetTransferableAmountOptionsBase, TGetXcmFeeBaseOptions, TGetXcmFeeBuilderOptions, TGetXcmFeeInternalOptions, TGetXcmFeeOptions, TGetXcmFeeResult, THopInfo, THopTransferInfo, TModuleError, TNativeTokenAsset, TOriginFeeDetails, TOtherReserveAsset, TPaymentInfo, TPolkadotXCMTransferOptions, TPolkadotXcmMethod, TProviderEntry, TReserveAsset, TResolveHopParams, TScenario, TSelfReserveAsset, TSender, TSerializedExtrinsics, TSerializedRuntimeApiQuery, TSerializedStateQuery, TSetBalanceRes, TStatusChangeCallback, TSubstrateTransferBaseOptions, TSubstrateTransferBaseOptionsWithSender, TSubstrateTransferOptions, TSwapBuilder, TSwapBuilderFactory, TSwapConfig, TSwapEvent, TSwapEventType, TSwapExtension, TSwapFeeEstimates, TSwapOptions, TTransactOptions, TTransactOrigin, TTransactionContext, TTransactionType, TTransferBaseOptions, TTransferBaseOptionsWithSender, TTransferBaseOptionsWithSwap, TTransferFeeEstimates, TTransferInfo, TTransferInternalOptions, TTransferLocalOptions, TTransferOptions, TTransferOptionsWithSwap, TTxFactory, TTypeAndThenCallContext, TTypeAndThenFees, TTypeAndThenOverrides, TUrl, TVerifyEdOnDestinationOptions, TVerifyEdOnDestinationOptionsBase, TWeight, TXTokensCurrencySelection, TXTokensMethod, TXTokensTransferOptions, TXcmAsset, TXcmFeeBase, TXcmFeeDetail, TXcmFeeDetailError, TXcmFeeDetailSuccess, TXcmFeeDetailWithFallback, TXcmFeeDetailWithForwardedXcm, TXcmFeeHopInfo, TXcmFeeHopResult, TXcmFeeSwapConfig, TXcmForeignAsset, TXcmPalletMethod, TXcmVersioned, TZeitgeistAsset, WithApi, WithRequiredSender, WithRequiredSwapOptions };