@galacticcouncil/xc-cfg 1.1.0 → 1.2.0-pr297-4f08471
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/build/builders/ContractBuilder.d.ts +1 -1
- package/build/builders/ExtrinsicBuilder.d.ts +6 -0
- package/build/builders/contracts/snowbridge/codec.d.ts +8 -0
- package/build/builders/contracts/{Snowbridge.d.ts → snowbridge/index.d.ts} +1 -1
- package/build/builders/extrinsics/xcm/builder/Snowbridge.d.ts +86 -0
- package/build/builders/extrinsics/xcm/builder/buildParaERC20ReceivedV5.d.ts +16 -0
- package/build/builders/extrinsics/xcm/builder/index.d.ts +2 -0
- package/build/builders/extrinsics/xcm/polkadotXcm.d.ts +7 -1
- package/build/clients/base.d.ts +2 -1
- package/build/clients/chain/assethub.d.ts +8 -0
- package/build/index.cjs +1 -1
- package/build/index.mjs +1 -1
- package/package.json +2 -2
|
@@ -11,7 +11,7 @@ export declare function ContractBuilder(): {
|
|
|
11
11
|
};
|
|
12
12
|
PolkadotXcm: typeof PolkadotXcm;
|
|
13
13
|
Snowbridge: () => {
|
|
14
|
-
|
|
14
|
+
v2SendMessage: () => import("@galacticcouncil/xc-core").ContractConfigBuilder;
|
|
15
15
|
};
|
|
16
16
|
Wormhole: typeof Wormhole;
|
|
17
17
|
};
|
|
@@ -22,6 +22,12 @@ export declare function ExtrinsicBuilder(): {
|
|
|
22
22
|
transferAssetsUsingTypeAndThen: (opts: {
|
|
23
23
|
transferType: import(".").XcmTransferType;
|
|
24
24
|
}) => ExtrinsicConfigBuilder;
|
|
25
|
+
execute: {
|
|
26
|
+
(messageBuilder: import("./extrinsics/xcm/polkadotXcm").XcmMessageBuilder): ExtrinsicConfigBuilder;
|
|
27
|
+
(): {
|
|
28
|
+
viaSnowbridge: () => ExtrinsicConfigBuilder;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
25
31
|
send: () => {
|
|
26
32
|
transact: (opts: {
|
|
27
33
|
fee: number;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Codec } from 'polkadot-api';
|
|
2
|
+
import { XcmVersionedXcm, XcmVersionedLocation } from '@galacticcouncil/descriptors';
|
|
3
|
+
interface XcmCodecs {
|
|
4
|
+
message: Codec<XcmVersionedXcm>;
|
|
5
|
+
location: Codec<XcmVersionedLocation>;
|
|
6
|
+
}
|
|
7
|
+
export declare function getXcmCodecs(): Promise<XcmCodecs>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { ExtrinsicConfigBuilderParams } from '@galacticcouncil/xc-core';
|
|
2
|
+
import { XcmV5Instruction, XcmV5Junction } from '@galacticcouncil/descriptors';
|
|
3
|
+
import { SizedHex } from 'polkadot-api';
|
|
4
|
+
/**
|
|
5
|
+
* Location helpers for Snowbridge V2 XCM
|
|
6
|
+
*/
|
|
7
|
+
export declare const etherLocation: (ethChainId: number) => {
|
|
8
|
+
parents: number;
|
|
9
|
+
interior: {
|
|
10
|
+
type: "X1";
|
|
11
|
+
value: XcmV5Junction;
|
|
12
|
+
} & {
|
|
13
|
+
type: "X1";
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export declare const erc20Location: (ethChainId: number, tokenAddress: string) => {
|
|
17
|
+
parents: number;
|
|
18
|
+
interior: {
|
|
19
|
+
type: "X2";
|
|
20
|
+
value: import("polkadot-api").FixedSizeArray<2, XcmV5Junction>;
|
|
21
|
+
} & {
|
|
22
|
+
type: "X2";
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export type SnowbridgeInboundXcmParams = {
|
|
26
|
+
ethChainId: number;
|
|
27
|
+
destinationParaId: number;
|
|
28
|
+
tokenAddress: string;
|
|
29
|
+
beneficiaryHex: string;
|
|
30
|
+
tokenAmount: bigint;
|
|
31
|
+
remoteEtherFeeAmount: bigint;
|
|
32
|
+
remoteDotFeeAmount?: bigint;
|
|
33
|
+
topic: SizedHex<32>;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Builds the XCM V5 program passed to `v2_sendMessage` for
|
|
37
|
+
* transferring ERC20/ETH from Ethereum to a Polkadot parachain.
|
|
38
|
+
*
|
|
39
|
+
* If `remoteDotFeeAmount` is provided, an ExchangeAsset instruction
|
|
40
|
+
* is prepended to swap Ether for DOT on AssetHub (for parachains
|
|
41
|
+
* that require DOT as the fee asset).
|
|
42
|
+
*
|
|
43
|
+
* Flow:
|
|
44
|
+
* 1. (Optional) ExchangeAsset: swap Ether for DOT on AssetHub
|
|
45
|
+
* 2. InitiateTransfer to destination parachain
|
|
46
|
+
* - remote_fees: ReserveDeposit(ether or DOT) for destination execution
|
|
47
|
+
* - assets: ReserveDeposit(token) for the actual transfer
|
|
48
|
+
* - remote_xcm: RefundSurplus + DepositAsset to beneficiary
|
|
49
|
+
* 3. RefundSurplus (reclaim unused ether on Asset Hub)
|
|
50
|
+
* 4. DepositAsset remaining ether to beneficiary on Asset Hub
|
|
51
|
+
* 5. SetTopic for tracking
|
|
52
|
+
*/
|
|
53
|
+
export declare function buildSnowbridgeInboundXcm(params: SnowbridgeInboundXcmParams): XcmV5Instruction[];
|
|
54
|
+
export type SnowbridgeOutboundXcmParams = {
|
|
55
|
+
tokenAddress: string;
|
|
56
|
+
senderPubKey: string;
|
|
57
|
+
beneficiaryHex: string;
|
|
58
|
+
tokenAmount: bigint;
|
|
59
|
+
sourceExecutionFee: bigint;
|
|
60
|
+
dotRemoteFee: bigint;
|
|
61
|
+
dotToEtherSwapAmount: bigint;
|
|
62
|
+
etherFeeAmount: bigint;
|
|
63
|
+
topic: SizedHex<32>;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Builds the V5 XCM program for `polkadotXcm.execute` to transfer
|
|
67
|
+
* ERC20/ETH from a Polkadot parachain to Ethereum via Snowbridge V2.
|
|
68
|
+
*
|
|
69
|
+
* 3-leg program:
|
|
70
|
+
*
|
|
71
|
+
* Leg 1 — Source parachain:
|
|
72
|
+
* WithdrawAsset, PayFees, SetAppendix (error recovery), InitiateTransfer → AssetHub
|
|
73
|
+
*
|
|
74
|
+
* Leg 2 — AssetHub (remote_xcm):
|
|
75
|
+
* SetAppendix (error recovery), ExchangeAsset (DOT→Ether), InitiateTransfer → Ethereum
|
|
76
|
+
*
|
|
77
|
+
* Leg 3 — Ethereum (innermost remote_xcm):
|
|
78
|
+
* DepositAsset to beneficiary, SetTopic
|
|
79
|
+
*/
|
|
80
|
+
export declare function buildSnowbridgeOutboundXcm(params: SnowbridgeOutboundXcmParams): XcmV5Instruction[];
|
|
81
|
+
export declare function snowbridgeOutboundMessage(params: ExtrinsicConfigBuilderParams): {
|
|
82
|
+
type: "V5";
|
|
83
|
+
value: XcmV5Instruction[];
|
|
84
|
+
} & {
|
|
85
|
+
type: "V5";
|
|
86
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { XcmV5Instruction } from '@galacticcouncil/descriptors';
|
|
2
|
+
import { Asset, Parachain } from '@galacticcouncil/xc-core';
|
|
3
|
+
/**
|
|
4
|
+
* Builds the V5 XCM program that InitiateTransfer generates on the
|
|
5
|
+
* destination parachain (e.g. Hydration). Used for weight/fee estimation.
|
|
6
|
+
*
|
|
7
|
+
* This matches what actually executes on the destination:
|
|
8
|
+
* 1. ReserveAssetDeposited(DOT)
|
|
9
|
+
* 2. PayFees(DOT)
|
|
10
|
+
* 3. ReserveAssetDeposited(token)
|
|
11
|
+
* 4. ClearOrigin
|
|
12
|
+
* 5. RefundSurplus
|
|
13
|
+
* 6. DepositAsset
|
|
14
|
+
* 7. SetTopic
|
|
15
|
+
*/
|
|
16
|
+
export declare function buildParaERC20ReceivedV5(asset: Asset, chain: Parachain): XcmV5Instruction[];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ExtrinsicConfigBuilder } from '@galacticcouncil/xc-core';
|
|
1
|
+
import { ExtrinsicConfigBuilder, ExtrinsicConfigBuilderParams } from '@galacticcouncil/xc-core';
|
|
2
|
+
export type XcmMessageBuilder = (params: ExtrinsicConfigBuilderParams) => any;
|
|
2
3
|
import { XcmTransferType } from './types';
|
|
3
4
|
type TransferOpts = {
|
|
4
5
|
transferType: XcmTransferType;
|
|
@@ -6,12 +7,17 @@ type TransferOpts = {
|
|
|
6
7
|
type TransactOpts = {
|
|
7
8
|
fee: number;
|
|
8
9
|
};
|
|
10
|
+
declare function execute(messageBuilder: XcmMessageBuilder): ExtrinsicConfigBuilder;
|
|
11
|
+
declare function execute(): {
|
|
12
|
+
viaSnowbridge: () => ExtrinsicConfigBuilder;
|
|
13
|
+
};
|
|
9
14
|
export declare const polkadotXcm: () => {
|
|
10
15
|
limitedReserveTransferAssets: () => ExtrinsicConfigBuilder;
|
|
11
16
|
limitedTeleportAssets: () => ExtrinsicConfigBuilder;
|
|
12
17
|
reserveTransferAssets: () => ExtrinsicConfigBuilder;
|
|
13
18
|
transferAssets: () => ExtrinsicConfigBuilder;
|
|
14
19
|
transferAssetsUsingTypeAndThen: (opts: TransferOpts) => ExtrinsicConfigBuilder;
|
|
20
|
+
execute: typeof execute;
|
|
15
21
|
send: () => {
|
|
16
22
|
transact: (opts: TransactOpts) => ExtrinsicConfigBuilder;
|
|
17
23
|
transferAsset: (opts: TransactOpts) => ExtrinsicConfigBuilder;
|
package/build/clients/base.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ChainDefinition, TypedApi } from 'polkadot-api';
|
|
2
2
|
import { Asset, Parachain } from '@galacticcouncil/xc-core';
|
|
3
|
-
import { hub, XcmV4Instruction } from '@galacticcouncil/descriptors';
|
|
3
|
+
import { hub, XcmV4Instruction, XcmV5Instruction } from '@galacticcouncil/descriptors';
|
|
4
4
|
export declare class BaseClient<C extends ChainDefinition = typeof hub> {
|
|
5
5
|
readonly chain: Parachain;
|
|
6
6
|
protected descriptor: C;
|
|
@@ -10,4 +10,5 @@ export declare class BaseClient<C extends ChainDefinition = typeof hub> {
|
|
|
10
10
|
private get refApi();
|
|
11
11
|
getSystemAccountBalance(address: string): Promise<bigint>;
|
|
12
12
|
calculateDestinationFee(xcm: XcmV4Instruction[], asset: Asset): Promise<bigint>;
|
|
13
|
+
calculateDestinationFeeV5(xcm: XcmV5Instruction[], asset: Asset): Promise<bigint>;
|
|
13
14
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { Asset, Parachain } from '@galacticcouncil/xc-core';
|
|
2
2
|
import { XcmV4Instruction, Hub } from '@galacticcouncil/descriptors';
|
|
3
|
+
type AssetLocation = {
|
|
4
|
+
parents: number;
|
|
5
|
+
interior: any;
|
|
6
|
+
};
|
|
3
7
|
import { BaseClient } from '../base';
|
|
4
8
|
export declare class AssethubClient extends BaseClient<Hub> {
|
|
5
9
|
constructor(chain: Parachain);
|
|
@@ -10,4 +14,8 @@ export declare class AssethubClient extends BaseClient<Hub> {
|
|
|
10
14
|
defaultFee: bigint;
|
|
11
15
|
}): Promise<bigint>;
|
|
12
16
|
calculateDeliveryFee(xcm: XcmV4Instruction[], destParachainId: number): Promise<bigint>;
|
|
17
|
+
quoteDotToEther(etherLocation: AssetLocation, dotAmount: bigint): Promise<bigint>;
|
|
18
|
+
quoteEtherForDot(etherLocation: AssetLocation, dotAmount: bigint): Promise<bigint>;
|
|
19
|
+
quoteDotForExactEther(etherLocation: AssetLocation, etherAmount: bigint): Promise<bigint>;
|
|
13
20
|
}
|
|
21
|
+
export {};
|