@paraspell/sdk-core 8.3.1 → 8.4.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/dist/index.cjs +652 -446
- package/dist/index.d.ts +19 -8
- package/dist/index.mjs +649 -447
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2717,7 +2717,7 @@ var Darwinia$3 = {
|
|
|
2717
2717
|
relayChainAssetSymbol: "DOT",
|
|
2718
2718
|
nativeAssetSymbol: "RING",
|
|
2719
2719
|
isEVM: true,
|
|
2720
|
-
supportsDryRunApi:
|
|
2720
|
+
supportsDryRunApi: true,
|
|
2721
2721
|
nativeAssets: [
|
|
2722
2722
|
{
|
|
2723
2723
|
symbol: "RING",
|
|
@@ -2840,6 +2840,84 @@ var Hydration$3 = {
|
|
|
2840
2840
|
existentialDeposit: "10000",
|
|
2841
2841
|
alias: "USDC1"
|
|
2842
2842
|
},
|
|
2843
|
+
{
|
|
2844
|
+
assetId: "1000796",
|
|
2845
|
+
symbol: "LDO",
|
|
2846
|
+
decimals: 18,
|
|
2847
|
+
multiLocation: {
|
|
2848
|
+
parents: 2,
|
|
2849
|
+
interior: {
|
|
2850
|
+
X2: [
|
|
2851
|
+
{
|
|
2852
|
+
GlobalConsensus: {
|
|
2853
|
+
Ethereum: {
|
|
2854
|
+
chainId: 1
|
|
2855
|
+
}
|
|
2856
|
+
}
|
|
2857
|
+
},
|
|
2858
|
+
{
|
|
2859
|
+
AccountKey20: {
|
|
2860
|
+
network: null,
|
|
2861
|
+
key: "0x5a98fcbea516cf06857215779fd812ca3bef1b32"
|
|
2862
|
+
}
|
|
2863
|
+
}
|
|
2864
|
+
]
|
|
2865
|
+
}
|
|
2866
|
+
},
|
|
2867
|
+
existentialDeposit: "5102040816326530"
|
|
2868
|
+
},
|
|
2869
|
+
{
|
|
2870
|
+
assetId: "1000795",
|
|
2871
|
+
symbol: "SKY",
|
|
2872
|
+
decimals: 18,
|
|
2873
|
+
multiLocation: {
|
|
2874
|
+
parents: 2,
|
|
2875
|
+
interior: {
|
|
2876
|
+
X2: [
|
|
2877
|
+
{
|
|
2878
|
+
GlobalConsensus: {
|
|
2879
|
+
Ethereum: {
|
|
2880
|
+
chainId: 1
|
|
2881
|
+
}
|
|
2882
|
+
}
|
|
2883
|
+
},
|
|
2884
|
+
{
|
|
2885
|
+
AccountKey20: {
|
|
2886
|
+
network: null,
|
|
2887
|
+
key: "0x56072c95faa701256059aa122697b133aded9279"
|
|
2888
|
+
}
|
|
2889
|
+
}
|
|
2890
|
+
]
|
|
2891
|
+
}
|
|
2892
|
+
},
|
|
2893
|
+
existentialDeposit: "211685012701101000"
|
|
2894
|
+
},
|
|
2895
|
+
{
|
|
2896
|
+
assetId: "1000794",
|
|
2897
|
+
symbol: "LINK",
|
|
2898
|
+
decimals: 18,
|
|
2899
|
+
multiLocation: {
|
|
2900
|
+
parents: 2,
|
|
2901
|
+
interior: {
|
|
2902
|
+
X2: [
|
|
2903
|
+
{
|
|
2904
|
+
GlobalConsensus: {
|
|
2905
|
+
Ethereum: {
|
|
2906
|
+
chainId: 1
|
|
2907
|
+
}
|
|
2908
|
+
}
|
|
2909
|
+
},
|
|
2910
|
+
{
|
|
2911
|
+
AccountKey20: {
|
|
2912
|
+
network: null,
|
|
2913
|
+
key: "0x514910771af9ca656af840dff83e8264ecf986ca"
|
|
2914
|
+
}
|
|
2915
|
+
}
|
|
2916
|
+
]
|
|
2917
|
+
}
|
|
2918
|
+
},
|
|
2919
|
+
existentialDeposit: "436681222707424"
|
|
2920
|
+
},
|
|
2843
2921
|
{
|
|
2844
2922
|
assetId: "1000625",
|
|
2845
2923
|
symbol: "sUSDe",
|
|
@@ -2958,6 +3036,32 @@ var Hydration$3 = {
|
|
|
2958
3036
|
existentialDeposit: "9910802775024780",
|
|
2959
3037
|
alias: "sUSDS1"
|
|
2960
3038
|
},
|
|
3039
|
+
{
|
|
3040
|
+
assetId: "1000809",
|
|
3041
|
+
symbol: "wstETH",
|
|
3042
|
+
decimals: 18,
|
|
3043
|
+
multiLocation: {
|
|
3044
|
+
parents: 2,
|
|
3045
|
+
interior: {
|
|
3046
|
+
X2: [
|
|
3047
|
+
{
|
|
3048
|
+
GlobalConsensus: {
|
|
3049
|
+
Ethereum: {
|
|
3050
|
+
chainId: 1
|
|
3051
|
+
}
|
|
3052
|
+
}
|
|
3053
|
+
},
|
|
3054
|
+
{
|
|
3055
|
+
AccountKey20: {
|
|
3056
|
+
network: null,
|
|
3057
|
+
key: "0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0"
|
|
3058
|
+
}
|
|
3059
|
+
}
|
|
3060
|
+
]
|
|
3061
|
+
}
|
|
3062
|
+
},
|
|
3063
|
+
existentialDeposit: "3244646333550"
|
|
3064
|
+
},
|
|
2961
3065
|
{
|
|
2962
3066
|
assetId: "1000767",
|
|
2963
3067
|
symbol: "USDT",
|
|
@@ -3999,6 +4103,20 @@ var Hydration$3 = {
|
|
|
3999
4103
|
}
|
|
4000
4104
|
},
|
|
4001
4105
|
existentialDeposit: "21367521367521400"
|
|
4106
|
+
},
|
|
4107
|
+
{
|
|
4108
|
+
assetId: "3370",
|
|
4109
|
+
symbol: "LAOS",
|
|
4110
|
+
decimals: 18,
|
|
4111
|
+
multiLocation: {
|
|
4112
|
+
parents: 1,
|
|
4113
|
+
interior: {
|
|
4114
|
+
X1: {
|
|
4115
|
+
Parachain: 3370
|
|
4116
|
+
}
|
|
4117
|
+
}
|
|
4118
|
+
},
|
|
4119
|
+
existentialDeposit: "1"
|
|
4002
4120
|
}
|
|
4003
4121
|
]
|
|
4004
4122
|
};
|
|
@@ -4381,12 +4499,12 @@ var Interlay$3 = {
|
|
|
4381
4499
|
};
|
|
4382
4500
|
var Litentry$3 = {
|
|
4383
4501
|
relayChainAssetSymbol: "DOT",
|
|
4384
|
-
nativeAssetSymbol: "
|
|
4502
|
+
nativeAssetSymbol: "HEI",
|
|
4385
4503
|
isEVM: false,
|
|
4386
4504
|
supportsDryRunApi: false,
|
|
4387
4505
|
nativeAssets: [
|
|
4388
4506
|
{
|
|
4389
|
-
symbol: "
|
|
4507
|
+
symbol: "HEI",
|
|
4390
4508
|
decimals: 18,
|
|
4391
4509
|
existentialDeposit: "100000000000000000"
|
|
4392
4510
|
}
|
|
@@ -4541,6 +4659,28 @@ var Moonbeam$3 = {
|
|
|
4541
4659
|
},
|
|
4542
4660
|
existentialDeposit: "1"
|
|
4543
4661
|
},
|
|
4662
|
+
{
|
|
4663
|
+
assetId: "66249247788835743307843320271452141931",
|
|
4664
|
+
symbol: "xcvBNC",
|
|
4665
|
+
decimals: 12,
|
|
4666
|
+
multiLocation: {
|
|
4667
|
+
parents: 1,
|
|
4668
|
+
interior: {
|
|
4669
|
+
X2: [
|
|
4670
|
+
{
|
|
4671
|
+
Parachain: 2030
|
|
4672
|
+
},
|
|
4673
|
+
{
|
|
4674
|
+
GeneralKey: {
|
|
4675
|
+
length: 2,
|
|
4676
|
+
data: "0x0101000000000000000000000000000000000000000000000000000000000000"
|
|
4677
|
+
}
|
|
4678
|
+
}
|
|
4679
|
+
]
|
|
4680
|
+
}
|
|
4681
|
+
},
|
|
4682
|
+
existentialDeposit: "1"
|
|
4683
|
+
},
|
|
4544
4684
|
{
|
|
4545
4685
|
assetId: "125699734534028342599692732320197985871",
|
|
4546
4686
|
symbol: "xcRING",
|
|
@@ -10987,12 +11127,13 @@ var Ethereum = {
|
|
|
10987
11127
|
{
|
|
10988
11128
|
GlobalConsensus: {
|
|
10989
11129
|
Ethereum: {
|
|
10990
|
-
|
|
11130
|
+
chainId: 1
|
|
10991
11131
|
}
|
|
10992
11132
|
}
|
|
10993
11133
|
},
|
|
10994
11134
|
{
|
|
10995
11135
|
AccountKey20: {
|
|
11136
|
+
network: null,
|
|
10996
11137
|
key: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
|
|
10997
11138
|
}
|
|
10998
11139
|
}
|
|
@@ -11011,12 +11152,13 @@ var Ethereum = {
|
|
|
11011
11152
|
{
|
|
11012
11153
|
GlobalConsensus: {
|
|
11013
11154
|
Ethereum: {
|
|
11014
|
-
|
|
11155
|
+
chainId: 1
|
|
11015
11156
|
}
|
|
11016
11157
|
}
|
|
11017
11158
|
},
|
|
11018
11159
|
{
|
|
11019
11160
|
AccountKey20: {
|
|
11161
|
+
network: null,
|
|
11020
11162
|
key: "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599"
|
|
11021
11163
|
}
|
|
11022
11164
|
}
|
|
@@ -11035,12 +11177,13 @@ var Ethereum = {
|
|
|
11035
11177
|
{
|
|
11036
11178
|
GlobalConsensus: {
|
|
11037
11179
|
Ethereum: {
|
|
11038
|
-
|
|
11180
|
+
chainId: 1
|
|
11039
11181
|
}
|
|
11040
11182
|
}
|
|
11041
11183
|
},
|
|
11042
11184
|
{
|
|
11043
11185
|
AccountKey20: {
|
|
11186
|
+
network: null,
|
|
11044
11187
|
key: "0x95ad61b0a150d79219dcf64e1e6cc01f0b64c4ce"
|
|
11045
11188
|
}
|
|
11046
11189
|
}
|
|
@@ -11059,12 +11202,13 @@ var Ethereum = {
|
|
|
11059
11202
|
{
|
|
11060
11203
|
GlobalConsensus: {
|
|
11061
11204
|
Ethereum: {
|
|
11062
|
-
|
|
11205
|
+
chainId: 1
|
|
11063
11206
|
}
|
|
11064
11207
|
}
|
|
11065
11208
|
},
|
|
11066
11209
|
{
|
|
11067
11210
|
AccountKey20: {
|
|
11211
|
+
network: null,
|
|
11068
11212
|
key: "0x6982508145454ce325ddbe47a25d4ec3d2311933"
|
|
11069
11213
|
}
|
|
11070
11214
|
}
|
|
@@ -11083,12 +11227,13 @@ var Ethereum = {
|
|
|
11083
11227
|
{
|
|
11084
11228
|
GlobalConsensus: {
|
|
11085
11229
|
Ethereum: {
|
|
11086
|
-
|
|
11230
|
+
chainId: 1
|
|
11087
11231
|
}
|
|
11088
11232
|
}
|
|
11089
11233
|
},
|
|
11090
11234
|
{
|
|
11091
11235
|
AccountKey20: {
|
|
11236
|
+
network: null,
|
|
11092
11237
|
key: "0x582d872a1b094fc48f5de31d3b73f2d9be47def1"
|
|
11093
11238
|
}
|
|
11094
11239
|
}
|
|
@@ -11107,12 +11252,13 @@ var Ethereum = {
|
|
|
11107
11252
|
{
|
|
11108
11253
|
GlobalConsensus: {
|
|
11109
11254
|
Ethereum: {
|
|
11110
|
-
|
|
11255
|
+
chainId: 1
|
|
11111
11256
|
}
|
|
11112
11257
|
}
|
|
11113
11258
|
},
|
|
11114
11259
|
{
|
|
11115
11260
|
AccountKey20: {
|
|
11261
|
+
network: null,
|
|
11116
11262
|
key: "0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0"
|
|
11117
11263
|
}
|
|
11118
11264
|
}
|
|
@@ -11131,12 +11277,13 @@ var Ethereum = {
|
|
|
11131
11277
|
{
|
|
11132
11278
|
GlobalConsensus: {
|
|
11133
11279
|
Ethereum: {
|
|
11134
|
-
|
|
11280
|
+
chainId: 1
|
|
11135
11281
|
}
|
|
11136
11282
|
}
|
|
11137
11283
|
},
|
|
11138
11284
|
{
|
|
11139
11285
|
AccountKey20: {
|
|
11286
|
+
network: null,
|
|
11140
11287
|
key: "0x18084fba666a33d37592fa2633fd49a74dd93a88"
|
|
11141
11288
|
}
|
|
11142
11289
|
}
|
|
@@ -11155,12 +11302,13 @@ var Ethereum = {
|
|
|
11155
11302
|
{
|
|
11156
11303
|
GlobalConsensus: {
|
|
11157
11304
|
Ethereum: {
|
|
11158
|
-
|
|
11305
|
+
chainId: 1
|
|
11159
11306
|
}
|
|
11160
11307
|
}
|
|
11161
11308
|
},
|
|
11162
11309
|
{
|
|
11163
11310
|
AccountKey20: {
|
|
11311
|
+
network: null,
|
|
11164
11312
|
key: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
|
|
11165
11313
|
}
|
|
11166
11314
|
}
|
|
@@ -11179,12 +11327,13 @@ var Ethereum = {
|
|
|
11179
11327
|
{
|
|
11180
11328
|
GlobalConsensus: {
|
|
11181
11329
|
Ethereum: {
|
|
11182
|
-
|
|
11330
|
+
chainId: 1
|
|
11183
11331
|
}
|
|
11184
11332
|
}
|
|
11185
11333
|
},
|
|
11186
11334
|
{
|
|
11187
11335
|
AccountKey20: {
|
|
11336
|
+
network: null,
|
|
11188
11337
|
key: "0xdac17f958d2ee523a2206206994597c13d831ec7"
|
|
11189
11338
|
}
|
|
11190
11339
|
}
|
|
@@ -11203,12 +11352,13 @@ var Ethereum = {
|
|
|
11203
11352
|
{
|
|
11204
11353
|
GlobalConsensus: {
|
|
11205
11354
|
Ethereum: {
|
|
11206
|
-
|
|
11355
|
+
chainId: 1
|
|
11207
11356
|
}
|
|
11208
11357
|
}
|
|
11209
11358
|
},
|
|
11210
11359
|
{
|
|
11211
11360
|
AccountKey20: {
|
|
11361
|
+
network: null,
|
|
11212
11362
|
key: "0x6b175474e89094c44da98b954eedeac495271d0f"
|
|
11213
11363
|
}
|
|
11214
11364
|
}
|
|
@@ -11227,12 +11377,13 @@ var Ethereum = {
|
|
|
11227
11377
|
{
|
|
11228
11378
|
GlobalConsensus: {
|
|
11229
11379
|
Ethereum: {
|
|
11230
|
-
|
|
11380
|
+
chainId: 1
|
|
11231
11381
|
}
|
|
11232
11382
|
}
|
|
11233
11383
|
},
|
|
11234
11384
|
{
|
|
11235
11385
|
AccountKey20: {
|
|
11386
|
+
network: null,
|
|
11236
11387
|
key: "0x5d3d01fd6d2ad1169b17918eb4f153c6616288eb"
|
|
11237
11388
|
}
|
|
11238
11389
|
}
|
|
@@ -11251,12 +11402,13 @@ var Ethereum = {
|
|
|
11251
11402
|
{
|
|
11252
11403
|
GlobalConsensus: {
|
|
11253
11404
|
Ethereum: {
|
|
11254
|
-
|
|
11405
|
+
chainId: 1
|
|
11255
11406
|
}
|
|
11256
11407
|
}
|
|
11257
11408
|
},
|
|
11258
11409
|
{
|
|
11259
11410
|
AccountKey20: {
|
|
11411
|
+
network: null,
|
|
11260
11412
|
key: "0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9"
|
|
11261
11413
|
}
|
|
11262
11414
|
}
|
|
@@ -11805,11 +11957,12 @@ var PolkadotXcmError;
|
|
|
11805
11957
|
})(PolkadotXcmError || (PolkadotXcmError = {}));
|
|
11806
11958
|
|
|
11807
11959
|
var DEFAULT_FEE_ASSET = 0;
|
|
11808
|
-
var
|
|
11960
|
+
var ETH_PARA_ID = 1;
|
|
11961
|
+
var ETH_CHAIN_ID = BigInt(ETH_PARA_ID);
|
|
11809
11962
|
var ETHEREUM_JUNCTION = {
|
|
11810
11963
|
GlobalConsensus: {
|
|
11811
11964
|
Ethereum: {
|
|
11812
|
-
|
|
11965
|
+
chainId: ETH_CHAIN_ID
|
|
11813
11966
|
}
|
|
11814
11967
|
}
|
|
11815
11968
|
};
|
|
@@ -13491,6 +13644,9 @@ var getNodeProviders = function getNodeProviders(node) {
|
|
|
13491
13644
|
* @returns The parachain ID of the node.
|
|
13492
13645
|
*/
|
|
13493
13646
|
var getParaId = function getParaId(node) {
|
|
13647
|
+
if (node === 'Ethereum') {
|
|
13648
|
+
return ETH_PARA_ID;
|
|
13649
|
+
}
|
|
13494
13650
|
return getNodeConfig(node).paraId;
|
|
13495
13651
|
};
|
|
13496
13652
|
|
|
@@ -13605,10 +13761,10 @@ var resolveTNodeFromMultiLocation = function resolveTNodeFromMultiLocation(relay
|
|
|
13605
13761
|
return node;
|
|
13606
13762
|
};
|
|
13607
13763
|
var throwUnsupportedCurrency = function throwUnsupportedCurrency(currency, node) {
|
|
13608
|
-
var
|
|
13764
|
+
var _ref8 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
13609
13765
|
isDestination: false
|
|
13610
13766
|
},
|
|
13611
|
-
isDestination =
|
|
13767
|
+
isDestination = _ref8.isDestination;
|
|
13612
13768
|
if ('multilocation' in currency) {
|
|
13613
13769
|
throw new InvalidCurrencyError("\n Selected chain doesn't support multilocation you provided. Maybe you meant custom multilocation. If so, you need to use override option. Your selection should look like this: {multilocation: Override(".concat(JSON.stringify(currency.multilocation), ")}."));
|
|
13614
13770
|
}
|
|
@@ -13761,78 +13917,265 @@ var resolveParaId = function resolveParaId(paraId, destination) {
|
|
|
13761
13917
|
return paraId !== null && paraId !== undefined ? paraId : getParaId(destination);
|
|
13762
13918
|
};
|
|
13763
13919
|
|
|
13764
|
-
var
|
|
13765
|
-
|
|
13766
|
-
|
|
13767
|
-
|
|
13768
|
-
|
|
13769
|
-
|
|
13770
|
-
|
|
13771
|
-
|
|
13772
|
-
|
|
13773
|
-
|
|
13774
|
-
|
|
13775
|
-
|
|
13776
|
-
|
|
13777
|
-
|
|
13778
|
-
|
|
13779
|
-
|
|
13780
|
-
|
|
13920
|
+
var calculateFee = /*#__PURE__*/function () {
|
|
13921
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(ahApi) {
|
|
13922
|
+
var DEFAULT_FEE, feeStorageItem, leFeeHex, leFee, transfer_bridge_fee, transfer_assethub_execution_fee;
|
|
13923
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
13924
|
+
while (1) switch (_context.prev = _context.next) {
|
|
13925
|
+
case 0:
|
|
13926
|
+
DEFAULT_FEE = 2750872500000n;
|
|
13927
|
+
_context.next = 3;
|
|
13928
|
+
return ahApi.getFromStorage('0x5fbc5c7ba58845ad1f1a9a7c5bc12fad');
|
|
13929
|
+
case 3:
|
|
13930
|
+
feeStorageItem = _context.sent;
|
|
13931
|
+
leFeeHex = feeStorageItem.replace('0x', '');
|
|
13932
|
+
_context.next = 7;
|
|
13933
|
+
return ahApi.disconnect();
|
|
13934
|
+
case 7:
|
|
13935
|
+
leFee = BigInt('0x' + leFeeHex.split('').reverse().join(''));
|
|
13936
|
+
transfer_bridge_fee = leFee === 0n ? DEFAULT_FEE : BigInt(leFee.toString());
|
|
13937
|
+
transfer_assethub_execution_fee = 2200000000n;
|
|
13938
|
+
return _context.abrupt("return", (transfer_bridge_fee + transfer_assethub_execution_fee).toString());
|
|
13939
|
+
case 11:
|
|
13940
|
+
case "end":
|
|
13941
|
+
return _context.stop();
|
|
13942
|
+
}
|
|
13943
|
+
}, _callee);
|
|
13944
|
+
}));
|
|
13945
|
+
return function calculateFee(_x) {
|
|
13946
|
+
return _ref.apply(this, arguments);
|
|
13947
|
+
};
|
|
13948
|
+
}();
|
|
13949
|
+
|
|
13950
|
+
var generateAddressPayload = function generateAddressPayload(api, scenario, pallet, recipientAddress, version, nodeId) {
|
|
13951
|
+
var isMultiLocation = _typeof(recipientAddress) === 'object';
|
|
13952
|
+
if (isMultiLocation) {
|
|
13953
|
+
return _defineProperty({}, version, recipientAddress);
|
|
13781
13954
|
}
|
|
13782
|
-
|
|
13783
|
-
|
|
13784
|
-
|
|
13785
|
-
|
|
13786
|
-
|
|
13787
|
-
|
|
13788
|
-
|
|
13789
|
-
|
|
13790
|
-
|
|
13791
|
-
|
|
13792
|
-
|
|
13793
|
-
|
|
13794
|
-
|
|
13795
|
-
|
|
13796
|
-
}
|
|
13797
|
-
|
|
13798
|
-
|
|
13799
|
-
|
|
13800
|
-
|
|
13801
|
-
|
|
13802
|
-
|
|
13803
|
-
|
|
13804
|
-
|
|
13805
|
-
|
|
13806
|
-
|
|
13807
|
-
|
|
13808
|
-
|
|
13809
|
-
|
|
13810
|
-
|
|
13811
|
-
|
|
13812
|
-
|
|
13813
|
-
|
|
13814
|
-
|
|
13815
|
-
|
|
13816
|
-
|
|
13817
|
-
|
|
13818
|
-
|
|
13819
|
-
|
|
13820
|
-
|
|
13821
|
-
|
|
13822
|
-
|
|
13823
|
-
|
|
13824
|
-
|
|
13825
|
-
|
|
13826
|
-
|
|
13827
|
-
|
|
13828
|
-
|
|
13829
|
-
|
|
13830
|
-
|
|
13831
|
-
|
|
13832
|
-
|
|
13833
|
-
|
|
13834
|
-
|
|
13835
|
-
|
|
13955
|
+
var isEthAddress = ethers.isAddress(recipientAddress);
|
|
13956
|
+
if (scenario === 'ParaToRelay') {
|
|
13957
|
+
return _defineProperty({}, version, {
|
|
13958
|
+
parents: pallet === 'XTokens' ? Parents.ONE : Parents.ZERO,
|
|
13959
|
+
interior: createX1Payload(version, {
|
|
13960
|
+
AccountId32: _objectSpread2(_objectSpread2({}, version === Version.V1 && {
|
|
13961
|
+
network: 'any'
|
|
13962
|
+
}), {}, {
|
|
13963
|
+
id: api.createAccountId(recipientAddress)
|
|
13964
|
+
})
|
|
13965
|
+
})
|
|
13966
|
+
});
|
|
13967
|
+
}
|
|
13968
|
+
if (scenario === 'ParaToPara' && pallet === 'XTokens') {
|
|
13969
|
+
return _defineProperty({}, version, {
|
|
13970
|
+
parents: Parents.ONE,
|
|
13971
|
+
interior: {
|
|
13972
|
+
X2: [{
|
|
13973
|
+
Parachain: nodeId
|
|
13974
|
+
}, isEthAddress ? {
|
|
13975
|
+
AccountKey20: _objectSpread2(_objectSpread2({}, (version === Version.V1 || version === Version.V2) && {
|
|
13976
|
+
network: 'any'
|
|
13977
|
+
}), {}, {
|
|
13978
|
+
key: recipientAddress
|
|
13979
|
+
})
|
|
13980
|
+
} : {
|
|
13981
|
+
AccountId32: _objectSpread2(_objectSpread2({}, (version === Version.V1 || version === Version.V2) && {
|
|
13982
|
+
network: 'any'
|
|
13983
|
+
}), {}, {
|
|
13984
|
+
id: api.createAccountId(recipientAddress)
|
|
13985
|
+
})
|
|
13986
|
+
}]
|
|
13987
|
+
}
|
|
13988
|
+
});
|
|
13989
|
+
}
|
|
13990
|
+
if (scenario === 'ParaToPara' && pallet === 'PolkadotXcm') {
|
|
13991
|
+
return _defineProperty({}, version, {
|
|
13992
|
+
parents: Parents.ZERO,
|
|
13993
|
+
interior: createX1Payload(version, isEthAddress ? {
|
|
13994
|
+
AccountKey20: _objectSpread2(_objectSpread2({}, (version === Version.V1 || version === Version.V2) && {
|
|
13995
|
+
network: 'any'
|
|
13996
|
+
}), {}, {
|
|
13997
|
+
key: recipientAddress
|
|
13998
|
+
})
|
|
13999
|
+
} : {
|
|
14000
|
+
AccountId32: _objectSpread2(_objectSpread2({}, (version === Version.V1 || version === Version.V2) && {
|
|
14001
|
+
network: 'any'
|
|
14002
|
+
}), {}, {
|
|
14003
|
+
id: api.createAccountId(recipientAddress)
|
|
14004
|
+
})
|
|
14005
|
+
})
|
|
14006
|
+
});
|
|
14007
|
+
}
|
|
14008
|
+
return _defineProperty({}, version, {
|
|
14009
|
+
parents: Parents.ZERO,
|
|
14010
|
+
interior: createX1Payload(version, isEthAddress ? {
|
|
14011
|
+
AccountKey20: {
|
|
14012
|
+
key: recipientAddress
|
|
14013
|
+
}
|
|
14014
|
+
} : {
|
|
14015
|
+
AccountId32: {
|
|
14016
|
+
id: api.createAccountId(recipientAddress)
|
|
14017
|
+
}
|
|
14018
|
+
})
|
|
14019
|
+
});
|
|
14020
|
+
};
|
|
14021
|
+
|
|
14022
|
+
var createCustomXcmOnDest = function createCustomXcmOnDest(_ref, version) {
|
|
14023
|
+
var api = _ref.api,
|
|
14024
|
+
address = _ref.address,
|
|
14025
|
+
asset = _ref.asset,
|
|
14026
|
+
scenario = _ref.scenario,
|
|
14027
|
+
ahAddress = _ref.ahAddress;
|
|
14028
|
+
if (!isForeignAsset(asset)) {
|
|
14029
|
+
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
|
|
14030
|
+
}
|
|
14031
|
+
if (!asset.multiLocation) {
|
|
14032
|
+
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multiLocation"));
|
|
14033
|
+
}
|
|
14034
|
+
var ethAsset = findAssetByMultiLocation(getOtherAssets('Ethereum'), asset.multiLocation);
|
|
14035
|
+
if (!ethAsset) {
|
|
14036
|
+
throw new InvalidCurrencyError("Could not obtain Ethereum asset address for ".concat(JSON.stringify(asset)));
|
|
14037
|
+
}
|
|
14038
|
+
return _defineProperty({}, version, [{
|
|
14039
|
+
SetAppendix: [{
|
|
14040
|
+
DepositAsset: {
|
|
14041
|
+
assets: {
|
|
14042
|
+
Wild: 'All'
|
|
14043
|
+
},
|
|
14044
|
+
beneficiary: Object.values(generateAddressPayload(api, scenario, 'PolkadotXcm', ahAddress !== null && ahAddress !== undefined ? ahAddress : '', version, undefined))[0]
|
|
14045
|
+
}
|
|
14046
|
+
}]
|
|
14047
|
+
}, {
|
|
14048
|
+
InitiateReserveWithdraw: {
|
|
14049
|
+
assets: {
|
|
14050
|
+
Wild: {
|
|
14051
|
+
AllOf: {
|
|
14052
|
+
id: asset.multiLocation,
|
|
14053
|
+
fun: 'Fungible'
|
|
14054
|
+
}
|
|
14055
|
+
}
|
|
14056
|
+
},
|
|
14057
|
+
reserve: {
|
|
14058
|
+
parents: Parents.TWO,
|
|
14059
|
+
interior: {
|
|
14060
|
+
X1: [ETHEREUM_JUNCTION]
|
|
14061
|
+
}
|
|
14062
|
+
},
|
|
14063
|
+
xcm: [{
|
|
14064
|
+
BuyExecution: {
|
|
14065
|
+
fees: {
|
|
14066
|
+
id: {
|
|
14067
|
+
parents: Parents.ZERO,
|
|
14068
|
+
interior: {
|
|
14069
|
+
X1: [{
|
|
14070
|
+
AccountKey20: {
|
|
14071
|
+
network: null,
|
|
14072
|
+
key: ethAsset.assetId
|
|
14073
|
+
}
|
|
14074
|
+
}]
|
|
14075
|
+
}
|
|
14076
|
+
},
|
|
14077
|
+
fun: {
|
|
14078
|
+
Fungible: 1n
|
|
14079
|
+
}
|
|
14080
|
+
},
|
|
14081
|
+
weight_limit: 'Unlimited'
|
|
14082
|
+
}
|
|
14083
|
+
}, {
|
|
14084
|
+
DepositAsset: {
|
|
14085
|
+
assets: {
|
|
14086
|
+
Wild: {
|
|
14087
|
+
AllCounted: 1
|
|
14088
|
+
}
|
|
14089
|
+
},
|
|
14090
|
+
beneficiary: {
|
|
14091
|
+
parents: Parents.ZERO,
|
|
14092
|
+
interior: {
|
|
14093
|
+
X1: [{
|
|
14094
|
+
AccountKey20: {
|
|
14095
|
+
network: null,
|
|
14096
|
+
key: address
|
|
14097
|
+
}
|
|
14098
|
+
}]
|
|
14099
|
+
}
|
|
14100
|
+
}
|
|
14101
|
+
}
|
|
14102
|
+
}]
|
|
14103
|
+
}
|
|
14104
|
+
}]);
|
|
14105
|
+
};
|
|
14106
|
+
|
|
14107
|
+
var supportsXTokens = function supportsXTokens(obj) {
|
|
14108
|
+
return _typeof(obj) === 'object' && obj !== null && 'transferXTokens' in obj;
|
|
14109
|
+
};
|
|
14110
|
+
var supportsXTransfer = function supportsXTransfer(obj) {
|
|
14111
|
+
return _typeof(obj) === 'object' && obj !== null && 'transferXTransfer' in obj;
|
|
14112
|
+
};
|
|
14113
|
+
var supportsPolkadotXCM = function supportsPolkadotXCM(obj) {
|
|
14114
|
+
return _typeof(obj) === 'object' && obj !== null && 'transferPolkadotXCM' in obj;
|
|
14115
|
+
};
|
|
14116
|
+
var ParachainNode = /*#__PURE__*/function () {
|
|
14117
|
+
function ParachainNode(node, info, type, version) {
|
|
14118
|
+
_classCallCheck(this, ParachainNode);
|
|
14119
|
+
this._assetCheckEnabled = true;
|
|
14120
|
+
this._info = info;
|
|
14121
|
+
this._type = type;
|
|
14122
|
+
this._node = node;
|
|
14123
|
+
this._version = version;
|
|
14124
|
+
}
|
|
14125
|
+
return _createClass(ParachainNode, [{
|
|
14126
|
+
key: "info",
|
|
14127
|
+
get: function get() {
|
|
14128
|
+
return this._info;
|
|
14129
|
+
}
|
|
14130
|
+
}, {
|
|
14131
|
+
key: "type",
|
|
14132
|
+
get: function get() {
|
|
14133
|
+
return this._type;
|
|
14134
|
+
}
|
|
14135
|
+
}, {
|
|
14136
|
+
key: "node",
|
|
14137
|
+
get: function get() {
|
|
14138
|
+
return this._node;
|
|
14139
|
+
}
|
|
14140
|
+
}, {
|
|
14141
|
+
key: "version",
|
|
14142
|
+
get: function get() {
|
|
14143
|
+
return this._version;
|
|
14144
|
+
}
|
|
14145
|
+
}, {
|
|
14146
|
+
key: "assetCheckEnabled",
|
|
14147
|
+
get: function get() {
|
|
14148
|
+
return this._assetCheckEnabled;
|
|
14149
|
+
}
|
|
14150
|
+
}, {
|
|
14151
|
+
key: "canUseXTokens",
|
|
14152
|
+
value: function canUseXTokens(_) {
|
|
14153
|
+
return true;
|
|
14154
|
+
}
|
|
14155
|
+
}, {
|
|
14156
|
+
key: "transfer",
|
|
14157
|
+
value: function () {
|
|
14158
|
+
var _transfer = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
14159
|
+
var api, asset, address, destination, paraIdTo, overriddenAsset, version, ahAddress, pallet, method, isRelayDestination, scenario, paraId, versionOrDefault, isBifrostOrigin, isAssetHubDest, shouldUseMultiasset, input;
|
|
14160
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
14161
|
+
while (1) switch (_context.prev = _context.next) {
|
|
14162
|
+
case 0:
|
|
14163
|
+
api = options.api, asset = options.asset, address = options.address, destination = options.destination, paraIdTo = options.paraIdTo, overriddenAsset = options.overriddenAsset, version = options.version, ahAddress = options.ahAddress, pallet = options.pallet, method = options.method;
|
|
14164
|
+
isRelayDestination = !isTMultiLocation(destination) && isRelayChain(destination);
|
|
14165
|
+
scenario = isRelayDestination ? 'ParaToRelay' : 'ParaToPara';
|
|
14166
|
+
paraId = resolveParaId(paraIdTo, destination);
|
|
14167
|
+
if (!(destination === 'Polimec' && this.node !== 'AssetHubPolkadot')) {
|
|
14168
|
+
_context.next = 6;
|
|
14169
|
+
break;
|
|
14170
|
+
}
|
|
14171
|
+
throw new Error('Sending assets to Polimec is supported only from AssetHubPolkadot');
|
|
14172
|
+
case 6:
|
|
14173
|
+
versionOrDefault = version !== null && version !== undefined ? version : this.version;
|
|
14174
|
+
if (!(supportsXTokens(this) && this.canUseXTokens(options))) {
|
|
14175
|
+
_context.next = 17;
|
|
14176
|
+
break;
|
|
14177
|
+
}
|
|
14178
|
+
isBifrostOrigin = this.node === 'BifrostPolkadot' || this.node === 'BifrostKusama';
|
|
13836
14179
|
isAssetHubDest = destination === 'AssetHubPolkadot' || destination === 'AssetHubKusama';
|
|
13837
14180
|
shouldUseMultiasset = isAssetHubDest && !isBifrostOrigin;
|
|
13838
14181
|
input = {
|
|
@@ -13946,6 +14289,65 @@ var ParachainNode = /*#__PURE__*/function () {
|
|
|
13946
14289
|
value: function getNativeAssetSymbol$1() {
|
|
13947
14290
|
return getNativeAssetSymbol(this.node);
|
|
13948
14291
|
}
|
|
14292
|
+
}, {
|
|
14293
|
+
key: "transferToEthereum",
|
|
14294
|
+
value: function () {
|
|
14295
|
+
var _transferToEthereum = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(input) {
|
|
14296
|
+
var api, asset, scenario, version, destination, ahAddress, versionOrDefault, ethMultiAsset, ahApi, fee, call;
|
|
14297
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
14298
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
14299
|
+
case 0:
|
|
14300
|
+
api = input.api, asset = input.asset, scenario = input.scenario, version = input.version, destination = input.destination, ahAddress = input.ahAddress;
|
|
14301
|
+
if (isForeignAsset(asset)) {
|
|
14302
|
+
_context2.next = 3;
|
|
14303
|
+
break;
|
|
14304
|
+
}
|
|
14305
|
+
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
|
|
14306
|
+
case 3:
|
|
14307
|
+
if (!(ahAddress === undefined)) {
|
|
14308
|
+
_context2.next = 5;
|
|
14309
|
+
break;
|
|
14310
|
+
}
|
|
14311
|
+
throw new Error('AssetHub address is required for Ethereum transfers');
|
|
14312
|
+
case 5:
|
|
14313
|
+
versionOrDefault = version !== null && version !== undefined ? version : Version.V4;
|
|
14314
|
+
ethMultiAsset = Object.values(createCurrencySpec(asset.amount, versionOrDefault, Parents.TWO, asset.multiLocation))[0][0];
|
|
14315
|
+
_context2.next = 9;
|
|
14316
|
+
return api.createApiForNode('AssetHubPolkadot');
|
|
14317
|
+
case 9:
|
|
14318
|
+
ahApi = _context2.sent;
|
|
14319
|
+
_context2.next = 12;
|
|
14320
|
+
return calculateFee(ahApi);
|
|
14321
|
+
case 12:
|
|
14322
|
+
fee = _context2.sent;
|
|
14323
|
+
call = {
|
|
14324
|
+
module: 'PolkadotXcm',
|
|
14325
|
+
section: 'transfer_assets_using_type_and_then',
|
|
14326
|
+
parameters: {
|
|
14327
|
+
dest: this.createPolkadotXcmHeader(scenario, versionOrDefault, destination, getParaId('AssetHubPolkadot')),
|
|
14328
|
+
assets: _defineProperty({}, versionOrDefault, [Object.values(this.createCurrencySpec(fee, 'ParaToRelay', versionOrDefault))[0][0], ethMultiAsset]),
|
|
14329
|
+
assets_transfer_type: 'DestinationReserve',
|
|
14330
|
+
remote_fees_id: _defineProperty({}, versionOrDefault, {
|
|
14331
|
+
parents: Parents.ONE,
|
|
14332
|
+
interior: 'Here'
|
|
14333
|
+
}),
|
|
14334
|
+
fees_transfer_type: 'DestinationReserve',
|
|
14335
|
+
custom_xcm_on_dest: createCustomXcmOnDest(input, versionOrDefault),
|
|
14336
|
+
weight_limit: 'Unlimited'
|
|
14337
|
+
}
|
|
14338
|
+
};
|
|
14339
|
+
return _context2.abrupt("return", api.callTxMethod(call));
|
|
14340
|
+
case 15:
|
|
14341
|
+
case "end":
|
|
14342
|
+
return _context2.stop();
|
|
14343
|
+
}
|
|
14344
|
+
}, _callee2, this);
|
|
14345
|
+
}));
|
|
14346
|
+
function transferToEthereum(_x2) {
|
|
14347
|
+
return _transferToEthereum.apply(this, arguments);
|
|
14348
|
+
}
|
|
14349
|
+
return transferToEthereum;
|
|
14350
|
+
}()
|
|
13949
14351
|
}]);
|
|
13950
14352
|
}();
|
|
13951
14353
|
|
|
@@ -14100,8 +14502,8 @@ var BifrostPolkadot$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
14100
14502
|
}
|
|
14101
14503
|
// Handles DOT, WETH transfers to AssetHubPolkadot
|
|
14102
14504
|
}, {
|
|
14103
|
-
key: "
|
|
14104
|
-
value: function
|
|
14505
|
+
key: "transferToAssetHub",
|
|
14506
|
+
value: function transferToAssetHub(input) {
|
|
14105
14507
|
var _getAssetId;
|
|
14106
14508
|
var overriddenAsset = input.overriddenAsset,
|
|
14107
14509
|
asset = input.asset;
|
|
@@ -14115,11 +14517,21 @@ var BifrostPolkadot$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
14115
14517
|
} : undefined)
|
|
14116
14518
|
}), 'transfer_assets', 'Unlimited'));
|
|
14117
14519
|
}
|
|
14520
|
+
}, {
|
|
14521
|
+
key: "transferPolkadotXCM",
|
|
14522
|
+
value: function transferPolkadotXCM(input) {
|
|
14523
|
+
var destination = input.destination;
|
|
14524
|
+
if (destination === 'Ethereum') {
|
|
14525
|
+
return this.transferToEthereum(input);
|
|
14526
|
+
}
|
|
14527
|
+
return this.transferToAssetHub(input);
|
|
14528
|
+
}
|
|
14118
14529
|
}, {
|
|
14119
14530
|
key: "canUseXTokens",
|
|
14120
14531
|
value: function canUseXTokens(_ref) {
|
|
14121
14532
|
var asset = _ref.asset,
|
|
14122
14533
|
destination = _ref.destination;
|
|
14534
|
+
if (destination === 'Ethereum') return false;
|
|
14123
14535
|
return asset.symbol !== 'WETH' && asset.symbol !== 'DOT' || destination !== 'AssetHubPolkadot';
|
|
14124
14536
|
}
|
|
14125
14537
|
}]);
|
|
@@ -14168,150 +14580,29 @@ var ComposableFinance$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
14168
14580
|
}
|
|
14169
14581
|
_inherits(ComposableFinance, _ParachainNode);
|
|
14170
14582
|
return _createClass(ComposableFinance, [{
|
|
14171
|
-
key: "transferXTokens",
|
|
14172
|
-
value: function transferXTokens(input) {
|
|
14173
|
-
var asset = input.asset;
|
|
14174
|
-
if (!isForeignAsset(asset) || !asset.assetId) {
|
|
14175
|
-
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
|
|
14176
|
-
}
|
|
14177
|
-
return XTokensTransferImpl.transferXTokens(input, BigInt(asset.assetId));
|
|
14178
|
-
}
|
|
14179
|
-
}]);
|
|
14180
|
-
}(ParachainNode);
|
|
14181
|
-
|
|
14182
|
-
var createEthereumTokenLocation = function createEthereumTokenLocation(currencyId) {
|
|
14183
|
-
return {
|
|
14184
|
-
parents: Parents.TWO,
|
|
14185
|
-
interior: {
|
|
14186
|
-
X2: [ETHEREUM_JUNCTION, {
|
|
14187
|
-
AccountKey20: {
|
|
14188
|
-
key: currencyId
|
|
14189
|
-
}
|
|
14190
|
-
}]
|
|
14191
|
-
}
|
|
14192
|
-
};
|
|
14193
|
-
};
|
|
14194
|
-
|
|
14195
|
-
var calculateFee = /*#__PURE__*/function () {
|
|
14196
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(api) {
|
|
14197
|
-
var DEFAULT_FEE, ahApi, feeStorageItem, leFeeHex, leFee, transfer_bridge_fee, transfer_assethub_execution_fee;
|
|
14198
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
14199
|
-
while (1) switch (_context.prev = _context.next) {
|
|
14200
|
-
case 0:
|
|
14201
|
-
DEFAULT_FEE = 2750872500000n;
|
|
14202
|
-
_context.next = 3;
|
|
14203
|
-
return api.createApiForNode('AssetHubPolkadot');
|
|
14204
|
-
case 3:
|
|
14205
|
-
ahApi = _context.sent;
|
|
14206
|
-
_context.next = 6;
|
|
14207
|
-
return ahApi.getFromStorage('0x5fbc5c7ba58845ad1f1a9a7c5bc12fad');
|
|
14208
|
-
case 6:
|
|
14209
|
-
feeStorageItem = _context.sent;
|
|
14210
|
-
leFeeHex = feeStorageItem.replace('0x', '');
|
|
14211
|
-
leFee = BigInt('0x' + leFeeHex.split('').reverse().join(''));
|
|
14212
|
-
transfer_bridge_fee = leFee === 0n ? DEFAULT_FEE : BigInt(leFee.toString());
|
|
14213
|
-
transfer_assethub_execution_fee = 2200000000n;
|
|
14214
|
-
return _context.abrupt("return", (transfer_bridge_fee + transfer_assethub_execution_fee).toString());
|
|
14215
|
-
case 12:
|
|
14216
|
-
case "end":
|
|
14217
|
-
return _context.stop();
|
|
14218
|
-
}
|
|
14219
|
-
}, _callee);
|
|
14220
|
-
}));
|
|
14221
|
-
return function calculateFee(_x) {
|
|
14222
|
-
return _ref.apply(this, arguments);
|
|
14223
|
-
};
|
|
14224
|
-
}();
|
|
14225
|
-
var createCustomXcmAh = function createCustomXcmAh(_ref2, version) {
|
|
14226
|
-
var api = _ref2.api,
|
|
14227
|
-
scenario = _ref2.scenario,
|
|
14228
|
-
address = _ref2.address;
|
|
14229
|
-
return _defineProperty({}, version, [{
|
|
14230
|
-
DepositAsset: {
|
|
14231
|
-
assets: {
|
|
14232
|
-
Wild: {
|
|
14233
|
-
AllCounted: 1
|
|
14234
|
-
}
|
|
14235
|
-
},
|
|
14236
|
-
beneficiary: Object.values(generateAddressPayload(api, scenario, 'PolkadotXcm', address, version, undefined))[0]
|
|
14237
|
-
}
|
|
14238
|
-
}]);
|
|
14239
|
-
};
|
|
14240
|
-
var createCustomXcmOnDest = function createCustomXcmOnDest(_ref4, version) {
|
|
14241
|
-
var _asset$assetId;
|
|
14242
|
-
var api = _ref4.api,
|
|
14243
|
-
address = _ref4.address,
|
|
14244
|
-
asset = _ref4.asset,
|
|
14245
|
-
scenario = _ref4.scenario,
|
|
14246
|
-
ahAddress = _ref4.ahAddress;
|
|
14247
|
-
if (!isForeignAsset(asset)) {
|
|
14248
|
-
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
|
|
14249
|
-
}
|
|
14250
|
-
return _defineProperty({}, version, [{
|
|
14251
|
-
SetAppendix: [{
|
|
14252
|
-
DepositAsset: {
|
|
14253
|
-
assets: {
|
|
14254
|
-
Wild: 'All'
|
|
14255
|
-
},
|
|
14256
|
-
beneficiary: Object.values(generateAddressPayload(api, scenario, 'PolkadotXcm', ahAddress !== null && ahAddress !== undefined ? ahAddress : '', version, undefined))[0]
|
|
14583
|
+
key: "transferXTokens",
|
|
14584
|
+
value: function transferXTokens(input) {
|
|
14585
|
+
var asset = input.asset;
|
|
14586
|
+
if (!isForeignAsset(asset) || !asset.assetId) {
|
|
14587
|
+
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
|
|
14257
14588
|
}
|
|
14258
|
-
|
|
14259
|
-
|
|
14260
|
-
|
|
14589
|
+
return XTokensTransferImpl.transferXTokens(input, BigInt(asset.assetId));
|
|
14590
|
+
}
|
|
14591
|
+
}]);
|
|
14592
|
+
}(ParachainNode);
|
|
14593
|
+
|
|
14594
|
+
var createCustomXcmAh = function createCustomXcmAh(_ref, version) {
|
|
14595
|
+
var api = _ref.api,
|
|
14596
|
+
scenario = _ref.scenario,
|
|
14597
|
+
address = _ref.address;
|
|
14598
|
+
return _defineProperty({}, version, [{
|
|
14599
|
+
DepositAsset: {
|
|
14261
14600
|
assets: {
|
|
14262
14601
|
Wild: {
|
|
14263
|
-
|
|
14264
|
-
id: createEthereumTokenLocation((_asset$assetId = asset.assetId) !== null && _asset$assetId !== undefined ? _asset$assetId : ''),
|
|
14265
|
-
fun: 'Fungible'
|
|
14266
|
-
}
|
|
14267
|
-
}
|
|
14268
|
-
},
|
|
14269
|
-
reserve: {
|
|
14270
|
-
parents: Parents.TWO,
|
|
14271
|
-
interior: {
|
|
14272
|
-
X1: [ETHEREUM_JUNCTION]
|
|
14602
|
+
AllCounted: 1
|
|
14273
14603
|
}
|
|
14274
14604
|
},
|
|
14275
|
-
|
|
14276
|
-
BuyExecution: {
|
|
14277
|
-
fees: {
|
|
14278
|
-
id: {
|
|
14279
|
-
parents: Parents.ZERO,
|
|
14280
|
-
interior: {
|
|
14281
|
-
X1: [{
|
|
14282
|
-
AccountKey20: {
|
|
14283
|
-
network: null,
|
|
14284
|
-
key: asset.assetId
|
|
14285
|
-
}
|
|
14286
|
-
}]
|
|
14287
|
-
}
|
|
14288
|
-
},
|
|
14289
|
-
fun: {
|
|
14290
|
-
Fungible: 1n
|
|
14291
|
-
}
|
|
14292
|
-
},
|
|
14293
|
-
weight_limit: 'Unlimited'
|
|
14294
|
-
}
|
|
14295
|
-
}, {
|
|
14296
|
-
DepositAsset: {
|
|
14297
|
-
assets: {
|
|
14298
|
-
Wild: {
|
|
14299
|
-
AllCounted: 1
|
|
14300
|
-
}
|
|
14301
|
-
},
|
|
14302
|
-
beneficiary: {
|
|
14303
|
-
parents: Parents.ZERO,
|
|
14304
|
-
interior: {
|
|
14305
|
-
X1: [{
|
|
14306
|
-
AccountKey20: {
|
|
14307
|
-
network: null,
|
|
14308
|
-
key: address
|
|
14309
|
-
}
|
|
14310
|
-
}]
|
|
14311
|
-
}
|
|
14312
|
-
}
|
|
14313
|
-
}
|
|
14314
|
-
}]
|
|
14605
|
+
beneficiary: Object.values(generateAddressPayload(api, scenario, 'PolkadotXcm', address, version, undefined))[0]
|
|
14315
14606
|
}
|
|
14316
14607
|
}]);
|
|
14317
14608
|
};
|
|
@@ -14322,74 +14613,6 @@ var Hydration$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
14322
14613
|
}
|
|
14323
14614
|
_inherits(Hydration, _ParachainNode);
|
|
14324
14615
|
return _createClass(Hydration, [{
|
|
14325
|
-
key: "transferToEthereum",
|
|
14326
|
-
value: function () {
|
|
14327
|
-
var _transferToEthereum = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(input) {
|
|
14328
|
-
var _asset$symbol, _asset$assetId2;
|
|
14329
|
-
var api, address, asset, scenario, version, destination, ahAddress, versionOrDefault, ethMultiAsset, fee, call;
|
|
14330
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
14331
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
14332
|
-
case 0:
|
|
14333
|
-
api = input.api, address = input.address, asset = input.asset, scenario = input.scenario, version = input.version, destination = input.destination, ahAddress = input.ahAddress;
|
|
14334
|
-
if (ethers.isAddress(address)) {
|
|
14335
|
-
_context2.next = 3;
|
|
14336
|
-
break;
|
|
14337
|
-
}
|
|
14338
|
-
throw new Error('Only Ethereum addresses are supported for Ethereum transfers');
|
|
14339
|
-
case 3:
|
|
14340
|
-
if (!(((_asset$symbol = asset.symbol) === null || _asset$symbol === undefined ? undefined : _asset$symbol.toUpperCase()) !== 'WETH')) {
|
|
14341
|
-
_context2.next = 5;
|
|
14342
|
-
break;
|
|
14343
|
-
}
|
|
14344
|
-
throw new InvalidCurrencyError("Currency ".concat(asset.symbol, " is not supported for Ethereum transfers from Hydration"));
|
|
14345
|
-
case 5:
|
|
14346
|
-
if (isForeignAsset(asset)) {
|
|
14347
|
-
_context2.next = 7;
|
|
14348
|
-
break;
|
|
14349
|
-
}
|
|
14350
|
-
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
|
|
14351
|
-
case 7:
|
|
14352
|
-
if (!(ahAddress === undefined)) {
|
|
14353
|
-
_context2.next = 9;
|
|
14354
|
-
break;
|
|
14355
|
-
}
|
|
14356
|
-
throw new Error('AssetHub address is required for Ethereum transfers');
|
|
14357
|
-
case 9:
|
|
14358
|
-
versionOrDefault = version !== null && version !== undefined ? version : Version.V4;
|
|
14359
|
-
ethMultiAsset = Object.values(createCurrencySpec(asset.amount, versionOrDefault, Parents.TWO, createEthereumTokenLocation((_asset$assetId2 = asset.assetId) !== null && _asset$assetId2 !== undefined ? _asset$assetId2 : '')))[0][0];
|
|
14360
|
-
_context2.next = 13;
|
|
14361
|
-
return calculateFee(api);
|
|
14362
|
-
case 13:
|
|
14363
|
-
fee = _context2.sent;
|
|
14364
|
-
call = {
|
|
14365
|
-
module: 'PolkadotXcm',
|
|
14366
|
-
section: 'transfer_assets_using_type_and_then',
|
|
14367
|
-
parameters: {
|
|
14368
|
-
dest: this.createPolkadotXcmHeader(scenario, versionOrDefault, destination, getParaId('AssetHubPolkadot')),
|
|
14369
|
-
assets: _defineProperty({}, versionOrDefault, [Object.values(this.createCurrencySpec(fee, 'ParaToRelay', versionOrDefault))[0][0], ethMultiAsset]),
|
|
14370
|
-
assets_transfer_type: 'DestinationReserve',
|
|
14371
|
-
remote_fees_id: _defineProperty({}, versionOrDefault, {
|
|
14372
|
-
parents: Parents.ONE,
|
|
14373
|
-
interior: 'Here'
|
|
14374
|
-
}),
|
|
14375
|
-
fees_transfer_type: 'DestinationReserve',
|
|
14376
|
-
custom_xcm_on_dest: createCustomXcmOnDest(input, versionOrDefault),
|
|
14377
|
-
weight_limit: 'Unlimited'
|
|
14378
|
-
}
|
|
14379
|
-
};
|
|
14380
|
-
return _context2.abrupt("return", api.callTxMethod(call));
|
|
14381
|
-
case 16:
|
|
14382
|
-
case "end":
|
|
14383
|
-
return _context2.stop();
|
|
14384
|
-
}
|
|
14385
|
-
}, _callee2, this);
|
|
14386
|
-
}));
|
|
14387
|
-
function transferToEthereum(_x2) {
|
|
14388
|
-
return _transferToEthereum.apply(this, arguments);
|
|
14389
|
-
}
|
|
14390
|
-
return transferToEthereum;
|
|
14391
|
-
}()
|
|
14392
|
-
}, {
|
|
14393
14616
|
key: "transferToAssetHub",
|
|
14394
14617
|
value: function transferToAssetHub(input) {
|
|
14395
14618
|
var api = input.api,
|
|
@@ -14418,30 +14641,30 @@ var Hydration$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
14418
14641
|
};
|
|
14419
14642
|
return api.callTxMethod(call);
|
|
14420
14643
|
}
|
|
14421
|
-
// Handles
|
|
14644
|
+
// Handles transfers to Ethereum
|
|
14422
14645
|
}, {
|
|
14423
14646
|
key: "transferPolkadotXCM",
|
|
14424
14647
|
value: function () {
|
|
14425
|
-
var _transferPolkadotXCM = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
14648
|
+
var _transferPolkadotXCM = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(input) {
|
|
14426
14649
|
var destination;
|
|
14427
|
-
return _regeneratorRuntime().wrap(function
|
|
14428
|
-
while (1) switch (
|
|
14650
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
14651
|
+
while (1) switch (_context.prev = _context.next) {
|
|
14429
14652
|
case 0:
|
|
14430
14653
|
destination = input.destination;
|
|
14431
14654
|
if (!(destination === 'Ethereum')) {
|
|
14432
|
-
|
|
14655
|
+
_context.next = 3;
|
|
14433
14656
|
break;
|
|
14434
14657
|
}
|
|
14435
|
-
return
|
|
14658
|
+
return _context.abrupt("return", this.transferToEthereum(input));
|
|
14436
14659
|
case 3:
|
|
14437
|
-
return
|
|
14660
|
+
return _context.abrupt("return", this.transferToAssetHub(input));
|
|
14438
14661
|
case 4:
|
|
14439
14662
|
case "end":
|
|
14440
|
-
return
|
|
14663
|
+
return _context.stop();
|
|
14441
14664
|
}
|
|
14442
|
-
},
|
|
14665
|
+
}, _callee, this);
|
|
14443
14666
|
}));
|
|
14444
|
-
function transferPolkadotXCM(
|
|
14667
|
+
function transferPolkadotXCM(_x) {
|
|
14445
14668
|
return _transferPolkadotXCM.apply(this, arguments);
|
|
14446
14669
|
}
|
|
14447
14670
|
return transferPolkadotXCM;
|
|
@@ -14460,9 +14683,9 @@ var Hydration$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
14460
14683
|
}
|
|
14461
14684
|
}, {
|
|
14462
14685
|
key: "canUseXTokens",
|
|
14463
|
-
value: function canUseXTokens(
|
|
14464
|
-
var destination =
|
|
14465
|
-
asset =
|
|
14686
|
+
value: function canUseXTokens(_ref3) {
|
|
14687
|
+
var destination = _ref3.destination,
|
|
14688
|
+
asset = _ref3.asset;
|
|
14466
14689
|
return destination !== 'Ethereum' && !(destination === 'AssetHubPolkadot' && asset.symbol === 'DOT');
|
|
14467
14690
|
}
|
|
14468
14691
|
}]);
|
|
@@ -14922,78 +15145,6 @@ var generateAddressMultiLocationV4 = function generateAddressMultiLocationV4(api
|
|
|
14922
15145
|
});
|
|
14923
15146
|
};
|
|
14924
15147
|
|
|
14925
|
-
var generateAddressPayload = function generateAddressPayload(api, scenario, pallet, recipientAddress, version, nodeId) {
|
|
14926
|
-
var isMultiLocation = _typeof(recipientAddress) === 'object';
|
|
14927
|
-
if (isMultiLocation) {
|
|
14928
|
-
return _defineProperty({}, version, recipientAddress);
|
|
14929
|
-
}
|
|
14930
|
-
var isEthAddress = ethers.isAddress(recipientAddress);
|
|
14931
|
-
if (scenario === 'ParaToRelay') {
|
|
14932
|
-
return _defineProperty({}, version, {
|
|
14933
|
-
parents: pallet === 'XTokens' ? Parents.ONE : Parents.ZERO,
|
|
14934
|
-
interior: createX1Payload(version, {
|
|
14935
|
-
AccountId32: _objectSpread2(_objectSpread2({}, version === Version.V1 && {
|
|
14936
|
-
network: 'any'
|
|
14937
|
-
}), {}, {
|
|
14938
|
-
id: api.createAccountId(recipientAddress)
|
|
14939
|
-
})
|
|
14940
|
-
})
|
|
14941
|
-
});
|
|
14942
|
-
}
|
|
14943
|
-
if (scenario === 'ParaToPara' && pallet === 'XTokens') {
|
|
14944
|
-
return _defineProperty({}, version, {
|
|
14945
|
-
parents: Parents.ONE,
|
|
14946
|
-
interior: {
|
|
14947
|
-
X2: [{
|
|
14948
|
-
Parachain: nodeId
|
|
14949
|
-
}, isEthAddress ? {
|
|
14950
|
-
AccountKey20: _objectSpread2(_objectSpread2({}, (version === Version.V1 || version === Version.V2) && {
|
|
14951
|
-
network: 'any'
|
|
14952
|
-
}), {}, {
|
|
14953
|
-
key: recipientAddress
|
|
14954
|
-
})
|
|
14955
|
-
} : {
|
|
14956
|
-
AccountId32: _objectSpread2(_objectSpread2({}, (version === Version.V1 || version === Version.V2) && {
|
|
14957
|
-
network: 'any'
|
|
14958
|
-
}), {}, {
|
|
14959
|
-
id: api.createAccountId(recipientAddress)
|
|
14960
|
-
})
|
|
14961
|
-
}]
|
|
14962
|
-
}
|
|
14963
|
-
});
|
|
14964
|
-
}
|
|
14965
|
-
if (scenario === 'ParaToPara' && pallet === 'PolkadotXcm') {
|
|
14966
|
-
return _defineProperty({}, version, {
|
|
14967
|
-
parents: Parents.ZERO,
|
|
14968
|
-
interior: createX1Payload(version, isEthAddress ? {
|
|
14969
|
-
AccountKey20: _objectSpread2(_objectSpread2({}, (version === Version.V1 || version === Version.V2) && {
|
|
14970
|
-
network: 'any'
|
|
14971
|
-
}), {}, {
|
|
14972
|
-
key: recipientAddress
|
|
14973
|
-
})
|
|
14974
|
-
} : {
|
|
14975
|
-
AccountId32: _objectSpread2(_objectSpread2({}, (version === Version.V1 || version === Version.V2) && {
|
|
14976
|
-
network: 'any'
|
|
14977
|
-
}), {}, {
|
|
14978
|
-
id: api.createAccountId(recipientAddress)
|
|
14979
|
-
})
|
|
14980
|
-
})
|
|
14981
|
-
});
|
|
14982
|
-
}
|
|
14983
|
-
return _defineProperty({}, version, {
|
|
14984
|
-
parents: Parents.ZERO,
|
|
14985
|
-
interior: createX1Payload(version, isEthAddress ? {
|
|
14986
|
-
AccountKey20: {
|
|
14987
|
-
key: recipientAddress
|
|
14988
|
-
}
|
|
14989
|
-
} : {
|
|
14990
|
-
AccountId32: {
|
|
14991
|
-
id: api.createAccountId(recipientAddress)
|
|
14992
|
-
}
|
|
14993
|
-
})
|
|
14994
|
-
});
|
|
14995
|
-
};
|
|
14996
|
-
|
|
14997
15148
|
var createCustomXcmToBifrost = function createCustomXcmToBifrost(_ref, version) {
|
|
14998
15149
|
var api = _ref.api,
|
|
14999
15150
|
address = _ref.address,
|
|
@@ -15013,26 +15164,27 @@ var AssetHubPolkadot$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
15013
15164
|
_classCallCheck(this, AssetHubPolkadot);
|
|
15014
15165
|
_this = _callSuper(this, AssetHubPolkadot, ['AssetHubPolkadot', 'PolkadotAssetHub', 'polkadot', Version.V3]);
|
|
15015
15166
|
_this.handleBifrostEthTransfer = function (input) {
|
|
15016
|
-
var _asset$assetId;
|
|
15017
15167
|
var api = input.api,
|
|
15018
15168
|
scenario = input.scenario,
|
|
15019
15169
|
version = input.version,
|
|
15020
15170
|
destination = input.destination,
|
|
15021
15171
|
asset = input.asset;
|
|
15022
15172
|
if (!isForeignAsset(asset)) {
|
|
15023
|
-
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), "
|
|
15173
|
+
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
|
|
15174
|
+
}
|
|
15175
|
+
if (!asset.multiLocation) {
|
|
15176
|
+
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multiLocation"));
|
|
15024
15177
|
}
|
|
15025
15178
|
var versionOrDefault = version !== null && version !== undefined ? version : _this.version;
|
|
15026
|
-
var ethereumTokenLocation = createEthereumTokenLocation((_asset$assetId = asset.assetId) !== null && _asset$assetId !== undefined ? _asset$assetId : '');
|
|
15027
15179
|
var call = {
|
|
15028
15180
|
module: 'PolkadotXcm',
|
|
15029
15181
|
section: 'transfer_assets_using_type_and_then',
|
|
15030
15182
|
parameters: {
|
|
15031
15183
|
dest: _this.createPolkadotXcmHeader(scenario, versionOrDefault, destination, getParaId('BifrostPolkadot')),
|
|
15032
|
-
assets: _defineProperty({}, versionOrDefault, [Object.values(createCurrencySpec(asset.amount, versionOrDefault, Parents.TWO,
|
|
15184
|
+
assets: _defineProperty({}, versionOrDefault, [Object.values(createCurrencySpec(asset.amount, versionOrDefault, Parents.TWO, asset.multiLocation))[0][0]]),
|
|
15033
15185
|
assets_transfer_type: 'LocalReserve',
|
|
15034
15186
|
remote_fees_id: _defineProperty({}, versionOrDefault, {
|
|
15035
|
-
Concrete:
|
|
15187
|
+
Concrete: asset.multiLocation
|
|
15036
15188
|
}),
|
|
15037
15189
|
fees_transfer_type: 'LocalReserve',
|
|
15038
15190
|
custom_xcm_on_dest: createCustomXcmToBifrost(input, versionOrDefault),
|
|
@@ -15067,7 +15219,6 @@ var AssetHubPolkadot$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
15067
15219
|
}, {
|
|
15068
15220
|
key: "handleEthBridgeTransfer",
|
|
15069
15221
|
value: function handleEthBridgeTransfer(input) {
|
|
15070
|
-
var _ethAsset$assetId;
|
|
15071
15222
|
var api = input.api,
|
|
15072
15223
|
scenario = input.scenario,
|
|
15073
15224
|
destination = input.destination,
|
|
@@ -15077,26 +15228,16 @@ var AssetHubPolkadot$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
15077
15228
|
if (!ethers.isAddress(address)) {
|
|
15078
15229
|
throw new Error('Only Ethereum addresses are supported for Ethereum transfers');
|
|
15079
15230
|
}
|
|
15080
|
-
|
|
15081
|
-
|
|
15082
|
-
|
|
15083
|
-
|
|
15084
|
-
|
|
15085
|
-
throw new InvalidCurrencyError("Currency ".concat(asset.symbol, " is not supported for Ethereum transfers"));
|
|
15231
|
+
if (!isForeignAsset(asset)) {
|
|
15232
|
+
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
|
|
15233
|
+
}
|
|
15234
|
+
if (!asset.multiLocation) {
|
|
15235
|
+
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multiLocation"));
|
|
15086
15236
|
}
|
|
15087
15237
|
var modifiedInput = _objectSpread2(_objectSpread2({}, input), {}, {
|
|
15088
15238
|
header: createPolkadotXcmHeader(scenario, this.version, destination, paraIdTo, ETHEREUM_JUNCTION, Parents.TWO),
|
|
15089
15239
|
addressSelection: generateAddressPayload(api, scenario, 'PolkadotXcm', address, this.version, paraIdTo),
|
|
15090
|
-
currencySelection: createCurrencySpec(input.asset.amount, Version.V3, Parents.TWO,
|
|
15091
|
-
parents: Parents.TWO,
|
|
15092
|
-
interior: {
|
|
15093
|
-
X2: [ETHEREUM_JUNCTION, {
|
|
15094
|
-
AccountKey20: {
|
|
15095
|
-
key: (_ethAsset$assetId = ethAsset.assetId) !== null && _ethAsset$assetId !== undefined ? _ethAsset$assetId : ''
|
|
15096
|
-
}
|
|
15097
|
-
}]
|
|
15098
|
-
}
|
|
15099
|
-
})
|
|
15240
|
+
currencySelection: createCurrencySpec(input.asset.amount, Version.V3, Parents.TWO, asset.multiLocation)
|
|
15100
15241
|
});
|
|
15101
15242
|
return PolkadotXCMTransferImpl.transferPolkadotXCM(modifiedInput, 'transfer_assets', 'Unlimited');
|
|
15102
15243
|
}
|
|
@@ -16464,25 +16605,29 @@ var findAssetById = function findAssetById(assets, assetId) {
|
|
|
16464
16605
|
var sanitizeMultiLocation = function sanitizeMultiLocation(multiLocation) {
|
|
16465
16606
|
return multiLocation.replace(/"(\d+),(\d+)"/g, '"$1$2"');
|
|
16466
16607
|
};
|
|
16608
|
+
var compareMultiLocations = function compareMultiLocations(input, asset) {
|
|
16609
|
+
var _asset$multiLocation, _asset$xcmInterior;
|
|
16610
|
+
var sanitizedInput = sanitizeMultiLocation(input);
|
|
16611
|
+
var assetMLStr = JSON.stringify((_asset$multiLocation = asset.multiLocation) !== null && _asset$multiLocation !== undefined ? _asset$multiLocation : '');
|
|
16612
|
+
var assetMLInteriorStr = JSON.stringify((_asset$xcmInterior = asset.xcmInterior) !== null && _asset$xcmInterior !== undefined ? _asset$xcmInterior : '');
|
|
16613
|
+
var sanitizedAssetMLStr = sanitizeMultiLocation(assetMLStr);
|
|
16614
|
+
var sanitizedAssetMLInteriorStr = sanitizeMultiLocation(assetMLInteriorStr);
|
|
16615
|
+
return (
|
|
16616
|
+
// Compare sanitized input with sanitized asset values
|
|
16617
|
+
sanitizedInput === sanitizedAssetMLStr || sanitizedInput === sanitizedAssetMLInteriorStr ||
|
|
16618
|
+
// Compare original input with sanitized asset values
|
|
16619
|
+
input === sanitizedAssetMLStr || input === sanitizedAssetMLInteriorStr ||
|
|
16620
|
+
// Compare original input with original asset values
|
|
16621
|
+
input === assetMLStr || input === assetMLInteriorStr ||
|
|
16622
|
+
// Compare sanitized input with original asset values
|
|
16623
|
+
sanitizedInput === assetMLStr || sanitizedInput === assetMLInteriorStr
|
|
16624
|
+
);
|
|
16625
|
+
};
|
|
16626
|
+
|
|
16467
16627
|
var findAssetByMultiLocation = function findAssetByMultiLocation(foreignAssets, multiLocation) {
|
|
16468
16628
|
if (typeof multiLocation === 'string') {
|
|
16469
|
-
var sanitizedInput = sanitizeMultiLocation(multiLocation);
|
|
16470
16629
|
return foreignAssets.find(function (asset) {
|
|
16471
|
-
|
|
16472
|
-
var assetMLStr = JSON.stringify((_asset$multiLocation = asset.multiLocation) !== null && _asset$multiLocation !== undefined ? _asset$multiLocation : '');
|
|
16473
|
-
var assetMLInteriorStr = JSON.stringify((_asset$xcmInterior = asset.xcmInterior) !== null && _asset$xcmInterior !== undefined ? _asset$xcmInterior : '');
|
|
16474
|
-
var sanitizedAssetMLStr = sanitizeMultiLocation(assetMLStr);
|
|
16475
|
-
var sanitizedAssetMLInteriorStr = sanitizeMultiLocation(assetMLInteriorStr);
|
|
16476
|
-
return (
|
|
16477
|
-
// Compare inputNoCommas with assetNoCommas
|
|
16478
|
-
sanitizedInput === sanitizedAssetMLStr || sanitizedInput === sanitizedAssetMLInteriorStr ||
|
|
16479
|
-
// Compare inputOriginal with assetNoCommas
|
|
16480
|
-
multiLocation === sanitizedAssetMLStr || multiLocation === sanitizedAssetMLInteriorStr ||
|
|
16481
|
-
// Compare inputOriginal with assetOriginal
|
|
16482
|
-
multiLocation === assetMLStr || multiLocation === assetMLInteriorStr ||
|
|
16483
|
-
// Compare inputNoCommas with assetOriginal
|
|
16484
|
-
sanitizedInput === assetMLStr || sanitizedInput === assetMLInteriorStr
|
|
16485
|
-
);
|
|
16630
|
+
return compareMultiLocations(multiLocation, asset);
|
|
16486
16631
|
});
|
|
16487
16632
|
} else if (Array.isArray(multiLocation)) {
|
|
16488
16633
|
return foreignAssets.find(function (asset) {
|
|
@@ -16495,6 +16640,15 @@ var findAssetByMultiLocation = function findAssetByMultiLocation(foreignAssets,
|
|
|
16495
16640
|
}
|
|
16496
16641
|
};
|
|
16497
16642
|
|
|
16643
|
+
var filterEthCompatibleAssets = function filterEthCompatibleAssets(assets) {
|
|
16644
|
+
var ethAssets = getOtherAssets('Ethereum');
|
|
16645
|
+
return assets.filter(function (asset) {
|
|
16646
|
+
var assetMultiLoc = asset.multiLocation || asset.xcmInterior;
|
|
16647
|
+
if (!assetMultiLoc) return false;
|
|
16648
|
+
return Boolean(findAssetByMultiLocation(ethAssets, assetMultiLoc));
|
|
16649
|
+
});
|
|
16650
|
+
};
|
|
16651
|
+
|
|
16498
16652
|
var getAssetBySymbolOrId = function getAssetBySymbolOrId(node, currency, destination) {
|
|
16499
16653
|
if ('multilocation' in currency && isOverrideMultiLocationSpecifier(currency.multilocation) || 'multiasset' in currency) {
|
|
16500
16654
|
return null;
|
|
@@ -16502,21 +16656,37 @@ var getAssetBySymbolOrId = function getAssetBySymbolOrId(node, currency, destina
|
|
|
16502
16656
|
var _getAssetsObject = getAssetsObject(node),
|
|
16503
16657
|
otherAssets = _getAssetsObject.otherAssets,
|
|
16504
16658
|
nativeAssets = _getAssetsObject.nativeAssets;
|
|
16505
|
-
var
|
|
16659
|
+
var isEthereumDestination = destination === 'Ethereum';
|
|
16660
|
+
var getEthereumAssets = function getEthereumAssets() {
|
|
16661
|
+
return getOtherAssets('Ethereum');
|
|
16662
|
+
};
|
|
16663
|
+
var getFilteredEthereumAssets = function getFilteredEthereumAssets() {
|
|
16664
|
+
return filterEthCompatibleAssets(otherAssets);
|
|
16665
|
+
};
|
|
16506
16666
|
var asset;
|
|
16507
16667
|
if ('symbol' in currency) {
|
|
16508
|
-
|
|
16668
|
+
// If destination is Ethereum first try to find Ethereum compatible assets
|
|
16669
|
+
// If not found, search Ethereum assets directly
|
|
16670
|
+
if (isEthereumDestination) {
|
|
16671
|
+
var _findAssetBySymbol;
|
|
16672
|
+
asset = (_findAssetBySymbol = findAssetBySymbol(node, destination, getFilteredEthereumAssets(), nativeAssets, currency.symbol)) !== null && _findAssetBySymbol !== undefined ? _findAssetBySymbol : findAssetBySymbol(node, destination, getEthereumAssets(), nativeAssets, currency.symbol);
|
|
16673
|
+
} else {
|
|
16674
|
+
asset = findAssetBySymbol(node, destination, otherAssets, nativeAssets, currency.symbol);
|
|
16675
|
+
}
|
|
16509
16676
|
} else if ('multilocation' in currency && !isOverrideMultiLocationSpecifier(currency.multilocation)) {
|
|
16510
|
-
|
|
16677
|
+
var resolvedAssets = isEthereumDestination ? getEthereumAssets() : otherAssets;
|
|
16678
|
+
asset = findAssetByMultiLocation(resolvedAssets, currency.multilocation);
|
|
16511
16679
|
} else if ('id' in currency) {
|
|
16512
|
-
|
|
16680
|
+
if (isEthereumDestination) {
|
|
16681
|
+
var _findAssetById;
|
|
16682
|
+
asset = (_findAssetById = findAssetById(getFilteredEthereumAssets(), currency.id)) !== null && _findAssetById !== undefined ? _findAssetById : findAssetById(getEthereumAssets(), currency.id);
|
|
16683
|
+
} else {
|
|
16684
|
+
asset = findAssetById(otherAssets, currency.id);
|
|
16685
|
+
}
|
|
16513
16686
|
} else {
|
|
16514
16687
|
throw new Error('Invalid currency input');
|
|
16515
16688
|
}
|
|
16516
|
-
|
|
16517
|
-
return asset;
|
|
16518
|
-
}
|
|
16519
|
-
return null;
|
|
16689
|
+
return asset !== null && asset !== undefined ? asset : null;
|
|
16520
16690
|
};
|
|
16521
16691
|
|
|
16522
16692
|
var getAssetMultiLocation = function getAssetMultiLocation(node, currency) {
|
|
@@ -16716,6 +16886,9 @@ var getTNode = function getTNode(paraId, ecosystem) {
|
|
|
16716
16886
|
if (paraId === 0) {
|
|
16717
16887
|
return ecosystem === 'polkadot' ? 'Polkadot' : 'Kusama';
|
|
16718
16888
|
}
|
|
16889
|
+
if (paraId === 1) {
|
|
16890
|
+
return 'Ethereum';
|
|
16891
|
+
}
|
|
16719
16892
|
return (_NODE_NAMES_DOT_KSM$f = NODE_NAMES_DOT_KSM.find(function (nodeName) {
|
|
16720
16893
|
return getNode(nodeName).type === ecosystem && getParaId(nodeName) === paraId;
|
|
16721
16894
|
})) !== null && _NODE_NAMES_DOT_KSM$f !== undefined ? _NODE_NAMES_DOT_KSM$f : null;
|
|
@@ -18793,7 +18966,10 @@ var getSupportedAssets = function getSupportedAssets(origin, destination) {
|
|
|
18793
18966
|
var originAssets = getAssets(origin);
|
|
18794
18967
|
var destinationAssets = getAssets(destination);
|
|
18795
18968
|
if (destination === 'Ethereum' || origin === 'Ethereum') {
|
|
18796
|
-
|
|
18969
|
+
var otherAssets = getOtherAssets(origin);
|
|
18970
|
+
var ethereumCompatibleAssets = filterEthCompatibleAssets(otherAssets);
|
|
18971
|
+
var ethereumAssets = getOtherAssets('Ethereum');
|
|
18972
|
+
return [].concat(_toConsumableArray(ethereumCompatibleAssets), _toConsumableArray(ethereumAssets));
|
|
18797
18973
|
}
|
|
18798
18974
|
if (origin === 'AssetHubPolkadot' && destination === 'AssetHubKusama' || origin === 'AssetHubKusama' && destination === 'AssetHubPolkadot') {
|
|
18799
18975
|
var polkadotAsset = getAssetBySymbolOrId('Polkadot', {
|
|
@@ -18895,15 +19071,35 @@ var getNode = function getNode(node) {
|
|
|
18895
19071
|
return nodeMap[node];
|
|
18896
19072
|
};
|
|
18897
19073
|
|
|
19074
|
+
var shuffleArray = function shuffleArray(array) {
|
|
19075
|
+
var copy = _toConsumableArray(array);
|
|
19076
|
+
for (var i = copy.length - 1; i > 0; i--) {
|
|
19077
|
+
var j = Math.floor(Math.random() * (i + 1));
|
|
19078
|
+
var _ref = [copy[j], copy[i]];
|
|
19079
|
+
copy[i] = _ref[0];
|
|
19080
|
+
copy[j] = _ref[1];
|
|
19081
|
+
}
|
|
19082
|
+
return copy;
|
|
19083
|
+
};
|
|
19084
|
+
|
|
19085
|
+
var shuffleWsProviders = function shuffleWsProviders(node, wsProviders) {
|
|
19086
|
+
var ALLOWED_NODES = ['Hydration'];
|
|
19087
|
+
if (ALLOWED_NODES.includes(node)) {
|
|
19088
|
+
return shuffleArray(wsProviders);
|
|
19089
|
+
}
|
|
19090
|
+
return wsProviders;
|
|
19091
|
+
};
|
|
19092
|
+
|
|
18898
19093
|
var createApiInstanceForNode = /*#__PURE__*/function () {
|
|
18899
19094
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(api, node) {
|
|
18900
|
-
var wsUrl;
|
|
19095
|
+
var wsUrl, resolvedWsUrl;
|
|
18901
19096
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
18902
19097
|
while (1) switch (_context.prev = _context.next) {
|
|
18903
19098
|
case 0:
|
|
18904
19099
|
wsUrl = getNodeProviders(node);
|
|
18905
|
-
|
|
18906
|
-
|
|
19100
|
+
resolvedWsUrl = Array.isArray(wsUrl) ? shuffleWsProviders(node, wsUrl) : wsUrl;
|
|
19101
|
+
return _context.abrupt("return", api.createApiInstance(resolvedWsUrl));
|
|
19102
|
+
case 3:
|
|
18907
19103
|
case "end":
|
|
18908
19104
|
return _context.stop();
|
|
18909
19105
|
}
|
|
@@ -19135,7 +19331,7 @@ var validateDestination = function validateDestination(origin, destination) {
|
|
|
19135
19331
|
if (isRelayChain(origin) && !isTMultiLocation(destination) && isRelayChain(destination)) {
|
|
19136
19332
|
throw new IncompatibleNodesError('Direct relay chain to relay chain transfers are not supported. Please use Polkadot <-> Kusama bridge through AssetHub.');
|
|
19137
19333
|
}
|
|
19138
|
-
if (destination === 'Ethereum' && origin !== 'AssetHubPolkadot' && origin !== 'Hydration') {
|
|
19334
|
+
if (destination === 'Ethereum' && origin !== 'AssetHubPolkadot' && origin !== 'Hydration' && origin !== 'BifrostPolkadot') {
|
|
19139
19335
|
throw new IncompatibleNodesError('Transfers to Ethereum are only supported from AssetHubPolkadot and Hydration.');
|
|
19140
19336
|
}
|
|
19141
19337
|
var isMultiLocationDestination = _typeof(destination) === 'object';
|
|
@@ -19270,33 +19466,39 @@ var send = /*#__PURE__*/function () {
|
|
|
19270
19466
|
validateCurrency(currency);
|
|
19271
19467
|
validateDestination(origin, destination);
|
|
19272
19468
|
validateDestinationAddress(address, destination);
|
|
19273
|
-
if (!(
|
|
19469
|
+
if (!(ahAddress && ethers.isAddress(ahAddress))) {
|
|
19274
19470
|
_context.next = 6;
|
|
19275
19471
|
break;
|
|
19276
19472
|
}
|
|
19277
|
-
throw new Error('
|
|
19473
|
+
throw new Error('AssetHub address needs to be in Substrate format');
|
|
19278
19474
|
case 6:
|
|
19475
|
+
if (!(isRelayChain(origin) && !isTMultiLocation(destination) && isRelayChain(destination))) {
|
|
19476
|
+
_context.next = 8;
|
|
19477
|
+
break;
|
|
19478
|
+
}
|
|
19479
|
+
throw new Error('Relay chain to relay chain transfers are not supported.');
|
|
19480
|
+
case 8:
|
|
19279
19481
|
isBridge = isBridgeTransfer(origin, destination);
|
|
19280
19482
|
assetCheckEnabled = determineAssetCheckEnabled(origin, currency, isBridge);
|
|
19281
19483
|
validateAssetSpecifiers(assetCheckEnabled, currency);
|
|
19282
19484
|
asset = resolveAsset(currency, origin, destination, assetCheckEnabled);
|
|
19283
19485
|
validateAssetSupport(options, assetCheckEnabled, isBridge, asset);
|
|
19284
19486
|
if (!isRelayChain(origin)) {
|
|
19285
|
-
_context.next =
|
|
19487
|
+
_context.next = 19;
|
|
19286
19488
|
break;
|
|
19287
19489
|
}
|
|
19288
19490
|
if (!(destination === 'Ethereum')) {
|
|
19289
|
-
_context.next =
|
|
19491
|
+
_context.next = 16;
|
|
19290
19492
|
break;
|
|
19291
19493
|
}
|
|
19292
19494
|
throw new Error('Transfers from relay chain to Ethereum are not supported.');
|
|
19293
|
-
case
|
|
19495
|
+
case 16:
|
|
19294
19496
|
if (asset) {
|
|
19295
|
-
_context.next =
|
|
19497
|
+
_context.next = 18;
|
|
19296
19498
|
break;
|
|
19297
19499
|
}
|
|
19298
19500
|
throw new Error('Asset is required for relay chain to relay chain transfers.');
|
|
19299
|
-
case
|
|
19501
|
+
case 18:
|
|
19300
19502
|
return _context.abrupt("return", transferRelayToPara({
|
|
19301
19503
|
api: api,
|
|
19302
19504
|
origin: origin,
|
|
@@ -19310,11 +19512,11 @@ var send = /*#__PURE__*/function () {
|
|
|
19310
19512
|
pallet: pallet,
|
|
19311
19513
|
method: method
|
|
19312
19514
|
}));
|
|
19313
|
-
case
|
|
19515
|
+
case 19:
|
|
19314
19516
|
overriddenAsset = resolveOverriddenAsset(options, isBridge, assetCheckEnabled);
|
|
19315
|
-
_context.next =
|
|
19517
|
+
_context.next = 22;
|
|
19316
19518
|
return api.init(origin);
|
|
19317
|
-
case
|
|
19519
|
+
case 22:
|
|
19318
19520
|
// In case asset check is disabled, we create asset object from currency symbol
|
|
19319
19521
|
resolvedAsset = asset !== null && asset !== undefined ? asset : {
|
|
19320
19522
|
symbol: 'symbol' in currency ? currency.symbol : undefined
|
|
@@ -19334,7 +19536,7 @@ var send = /*#__PURE__*/function () {
|
|
|
19334
19536
|
pallet: pallet,
|
|
19335
19537
|
method: method
|
|
19336
19538
|
}));
|
|
19337
|
-
case
|
|
19539
|
+
case 25:
|
|
19338
19540
|
case "end":
|
|
19339
19541
|
return _context.stop();
|
|
19340
19542
|
}
|
|
@@ -19609,4 +19811,4 @@ var transferMoonbeamEvm = /*#__PURE__*/function () {
|
|
|
19609
19811
|
};
|
|
19610
19812
|
}();
|
|
19611
19813
|
|
|
19612
|
-
export { BatchMode, Builder, DuplicateAssetError, DuplicateAssetIdError, Foreign, ForeignAbstract, GeneralBuilder, IncompatibleNodesError, InvalidAddressError, InvalidCurrencyError, NODES_WITH_RELAY_CHAINS, NODES_WITH_RELAY_CHAINS_DOT_KSM, NODE_NAMES, NODE_NAMES_DOT_KSM, Native, NoXCMSupportImplementedError, NodeNotSupportedError, Override, Parents, PolkadotXcmError, SUPPORTED_PALLETS, ScenarioNotSupportedError, Version, XTokensError, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, createApiInstanceForNode, createX1Payload, _deepEqual as deepEqual, determineRelayChain, findAssetById, findAssetByMultiLocation, findAssetBySymbol, findBestMatches, generateAddressMultiLocationV4, generateAddressPayload, getAllAssetsSymbols, getAssetBalance, getAssetBalanceInternal, getAssetBySymbolOrId, getAssetDecimals, getAssetId, getAssetMultiLocation, getAssets, getAssetsObject, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getDefaultPallet, getDryRun, getExistentialDeposit, getFees, getMaxForeignTransferableAmount, getMaxNativeTransferableAmount, getNativeAssetSymbol, getNativeAssets, getNode, getNodeConfig, getNodeProviders, getOriginFeeDetails, getOriginFeeDetailsInternal, getOtherAssets, getParaId, getRelayChainSymbol, getSupportedAssets, getSupportedPallets, getSupportedPalletsDetails, getTNode, getTransferInfo, getTransferableAmount, hasSupportForAsset, isForeignAsset, isNodeEvm, isOverrideMultiLocationSpecifier, isRelayChain, isSymbolSpecifier, normalizeSymbol, resolveModuleError, resolveParaId, send, transferMoonbeamEvm, transferRelayToPara };
|
|
19814
|
+
export { BatchMode, Builder, DuplicateAssetError, DuplicateAssetIdError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, Foreign, ForeignAbstract, GeneralBuilder, IncompatibleNodesError, InvalidAddressError, InvalidCurrencyError, NODES_WITH_RELAY_CHAINS, NODES_WITH_RELAY_CHAINS_DOT_KSM, NODE_NAMES, NODE_NAMES_DOT_KSM, Native, NoXCMSupportImplementedError, NodeNotSupportedError, Override, Parents, PolkadotXcmError, SUPPORTED_PALLETS, ScenarioNotSupportedError, Version, XTokensError, calculateFee, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, createApiInstanceForNode, createX1Payload, _deepEqual as deepEqual, determineRelayChain, findAssetById, findAssetByMultiLocation, findAssetBySymbol, findBestMatches, generateAddressMultiLocationV4, generateAddressPayload, getAllAssetsSymbols, getAssetBalance, getAssetBalanceInternal, getAssetBySymbolOrId, getAssetDecimals, getAssetId, getAssetMultiLocation, getAssets, getAssetsObject, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getDefaultPallet, getDryRun, getExistentialDeposit, getFees, getMaxForeignTransferableAmount, getMaxNativeTransferableAmount, getNativeAssetSymbol, getNativeAssets, getNode, getNodeConfig, getNodeProviders, getOriginFeeDetails, getOriginFeeDetailsInternal, getOtherAssets, getParaId, getRelayChainSymbol, getSupportedAssets, getSupportedPallets, getSupportedPalletsDetails, getTNode, getTransferInfo, getTransferableAmount, hasSupportForAsset, isForeignAsset, isNodeEvm, isOverrideMultiLocationSpecifier, isRelayChain, isSymbolSpecifier, normalizeSymbol, resolveModuleError, resolveParaId, send, transferMoonbeamEvm, transferRelayToPara, validateAddress };
|