@galacticcouncil/xc-sdk 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 (67) hide show
  1. package/README.md +114 -0
  2. package/build/index.cjs +4 -0
  3. package/build/index.mjs +4 -0
  4. package/build/types/FeeSwap.d.ts +47 -0
  5. package/build/types/Wallet.d.ts +20 -0
  6. package/build/types/Wallet.utils.d.ts +47 -0
  7. package/build/types/clients/WormholeScan.d.ts +87 -0
  8. package/build/types/clients/WormholeTransfer.d.ts +16 -0
  9. package/build/types/clients/index.d.ts +3 -0
  10. package/build/types/clients/types.d.ts +20 -0
  11. package/build/types/index.d.ts +6 -0
  12. package/build/types/platforms/adapter.d.ts +15 -0
  13. package/build/types/platforms/evm/EvmClaim.d.ts +7 -0
  14. package/build/types/platforms/evm/EvmPlatform.d.ts +12 -0
  15. package/build/types/platforms/evm/balance/Erc20.d.ts +8 -0
  16. package/build/types/platforms/evm/balance/EvmBalance.d.ts +10 -0
  17. package/build/types/platforms/evm/balance/EvmBalanceFactory.d.ts +5 -0
  18. package/build/types/platforms/evm/balance/Native.d.ts +5 -0
  19. package/build/types/platforms/evm/balance/index.d.ts +2 -0
  20. package/build/types/platforms/evm/index.d.ts +3 -0
  21. package/build/types/platforms/evm/transfer/EvmTransfer.d.ts +23 -0
  22. package/build/types/platforms/evm/transfer/EvmTransferFactory.d.ts +5 -0
  23. package/build/types/platforms/evm/transfer/index.d.ts +2 -0
  24. package/build/types/platforms/evm/transfer/utils.d.ts +3 -0
  25. package/build/types/platforms/evm/types.d.ts +19 -0
  26. package/build/types/platforms/index.d.ts +6 -0
  27. package/build/types/platforms/solana/SolanaClaim.d.ts +9 -0
  28. package/build/types/platforms/solana/SolanaLilJit.d.ts +54 -0
  29. package/build/types/platforms/solana/SolanaPlatform.d.ts +12 -0
  30. package/build/types/platforms/solana/balance/Native.d.ts +5 -0
  31. package/build/types/platforms/solana/balance/SolanaBalance.d.ts +11 -0
  32. package/build/types/platforms/solana/balance/SolanaBalanceFactory.d.ts +6 -0
  33. package/build/types/platforms/solana/balance/Token.d.ts +9 -0
  34. package/build/types/platforms/solana/balance/index.d.ts +2 -0
  35. package/build/types/platforms/solana/index.d.ts +5 -0
  36. package/build/types/platforms/solana/transfer/SolanaTransfer.d.ts +33 -0
  37. package/build/types/platforms/solana/transfer/SolanaTransferFactory.d.ts +6 -0
  38. package/build/types/platforms/solana/transfer/index.d.ts +2 -0
  39. package/build/types/platforms/solana/types.d.ts +15 -0
  40. package/build/types/platforms/solana/utils.d.ts +6 -0
  41. package/build/types/platforms/substrate/SubstrateClaim.d.ts +9 -0
  42. package/build/types/platforms/substrate/SubstrateExec.d.ts +11 -0
  43. package/build/types/platforms/substrate/SubstratePlatform.d.ts +23 -0
  44. package/build/types/platforms/substrate/SubstrateService.d.ts +32 -0
  45. package/build/types/platforms/substrate/index.d.ts +5 -0
  46. package/build/types/platforms/substrate/types.d.ts +12 -0
  47. package/build/types/platforms/substrate/utils/amount.d.ts +12 -0
  48. package/build/types/platforms/substrate/utils/dryRun.d.ts +2 -0
  49. package/build/types/platforms/substrate/utils/index.d.ts +4 -0
  50. package/build/types/platforms/substrate/utils/naming.d.ts +24 -0
  51. package/build/types/platforms/substrate/utils/xcm.d.ts +110 -0
  52. package/build/types/platforms/sui/SuiPlatform.d.ts +12 -0
  53. package/build/types/platforms/sui/balance/Native.d.ts +5 -0
  54. package/build/types/platforms/sui/balance/SuiBalance.d.ts +11 -0
  55. package/build/types/platforms/sui/balance/SuiBalanceFactory.d.ts +6 -0
  56. package/build/types/platforms/sui/balance/index.d.ts +2 -0
  57. package/build/types/platforms/sui/index.d.ts +2 -0
  58. package/build/types/platforms/sui/types.d.ts +4 -0
  59. package/build/types/platforms/sui/utils.d.ts +10 -0
  60. package/build/types/platforms/types.d.ts +25 -0
  61. package/build/types/transfer/DataOriginProcessor.d.ts +42 -0
  62. package/build/types/transfer/DataProcessor.d.ts +12 -0
  63. package/build/types/transfer/DataReverseProcessor.d.ts +6 -0
  64. package/build/types/transfer/index.d.ts +3 -0
  65. package/build/types/transfer/utils.d.ts +41 -0
  66. package/build/types/types.d.ts +51 -0
  67. package/package.json +38 -0
@@ -0,0 +1,42 @@
1
+ import { Asset, AssetAmount, TransferCtx, TransferConfig, TransactCtx } from '@galacticcouncil/xc-core';
2
+ import { Call, PlatformAdapter } from '../platforms';
3
+ import { DataProcessor } from './DataProcessor';
4
+ export declare class DataOriginProcessor extends DataProcessor {
5
+ constructor(adapter: PlatformAdapter, config: TransferConfig);
6
+ getCall(ctx: TransferCtx): Promise<Call>;
7
+ getDestinationFee(): Promise<{
8
+ fee: AssetAmount;
9
+ feeBreakdown: {
10
+ [key: string]: bigint;
11
+ };
12
+ }>;
13
+ getDestinationFeeBalance(address: string): Promise<AssetAmount>;
14
+ getFee(ctx: TransferCtx): Promise<AssetAmount>;
15
+ getFeeBalance(address: string): Promise<AssetAmount>;
16
+ getFeeAsset(address: string): Promise<Asset>;
17
+ private getTransfer;
18
+ getTransact(ctx: TransferCtx): Promise<TransactCtx | undefined>;
19
+ /**
20
+ * Transact remote execution context
21
+ *
22
+ * @param cfg - transact config
23
+ * @param ctx - augmented transfer context
24
+ * @returns transact remote call context
25
+ */
26
+ private getTransactData;
27
+ /**
28
+ * Transact fee on source chain
29
+ *
30
+ * @param cfg - transact config
31
+ * @returns transact source chain fee
32
+ */
33
+ private getTransactFee;
34
+ /**
35
+ * Transact fee balance on source chain
36
+ *
37
+ * @param cfg - transact config
38
+ * @param ctx - augmented transfer context
39
+ * @returns transact source chain fee balance
40
+ */
41
+ private getTransactFeeBalance;
42
+ }
@@ -0,0 +1,12 @@
1
+ import { Asset, AssetAmount, TransferConfig } from '@galacticcouncil/xc-core';
2
+ import { PlatformAdapter } from '../platforms';
3
+ export declare abstract class DataProcessor {
4
+ readonly adapter: PlatformAdapter;
5
+ readonly config: TransferConfig;
6
+ constructor(adapter: PlatformAdapter, config: TransferConfig);
7
+ getEd(): Promise<AssetAmount | undefined>;
8
+ getBalance(address: string): Promise<AssetAmount>;
9
+ getMin(): Promise<AssetAmount>;
10
+ private getAssetMin;
11
+ protected getDecimals(asset: Asset): Promise<number>;
12
+ }
@@ -0,0 +1,6 @@
1
+ import { TransferConfig } from '@galacticcouncil/xc-core';
2
+ import { PlatformAdapter } from '../platforms';
3
+ import { DataProcessor } from './DataProcessor';
4
+ export declare class DataReverseProcessor extends DataProcessor {
5
+ constructor(adapter: PlatformAdapter, config: TransferConfig);
6
+ }
@@ -0,0 +1,3 @@
1
+ export { DataOriginProcessor } from './DataOriginProcessor';
2
+ export { DataReverseProcessor } from './DataReverseProcessor';
3
+ export * from './utils';
@@ -0,0 +1,41 @@
1
+ import { AnyChain, AssetAmount } from '@galacticcouncil/xc-core';
2
+ /**
3
+ * Calculate maximum allowed amount of asset to send from source to
4
+ * destination chain.
5
+ *
6
+ * @param balance - source chain asset balance
7
+ * @param fee - source chain transfer fee
8
+ * @param min - source chain minimum
9
+ * @param ed - source chain existential deposit (opt)
10
+ * @returns - maximum allowed amount of tokens to send or zero in
11
+ * case of not enough funds
12
+ */
13
+ export declare function calculateMax(balance: AssetAmount, fee: AssetAmount, min: AssetAmount, ed?: AssetAmount): AssetAmount;
14
+ /**
15
+ * Calculate minimum required amount of asset to send from source to
16
+ * destination chain.
17
+ *
18
+ * @param balance - destination chain asset balance
19
+ * @param fee - destination chain transfer fee
20
+ * @param min - destination chain minimum
21
+ * @param ed - destination chain existential deposit (opt)
22
+ * @returns - minimum required amount of tokens to send or zero in
23
+ * case of no available funds
24
+ */
25
+ export declare function calculateMin(balance: AssetAmount, fee: AssetAmount, min: AssetAmount, ed?: AssetAmount): AssetAmount;
26
+ /**
27
+ * Return h160 derivated address in case of Evm parachain
28
+ *
29
+ * @param address - h160 or ss58 address format
30
+ * @param chain - transfer chain ctx
31
+ * @returns - derivated address if evm resolver defined, fallback to default
32
+ */
33
+ export declare function formatEvmAddress(address: string, chain: AnyChain): Promise<string>;
34
+ /**
35
+ * Format amount if defined
36
+ *
37
+ * @param decimals - fee asset decimals
38
+ * @param amount - fee amount
39
+ * @returns formatted amount or 0
40
+ */
41
+ export declare function formatAmount(decimals: number, amount?: number): bigint;
@@ -0,0 +1,51 @@
1
+ import { AssetAmount, SwapCtx, TransferValidationReport } from '@galacticcouncil/xc-core';
2
+ import { Call } from './platforms';
3
+ /**
4
+ * Transfer source data
5
+ *
6
+ * @interface TransferSourceData
7
+ * @member {AssetAmount} balance Transfer asset balance
8
+ * @member {AssetAmount} destinationFee Transfer destination fee
9
+ * @member {AssetAmount} destinationFeeBalance Transfer destination fee asset balance
10
+ * @member {AssetAmount} fee Transfer fee
11
+ * @member {AssetAmount} feeBalance Transfer fee asset balance
12
+ * @member {SwapCtx} feeSwap Transfer fee swap context details
13
+ * @member {AssetAmount} max Maximum allowed amount of transfer asset to send
14
+ * @member {AssetAmount} min Minimum required amount of transfer asset to send
15
+ */
16
+ export interface TransferSourceData {
17
+ balance: AssetAmount;
18
+ destinationFee: AssetAmount;
19
+ destinationFeeBalance: AssetAmount;
20
+ destinationFeeSwap: SwapCtx;
21
+ fee: AssetAmount;
22
+ feeBalance: AssetAmount;
23
+ feeSwap: SwapCtx;
24
+ max: AssetAmount;
25
+ min: AssetAmount;
26
+ }
27
+ /**
28
+ * Transfer destination data
29
+ *
30
+ * @interface TransferDestinationData
31
+ * @member {AssetAmount} balance Received asset balance
32
+ * @member {AssetAmount} fee Transfer destination fee
33
+ */
34
+ export interface TransferDestinationData {
35
+ balance: AssetAmount;
36
+ fee: AssetAmount;
37
+ }
38
+ /**
39
+ * Transfer input
40
+ *
41
+ * @interface Transfer
42
+ * @member {TransferSourceData} source Source chain data
43
+ * @member {TransferDestinationData} destination Destination chain data
44
+ */
45
+ export interface Transfer {
46
+ source: TransferSourceData;
47
+ destination: TransferDestinationData;
48
+ buildCall(amount: bigint | number | string): Promise<Call>;
49
+ estimateFee(amount: bigint | number | string): Promise<AssetAmount>;
50
+ validate(fee?: bigint): Promise<TransferValidationReport[]>;
51
+ }
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@galacticcouncil/xc-sdk",
3
+ "version": "0.1.0",
4
+ "description": "Cross-chain sdk",
5
+ "author": "GalacticCouncil",
6
+ "type": "module",
7
+ "repository": {
8
+ "directory": "packages/xc-sdk",
9
+ "type": "git",
10
+ "url": "git+https://github.com/galacticcouncil/sdk.git"
11
+ },
12
+ "keywords": [
13
+ "evm",
14
+ "substrate",
15
+ "wallet",
16
+ "xcm",
17
+ "wormhole"
18
+ ],
19
+ "bugs": {
20
+ "url": "https://github.com/galacticcouncil/sdk/issues"
21
+ },
22
+ "files": [
23
+ "build"
24
+ ],
25
+ "main": "./build/index.cjs",
26
+ "module": "./build/index.mjs",
27
+ "types": "./build/types/index.d.ts",
28
+ "scripts": {
29
+ "build": "npm run clean && node ./esbuild.dist.mjs",
30
+ "build:watch": "node ./esbuild.dev.mjs",
31
+ "postbuild": "tsc --emitDeclarationOnly --outDir build/types",
32
+ "clean": "rimraf build",
33
+ "link": "npm ln"
34
+ },
35
+ "dependencies": {
36
+ "@galacticcouncil/xc-core": "^0.1.0"
37
+ }
38
+ }