@galacticcouncil/xc-core 0.1.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 (82) hide show
  1. package/README.md +11 -0
  2. package/build/index.cjs +1 -0
  3. package/build/index.mjs +1 -0
  4. package/build/types/asset/Asset.d.ts +10 -0
  5. package/build/types/asset/AssetAmount.d.ts +23 -0
  6. package/build/types/asset/index.d.ts +2 -0
  7. package/build/types/bridge/index.d.ts +2 -0
  8. package/build/types/bridge/snowbridge.d.ts +14 -0
  9. package/build/types/bridge/wormhole.d.ts +30 -0
  10. package/build/types/chain/Chain.d.ts +75 -0
  11. package/build/types/chain/EvmChain.d.ts +22 -0
  12. package/build/types/chain/EvmParachain.d.ts +21 -0
  13. package/build/types/chain/Parachain.d.ts +75 -0
  14. package/build/types/chain/SolanaChain.d.ts +17 -0
  15. package/build/types/chain/SuiChain.d.ts +15 -0
  16. package/build/types/chain/dex/factory.d.ts +9 -0
  17. package/build/types/chain/dex/index.d.ts +2 -0
  18. package/build/types/chain/dex/types.d.ts +11 -0
  19. package/build/types/chain/index.d.ts +8 -0
  20. package/build/types/chain/types.d.ts +8 -0
  21. package/build/types/config/ConfigBuilder.d.ts +19 -0
  22. package/build/types/config/ConfigService.d.ts +25 -0
  23. package/build/types/config/definition/AssetRoute.d.ts +50 -0
  24. package/build/types/config/definition/ChainRoutes.d.ts +17 -0
  25. package/build/types/config/definition/balance/BalanceConfigBuilder.d.ts +12 -0
  26. package/build/types/config/definition/balance/index.d.ts +1 -0
  27. package/build/types/config/definition/base/BaseConfig.d.ts +13 -0
  28. package/build/types/config/definition/base/SolanaQueryConfig.d.ts +10 -0
  29. package/build/types/config/definition/base/SubstrateQueryConfig.d.ts +10 -0
  30. package/build/types/config/definition/base/SuiQueryConfig.d.ts +9 -0
  31. package/build/types/config/definition/base/index.d.ts +5 -0
  32. package/build/types/config/definition/base/types.d.ts +6 -0
  33. package/build/types/config/definition/contract/ContractConfig.d.ts +16 -0
  34. package/build/types/config/definition/contract/ContractConfigBuilder.d.ts +7 -0
  35. package/build/types/config/definition/contract/index.d.ts +2 -0
  36. package/build/types/config/definition/extrinsic/ExtrinsicConfig.d.ts +9 -0
  37. package/build/types/config/definition/extrinsic/ExtrinsicConfigBuilder.d.ts +22 -0
  38. package/build/types/config/definition/extrinsic/index.d.ts +2 -0
  39. package/build/types/config/definition/fee/FeeAmountConfigBuilder.d.ts +17 -0
  40. package/build/types/config/definition/fee/FeeAssetConfigBuilder.d.ts +9 -0
  41. package/build/types/config/definition/fee/FeeConfig.d.ts +20 -0
  42. package/build/types/config/definition/fee/index.d.ts +3 -0
  43. package/build/types/config/definition/index.d.ts +10 -0
  44. package/build/types/config/definition/min/MinConfigBuilder.d.ts +8 -0
  45. package/build/types/config/definition/min/index.d.ts +1 -0
  46. package/build/types/config/definition/move/MoveConfig.d.ts +9 -0
  47. package/build/types/config/definition/move/MoveConfigBuilder.d.ts +7 -0
  48. package/build/types/config/definition/move/index.d.ts +2 -0
  49. package/build/types/config/definition/program/ProgramConfig.d.ts +11 -0
  50. package/build/types/config/definition/program/ProgramConfigBuilder.d.ts +7 -0
  51. package/build/types/config/definition/program/index.d.ts +2 -0
  52. package/build/types/config/index.d.ts +5 -0
  53. package/build/types/config/types.d.ts +42 -0
  54. package/build/types/config/validation.d.ts +23 -0
  55. package/build/types/evm/Erc20Client.d.ts +13 -0
  56. package/build/types/evm/EvmClient.d.ts +13 -0
  57. package/build/types/evm/EvmResolver.d.ts +4 -0
  58. package/build/types/evm/abi/Batch.d.ts +87 -0
  59. package/build/types/evm/abi/Erc20.d.ts +150 -0
  60. package/build/types/evm/abi/Gmp.d.ts +11 -0
  61. package/build/types/evm/abi/Meta.d.ts +738 -0
  62. package/build/types/evm/abi/Snowbridge.d.ts +836 -0
  63. package/build/types/evm/abi/TokenBridge.d.ts +981 -0
  64. package/build/types/evm/abi/TokenRelayer.d.ts +83 -0
  65. package/build/types/evm/abi/Weth.d.ts +0 -0
  66. package/build/types/evm/abi/Xtokens.d.ts +72 -0
  67. package/build/types/evm/abi/index.d.ts +2 -0
  68. package/build/types/evm/index.d.ts +5 -0
  69. package/build/types/evm/precompile.d.ts +1 -0
  70. package/build/types/index.d.ts +7 -0
  71. package/build/types/substrate/SubstrateApis.d.ts +13 -0
  72. package/build/types/substrate/index.d.ts +1 -0
  73. package/build/types/utils/account.d.ts +24 -0
  74. package/build/types/utils/account.spec.d.ts +1 -0
  75. package/build/types/utils/address.d.ts +31 -0
  76. package/build/types/utils/address.spec.d.ts +1 -0
  77. package/build/types/utils/index.d.ts +4 -0
  78. package/build/types/utils/mrl.d.ts +18 -0
  79. package/build/types/utils/mrl.spec.d.ts +1 -0
  80. package/build/types/utils/multilocation.d.ts +5 -0
  81. package/build/types/utils/multilocation.spec.d.ts +1 -0
  82. package/package.json +61 -0
@@ -0,0 +1,75 @@
1
+ import { PolkadotClient } from 'polkadot-api';
2
+ import { Asset } from '../asset';
3
+ import { Chain, ChainAssetData, ChainAssetId, ChainCurrency, ChainParams, ChainType } from './Chain';
4
+ /**
5
+ * Type for XCM multi-location objects (JSON-serializable)
6
+ */
7
+ type XcmLocation = Record<string, any>;
8
+ /**
9
+ * XCM Version enum
10
+ */
11
+ export declare enum XcmVersion {
12
+ v1 = "V1",
13
+ v2 = "V2",
14
+ v3 = "V3",
15
+ v4 = "V4",
16
+ v5 = "V5"
17
+ }
18
+ /**
19
+ * Parachain Asset Data
20
+ *
21
+ * @interface ParachainAssetsData
22
+ * @member {ChainAssetId} metadataId asset id to query metadata (if other than internal)
23
+ * @member {ChainAssetId} minId asset id to query minimal deposit (if other than internal)
24
+ * @member {XcmLocation} xcmLocation asset xcm location
25
+ */
26
+ export interface ParachainAssetData extends ChainAssetData {
27
+ metadataId?: ChainAssetId;
28
+ minId?: ChainAssetId;
29
+ xcmLocation?: XcmLocation;
30
+ }
31
+ export interface ParachainParams extends ChainParams<ParachainAssetData> {
32
+ genesisHash: string;
33
+ parachainId: number;
34
+ ss58Format: number;
35
+ treasury?: string;
36
+ usesChainDecimals?: boolean;
37
+ usesCexForwarding?: boolean;
38
+ usesDeliveryFee?: boolean;
39
+ usesSignerFee?: boolean;
40
+ usesH160Acc?: boolean;
41
+ ws: string | string[];
42
+ xcmVersion?: XcmVersion;
43
+ }
44
+ export declare class Parachain extends Chain<ParachainAssetData> {
45
+ readonly genesisHash: string;
46
+ readonly parachainId: number;
47
+ readonly ss58Format: number;
48
+ readonly treasury: string | undefined;
49
+ readonly usesChainDecimals: boolean;
50
+ readonly usesCexForwarding: boolean;
51
+ readonly usesDeliveryFee: boolean;
52
+ readonly usesSignerFee: boolean;
53
+ readonly usesH160Acc: boolean;
54
+ readonly ws: string | string[];
55
+ readonly xcmVersion: XcmVersion;
56
+ constructor({ genesisHash, parachainId, ss58Format, treasury, usesChainDecimals, usesCexForwarding, usesDeliveryFee, usesSignerFee, usesH160Acc, ws, xcmVersion, ...others }: ParachainParams);
57
+ /**
58
+ * Get XCM version for a specific pallet call by inspecting runtime metadata via PAPI
59
+ * This dynamically detects which XCM versions are supported by the pallet
60
+ *
61
+ * @param pallet - Pallet name (e.g., 'xTokens', 'polkadotXcm')
62
+ * @param method - Method name (e.g., 'transfer', 'transferMultiasset')
63
+ * @param argIndex - Index of the argument to inspect (usually the dest/beneficiary param)
64
+ * @returns Promise<XcmVersion> - Detected XCM version
65
+ */
66
+ getXcmVersionForCall(pallet: string, method: string, argIndex?: number): Promise<XcmVersion>;
67
+ get api(): PolkadotClient;
68
+ getType(): ChainType;
69
+ getCurrency(): Promise<ChainCurrency>;
70
+ getAssetXcmLocation(asset: Asset): XcmLocation | undefined;
71
+ getMetadataAssetId(asset: Asset): ChainAssetId;
72
+ getMinAssetId(asset: Asset): ChainAssetId;
73
+ findAssetById(id: string): ParachainAssetData | undefined;
74
+ }
75
+ export {};
@@ -0,0 +1,17 @@
1
+ import { Connection } from '@solana/web3.js';
2
+ import { Chain, ChainAssetData, ChainCurrency, ChainParams, ChainRpcs, ChainType } from './Chain';
3
+ import { Wormhole, WormholeDef } from '../bridge';
4
+ export interface SolanaChainParams extends ChainParams<ChainAssetData> {
5
+ id: number;
6
+ rpcUrls: ChainRpcs;
7
+ wormhole?: WormholeDef;
8
+ }
9
+ export declare class SolanaChain extends Chain<ChainAssetData> {
10
+ readonly id: number;
11
+ readonly rpcUrls: ChainRpcs;
12
+ readonly wormhole?: Wormhole;
13
+ constructor({ id, rpcUrls, wormhole, ...others }: SolanaChainParams);
14
+ get connection(): Connection;
15
+ getType(): ChainType;
16
+ getCurrency(): Promise<ChainCurrency>;
17
+ }
@@ -0,0 +1,15 @@
1
+ import { SuiClient } from '@mysten/sui/client';
2
+ import { Chain, ChainAssetData, ChainCurrency, ChainParams, ChainType } from './Chain';
3
+ import { Wormhole, WormholeDef } from '../bridge';
4
+ export interface SuiChainParams extends ChainParams<ChainAssetData> {
5
+ id: string;
6
+ wormhole?: WormholeDef;
7
+ }
8
+ export declare class SuiChain extends Chain<ChainAssetData> {
9
+ readonly id: string;
10
+ readonly wormhole?: Wormhole;
11
+ constructor({ id, wormhole, ...others }: SuiChainParams);
12
+ get client(): SuiClient;
13
+ getType(): ChainType;
14
+ getCurrency(): Promise<ChainCurrency>;
15
+ }
@@ -0,0 +1,9 @@
1
+ import { Dex } from './types';
2
+ export declare class DexFactory {
3
+ private static _instance;
4
+ private _dex;
5
+ constructor();
6
+ static getInstance(): DexFactory;
7
+ register(dex: Dex): void;
8
+ get(key: string): Dex | undefined;
9
+ }
@@ -0,0 +1,2 @@
1
+ export * from './factory';
2
+ export * from './types';
@@ -0,0 +1,11 @@
1
+ import { Asset, AssetAmount } from '../../asset';
2
+ import { AnyChain } from '../types';
3
+ export type SwapQuote = {
4
+ amount: bigint;
5
+ route: {};
6
+ };
7
+ export interface Dex {
8
+ chain: AnyChain;
9
+ getQuote(assetIn: Asset, assetOut: Asset, amountOut: AssetAmount, fallbackPrice?: boolean): Promise<SwapQuote>;
10
+ getCalldata(account: string, assetIn: Asset, assetOut: Asset, amountOut: AssetAmount, slippage?: number): Promise<string>;
11
+ }
@@ -0,0 +1,8 @@
1
+ export * from './Chain';
2
+ export * from './Parachain';
3
+ export * from './EvmParachain';
4
+ export * from './EvmChain';
5
+ export * from './SolanaChain';
6
+ export * from './SuiChain';
7
+ export * from './dex';
8
+ export * from './types';
@@ -0,0 +1,8 @@
1
+ import { Parachain } from './Parachain';
2
+ import { EvmParachain } from './EvmParachain';
3
+ import { EvmChain } from './EvmChain';
4
+ import { SolanaChain } from './SolanaChain';
5
+ import { SuiChain } from './SuiChain';
6
+ export type AnyChain = Parachain | EvmParachain | EvmChain | SolanaChain | SuiChain;
7
+ export type AnyParachain = Parachain | EvmParachain;
8
+ export type AnyEvmChain = EvmChain | EvmParachain;
@@ -0,0 +1,19 @@
1
+ import { Asset } from '../asset';
2
+ import { AnyChain, ChainEcosystem } from '../chain';
3
+ import { TransferConfigs } from './types';
4
+ import { ConfigService } from './ConfigService';
5
+ export declare function ConfigBuilder(service: ConfigService): {
6
+ assets: (ecosystem?: ChainEcosystem) => {
7
+ assets: Asset[];
8
+ asset: (keyOrAsset: string | Asset) => {
9
+ sourceChains: AnyChain[];
10
+ source: (keyOrChain: string | AnyChain) => {
11
+ destinationChains: AnyChain[];
12
+ destination: (keyOrChain: string | AnyChain) => {
13
+ routes: import("./definition").AssetRoute[];
14
+ build: (assetOnDest?: string | Asset) => TransferConfigs;
15
+ };
16
+ };
17
+ };
18
+ };
19
+ };
@@ -0,0 +1,25 @@
1
+ import { Asset } from '../asset';
2
+ import { AnyChain, ChainEcosystem } from '../chain';
3
+ import { AssetRoute, ChainRoutes } from './definition';
4
+ export interface ConfigServiceOptions {
5
+ assets: Map<string, Asset>;
6
+ chains: Map<string, AnyChain>;
7
+ routes: Map<string, ChainRoutes>;
8
+ }
9
+ export declare class ConfigService {
10
+ readonly assets: Map<string, Asset>;
11
+ readonly chains: Map<string, AnyChain>;
12
+ readonly routes: Map<string, ChainRoutes>;
13
+ constructor({ assets, chains, routes }: ConfigServiceOptions);
14
+ getEcosystemAssets(ecosystem?: ChainEcosystem): Asset[];
15
+ getAsset(keyOrAsset: string | Asset): Asset;
16
+ getChain(keyOrChain: string | AnyChain): AnyChain;
17
+ getChainRoutes(keyOrChain: string | AnyChain): ChainRoutes;
18
+ getSourceChains(asset: Asset, ecosystem: ChainEcosystem | undefined): AnyChain[];
19
+ getDestinationChains(asset: Asset, source: AnyChain): AnyChain[];
20
+ getAssetRoutes(asset: Asset, source: AnyChain, destination: AnyChain): AssetRoute[];
21
+ updateAsset(asset: Asset): void;
22
+ updateChain(chain: AnyChain): void;
23
+ updateRoutes(routes: ChainRoutes): void;
24
+ updateChainRoute(chain: AnyChain, route: AssetRoute): void;
25
+ }
@@ -0,0 +1,50 @@
1
+ import { Asset } from '../../asset';
2
+ import { AnyChain, Parachain } from '../../chain';
3
+ import { BalanceConfigBuilder } from './balance';
4
+ import { ContractConfigBuilder } from './contract';
5
+ import { ExtrinsicConfigBuilder } from './extrinsic';
6
+ import { FeeConfig, DestinationFeeConfig, TransactFeeConfig } from './fee';
7
+ import { MinConfigBuilder } from './min';
8
+ import { ProgramConfigBuilder } from './program';
9
+ import { MoveConfigBuilder } from './move';
10
+ export interface SourceConfig {
11
+ asset: Asset;
12
+ balance: BalanceConfigBuilder;
13
+ destinationFee: {
14
+ asset?: Asset;
15
+ balance: BalanceConfigBuilder;
16
+ };
17
+ fee?: FeeConfig;
18
+ min?: MinConfigBuilder;
19
+ }
20
+ export interface DestinationConfig {
21
+ chain: AnyChain;
22
+ asset: Asset;
23
+ fee: DestinationFeeConfig;
24
+ }
25
+ export interface TransactConfig {
26
+ chain: Parachain;
27
+ fee: TransactFeeConfig;
28
+ extrinsic: ExtrinsicConfigBuilder;
29
+ }
30
+ export interface AssetRouteParams {
31
+ source: SourceConfig;
32
+ destination: DestinationConfig;
33
+ contract?: ContractConfigBuilder;
34
+ extrinsic?: ExtrinsicConfigBuilder;
35
+ move?: MoveConfigBuilder;
36
+ program?: ProgramConfigBuilder;
37
+ transact?: TransactConfig;
38
+ tags?: string[];
39
+ }
40
+ export declare class AssetRoute {
41
+ readonly source: SourceConfig;
42
+ readonly destination: DestinationConfig;
43
+ readonly contract?: ContractConfigBuilder;
44
+ readonly extrinsic?: ExtrinsicConfigBuilder;
45
+ readonly move?: MoveConfigBuilder;
46
+ readonly program?: ProgramConfigBuilder;
47
+ readonly transact?: TransactConfig;
48
+ readonly tags?: string[];
49
+ constructor({ source, destination, contract, extrinsic, move, program, transact, tags, }: AssetRouteParams);
50
+ }
@@ -0,0 +1,17 @@
1
+ import { Asset } from '../../asset';
2
+ import { AnyChain } from '../../chain';
3
+ import { AssetRoute } from './AssetRoute';
4
+ export interface ChainRoutesParams {
5
+ chain: AnyChain;
6
+ routes: AssetRoute[];
7
+ }
8
+ export declare class ChainRoutes {
9
+ readonly routes: Map<string, AssetRoute>;
10
+ readonly chain: AnyChain;
11
+ constructor({ chain, routes }: ChainRoutesParams);
12
+ getRoutes(): AssetRoute[];
13
+ getUniqueRoutes(): AssetRoute[];
14
+ getAssetRoutes(asset: Asset): AssetRoute[];
15
+ getAssetDestinations(asset: Asset): AnyChain[];
16
+ getAssetDestinationRoutes(asset: Asset, destination: AnyChain): AssetRoute[];
17
+ }
@@ -0,0 +1,12 @@
1
+ import { SolanaQueryConfig, SubstrateQueryConfig } from '../base';
2
+ import { ContractConfig } from '../contract';
3
+ import { Asset } from '../../../asset';
4
+ import { AnyChain } from '../../../chain';
5
+ export interface BalanceConfigBuilderParams {
6
+ address: string;
7
+ asset: Asset;
8
+ chain: AnyChain;
9
+ }
10
+ export interface BalanceConfigBuilder {
11
+ build: (params: BalanceConfigBuilderParams) => ContractConfig | SubstrateQueryConfig | SolanaQueryConfig;
12
+ }
@@ -0,0 +1 @@
1
+ export * from './BalanceConfigBuilder';
@@ -0,0 +1,13 @@
1
+ import { CallType } from './types';
2
+ export interface BaseConfigParams {
3
+ module: string;
4
+ func: string;
5
+ type: CallType;
6
+ }
7
+ export declare class BaseConfig {
8
+ readonly module: string;
9
+ readonly func: string;
10
+ readonly type: CallType;
11
+ constructor({ module, func, type }: BaseConfigParams);
12
+ toString(): string;
13
+ }
@@ -0,0 +1,10 @@
1
+ import { BaseConfig, BaseConfigParams } from './BaseConfig';
2
+ export interface SolanaQueryConfigParams extends Omit<BaseConfigParams, 'type'> {
3
+ address: string;
4
+ token?: string;
5
+ }
6
+ export declare class SolanaQueryConfig extends BaseConfig {
7
+ readonly address: string;
8
+ readonly token?: string;
9
+ constructor({ address, token, ...other }: SolanaQueryConfigParams);
10
+ }
@@ -0,0 +1,10 @@
1
+ import { BaseConfig, BaseConfigParams } from './BaseConfig';
2
+ export interface SubstrateQueryConfigParams extends Omit<BaseConfigParams, 'type'> {
3
+ args?: any[];
4
+ transform: (data: any) => Promise<bigint>;
5
+ }
6
+ export declare class SubstrateQueryConfig extends BaseConfig {
7
+ readonly args: any[];
8
+ readonly transform: (data: any) => Promise<bigint>;
9
+ constructor({ args, transform, ...other }: SubstrateQueryConfigParams);
10
+ }
@@ -0,0 +1,9 @@
1
+ import { BaseConfig, BaseConfigParams } from './BaseConfig';
2
+ export interface SuiQueryConfigParams extends Omit<BaseConfigParams, 'type'> {
3
+ address: string;
4
+ }
5
+ export declare class SuiQueryConfig extends BaseConfig {
6
+ readonly address: string;
7
+ readonly token?: string;
8
+ constructor({ address, ...other }: SuiQueryConfigParams);
9
+ }
@@ -0,0 +1,5 @@
1
+ export * from './BaseConfig';
2
+ export * from './SolanaQueryConfig';
3
+ export * from './SubstrateQueryConfig';
4
+ export * from './SuiQueryConfig';
5
+ export * from './types';
@@ -0,0 +1,6 @@
1
+ export declare enum CallType {
2
+ Evm = "Evm",
3
+ Substrate = "Substrate",
4
+ Solana = "Solana",
5
+ Sui = "Sui"
6
+ }
@@ -0,0 +1,16 @@
1
+ import { type Abi as TAbi } from 'viem';
2
+ import { BaseConfig, BaseConfigParams } from '../base';
3
+ export interface ContractConfigParams extends Omit<BaseConfigParams, 'type'> {
4
+ abi: TAbi;
5
+ args: any[];
6
+ address: string;
7
+ value?: bigint;
8
+ }
9
+ export declare class ContractConfig extends BaseConfig {
10
+ readonly abi: TAbi;
11
+ readonly address: string;
12
+ readonly args: any[];
13
+ readonly value?: bigint;
14
+ constructor({ abi, address, args, value, ...other }: ContractConfigParams);
15
+ encodeFunctionData(): `0x${string}`;
16
+ }
@@ -0,0 +1,7 @@
1
+ import { TransferCtx } from '../../types';
2
+ import { ContractConfig } from './ContractConfig';
3
+ export interface ContractConfigBuilderParams extends TransferCtx {
4
+ }
5
+ export interface ContractConfigBuilder {
6
+ build: (params: ContractConfigBuilderParams) => Promise<ContractConfig>;
7
+ }
@@ -0,0 +1,2 @@
1
+ export * from './ContractConfig';
2
+ export * from './ContractConfigBuilder';
@@ -0,0 +1,9 @@
1
+ import { BaseConfig, BaseConfigParams } from '../base';
2
+ export type TxData = Record<string, any> | undefined;
3
+ export interface ExtrinsicConfigParams extends Omit<BaseConfigParams, 'type'> {
4
+ getArgs: (func?: any) => TxData;
5
+ }
6
+ export declare class ExtrinsicConfig extends BaseConfig {
7
+ getArgs: (func?: any) => TxData;
8
+ constructor({ getArgs, ...other }: ExtrinsicConfigParams);
9
+ }
@@ -0,0 +1,22 @@
1
+ import { AssetAmount } from '../../../asset';
2
+ import { AnyParachain } from '../../../chain';
3
+ import { TransferCtx } from '../../types';
4
+ import { ExtrinsicConfig } from './ExtrinsicConfig';
5
+ export interface TxWeight {
6
+ proofSize: string;
7
+ refTime: number;
8
+ }
9
+ export interface TransactCtx {
10
+ chain: AnyParachain;
11
+ fee: AssetAmount;
12
+ feeBalance: AssetAmount;
13
+ call: `0x${string}`;
14
+ weight: TxWeight;
15
+ }
16
+ export interface ExtrinsicConfigBuilderParams extends TransferCtx {
17
+ messageId?: string;
18
+ transact?: TransactCtx;
19
+ }
20
+ export interface ExtrinsicConfigBuilder {
21
+ build: (params: ExtrinsicConfigBuilderParams) => ExtrinsicConfig;
22
+ }
@@ -0,0 +1,2 @@
1
+ export * from './ExtrinsicConfig';
2
+ export * from './ExtrinsicConfigBuilder';
@@ -0,0 +1,17 @@
1
+ import { Asset } from '../../../asset';
2
+ import { AnyChain } from '../../../chain';
3
+ export type FeeAmount = {
4
+ amount: bigint;
5
+ breakdown: {
6
+ [key: string]: bigint;
7
+ };
8
+ };
9
+ export interface FeeAmountConfigParams {
10
+ feeAsset: Asset;
11
+ transferAsset: Asset;
12
+ source: AnyChain;
13
+ destination: AnyChain;
14
+ }
15
+ export interface FeeAmountConfigBuilder {
16
+ build: (params: FeeAmountConfigParams) => Promise<FeeAmount>;
17
+ }
@@ -0,0 +1,9 @@
1
+ import { Asset } from '../../../asset';
2
+ import { Parachain } from '../../../chain';
3
+ export interface FeeAssetConfigParams {
4
+ address: string;
5
+ chain: Parachain;
6
+ }
7
+ export interface FeeAssetConfigBuilder {
8
+ build: (params: FeeAssetConfigParams) => Promise<Asset>;
9
+ }
@@ -0,0 +1,20 @@
1
+ import { BalanceConfigBuilder } from '../balance';
2
+ import { Asset } from '../../../asset';
3
+ import { FeeAssetConfigBuilder } from './FeeAssetConfigBuilder';
4
+ import { FeeAmountConfigBuilder } from './FeeAmountConfigBuilder';
5
+ export interface FeeConfig {
6
+ asset: Asset | FeeAssetConfigBuilder;
7
+ balance: BalanceConfigBuilder;
8
+ extra?: number;
9
+ swap?: boolean;
10
+ }
11
+ export interface DestinationFeeConfig {
12
+ amount: number | FeeAmountConfigBuilder;
13
+ asset: Asset;
14
+ balance?: BalanceConfigBuilder;
15
+ }
16
+ export interface TransactFeeConfig {
17
+ amount: number;
18
+ asset: Asset;
19
+ balance: BalanceConfigBuilder;
20
+ }
@@ -0,0 +1,3 @@
1
+ export * from './FeeConfig';
2
+ export * from './FeeAmountConfigBuilder';
3
+ export * from './FeeAssetConfigBuilder';
@@ -0,0 +1,10 @@
1
+ export * from './AssetRoute';
2
+ export * from './ChainRoutes';
3
+ export * from './balance';
4
+ export * from './base';
5
+ export * from './contract';
6
+ export * from './extrinsic';
7
+ export * from './move';
8
+ export * from './program';
9
+ export * from './fee';
10
+ export * from './min';
@@ -0,0 +1,8 @@
1
+ import { SubstrateQueryConfig } from '../base';
2
+ import { ChainAssetId } from '../../../chain';
3
+ export interface MinConfigBuilder {
4
+ build: (params: MinConfigBuilderParams) => SubstrateQueryConfig;
5
+ }
6
+ export interface MinConfigBuilderParams {
7
+ asset: ChainAssetId;
8
+ }
@@ -0,0 +1 @@
1
+ export * from './MinConfigBuilder';
@@ -0,0 +1,9 @@
1
+ import { Transaction } from '@mysten/sui/transactions';
2
+ import { BaseConfig, BaseConfigParams } from '../base';
3
+ export interface MoveConfigParams extends Omit<BaseConfigParams, 'type'> {
4
+ transaction: Transaction;
5
+ }
6
+ export declare class MoveConfig extends BaseConfig {
7
+ readonly transaction: Transaction;
8
+ constructor({ transaction, ...other }: MoveConfigParams);
9
+ }
@@ -0,0 +1,7 @@
1
+ import { TransferCtx } from '../../types';
2
+ import { MoveConfig } from './MoveConfig';
3
+ export interface MoveConfigBuilderParams extends TransferCtx {
4
+ }
5
+ export interface MoveConfigBuilder {
6
+ build: (params: MoveConfigBuilderParams) => Promise<MoveConfig>;
7
+ }
@@ -0,0 +1,2 @@
1
+ export * from './MoveConfig';
2
+ export * from './MoveConfigBuilder';
@@ -0,0 +1,11 @@
1
+ import { Keypair, TransactionInstruction } from '@solana/web3.js';
2
+ import { BaseConfig, BaseConfigParams } from '../base';
3
+ export interface ProgramConfigParams extends Omit<BaseConfigParams, 'type'> {
4
+ instructions: TransactionInstruction[];
5
+ signers: Keypair[];
6
+ }
7
+ export declare class ProgramConfig extends BaseConfig {
8
+ readonly instructions: TransactionInstruction[];
9
+ readonly signers: Keypair[];
10
+ constructor({ instructions, signers, ...other }: ProgramConfigParams);
11
+ }
@@ -0,0 +1,7 @@
1
+ import { TransferCtx } from '../../types';
2
+ import { ProgramConfig } from './ProgramConfig';
3
+ export interface ProgramConfigBuilderParams extends TransferCtx {
4
+ }
5
+ export interface ProgramConfigBuilder {
6
+ build: (params: ProgramConfigBuilderParams) => Promise<ProgramConfig>;
7
+ }
@@ -0,0 +1,2 @@
1
+ export * from './ProgramConfig';
2
+ export * from './ProgramConfigBuilder';
@@ -0,0 +1,5 @@
1
+ export * from './definition';
2
+ export * from './types';
3
+ export * from './validation';
4
+ export { ConfigBuilder } from './ConfigBuilder';
5
+ export { ConfigService } from './ConfigService';
@@ -0,0 +1,42 @@
1
+ import { Asset, AssetAmount } from '../asset';
2
+ import { AnyChain } from '../chain';
3
+ import { AssetRoute, TransactCtx } from './definition';
4
+ export interface SwapCtx {
5
+ aIn: AssetAmount;
6
+ aOut: AssetAmount;
7
+ enabled: boolean;
8
+ route: any;
9
+ }
10
+ export interface TransferCtx {
11
+ address: string;
12
+ amount: bigint;
13
+ asset: Asset;
14
+ sender: string;
15
+ source: {
16
+ balance: AssetAmount;
17
+ chain: AnyChain;
18
+ destinationFee: AssetAmount;
19
+ destinationFeeBalance: AssetAmount;
20
+ destinationFeeSwap?: SwapCtx;
21
+ fee: AssetAmount;
22
+ feeBalance: AssetAmount;
23
+ feeSwap?: SwapCtx;
24
+ };
25
+ destination: {
26
+ balance: AssetAmount;
27
+ chain: AnyChain;
28
+ fee: AssetAmount;
29
+ feeBreakdown: {
30
+ [key: string]: bigint;
31
+ };
32
+ };
33
+ transact?: TransactCtx;
34
+ }
35
+ export interface TransferConfig {
36
+ chain: AnyChain;
37
+ route: AssetRoute;
38
+ }
39
+ export interface TransferConfigs {
40
+ origin: TransferConfig;
41
+ reverse: TransferConfig;
42
+ }
@@ -0,0 +1,23 @@
1
+ import { AnyChain } from '../chain';
2
+ import { TransferCtx } from './types';
3
+ export interface TransferValidationReport {
4
+ [key: string]: any;
5
+ }
6
+ export declare class TransferValidationError extends Error {
7
+ readonly report: TransferValidationReport;
8
+ constructor(message: string, report: TransferValidationReport);
9
+ }
10
+ export type TransferValidationConstraint = (chain: AnyChain) => boolean;
11
+ export declare abstract class TransferValidation {
12
+ readonly sourceConstraint: TransferValidationConstraint;
13
+ readonly destinationConstraint: TransferValidationConstraint;
14
+ constructor(sourceConstraint: TransferValidationConstraint, destinationConstraint: TransferValidationConstraint);
15
+ private ruleFor;
16
+ abstract validate(ctx: TransferCtx): void;
17
+ check(ctx: TransferCtx): void;
18
+ }
19
+ export declare class TransferValidator {
20
+ private criterias;
21
+ constructor(...criterias: TransferValidation[]);
22
+ validate(ctx: TransferCtx): Promise<TransferValidationReport[]>;
23
+ }
@@ -0,0 +1,13 @@
1
+ import { EvmClient } from './EvmClient';
2
+ export declare class Erc20Client {
3
+ readonly client: EvmClient;
4
+ readonly address: string;
5
+ constructor(client: EvmClient, address: string);
6
+ private validateClient;
7
+ private validateContract;
8
+ private validateContractAddress;
9
+ balanceOf(account: string): Promise<bigint>;
10
+ decimals(): Promise<number>;
11
+ allowance(owner: string, spender: string): Promise<bigint>;
12
+ approve(spender: string, amount: bigint): string;
13
+ }