@moonbeam-network/xcm-builder 4.1.2 → 4.2.1
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/index.d.ts +2 -1
- package/build/index.mjs +116 -20
- package/build/index.mjs.map +1 -1
- package/package.json +8 -6
package/build/index.d.ts
CHANGED
|
@@ -379,7 +379,8 @@ declare function polkadotXcm$1(): {
|
|
|
379
379
|
X2AndFeeHere: () => ExtrinsicConfigBuilder;
|
|
380
380
|
};
|
|
381
381
|
transferAssetsUsingTypeAndThen: () => {
|
|
382
|
-
here: () => ExtrinsicConfigBuilder;
|
|
382
|
+
here: (parents?: number) => ExtrinsicConfigBuilder;
|
|
383
|
+
X2: (parents?: number) => ExtrinsicConfigBuilder;
|
|
383
384
|
globalConsensusEthereum: () => ExtrinsicConfigBuilder;
|
|
384
385
|
};
|
|
385
386
|
transferAssetsToEcosystem: () => {
|
package/build/index.mjs
CHANGED
|
@@ -1479,6 +1479,7 @@ function eqBalances() {
|
|
|
1479
1479
|
}
|
|
1480
1480
|
|
|
1481
1481
|
// src/extrinsic/pallets/polkadotXcm/polkadotXcm.util.ts
|
|
1482
|
+
import { Ecosystem } from "@moonbeam-network/xcm-types";
|
|
1482
1483
|
function getPolkadotXcmExtrinsicArgs({
|
|
1483
1484
|
assets: assets3,
|
|
1484
1485
|
destinationAddress,
|
|
@@ -1519,6 +1520,23 @@ function getPolkadotXcmExtrinsicArgs({
|
|
|
1519
1520
|
"Unlimited"
|
|
1520
1521
|
];
|
|
1521
1522
|
}
|
|
1523
|
+
function isKusamaDestination(destination) {
|
|
1524
|
+
return destination.ecosystem === Ecosystem.Kusama || destination.ecosystem === Ecosystem.MoonsamaRelay;
|
|
1525
|
+
}
|
|
1526
|
+
function isPolkadotDestination(destination) {
|
|
1527
|
+
return destination.ecosystem === Ecosystem.Polkadot || destination.ecosystem === Ecosystem.MoonlamaRelay;
|
|
1528
|
+
}
|
|
1529
|
+
function getGlobalConsensus(destination) {
|
|
1530
|
+
if (isKusamaDestination(destination)) {
|
|
1531
|
+
return "Kusama";
|
|
1532
|
+
}
|
|
1533
|
+
if (isPolkadotDestination(destination)) {
|
|
1534
|
+
return "Polkadot";
|
|
1535
|
+
}
|
|
1536
|
+
return {
|
|
1537
|
+
ByGenesis: destination.relayGenesisHash
|
|
1538
|
+
};
|
|
1539
|
+
}
|
|
1522
1540
|
function getEcosystemTransferExtrinsicArgs({
|
|
1523
1541
|
assets: assets3,
|
|
1524
1542
|
destinationAddress,
|
|
@@ -1527,6 +1545,7 @@ function getEcosystemTransferExtrinsicArgs({
|
|
|
1527
1545
|
feeIndex = 0
|
|
1528
1546
|
}) {
|
|
1529
1547
|
const version = getExtrinsicArgumentVersion(func);
|
|
1548
|
+
const globalConsensus = getGlobalConsensus(destination);
|
|
1530
1549
|
return [
|
|
1531
1550
|
// dest
|
|
1532
1551
|
{
|
|
@@ -1534,11 +1553,7 @@ function getEcosystemTransferExtrinsicArgs({
|
|
|
1534
1553
|
parents: 2,
|
|
1535
1554
|
interior: {
|
|
1536
1555
|
X2: [
|
|
1537
|
-
{
|
|
1538
|
-
GlobalConsensus: {
|
|
1539
|
-
ByGenesis: destination.relayGenesisHash
|
|
1540
|
-
}
|
|
1541
|
-
},
|
|
1556
|
+
{ GlobalConsensus: globalConsensus },
|
|
1542
1557
|
{
|
|
1543
1558
|
Parachain: destination.parachainId
|
|
1544
1559
|
}
|
|
@@ -2033,7 +2048,7 @@ function polkadotXcm() {
|
|
|
2033
2048
|
transferAssetsUsingTypeAndThen: () => {
|
|
2034
2049
|
const func = "transferAssetsUsingTypeAndThen";
|
|
2035
2050
|
return {
|
|
2036
|
-
here: () => ({
|
|
2051
|
+
here: (parents = 0) => ({
|
|
2037
2052
|
build: (params) => new ExtrinsicConfig({
|
|
2038
2053
|
module: pallet2,
|
|
2039
2054
|
func,
|
|
@@ -2056,7 +2071,7 @@ function polkadotXcm() {
|
|
|
2056
2071
|
[version]: [
|
|
2057
2072
|
{
|
|
2058
2073
|
id: {
|
|
2059
|
-
parents
|
|
2074
|
+
parents,
|
|
2060
2075
|
interior: "Here"
|
|
2061
2076
|
},
|
|
2062
2077
|
fun: {
|
|
@@ -2068,7 +2083,7 @@ function polkadotXcm() {
|
|
|
2068
2083
|
"LocalReserve",
|
|
2069
2084
|
{
|
|
2070
2085
|
[version]: {
|
|
2071
|
-
parents
|
|
2086
|
+
parents,
|
|
2072
2087
|
interior: "Here"
|
|
2073
2088
|
}
|
|
2074
2089
|
},
|
|
@@ -2097,6 +2112,92 @@ function polkadotXcm() {
|
|
|
2097
2112
|
}
|
|
2098
2113
|
})
|
|
2099
2114
|
}),
|
|
2115
|
+
X2: (parents = 0) => ({
|
|
2116
|
+
build: (params) => new ExtrinsicConfig({
|
|
2117
|
+
module: pallet2,
|
|
2118
|
+
func,
|
|
2119
|
+
getArgs: (extrinsicFunction) => {
|
|
2120
|
+
const version = getExtrinsicArgumentVersion(extrinsicFunction);
|
|
2121
|
+
const isSameAsset = params.asset.isSame(params.fee);
|
|
2122
|
+
const shouldFeeAssetPrecede = shouldFeeAssetPrecedeAsset(params);
|
|
2123
|
+
const asset = {
|
|
2124
|
+
parents: 0,
|
|
2125
|
+
interior: {
|
|
2126
|
+
X2: [
|
|
2127
|
+
{
|
|
2128
|
+
PalletInstance: params.asset.getAssetPalletInstance()
|
|
2129
|
+
},
|
|
2130
|
+
{
|
|
2131
|
+
GeneralIndex: params.asset.getAssetId()
|
|
2132
|
+
}
|
|
2133
|
+
]
|
|
2134
|
+
}
|
|
2135
|
+
};
|
|
2136
|
+
const assetWithAmount = {
|
|
2137
|
+
id: asset,
|
|
2138
|
+
fun: { Fungible: params.asset.amount }
|
|
2139
|
+
};
|
|
2140
|
+
const feeAsset = {
|
|
2141
|
+
parents,
|
|
2142
|
+
interior: "Here"
|
|
2143
|
+
};
|
|
2144
|
+
const feeAssetWithAmount = {
|
|
2145
|
+
id: feeAsset,
|
|
2146
|
+
fun: { Fungible: params.fee.amount }
|
|
2147
|
+
};
|
|
2148
|
+
const assets3 = isSameAsset ? [assetWithAmount] : shouldFeeAssetPrecede ? [feeAssetWithAmount, assetWithAmount] : [assetWithAmount, feeAssetWithAmount];
|
|
2149
|
+
return [
|
|
2150
|
+
// dest
|
|
2151
|
+
{
|
|
2152
|
+
[version]: {
|
|
2153
|
+
parents: 1,
|
|
2154
|
+
interior: {
|
|
2155
|
+
X1: [
|
|
2156
|
+
{
|
|
2157
|
+
Parachain: params.destination.parachainId
|
|
2158
|
+
}
|
|
2159
|
+
]
|
|
2160
|
+
}
|
|
2161
|
+
}
|
|
2162
|
+
},
|
|
2163
|
+
// assets
|
|
2164
|
+
{
|
|
2165
|
+
[version]: assets3
|
|
2166
|
+
},
|
|
2167
|
+
// assetsTransferType
|
|
2168
|
+
"LocalReserve",
|
|
2169
|
+
// remoteFeesId
|
|
2170
|
+
{
|
|
2171
|
+
[version]: isSameAsset ? asset : feeAsset
|
|
2172
|
+
},
|
|
2173
|
+
// feesTransferType
|
|
2174
|
+
"LocalReserve",
|
|
2175
|
+
// customXcmOnDest
|
|
2176
|
+
{
|
|
2177
|
+
[version]: [
|
|
2178
|
+
{
|
|
2179
|
+
DepositAsset: {
|
|
2180
|
+
assets: {
|
|
2181
|
+
Wild: { AllCounted: isSameAsset ? 1 : 2 }
|
|
2182
|
+
},
|
|
2183
|
+
beneficiary: {
|
|
2184
|
+
parents: 0,
|
|
2185
|
+
interior: {
|
|
2186
|
+
X1: [
|
|
2187
|
+
getExtrinsicAccount(params.destinationAddress)
|
|
2188
|
+
]
|
|
2189
|
+
}
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
}
|
|
2193
|
+
]
|
|
2194
|
+
},
|
|
2195
|
+
// weightLimit
|
|
2196
|
+
"Unlimited"
|
|
2197
|
+
];
|
|
2198
|
+
}
|
|
2199
|
+
})
|
|
2200
|
+
}),
|
|
2100
2201
|
// TODO we could pass a parameter globalConsensus in the chain asset if we need a different one
|
|
2101
2202
|
globalConsensusEthereum: () => ({
|
|
2102
2203
|
build: (params) => new ExtrinsicConfig({
|
|
@@ -2269,9 +2370,9 @@ function polkadotXcm() {
|
|
|
2269
2370
|
interior: {
|
|
2270
2371
|
X3: [
|
|
2271
2372
|
{
|
|
2272
|
-
GlobalConsensus:
|
|
2273
|
-
|
|
2274
|
-
|
|
2373
|
+
GlobalConsensus: getGlobalConsensus(
|
|
2374
|
+
params.destination
|
|
2375
|
+
)
|
|
2275
2376
|
},
|
|
2276
2377
|
{
|
|
2277
2378
|
Parachain: params.destination.parachainId
|
|
@@ -2309,6 +2410,7 @@ function polkadotXcm() {
|
|
|
2309
2410
|
const assetInDestination = params.destination.getChainAsset(
|
|
2310
2411
|
params.asset
|
|
2311
2412
|
);
|
|
2413
|
+
const globalConsensus = getGlobalConsensus(params.destination);
|
|
2312
2414
|
const assets3 = [
|
|
2313
2415
|
{
|
|
2314
2416
|
id: normalizeConcrete(version, {
|
|
@@ -2316,9 +2418,7 @@ function polkadotXcm() {
|
|
|
2316
2418
|
interior: {
|
|
2317
2419
|
X3: [
|
|
2318
2420
|
{
|
|
2319
|
-
GlobalConsensus:
|
|
2320
|
-
ByGenesis: params.destination.relayGenesisHash
|
|
2321
|
-
}
|
|
2421
|
+
GlobalConsensus: globalConsensus
|
|
2322
2422
|
},
|
|
2323
2423
|
{
|
|
2324
2424
|
Parachain: params.destination.parachainId
|
|
@@ -2339,9 +2439,7 @@ function polkadotXcm() {
|
|
|
2339
2439
|
interior: {
|
|
2340
2440
|
X4: [
|
|
2341
2441
|
{
|
|
2342
|
-
GlobalConsensus:
|
|
2343
|
-
ByGenesis: params.destination.relayGenesisHash
|
|
2344
|
-
}
|
|
2442
|
+
GlobalConsensus: globalConsensus
|
|
2345
2443
|
},
|
|
2346
2444
|
{
|
|
2347
2445
|
Parachain: params.destination.parachainId
|
|
@@ -2761,9 +2859,7 @@ function getUniversalOriginInstruction(source) {
|
|
|
2761
2859
|
}
|
|
2762
2860
|
return {
|
|
2763
2861
|
UniversalOrigin: {
|
|
2764
|
-
GlobalConsensus:
|
|
2765
|
-
ByGenesis: source.relayGenesisHash
|
|
2766
|
-
}
|
|
2862
|
+
GlobalConsensus: getGlobalConsensus(source)
|
|
2767
2863
|
}
|
|
2768
2864
|
};
|
|
2769
2865
|
}
|