@galacticcouncil/xc-cfg 0.1.0 → 0.2.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.
@@ -1,66 +1,86 @@
1
- import { ChainEcosystem, Parachain, TxWeight } from '@galacticcouncil/xc-core';
1
+ import { Parachain, TxWeight } from '@galacticcouncil/xc-core';
2
+ import { Binary } from 'polkadot-api';
3
+ import { XcmV3Junctions, XcmV3Junction, XcmV3MultiassetFungibility, XcmV4Instruction, XcmV4AssetAssetFilter, XcmV3WeightLimit, XcmV2OriginKind } from '@galacticcouncil/descriptors';
2
4
  import { XcmTransferType, XcmVersion } from './types';
3
5
  export declare const toDest: (version: XcmVersion, source: Parachain, destination: Parachain) => {
4
- [x: string]: {
6
+ type: XcmVersion;
7
+ value: {
5
8
  parents: number;
6
9
  interior: {
7
- X2: ({
8
- GlobalConsensus: ChainEcosystem | undefined;
9
- Parachain?: undefined;
10
- } | {
11
- Parachain: number;
12
- GlobalConsensus?: undefined;
13
- })[];
10
+ type: "X2";
11
+ value: import("polkadot-api").FixedSizeArray<2, XcmV3Junction>;
12
+ } & {
13
+ type: "X2";
14
14
  };
15
15
  };
16
16
  } | {
17
- [x: string]: {
17
+ type: XcmVersion;
18
+ value: {
18
19
  parents: number;
19
- interior: string;
20
+ interior: {
21
+ type: "Here";
22
+ value: undefined;
23
+ } & {
24
+ type: "Here";
25
+ };
20
26
  };
21
27
  } | {
22
- [x: string]: {
28
+ type: XcmVersion;
29
+ value: {
23
30
  parents: number;
24
31
  interior: {
25
- X1: any;
32
+ type: "X1";
33
+ value: XcmV3Junction;
34
+ } & {
35
+ type: "X1";
26
36
  };
27
37
  };
28
38
  };
29
39
  export declare const toBeneficiary: (version: XcmVersion, account: any) => {
30
- [x: string]: {
40
+ type: XcmVersion;
41
+ value: {
31
42
  parents: number;
32
43
  interior: {
33
- X1: any;
44
+ type: "X1";
45
+ value: XcmV3Junction;
46
+ } & {
47
+ type: "X1";
34
48
  };
35
49
  };
36
50
  };
37
- export declare const toTransferType: (version: XcmVersion, type: XcmTransferType, assetLocation: any) => XcmTransferType.Teleport | XcmTransferType.LocalReserve | XcmTransferType.DestinationReserve | {
38
- RemoteReserve: {
39
- [x: string]: any;
51
+ export declare const toTransferType: (version: XcmVersion, type: XcmTransferType, assetLocation: any) => {
52
+ type: string;
53
+ value: {
54
+ type: XcmVersion;
55
+ value: any;
40
56
  };
57
+ } | {
58
+ type: XcmTransferType.Teleport | XcmTransferType.LocalReserve | XcmTransferType.DestinationReserve;
59
+ value?: undefined;
41
60
  };
42
61
  export declare const toAsset: (assetLocation: object, amount: any) => {
43
62
  id: object;
44
63
  fun: {
45
- Fungible: any;
64
+ type: "Fungible";
65
+ value: bigint;
66
+ } & {
67
+ type: "Fungible";
46
68
  };
47
69
  };
48
70
  export declare const toDepositXcmOnDest: (version: XcmVersion, account: any) => {
49
- [x: string]: {
50
- DepositAsset: {
51
- assets: {
52
- Wild: {
53
- AllCounted: number;
54
- };
55
- };
71
+ type: XcmVersion;
72
+ value: ({
73
+ type: "DepositAsset";
74
+ value: {
75
+ assets: XcmV4AssetAssetFilter;
56
76
  beneficiary: {
57
77
  parents: number;
58
- interior: {
59
- X1: any;
60
- };
78
+ interior: XcmV3Junctions;
61
79
  };
62
80
  };
63
- }[];
81
+ } & {
82
+ type: "DepositAsset";
83
+ })[];
64
84
  };
65
85
  /**
66
86
  * Instructions are executed in 2 steps:
@@ -74,98 +94,34 @@ export declare const toDepositXcmOnDest: (version: XcmVersion, account: any) =>
74
94
  * @param transferAssetLocation - transfer asset xcm location
75
95
  * @returns xcm ethereum bridge instructions
76
96
  */
77
- export declare const toBridgeXcmOnDest: (version: XcmVersion, account: any, sender: any, transferAssetLocation: object, messageId: string | undefined) => {
78
- [x: string]: ({
79
- SetAppendix: {
80
- DepositAsset: {
81
- assets: {
82
- Wild: string;
83
- };
84
- beneficiary: {
85
- parents: number;
86
- interior: {
87
- X1: any;
88
- };
89
- };
90
- };
91
- }[];
92
- InitiateReserveWithdraw?: undefined;
93
- SetTopic?: undefined;
94
- } | {
95
- InitiateReserveWithdraw: {
96
- assets: {
97
- Wild: {
98
- AllOf: {
99
- id: object;
100
- fun: string;
101
- };
102
- };
103
- };
97
+ export declare const toBridgeXcmOnDest: (version: XcmVersion, account: any, sender: any, transferAssetLocation: {
98
+ parents: number;
99
+ interior: XcmV3Junctions;
100
+ }, messageId: any) => {
101
+ type: XcmVersion;
102
+ value: (({
103
+ type: "SetTopic";
104
+ value: import("polkadot-api").FixedSizeBinary<32>;
105
+ } & {
106
+ type: "SetTopic";
107
+ }) | ({
108
+ type: "SetAppendix";
109
+ value: XcmV4Instruction[];
110
+ } & {
111
+ type: "SetAppendix";
112
+ }) | ({
113
+ type: "InitiateReserveWithdraw";
114
+ value: {
115
+ assets: XcmV4AssetAssetFilter;
104
116
  reserve: {
105
117
  parents: number;
106
- interior: {
107
- X1: {
108
- GlobalConsensus: {
109
- Ethereum: {
110
- chain_id: number;
111
- };
112
- };
113
- }[];
114
- };
118
+ interior: XcmV3Junctions;
115
119
  };
116
- xcm: ({
117
- BuyExecution: {
118
- fees: {
119
- id: {
120
- parents: number;
121
- interior: {
122
- X1: any;
123
- Here?: undefined;
124
- };
125
- } | {
126
- parents: number;
127
- interior: {
128
- Here: null;
129
- X1?: undefined;
130
- };
131
- };
132
- fun: {
133
- Fungible: number;
134
- };
135
- };
136
- weightLimit: string;
137
- };
138
- DepositAsset?: undefined;
139
- SetTopic?: undefined;
140
- } | {
141
- DepositAsset: {
142
- assets: {
143
- Wild: {
144
- AllCounted: number;
145
- };
146
- };
147
- beneficiary: {
148
- parents: number;
149
- interior: {
150
- X1: any;
151
- };
152
- };
153
- };
154
- BuyExecution?: undefined;
155
- SetTopic?: undefined;
156
- } | {
157
- SetTopic: string | undefined;
158
- BuyExecution?: undefined;
159
- DepositAsset?: undefined;
160
- })[];
120
+ xcm: XcmV4Instruction[];
161
121
  };
162
- SetAppendix?: undefined;
163
- SetTopic?: undefined;
164
- } | {
165
- SetTopic: string | undefined;
166
- SetAppendix?: undefined;
167
- InitiateReserveWithdraw?: undefined;
168
- })[];
122
+ } & {
123
+ type: "InitiateReserveWithdraw";
124
+ }))[];
169
125
  };
170
126
  /**
171
127
  * Instructions are executed in 3 steps:
@@ -185,138 +141,128 @@ export declare const toBridgeXcmOnDest: (version: XcmVersion, account: any, send
185
141
  * @param transactWeight - transact weight
186
142
  * @returns xcm transact message instructions
187
143
  */
188
- export declare const toTransactMessage: (version: XcmVersion, account: any, transactFeeLocation: object, transactFeeAmount: any, transactCall: `0x${string}`, transactWeight: TxWeight) => {
189
- [x: string]: ({
190
- WithdrawAsset: {
191
- id: object;
192
- fun: {
193
- Fungible: any;
194
- };
195
- }[];
196
- BuyExecution?: undefined;
197
- Transact?: undefined;
198
- RefundSurplus?: undefined;
199
- DepositAsset?: undefined;
200
- } | {
201
- BuyExecution: {
144
+ export declare const toTransactMessage: (version: XcmVersion, account: any, transactFeeLocation: {
145
+ parents: number;
146
+ interior: XcmV3Junctions;
147
+ }, transactFeeAmount: any, transactCall: Binary, transactWeight: TxWeight) => {
148
+ type: XcmVersion;
149
+ value: (({
150
+ type: "BuyExecution";
151
+ value: {
202
152
  fees: {
203
- id: object;
204
- fun: {
205
- Fungible: any;
153
+ id: {
154
+ parents: number;
155
+ interior: XcmV3Junctions;
206
156
  };
157
+ fun: XcmV3MultiassetFungibility;
207
158
  };
208
- weightLimit: string;
209
- };
210
- WithdrawAsset?: undefined;
211
- Transact?: undefined;
212
- RefundSurplus?: undefined;
213
- DepositAsset?: undefined;
214
- } | {
215
- Transact: {
216
- originKind: string;
217
- requireWeightAtMost: TxWeight;
218
- call: {
219
- encoded: `0x${string}`;
220
- };
159
+ weight_limit: XcmV3WeightLimit;
221
160
  };
222
- WithdrawAsset?: undefined;
223
- BuyExecution?: undefined;
224
- RefundSurplus?: undefined;
225
- DepositAsset?: undefined;
226
- } | {
227
- RefundSurplus: {};
228
- WithdrawAsset?: undefined;
229
- BuyExecution?: undefined;
230
- Transact?: undefined;
231
- DepositAsset?: undefined;
232
- } | {
233
- DepositAsset: {
234
- assets: {
235
- Wild: {
236
- AllCounted: number;
237
- };
238
- };
161
+ } & {
162
+ type: "BuyExecution";
163
+ }) | ({
164
+ type: "DepositAsset";
165
+ value: {
166
+ assets: XcmV4AssetAssetFilter;
239
167
  beneficiary: {
240
168
  parents: number;
241
- interior: {
242
- X1: any;
243
- };
169
+ interior: XcmV3Junctions;
244
170
  };
245
171
  };
246
- WithdrawAsset?: undefined;
247
- BuyExecution?: undefined;
248
- Transact?: undefined;
249
- RefundSurplus?: undefined;
250
- })[];
251
- };
252
- export declare const toTransferMessage: (version: XcmVersion, account: any, transferAssetLocation: object, transferAssetAmount: any, transferFeeAmount: any, receiver: any) => {
253
- [x: string]: ({
254
- WithdrawAsset: {
255
- id: object;
256
- fun: {
257
- Fungible: any;
172
+ } & {
173
+ type: "DepositAsset";
174
+ }) | ({
175
+ type: "WithdrawAsset";
176
+ value: {
177
+ id: {
178
+ parents: number;
179
+ interior: XcmV3Junctions;
258
180
  };
181
+ fun: XcmV3MultiassetFungibility;
259
182
  }[];
260
- BuyExecution?: undefined;
261
- TransferAsset?: undefined;
262
- RefundSurplus?: undefined;
263
- DepositAsset?: undefined;
264
- } | {
265
- BuyExecution: {
183
+ } & {
184
+ type: "WithdrawAsset";
185
+ }) | ({
186
+ type: "Transact";
187
+ value: {
188
+ origin_kind: XcmV2OriginKind;
189
+ require_weight_at_most: {
190
+ ref_time: bigint;
191
+ proof_size: bigint;
192
+ };
193
+ call: Binary;
194
+ };
195
+ } & {
196
+ type: "Transact";
197
+ }) | ({
198
+ type: "RefundSurplus";
199
+ value: undefined;
200
+ } & {
201
+ type: "RefundSurplus";
202
+ }))[];
203
+ };
204
+ export declare const toTransferMessage: (version: XcmVersion, account: any, transferAssetLocation: {
205
+ parents: number;
206
+ interior: XcmV3Junctions;
207
+ }, transferAssetAmount: any, transferFeeAmount: any, receiver: any) => {
208
+ type: XcmVersion;
209
+ value: (({
210
+ type: "BuyExecution";
211
+ value: {
266
212
  fees: {
267
- id: object;
268
- fun: {
269
- Fungible: any;
213
+ id: {
214
+ parents: number;
215
+ interior: XcmV3Junctions;
270
216
  };
217
+ fun: XcmV3MultiassetFungibility;
271
218
  };
272
- weightLimit: string;
219
+ weight_limit: XcmV3WeightLimit;
273
220
  };
274
- WithdrawAsset?: undefined;
275
- TransferAsset?: undefined;
276
- RefundSurplus?: undefined;
277
- DepositAsset?: undefined;
278
- } | {
279
- TransferAsset: {
280
- assets: {
281
- id: object;
282
- fun: {
283
- Fungible: any;
284
- };
285
- }[];
221
+ } & {
222
+ type: "BuyExecution";
223
+ }) | ({
224
+ type: "DepositAsset";
225
+ value: {
226
+ assets: XcmV4AssetAssetFilter;
286
227
  beneficiary: {
287
228
  parents: number;
288
- interior: {
289
- X1: any;
290
- };
229
+ interior: XcmV3Junctions;
291
230
  };
292
231
  };
293
- WithdrawAsset?: undefined;
294
- BuyExecution?: undefined;
295
- RefundSurplus?: undefined;
296
- DepositAsset?: undefined;
297
- } | {
298
- RefundSurplus: {};
299
- WithdrawAsset?: undefined;
300
- BuyExecution?: undefined;
301
- TransferAsset?: undefined;
302
- DepositAsset?: undefined;
303
- } | {
304
- DepositAsset: {
232
+ } & {
233
+ type: "DepositAsset";
234
+ }) | ({
235
+ type: "WithdrawAsset";
236
+ value: {
237
+ id: {
238
+ parents: number;
239
+ interior: XcmV3Junctions;
240
+ };
241
+ fun: XcmV3MultiassetFungibility;
242
+ }[];
243
+ } & {
244
+ type: "WithdrawAsset";
245
+ }) | ({
246
+ type: "RefundSurplus";
247
+ value: undefined;
248
+ } & {
249
+ type: "RefundSurplus";
250
+ }) | ({
251
+ type: "TransferAsset";
252
+ value: {
305
253
  assets: {
306
- Wild: {
307
- AllCounted: number;
254
+ id: {
255
+ parents: number;
256
+ interior: XcmV3Junctions;
308
257
  };
309
- };
258
+ fun: XcmV3MultiassetFungibility;
259
+ }[];
310
260
  beneficiary: {
311
261
  parents: number;
312
- interior: {
313
- X1: any;
314
- };
262
+ interior: XcmV3Junctions;
315
263
  };
316
264
  };
317
- WithdrawAsset?: undefined;
318
- BuyExecution?: undefined;
319
- TransferAsset?: undefined;
320
- RefundSurplus?: undefined;
321
- })[];
265
+ } & {
266
+ type: "TransferAsset";
267
+ }))[];
322
268
  };
@@ -12,7 +12,3 @@ export declare enum XcmTransferType {
12
12
  RemoteReserve = "RemoteReserve"
13
13
  }
14
14
  export type Parents = 0 | 1 | 2;
15
- /**
16
- * Encoding mode for the XcmEncoder (typed API vs unsafe API)
17
- */
18
- export type EncodingMode = 'typed' | 'unsafe';
@@ -1,14 +1,20 @@
1
1
  import { Parachain } from '@galacticcouncil/xc-core';
2
- export declare function getExtrinsicAccount(address: string): {
3
- AccountKey20: {
4
- key: string;
2
+ import { FixedSizeBinary } from 'polkadot-api';
3
+ export declare function getExtrinsicAccount(address: string): ({
4
+ type: "AccountKey20";
5
+ value: {
6
+ network?: import("@galacticcouncil/descriptors").XcmV3JunctionNetworkId | undefined;
7
+ key: FixedSizeBinary<20>;
5
8
  };
6
- AccountId32?: undefined;
7
- } | {
8
- AccountId32: {
9
- id: string;
10
- network: null;
9
+ } & {
10
+ type: "AccountKey20";
11
+ }) | ({
12
+ type: "AccountId32";
13
+ value: {
14
+ network?: import("@galacticcouncil/descriptors").XcmV3JunctionNetworkId | undefined;
15
+ id: FixedSizeBinary<32>;
11
16
  };
12
- AccountKey20?: undefined;
13
- };
17
+ } & {
18
+ type: "AccountId32";
19
+ });
14
20
  export declare function getDerivativeAccount(from: Parachain, fromAddress: string, to: Parachain): string;
@@ -1,4 +1,2 @@
1
1
  import { Asset, Parachain } from '@galacticcouncil/xc-core';
2
- export declare function locationOrError(chain: Parachain, asset: Asset): {
3
- [x: string]: any;
4
- };
2
+ export declare function locationOrError(chain: Parachain, asset: Asset): import("@galacticcouncil/xc-core").XcmLocation;
@@ -1,65 +1,51 @@
1
+ import { XcmV3Junction } from '@galacticcouncil/descriptors';
1
2
  export declare const ETHER_TOKEN_ADDRESS = "0x0000000000000000000000000000000000000000";
2
3
  export declare function bridgeLocation(ethChainId: number): {
3
4
  parents: number;
4
5
  interior: {
5
- X1: {
6
- GlobalConsensus: {
7
- Ethereum: {
8
- chain_id: number;
9
- };
10
- };
11
- }[];
6
+ type: "X1";
7
+ value: XcmV3Junction;
8
+ } & {
9
+ type: "X1";
12
10
  };
13
11
  };
14
12
  export declare function parachainLocation(paraId: number): {
15
13
  parents: number;
16
14
  interior: {
17
- X1: {
18
- Parachain: number;
19
- }[];
15
+ type: "X1";
16
+ value: XcmV3Junction;
17
+ } & {
18
+ type: "X1";
20
19
  };
21
20
  };
22
21
  export declare function erc20Location(ethChainId: number, tokenAddress: string): {
23
22
  parents: number;
24
23
  interior: {
25
- X1: {
26
- GlobalConsensus: {
27
- Ethereum: {
28
- chain_id: number;
29
- };
30
- };
31
- }[];
24
+ type: "X1";
25
+ value: XcmV3Junction;
26
+ } & {
27
+ type: "X1";
32
28
  };
33
29
  } | {
34
30
  parents: number;
35
31
  interior: {
36
- X2: ({
37
- GlobalConsensus: {
38
- Ethereum: {
39
- chain_id: number;
40
- };
41
- };
42
- } | {
43
- AccountKey20: {
44
- key: string;
45
- };
46
- })[];
32
+ type: "X2";
33
+ value: import("polkadot-api").FixedSizeArray<2, XcmV3Junction>;
34
+ } & {
35
+ type: "X2";
47
36
  };
48
37
  };
49
38
  export declare function erc20LocationReanchored(tokenAddress: string): {
50
39
  parents: number;
51
40
  interior: {
52
- here: null;
53
- X1?: undefined;
41
+ type: string;
54
42
  };
55
43
  } | {
56
44
  parents: number;
57
45
  interior: {
58
- X1: {
59
- AccountKey20: {
60
- key: string;
61
- };
62
- }[];
63
- here?: undefined;
46
+ type: "X1";
47
+ value: XcmV3Junction;
48
+ } & {
49
+ type: "X1";
64
50
  };
65
51
  };
@@ -1,12 +1,10 @@
1
1
  import { XcmVersion } from '../types';
2
2
  /**
3
- * Get extrinsic X1 interior
3
+ * Normalizes an asset location to the specified XCM version format
4
4
  *
5
5
  * @param assetLocation - asset xcm location
6
- * @param version - xcm version
7
- * @returns normalized x1 interior if version prior to V4
6
+ * @param version - target xcm version
7
+ * @returns normalized location
8
8
  */
9
- export declare function getExtrinsicAssetLocation(assetLocation: Record<string, any>, version: XcmVersion): Record<string, any> | {
10
- Concrete: {};
11
- };
12
- export declare function getX1Junction(version: XcmVersion, junction: any): any;
9
+ export declare function getExtrinsicAssetLocation(assetLocation: Record<string, any>, version: XcmVersion): any;
10
+ export declare function normalizeLocation(assetLocation: Record<string, any>): Record<string, any>;
@@ -1,23 +1,35 @@
1
+ import { XcmV3Junction } from '@galacticcouncil/descriptors';
1
2
  import { Parachain } from '@galacticcouncil/xc-core';
2
3
  import { XcmVersion } from './types';
3
4
  export declare const toDest: (version: XcmVersion, destination: Parachain, account: any) => {
4
- [x: string]: {
5
+ type: XcmVersion;
6
+ value: {
5
7
  parents: number;
6
8
  interior: {
7
- X1: any;
9
+ type: "X1";
10
+ value: XcmV3Junction;
11
+ } & {
12
+ type: "X1";
8
13
  };
9
14
  };
10
15
  } | {
11
- [x: string]: {
16
+ type: XcmVersion;
17
+ value: {
12
18
  parents: number;
13
19
  interior: {
14
- X2: any[];
20
+ type: "X2";
21
+ value: import("polkadot-api").FixedSizeArray<2, XcmV3Junction>;
22
+ } & {
23
+ type: "X2";
15
24
  };
16
25
  };
17
26
  };
18
27
  export declare const toAsset: (assetLocation: object, amount: any) => {
19
28
  id: object;
20
29
  fun: {
21
- Fungible: any;
30
+ type: "Fungible";
31
+ value: bigint;
32
+ } & {
33
+ type: "Fungible";
22
34
  };
23
35
  };