@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.
- package/README.md +114 -0
- package/build/index.cjs +4 -0
- package/build/index.mjs +4 -0
- package/build/types/FeeSwap.d.ts +47 -0
- package/build/types/Wallet.d.ts +20 -0
- package/build/types/Wallet.utils.d.ts +47 -0
- package/build/types/clients/WormholeScan.d.ts +87 -0
- package/build/types/clients/WormholeTransfer.d.ts +16 -0
- package/build/types/clients/index.d.ts +3 -0
- package/build/types/clients/types.d.ts +20 -0
- package/build/types/index.d.ts +6 -0
- package/build/types/platforms/adapter.d.ts +15 -0
- package/build/types/platforms/evm/EvmClaim.d.ts +7 -0
- package/build/types/platforms/evm/EvmPlatform.d.ts +12 -0
- package/build/types/platforms/evm/balance/Erc20.d.ts +8 -0
- package/build/types/platforms/evm/balance/EvmBalance.d.ts +10 -0
- package/build/types/platforms/evm/balance/EvmBalanceFactory.d.ts +5 -0
- package/build/types/platforms/evm/balance/Native.d.ts +5 -0
- package/build/types/platforms/evm/balance/index.d.ts +2 -0
- package/build/types/platforms/evm/index.d.ts +3 -0
- package/build/types/platforms/evm/transfer/EvmTransfer.d.ts +23 -0
- package/build/types/platforms/evm/transfer/EvmTransferFactory.d.ts +5 -0
- package/build/types/platforms/evm/transfer/index.d.ts +2 -0
- package/build/types/platforms/evm/transfer/utils.d.ts +3 -0
- package/build/types/platforms/evm/types.d.ts +19 -0
- package/build/types/platforms/index.d.ts +6 -0
- package/build/types/platforms/solana/SolanaClaim.d.ts +9 -0
- package/build/types/platforms/solana/SolanaLilJit.d.ts +54 -0
- package/build/types/platforms/solana/SolanaPlatform.d.ts +12 -0
- package/build/types/platforms/solana/balance/Native.d.ts +5 -0
- package/build/types/platforms/solana/balance/SolanaBalance.d.ts +11 -0
- package/build/types/platforms/solana/balance/SolanaBalanceFactory.d.ts +6 -0
- package/build/types/platforms/solana/balance/Token.d.ts +9 -0
- package/build/types/platforms/solana/balance/index.d.ts +2 -0
- package/build/types/platforms/solana/index.d.ts +5 -0
- package/build/types/platforms/solana/transfer/SolanaTransfer.d.ts +33 -0
- package/build/types/platforms/solana/transfer/SolanaTransferFactory.d.ts +6 -0
- package/build/types/platforms/solana/transfer/index.d.ts +2 -0
- package/build/types/platforms/solana/types.d.ts +15 -0
- package/build/types/platforms/solana/utils.d.ts +6 -0
- package/build/types/platforms/substrate/SubstrateClaim.d.ts +9 -0
- package/build/types/platforms/substrate/SubstrateExec.d.ts +11 -0
- package/build/types/platforms/substrate/SubstratePlatform.d.ts +23 -0
- package/build/types/platforms/substrate/SubstrateService.d.ts +32 -0
- package/build/types/platforms/substrate/index.d.ts +5 -0
- package/build/types/platforms/substrate/types.d.ts +12 -0
- package/build/types/platforms/substrate/utils/amount.d.ts +12 -0
- package/build/types/platforms/substrate/utils/dryRun.d.ts +2 -0
- package/build/types/platforms/substrate/utils/index.d.ts +4 -0
- package/build/types/platforms/substrate/utils/naming.d.ts +24 -0
- package/build/types/platforms/substrate/utils/xcm.d.ts +110 -0
- package/build/types/platforms/sui/SuiPlatform.d.ts +12 -0
- package/build/types/platforms/sui/balance/Native.d.ts +5 -0
- package/build/types/platforms/sui/balance/SuiBalance.d.ts +11 -0
- package/build/types/platforms/sui/balance/SuiBalanceFactory.d.ts +6 -0
- package/build/types/platforms/sui/balance/index.d.ts +2 -0
- package/build/types/platforms/sui/index.d.ts +2 -0
- package/build/types/platforms/sui/types.d.ts +4 -0
- package/build/types/platforms/sui/utils.d.ts +10 -0
- package/build/types/platforms/types.d.ts +25 -0
- package/build/types/transfer/DataOriginProcessor.d.ts +42 -0
- package/build/types/transfer/DataProcessor.d.ts +12 -0
- package/build/types/transfer/DataReverseProcessor.d.ts +6 -0
- package/build/types/transfer/index.d.ts +3 -0
- package/build/types/transfer/utils.d.ts +41 -0
- package/build/types/types.d.ts +51 -0
- package/package.json +38 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ContractConfig, EvmClient } from '@galacticcouncil/xc-core';
|
|
2
|
+
import { Abi, BaseError, Log } from 'viem';
|
|
3
|
+
import { EvmEventLog } from '../types';
|
|
4
|
+
type SimulateCallResult = {
|
|
5
|
+
error: BaseError | undefined;
|
|
6
|
+
logs: Log[] | undefined;
|
|
7
|
+
};
|
|
8
|
+
export declare class EvmTransfer {
|
|
9
|
+
protected readonly client: EvmClient;
|
|
10
|
+
protected readonly config: ContractConfig;
|
|
11
|
+
constructor(client: EvmClient, config: ContractConfig);
|
|
12
|
+
private validateClient;
|
|
13
|
+
get abi(): Abi;
|
|
14
|
+
get asset(): string;
|
|
15
|
+
get calldata(): string;
|
|
16
|
+
estimateGas(account: string): Promise<bigint>;
|
|
17
|
+
estimateFee(account: string, balance: bigint): Promise<bigint>;
|
|
18
|
+
getGasPrice(): Promise<bigint>;
|
|
19
|
+
getNonce(account: string): Promise<number>;
|
|
20
|
+
simulateCall(account: string): Promise<SimulateCallResult>;
|
|
21
|
+
decodeEvents(logs: Log[] | undefined): EvmEventLog[];
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Call, DryRunResult } from '../types';
|
|
2
|
+
export interface EvmCall extends Call {
|
|
3
|
+
/** Solidity JSON string ABI. */
|
|
4
|
+
abi?: string;
|
|
5
|
+
/** Spending CAP */
|
|
6
|
+
allowance?: bigint;
|
|
7
|
+
/** The address the transaction is directed to. */
|
|
8
|
+
to: `0x${string}`;
|
|
9
|
+
/** Value sent with this transaction. */
|
|
10
|
+
value?: bigint;
|
|
11
|
+
}
|
|
12
|
+
export interface EvmEventLog {
|
|
13
|
+
eventName: string;
|
|
14
|
+
args: any[] | undefined;
|
|
15
|
+
}
|
|
16
|
+
export interface EvmDryRunResult extends DryRunResult {
|
|
17
|
+
error: string | undefined;
|
|
18
|
+
events: EvmEventLog[] | undefined;
|
|
19
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SolanaChain } from '@galacticcouncil/xc-core';
|
|
2
|
+
import { SolanaCall } from './types';
|
|
3
|
+
export declare class SolanaClaim {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(chain: SolanaChain);
|
|
6
|
+
redeem(from: string, vaaRaw: string): Promise<SolanaCall[]>;
|
|
7
|
+
private derivePostedVaaKey;
|
|
8
|
+
private getV0Message;
|
|
9
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { SolanaChain } from '@galacticcouncil/xc-core';
|
|
2
|
+
type JitoBundleSimulationResponse = {
|
|
3
|
+
context: {
|
|
4
|
+
apiVersion: string;
|
|
5
|
+
slot: number;
|
|
6
|
+
};
|
|
7
|
+
value: {
|
|
8
|
+
summary: 'succeeded' | {
|
|
9
|
+
failed: {
|
|
10
|
+
error: {
|
|
11
|
+
TransactionFailure: [number[], string];
|
|
12
|
+
};
|
|
13
|
+
tx_signature: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
transactionResults: Array<{
|
|
17
|
+
err: null | unknown;
|
|
18
|
+
logs: string[];
|
|
19
|
+
postExecutionAccounts: null | unknown;
|
|
20
|
+
preExecutionAccounts: null | unknown;
|
|
21
|
+
returnData: null | unknown;
|
|
22
|
+
unitsConsumed: number;
|
|
23
|
+
}>;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
type JitoBundleStatus = {
|
|
27
|
+
context: {
|
|
28
|
+
apiVersion: string;
|
|
29
|
+
slot: number;
|
|
30
|
+
};
|
|
31
|
+
value: Array<{
|
|
32
|
+
bundle_id: string;
|
|
33
|
+
landed_slot: number;
|
|
34
|
+
status: string;
|
|
35
|
+
}>;
|
|
36
|
+
};
|
|
37
|
+
export declare class SolanaLilJit {
|
|
38
|
+
#private;
|
|
39
|
+
constructor(chain: SolanaChain);
|
|
40
|
+
/**
|
|
41
|
+
* Returns bundle id
|
|
42
|
+
*
|
|
43
|
+
* @see https://explorer.jito.wtf/bundle/${bundle_id}
|
|
44
|
+
*
|
|
45
|
+
* @param encoded base 64 encoded tx
|
|
46
|
+
* @returns bundle id
|
|
47
|
+
*/
|
|
48
|
+
sendBundle(encoded: string[]): Promise<string>;
|
|
49
|
+
simulateBundle(encoded: string[]): Promise<JitoBundleSimulationResponse>;
|
|
50
|
+
getInflightBundleStatuses(bundleIds: string[]): Promise<JitoBundleStatus>;
|
|
51
|
+
getRegion(): Promise<string[]>;
|
|
52
|
+
getTipAccount(): Promise<string[]>;
|
|
53
|
+
}
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Asset, AssetAmount, ProgramConfig, SolanaChain, SolanaQueryConfig } from '@galacticcouncil/xc-core';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { SolanaCall } from './types';
|
|
4
|
+
import { Platform } from '../types';
|
|
5
|
+
export declare class SolanaPlatform implements Platform<ProgramConfig, SolanaQueryConfig> {
|
|
6
|
+
#private;
|
|
7
|
+
constructor(chain: SolanaChain);
|
|
8
|
+
buildCall(account: string, _amount: bigint, _feeBalance: AssetAmount, config: ProgramConfig): Promise<SolanaCall>;
|
|
9
|
+
estimateFee(account: string, amount: bigint, feeBalance: AssetAmount, config: ProgramConfig): Promise<AssetAmount>;
|
|
10
|
+
getBalance(asset: Asset, config: SolanaQueryConfig): Promise<AssetAmount>;
|
|
11
|
+
subscribeBalance(asset: Asset, config: SolanaQueryConfig): Promise<Observable<AssetAmount>>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SolanaQueryConfig } from '@galacticcouncil/xc-core';
|
|
2
|
+
import { Connection } from '@solana/web3.js';
|
|
3
|
+
export declare abstract class SolanaBalance {
|
|
4
|
+
readonly connection: Connection;
|
|
5
|
+
readonly config: SolanaQueryConfig;
|
|
6
|
+
constructor(connection: Connection, config: SolanaQueryConfig);
|
|
7
|
+
private validateConnection;
|
|
8
|
+
private validateConfig;
|
|
9
|
+
abstract getBalance(): Promise<bigint>;
|
|
10
|
+
abstract getDecimals(): Promise<number>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SolanaQueryConfig } from '@galacticcouncil/xc-core';
|
|
2
|
+
import { Connection } from '@solana/web3.js';
|
|
3
|
+
import { SolanaBalance } from './SolanaBalance';
|
|
4
|
+
export declare class SolanaBalanceFactory {
|
|
5
|
+
static get(connection: Connection, config: SolanaQueryConfig): SolanaBalance;
|
|
6
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SolanaQueryConfig } from '@galacticcouncil/xc-core';
|
|
2
|
+
import { Connection } from '@solana/web3.js';
|
|
3
|
+
import { SolanaBalance } from './SolanaBalance';
|
|
4
|
+
export declare class Token extends SolanaBalance {
|
|
5
|
+
constructor(connection: Connection, config: SolanaQueryConfig);
|
|
6
|
+
getBalance(): Promise<bigint>;
|
|
7
|
+
getDecimals(): Promise<number>;
|
|
8
|
+
private validateToken;
|
|
9
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ProgramConfig } from '@galacticcouncil/xc-core';
|
|
2
|
+
import { Connection, MessageV0, SimulatedTransactionResponse } from '@solana/web3.js';
|
|
3
|
+
export declare class SolanaTransfer {
|
|
4
|
+
readonly connection: Connection;
|
|
5
|
+
readonly config: ProgramConfig;
|
|
6
|
+
constructor(connection: Connection, config: ProgramConfig);
|
|
7
|
+
private validateConnection;
|
|
8
|
+
getPriorityMessage(account: string): Promise<MessageV0>;
|
|
9
|
+
estimateFee(account: string, balance: bigint): Promise<bigint>;
|
|
10
|
+
private getV0Message;
|
|
11
|
+
private createPriorityFeeInstructions;
|
|
12
|
+
simulateTransaction(account: string, message: MessageV0): Promise<SimulatedTransactionResponse>;
|
|
13
|
+
/**
|
|
14
|
+
* Determine compute budget from simulated transaction
|
|
15
|
+
*
|
|
16
|
+
* @param transaction - versioned transaction
|
|
17
|
+
* @returns Compute budget to 120% of the units used in the
|
|
18
|
+
* simulated transaction or default
|
|
19
|
+
*/
|
|
20
|
+
determineComputeBudget(message: MessageV0): Promise<number>;
|
|
21
|
+
/**
|
|
22
|
+
* Determine the priority fee to use for a transaction
|
|
23
|
+
*
|
|
24
|
+
* @param transaction - the transaction to determine the priority fee for
|
|
25
|
+
* @param percentile - the percentile of recent fees to use
|
|
26
|
+
* @param multiple - the multiple to apply to the percentile fee
|
|
27
|
+
* @param minPriorityFee - the minimum priority fee to use
|
|
28
|
+
* @param maxPriorityFee - the maximum priority fee to use
|
|
29
|
+
* @returns the priority fee to use according to the recent transactions and the given parameters
|
|
30
|
+
*/
|
|
31
|
+
determinePriorityFee(message: MessageV0, percentile?: number, multiple?: number, minPriorityFee?: number, maxPriorityFee?: number): Promise<number>;
|
|
32
|
+
private getTxAccounts;
|
|
33
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ProgramConfig } from '@galacticcouncil/xc-core';
|
|
2
|
+
import { Connection } from '@solana/web3.js';
|
|
3
|
+
import { SolanaTransfer } from './SolanaTransfer';
|
|
4
|
+
export declare class SolanaTransferFactory {
|
|
5
|
+
static get(connection: Connection, config: ProgramConfig): SolanaTransfer;
|
|
6
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Keypair, TransactionError } from '@solana/web3.js';
|
|
2
|
+
import { Call, DryRunResult } from '../types';
|
|
3
|
+
export interface SolanaCall extends Call {
|
|
4
|
+
ix: HumanizedIx[];
|
|
5
|
+
signers: Keypair[];
|
|
6
|
+
}
|
|
7
|
+
export interface HumanizedIx {
|
|
8
|
+
program: string;
|
|
9
|
+
data: string;
|
|
10
|
+
keys: string[];
|
|
11
|
+
}
|
|
12
|
+
export interface SolanaDryRunResult extends DryRunResult {
|
|
13
|
+
error: TransactionError | null;
|
|
14
|
+
events: string[] | null;
|
|
15
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { MessageV0, TransactionInstruction } from '@solana/web3.js';
|
|
2
|
+
import { HumanizedIx } from './types';
|
|
3
|
+
export declare function ixToHuman(instructions: TransactionInstruction[]): HumanizedIx[];
|
|
4
|
+
export declare function chunkBySize(instructions: TransactionInstruction[], maxBytes?: number): TransactionInstruction[][];
|
|
5
|
+
export declare function serializeV0(mssgV0: MessageV0): string;
|
|
6
|
+
export declare function deserializeV0(mssgV0: string): MessageV0;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { EvmParachain } from '@galacticcouncil/xc-core';
|
|
2
|
+
import { SubstrateCall } from './types';
|
|
3
|
+
import { EvmCall } from '../evm';
|
|
4
|
+
export declare class SubstrateClaim {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(chain: EvmParachain);
|
|
7
|
+
redeemMrl(from: string, vaaBytes: string): EvmCall;
|
|
8
|
+
redeemMrlViaXcm(from: string, vaaBytes: string): Promise<SubstrateCall>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Asset, AssetAmount } from '@galacticcouncil/xc-core';
|
|
2
|
+
import { SubstrateService } from './SubstrateService';
|
|
3
|
+
import { SubstrateCall } from './types';
|
|
4
|
+
import { Call } from '../types';
|
|
5
|
+
export declare class SubstrateExec {
|
|
6
|
+
#private;
|
|
7
|
+
constructor(src: SubstrateService, dst: SubstrateService);
|
|
8
|
+
remoteExec(srcAccount: string, dstAccount: string, dstCall: SubstrateCall, transfer: (fees: AssetAmount) => Promise<Call>, opts?: {
|
|
9
|
+
srcFeeAsset?: Asset;
|
|
10
|
+
}): Promise<SubstrateCall>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AnyParachain, Asset, AssetAmount, ExtrinsicConfig, SubstrateQueryConfig } from '@galacticcouncil/xc-core';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { SubstrateCall } from './types';
|
|
4
|
+
import { Platform } from '../types';
|
|
5
|
+
export declare class SubstratePlatform implements Platform<ExtrinsicConfig, SubstrateQueryConfig> {
|
|
6
|
+
#private;
|
|
7
|
+
constructor(chain: AnyParachain);
|
|
8
|
+
private useSignerFee;
|
|
9
|
+
buildCall(account: string, _amount: bigint, feeBalance: AssetAmount, config: ExtrinsicConfig): Promise<SubstrateCall>;
|
|
10
|
+
estimateFee(account: string, _amount: bigint, feeBalance: AssetAmount, config: ExtrinsicConfig): Promise<AssetAmount>;
|
|
11
|
+
getBalance(asset: Asset, config: SubstrateQueryConfig): Promise<AssetAmount>;
|
|
12
|
+
subscribeBalance(asset: Asset, config: SubstrateQueryConfig): Promise<Observable<AssetAmount>>;
|
|
13
|
+
/**
|
|
14
|
+
* Display native fee in user preferred fee payment asset
|
|
15
|
+
*
|
|
16
|
+
* Supported only if on-chain swap enabled (dex support)
|
|
17
|
+
*
|
|
18
|
+
* @param fee - native fee
|
|
19
|
+
* @param feeBalance - user preferred payment asset balance
|
|
20
|
+
* @returns - fee in user preferred payment asset
|
|
21
|
+
*/
|
|
22
|
+
private exchangeFee;
|
|
23
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { AnyParachain, Asset, AssetAmount, ExtrinsicConfig } from '@galacticcouncil/xc-core';
|
|
2
|
+
import { PolkadotClient, Transaction } from 'polkadot-api';
|
|
3
|
+
export declare class SubstrateService {
|
|
4
|
+
readonly client: PolkadotClient;
|
|
5
|
+
readonly api: ReturnType<PolkadotClient['getUnsafeApi']>;
|
|
6
|
+
readonly chain: AnyParachain;
|
|
7
|
+
private _chainSpec?;
|
|
8
|
+
private _asset?;
|
|
9
|
+
private _decimals?;
|
|
10
|
+
constructor(client: PolkadotClient, chain: AnyParachain);
|
|
11
|
+
static create(chain: AnyParachain): Promise<SubstrateService>;
|
|
12
|
+
private getChainSpec;
|
|
13
|
+
getAsset(): Promise<Asset>;
|
|
14
|
+
getDecimals(): Promise<number>;
|
|
15
|
+
getExistentialDeposit(): Promise<AssetAmount>;
|
|
16
|
+
isDryRunSupported(): boolean;
|
|
17
|
+
getDecimalsForAsset(asset: Asset): Promise<number>;
|
|
18
|
+
getExtrinsic(config: ExtrinsicConfig): Transaction<any, any, any, any>;
|
|
19
|
+
/**
|
|
20
|
+
* Check if extrinsic is a batch call
|
|
21
|
+
*/
|
|
22
|
+
private isBatchCall;
|
|
23
|
+
/**
|
|
24
|
+
* Build batch call with recursive ExtrinsicConfig processing
|
|
25
|
+
*/
|
|
26
|
+
private buildBatchCall;
|
|
27
|
+
buildMessageId(account: string, amount: bigint, asset: string, beneficiary: string): Promise<string>;
|
|
28
|
+
dryRun(account: string, extrinsic: Transaction<any, any, any, any>): Promise<any>;
|
|
29
|
+
estimateNetworkFee(account: string, config: ExtrinsicConfig): Promise<bigint>;
|
|
30
|
+
estimateDeliveryFee(account: string, config: ExtrinsicConfig): Promise<bigint>;
|
|
31
|
+
private estimateDeliveryFeeWith;
|
|
32
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Asset } from '@galacticcouncil/xc-core';
|
|
2
|
+
import { Call, DryRunResult } from '../types';
|
|
3
|
+
export interface SubstrateCall extends Call {
|
|
4
|
+
txOptions: {
|
|
5
|
+
asset: Asset | undefined;
|
|
6
|
+
} | undefined;
|
|
7
|
+
}
|
|
8
|
+
export interface SubstrateDryRunResult extends DryRunResult {
|
|
9
|
+
error: string | undefined;
|
|
10
|
+
events: any | undefined;
|
|
11
|
+
xcm: any | undefined;
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Asset, AssetAmountParams } from '@galacticcouncil/xc-core';
|
|
2
|
+
import { SubstrateService } from '../SubstrateService';
|
|
3
|
+
/**
|
|
4
|
+
* Normalize asset amount if chain uses solely chain decimals
|
|
5
|
+
* for balance representation of assets.
|
|
6
|
+
*
|
|
7
|
+
* @param amount - original chain amount
|
|
8
|
+
* @param asset - asset
|
|
9
|
+
* @param substrate - source chain substrate service
|
|
10
|
+
* @returns normalized asset amount if chain decimals used, otherwise default
|
|
11
|
+
*/
|
|
12
|
+
export declare function normalizeAssetAmount(amount: bigint, asset: Asset, substrate: SubstrateService): Promise<AssetAmountParams>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Naming conversion utilities for PAPI unsafe API
|
|
3
|
+
*
|
|
4
|
+
* These utilities convert config-style names to PAPI runtime names.
|
|
5
|
+
* Used when working with unsafe API for generic chain support.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Convert string to PascalCase (first letter uppercase)
|
|
9
|
+
* Used for pallet names and query function names in PAPI
|
|
10
|
+
* @example
|
|
11
|
+
* toPascalCase('balances') // 'Balances'
|
|
12
|
+
* toPascalCase('polkadotXcm') // 'PolkadotXcm'
|
|
13
|
+
* toPascalCase('multiTransactionPayment') // 'MultiTransactionPayment'
|
|
14
|
+
*/
|
|
15
|
+
export declare function toPascalCase(str: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Convert camelCase string to snake_case
|
|
18
|
+
* Used for extrinsic/function names in PAPI
|
|
19
|
+
* @example
|
|
20
|
+
* toSnakeCase('transferAll') // 'transfer_all'
|
|
21
|
+
* toSnakeCase('batchAll') // 'batch_all'
|
|
22
|
+
* toSnakeCase('setSufficient') // 'set_sufficient'
|
|
23
|
+
*/
|
|
24
|
+
export declare function toSnakeCase(str: string): string;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { AnyParachain, AssetAmount } from '@galacticcouncil/xc-core';
|
|
2
|
+
export declare function buildBeneficiary(dstAccount: string): {
|
|
3
|
+
parents: number;
|
|
4
|
+
interior: {
|
|
5
|
+
X1: {
|
|
6
|
+
AccountKey20: {
|
|
7
|
+
key: string;
|
|
8
|
+
};
|
|
9
|
+
}[];
|
|
10
|
+
};
|
|
11
|
+
} | {
|
|
12
|
+
parents: number;
|
|
13
|
+
interior: {
|
|
14
|
+
X1: {
|
|
15
|
+
AccountId32: {
|
|
16
|
+
id: string;
|
|
17
|
+
};
|
|
18
|
+
}[];
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export declare function buildXcmDest(dstChain: AnyParachain): {
|
|
22
|
+
V4: {
|
|
23
|
+
parents: number;
|
|
24
|
+
interior: {
|
|
25
|
+
X1: {
|
|
26
|
+
Parachain: number;
|
|
27
|
+
}[];
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export declare function buildXcmMessage(dstAccount: string, dstFeeLocation: any, dstFee: AssetAmount, dstRefTime: number, dstProofSize: string, dstCallEncoded: string): {
|
|
32
|
+
V4: ({
|
|
33
|
+
WithdrawAsset: {
|
|
34
|
+
id: any;
|
|
35
|
+
fun: {
|
|
36
|
+
Fungible: bigint;
|
|
37
|
+
};
|
|
38
|
+
}[];
|
|
39
|
+
BuyExecution?: undefined;
|
|
40
|
+
Transact?: undefined;
|
|
41
|
+
RefundSurplus?: undefined;
|
|
42
|
+
DepositAsset?: undefined;
|
|
43
|
+
} | {
|
|
44
|
+
BuyExecution: {
|
|
45
|
+
fees: {
|
|
46
|
+
id: any;
|
|
47
|
+
fun: {
|
|
48
|
+
Fungible: bigint;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
weightLimit: string;
|
|
52
|
+
};
|
|
53
|
+
WithdrawAsset?: undefined;
|
|
54
|
+
Transact?: undefined;
|
|
55
|
+
RefundSurplus?: undefined;
|
|
56
|
+
DepositAsset?: undefined;
|
|
57
|
+
} | {
|
|
58
|
+
Transact: {
|
|
59
|
+
originKind: string;
|
|
60
|
+
requireWeightAtMost: {
|
|
61
|
+
refTime: number;
|
|
62
|
+
proofSize: string;
|
|
63
|
+
};
|
|
64
|
+
call: {
|
|
65
|
+
encoded: string;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
WithdrawAsset?: undefined;
|
|
69
|
+
BuyExecution?: undefined;
|
|
70
|
+
RefundSurplus?: undefined;
|
|
71
|
+
DepositAsset?: undefined;
|
|
72
|
+
} | {
|
|
73
|
+
RefundSurplus: {};
|
|
74
|
+
WithdrawAsset?: undefined;
|
|
75
|
+
BuyExecution?: undefined;
|
|
76
|
+
Transact?: undefined;
|
|
77
|
+
DepositAsset?: undefined;
|
|
78
|
+
} | {
|
|
79
|
+
DepositAsset: {
|
|
80
|
+
assets: {
|
|
81
|
+
Wild: {
|
|
82
|
+
AllCounted: number;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
beneficiary: {
|
|
86
|
+
parents: number;
|
|
87
|
+
interior: {
|
|
88
|
+
X1: {
|
|
89
|
+
AccountKey20: {
|
|
90
|
+
key: string;
|
|
91
|
+
};
|
|
92
|
+
}[];
|
|
93
|
+
};
|
|
94
|
+
} | {
|
|
95
|
+
parents: number;
|
|
96
|
+
interior: {
|
|
97
|
+
X1: {
|
|
98
|
+
AccountId32: {
|
|
99
|
+
id: string;
|
|
100
|
+
};
|
|
101
|
+
}[];
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
WithdrawAsset?: undefined;
|
|
106
|
+
BuyExecution?: undefined;
|
|
107
|
+
Transact?: undefined;
|
|
108
|
+
RefundSurplus?: undefined;
|
|
109
|
+
})[];
|
|
110
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Asset, AssetAmount, MoveConfig, SuiChain, SuiQueryConfig } from '@galacticcouncil/xc-core';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { SuiCall } from './types';
|
|
4
|
+
import { Platform } from '../types';
|
|
5
|
+
export declare class SuiPlatform implements Platform<MoveConfig, SuiQueryConfig> {
|
|
6
|
+
#private;
|
|
7
|
+
constructor(chain: SuiChain);
|
|
8
|
+
buildCall(account: string, _amount: bigint, _feeBalance: AssetAmount, config: MoveConfig): Promise<SuiCall>;
|
|
9
|
+
estimateFee(account: string, _amount: bigint, feeBalance: AssetAmount, config: MoveConfig): Promise<AssetAmount>;
|
|
10
|
+
getBalance(asset: Asset, config: SuiQueryConfig): Promise<AssetAmount>;
|
|
11
|
+
subscribeBalance(asset: Asset, config: SuiQueryConfig): Promise<Observable<AssetAmount>>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SuiQueryConfig } from '@galacticcouncil/xc-core';
|
|
2
|
+
import { SuiClient } from '@mysten/sui/client';
|
|
3
|
+
export declare abstract class SuiBalance {
|
|
4
|
+
readonly client: SuiClient;
|
|
5
|
+
readonly config: SuiQueryConfig;
|
|
6
|
+
constructor(client: SuiClient, config: SuiQueryConfig);
|
|
7
|
+
private validateClient;
|
|
8
|
+
private validateConfig;
|
|
9
|
+
abstract getBalance(): Promise<bigint>;
|
|
10
|
+
abstract getDecimals(): Promise<number>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type NumberMode = 'string' | 'number' | 'bigint';
|
|
2
|
+
type Options = {
|
|
3
|
+
numbers?: NumberMode;
|
|
4
|
+
decode32As?: 'address' | 'vector<u8>';
|
|
5
|
+
};
|
|
6
|
+
export declare function resolveCommandsTyped(root: {
|
|
7
|
+
inputs: any[];
|
|
8
|
+
commands: any[];
|
|
9
|
+
}, opts?: Options): any[];
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Asset, AssetAmount, BaseConfig, CallType } from '@galacticcouncil/xc-core';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
export interface Platform<T extends BaseConfig, B extends BaseConfig> {
|
|
4
|
+
buildCall(account: string, amount: bigint, feeBalance: AssetAmount, config: T): Promise<Call>;
|
|
5
|
+
estimateFee(account: string, amount: bigint, feeBalance: AssetAmount, config: T): Promise<AssetAmount>;
|
|
6
|
+
getBalance(asset: Asset, config: B): Promise<AssetAmount>;
|
|
7
|
+
subscribeBalance(asset: Asset, config: B): Promise<Observable<AssetAmount>>;
|
|
8
|
+
}
|
|
9
|
+
export interface Call {
|
|
10
|
+
/** Owner of transation. */
|
|
11
|
+
from: string;
|
|
12
|
+
/** Hex-encoded call data. */
|
|
13
|
+
data: string;
|
|
14
|
+
/** Calltype. */
|
|
15
|
+
type: CallType;
|
|
16
|
+
/**
|
|
17
|
+
* Simulate call execution
|
|
18
|
+
*/
|
|
19
|
+
dryRun(): Promise<DryRunResult | undefined>;
|
|
20
|
+
}
|
|
21
|
+
export interface DryRunResult {
|
|
22
|
+
call: string;
|
|
23
|
+
error: any | undefined;
|
|
24
|
+
events: any | undefined;
|
|
25
|
+
}
|