@paraspell/sdk-core 8.5.2 → 8.5.3
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 +661 -319
- package/dist/index.d.ts +30 -18
- package/dist/index.mjs +658 -320
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -6101,260 +6101,286 @@ var AssetHubPolkadot$3 = {
|
|
|
6101
6101
|
assetId: "1024",
|
|
6102
6102
|
symbol: "NCTR",
|
|
6103
6103
|
decimals: 18,
|
|
6104
|
-
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
|
|
6115
|
-
|
|
6116
|
-
|
|
6117
|
-
|
|
6104
|
+
multiLocation: {
|
|
6105
|
+
parents: 1,
|
|
6106
|
+
interior: {
|
|
6107
|
+
X3: [
|
|
6108
|
+
{
|
|
6109
|
+
Parachain: 1000
|
|
6110
|
+
},
|
|
6111
|
+
{
|
|
6112
|
+
PalletInstance: 50
|
|
6113
|
+
},
|
|
6114
|
+
{
|
|
6115
|
+
GeneralIndex: 1024
|
|
6116
|
+
}
|
|
6117
|
+
]
|
|
6118
|
+
}
|
|
6119
|
+
},
|
|
6118
6120
|
existentialDeposit: "100000000"
|
|
6119
6121
|
},
|
|
6120
6122
|
{
|
|
6121
6123
|
assetId: "1337",
|
|
6122
6124
|
symbol: "USDC",
|
|
6123
6125
|
decimals: 6,
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
|
|
6131
|
-
|
|
6132
|
-
|
|
6133
|
-
|
|
6134
|
-
|
|
6135
|
-
|
|
6136
|
-
|
|
6137
|
-
|
|
6126
|
+
multiLocation: {
|
|
6127
|
+
parents: 1,
|
|
6128
|
+
interior: {
|
|
6129
|
+
X3: [
|
|
6130
|
+
{
|
|
6131
|
+
Parachain: 1000
|
|
6132
|
+
},
|
|
6133
|
+
{
|
|
6134
|
+
PalletInstance: 50
|
|
6135
|
+
},
|
|
6136
|
+
{
|
|
6137
|
+
GeneralIndex: 1337
|
|
6138
|
+
}
|
|
6139
|
+
]
|
|
6140
|
+
}
|
|
6141
|
+
},
|
|
6138
6142
|
existentialDeposit: "10000"
|
|
6139
6143
|
},
|
|
6140
6144
|
{
|
|
6141
6145
|
assetId: "17",
|
|
6142
6146
|
symbol: "WIFD",
|
|
6143
6147
|
decimals: 10,
|
|
6144
|
-
|
|
6145
|
-
|
|
6146
|
-
|
|
6147
|
-
|
|
6148
|
-
|
|
6149
|
-
|
|
6150
|
-
|
|
6151
|
-
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6148
|
+
multiLocation: {
|
|
6149
|
+
parents: 1,
|
|
6150
|
+
interior: {
|
|
6151
|
+
X3: [
|
|
6152
|
+
{
|
|
6153
|
+
Parachain: 1000
|
|
6154
|
+
},
|
|
6155
|
+
{
|
|
6156
|
+
PalletInstance: 50
|
|
6157
|
+
},
|
|
6158
|
+
{
|
|
6159
|
+
GeneralIndex: 17
|
|
6160
|
+
}
|
|
6161
|
+
]
|
|
6162
|
+
}
|
|
6163
|
+
},
|
|
6158
6164
|
existentialDeposit: "1"
|
|
6159
6165
|
},
|
|
6160
6166
|
{
|
|
6161
6167
|
assetId: "1984",
|
|
6162
6168
|
symbol: "USDt",
|
|
6163
6169
|
decimals: 6,
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
|
|
6169
|
-
|
|
6170
|
-
|
|
6171
|
-
|
|
6172
|
-
|
|
6173
|
-
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
6170
|
+
multiLocation: {
|
|
6171
|
+
parents: 1,
|
|
6172
|
+
interior: {
|
|
6173
|
+
X3: [
|
|
6174
|
+
{
|
|
6175
|
+
Parachain: 1000
|
|
6176
|
+
},
|
|
6177
|
+
{
|
|
6178
|
+
PalletInstance: 50
|
|
6179
|
+
},
|
|
6180
|
+
{
|
|
6181
|
+
GeneralIndex: 1984
|
|
6182
|
+
}
|
|
6183
|
+
]
|
|
6184
|
+
}
|
|
6185
|
+
},
|
|
6178
6186
|
existentialDeposit: "10000"
|
|
6179
6187
|
},
|
|
6180
6188
|
{
|
|
6181
6189
|
assetId: "21",
|
|
6182
6190
|
symbol: "WBTC",
|
|
6183
6191
|
decimals: 8,
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6197
|
-
|
|
6192
|
+
multiLocation: {
|
|
6193
|
+
parents: 1,
|
|
6194
|
+
interior: {
|
|
6195
|
+
X3: [
|
|
6196
|
+
{
|
|
6197
|
+
Parachain: 1000
|
|
6198
|
+
},
|
|
6199
|
+
{
|
|
6200
|
+
PalletInstance: 50
|
|
6201
|
+
},
|
|
6202
|
+
{
|
|
6203
|
+
GeneralIndex: 21
|
|
6204
|
+
}
|
|
6205
|
+
]
|
|
6206
|
+
}
|
|
6207
|
+
},
|
|
6198
6208
|
existentialDeposit: "3000"
|
|
6199
6209
|
},
|
|
6200
6210
|
{
|
|
6201
6211
|
assetId: "22222012",
|
|
6202
6212
|
symbol: "DAMN",
|
|
6203
6213
|
decimals: 12,
|
|
6204
|
-
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
|
|
6208
|
-
|
|
6209
|
-
|
|
6210
|
-
|
|
6211
|
-
|
|
6212
|
-
|
|
6213
|
-
|
|
6214
|
-
|
|
6215
|
-
|
|
6216
|
-
|
|
6217
|
-
|
|
6214
|
+
multiLocation: {
|
|
6215
|
+
parents: 1,
|
|
6216
|
+
interior: {
|
|
6217
|
+
X3: [
|
|
6218
|
+
{
|
|
6219
|
+
Parachain: 1000
|
|
6220
|
+
},
|
|
6221
|
+
{
|
|
6222
|
+
PalletInstance: 50
|
|
6223
|
+
},
|
|
6224
|
+
{
|
|
6225
|
+
GeneralIndex: 22222012
|
|
6226
|
+
}
|
|
6227
|
+
]
|
|
6228
|
+
}
|
|
6229
|
+
},
|
|
6218
6230
|
existentialDeposit: "1000000000000"
|
|
6219
6231
|
},
|
|
6220
6232
|
{
|
|
6221
6233
|
assetId: "23",
|
|
6222
6234
|
symbol: "PINK",
|
|
6223
6235
|
decimals: 10,
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6236
|
+
multiLocation: {
|
|
6237
|
+
parents: 1,
|
|
6238
|
+
interior: {
|
|
6239
|
+
X3: [
|
|
6240
|
+
{
|
|
6241
|
+
Parachain: 1000
|
|
6242
|
+
},
|
|
6243
|
+
{
|
|
6244
|
+
PalletInstance: 50
|
|
6245
|
+
},
|
|
6246
|
+
{
|
|
6247
|
+
GeneralIndex: 23
|
|
6248
|
+
}
|
|
6249
|
+
]
|
|
6250
|
+
}
|
|
6251
|
+
},
|
|
6238
6252
|
existentialDeposit: "1"
|
|
6239
6253
|
},
|
|
6240
6254
|
{
|
|
6241
6255
|
assetId: "30",
|
|
6242
6256
|
symbol: "DED",
|
|
6243
6257
|
decimals: 10,
|
|
6244
|
-
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
|
-
|
|
6248
|
-
|
|
6249
|
-
|
|
6250
|
-
|
|
6251
|
-
|
|
6252
|
-
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
|
|
6256
|
-
|
|
6257
|
-
|
|
6258
|
+
multiLocation: {
|
|
6259
|
+
parents: 1,
|
|
6260
|
+
interior: {
|
|
6261
|
+
X3: [
|
|
6262
|
+
{
|
|
6263
|
+
Parachain: 1000
|
|
6264
|
+
},
|
|
6265
|
+
{
|
|
6266
|
+
PalletInstance: 50
|
|
6267
|
+
},
|
|
6268
|
+
{
|
|
6269
|
+
GeneralIndex: 30
|
|
6270
|
+
}
|
|
6271
|
+
]
|
|
6272
|
+
}
|
|
6273
|
+
},
|
|
6258
6274
|
existentialDeposit: "1"
|
|
6259
6275
|
},
|
|
6260
6276
|
{
|
|
6261
6277
|
assetId: "31337",
|
|
6262
6278
|
symbol: "WUD",
|
|
6263
6279
|
decimals: 10,
|
|
6264
|
-
|
|
6265
|
-
|
|
6266
|
-
|
|
6267
|
-
|
|
6268
|
-
|
|
6269
|
-
|
|
6270
|
-
|
|
6271
|
-
|
|
6272
|
-
|
|
6273
|
-
|
|
6274
|
-
|
|
6275
|
-
|
|
6276
|
-
|
|
6277
|
-
|
|
6280
|
+
multiLocation: {
|
|
6281
|
+
parents: 1,
|
|
6282
|
+
interior: {
|
|
6283
|
+
X3: [
|
|
6284
|
+
{
|
|
6285
|
+
Parachain: 1000
|
|
6286
|
+
},
|
|
6287
|
+
{
|
|
6288
|
+
PalletInstance: 50
|
|
6289
|
+
},
|
|
6290
|
+
{
|
|
6291
|
+
GeneralIndex: 31337
|
|
6292
|
+
}
|
|
6293
|
+
]
|
|
6294
|
+
}
|
|
6295
|
+
},
|
|
6278
6296
|
existentialDeposit: "10000000"
|
|
6279
6297
|
},
|
|
6280
6298
|
{
|
|
6281
6299
|
assetId: "42069",
|
|
6282
6300
|
symbol: "STINK",
|
|
6283
6301
|
decimals: 10,
|
|
6284
|
-
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6302
|
+
multiLocation: {
|
|
6303
|
+
parents: 1,
|
|
6304
|
+
interior: {
|
|
6305
|
+
X3: [
|
|
6306
|
+
{
|
|
6307
|
+
Parachain: 1000
|
|
6308
|
+
},
|
|
6309
|
+
{
|
|
6310
|
+
PalletInstance: 50
|
|
6311
|
+
},
|
|
6312
|
+
{
|
|
6313
|
+
GeneralIndex: 42069
|
|
6314
|
+
}
|
|
6315
|
+
]
|
|
6316
|
+
}
|
|
6317
|
+
},
|
|
6298
6318
|
existentialDeposit: "1000000"
|
|
6299
6319
|
},
|
|
6300
6320
|
{
|
|
6301
6321
|
assetId: "50000028",
|
|
6302
6322
|
symbol: "LOVA",
|
|
6303
6323
|
decimals: 12,
|
|
6304
|
-
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
|
|
6308
|
-
|
|
6309
|
-
|
|
6310
|
-
|
|
6311
|
-
|
|
6312
|
-
|
|
6313
|
-
|
|
6314
|
-
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
|
|
6324
|
+
multiLocation: {
|
|
6325
|
+
parents: 1,
|
|
6326
|
+
interior: {
|
|
6327
|
+
X3: [
|
|
6328
|
+
{
|
|
6329
|
+
Parachain: 1000
|
|
6330
|
+
},
|
|
6331
|
+
{
|
|
6332
|
+
PalletInstance: 50
|
|
6333
|
+
},
|
|
6334
|
+
{
|
|
6335
|
+
GeneralIndex: 50000028
|
|
6336
|
+
}
|
|
6337
|
+
]
|
|
6338
|
+
}
|
|
6339
|
+
},
|
|
6318
6340
|
existentialDeposit: "1000000000000"
|
|
6319
6341
|
},
|
|
6320
6342
|
{
|
|
6321
6343
|
assetId: "50000069",
|
|
6322
6344
|
symbol: "LOTY",
|
|
6323
6345
|
decimals: 12,
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
|
|
6336
|
-
|
|
6337
|
-
|
|
6346
|
+
multiLocation: {
|
|
6347
|
+
parents: 1,
|
|
6348
|
+
interior: {
|
|
6349
|
+
X3: [
|
|
6350
|
+
{
|
|
6351
|
+
Parachain: 1000
|
|
6352
|
+
},
|
|
6353
|
+
{
|
|
6354
|
+
PalletInstance: 50
|
|
6355
|
+
},
|
|
6356
|
+
{
|
|
6357
|
+
GeneralIndex: 50000069
|
|
6358
|
+
}
|
|
6359
|
+
]
|
|
6360
|
+
}
|
|
6361
|
+
},
|
|
6338
6362
|
existentialDeposit: "100000000"
|
|
6339
6363
|
},
|
|
6340
6364
|
{
|
|
6341
6365
|
assetId: "555",
|
|
6342
6366
|
symbol: "GAME",
|
|
6343
6367
|
decimals: 10,
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6368
|
+
multiLocation: {
|
|
6369
|
+
parents: 1,
|
|
6370
|
+
interior: {
|
|
6371
|
+
X3: [
|
|
6372
|
+
{
|
|
6373
|
+
Parachain: 1000
|
|
6374
|
+
},
|
|
6375
|
+
{
|
|
6376
|
+
PalletInstance: 50
|
|
6377
|
+
},
|
|
6378
|
+
{
|
|
6379
|
+
GeneralIndex: 555
|
|
6380
|
+
}
|
|
6381
|
+
]
|
|
6382
|
+
}
|
|
6383
|
+
},
|
|
6358
6384
|
existentialDeposit: "100000"
|
|
6359
6385
|
},
|
|
6360
6386
|
{
|
|
@@ -10335,80 +10361,88 @@ var AssetHubKusama$3 = {
|
|
|
10335
10361
|
assetId: "16",
|
|
10336
10362
|
symbol: "ARIS",
|
|
10337
10363
|
decimals: 8,
|
|
10338
|
-
|
|
10339
|
-
|
|
10340
|
-
|
|
10341
|
-
|
|
10342
|
-
|
|
10343
|
-
|
|
10344
|
-
|
|
10345
|
-
|
|
10346
|
-
|
|
10347
|
-
|
|
10348
|
-
|
|
10349
|
-
|
|
10350
|
-
|
|
10351
|
-
|
|
10364
|
+
multiLocation: {
|
|
10365
|
+
parents: 1,
|
|
10366
|
+
interior: {
|
|
10367
|
+
X3: [
|
|
10368
|
+
{
|
|
10369
|
+
Parachain: 1000
|
|
10370
|
+
},
|
|
10371
|
+
{
|
|
10372
|
+
PalletInstance: 50
|
|
10373
|
+
},
|
|
10374
|
+
{
|
|
10375
|
+
GeneralIndex: 16
|
|
10376
|
+
}
|
|
10377
|
+
]
|
|
10378
|
+
}
|
|
10379
|
+
},
|
|
10352
10380
|
existentialDeposit: "10000000"
|
|
10353
10381
|
},
|
|
10354
10382
|
{
|
|
10355
10383
|
assetId: "1984",
|
|
10356
10384
|
symbol: "USDt",
|
|
10357
10385
|
decimals: 6,
|
|
10358
|
-
|
|
10359
|
-
|
|
10360
|
-
|
|
10361
|
-
|
|
10362
|
-
|
|
10363
|
-
|
|
10364
|
-
|
|
10365
|
-
|
|
10366
|
-
|
|
10367
|
-
|
|
10368
|
-
|
|
10369
|
-
|
|
10370
|
-
|
|
10371
|
-
|
|
10386
|
+
multiLocation: {
|
|
10387
|
+
parents: 1,
|
|
10388
|
+
interior: {
|
|
10389
|
+
X3: [
|
|
10390
|
+
{
|
|
10391
|
+
Parachain: 1000
|
|
10392
|
+
},
|
|
10393
|
+
{
|
|
10394
|
+
PalletInstance: 50
|
|
10395
|
+
},
|
|
10396
|
+
{
|
|
10397
|
+
GeneralIndex: 1984
|
|
10398
|
+
}
|
|
10399
|
+
]
|
|
10400
|
+
}
|
|
10401
|
+
},
|
|
10372
10402
|
existentialDeposit: "100"
|
|
10373
10403
|
},
|
|
10374
10404
|
{
|
|
10375
10405
|
assetId: "223",
|
|
10376
10406
|
symbol: "BILL",
|
|
10377
10407
|
decimals: 8,
|
|
10378
|
-
|
|
10379
|
-
|
|
10380
|
-
|
|
10381
|
-
|
|
10382
|
-
|
|
10383
|
-
|
|
10384
|
-
|
|
10385
|
-
|
|
10386
|
-
|
|
10387
|
-
|
|
10388
|
-
|
|
10389
|
-
|
|
10390
|
-
|
|
10391
|
-
|
|
10408
|
+
multiLocation: {
|
|
10409
|
+
parents: 1,
|
|
10410
|
+
interior: {
|
|
10411
|
+
X3: [
|
|
10412
|
+
{
|
|
10413
|
+
Parachain: 1000
|
|
10414
|
+
},
|
|
10415
|
+
{
|
|
10416
|
+
PalletInstance: 50
|
|
10417
|
+
},
|
|
10418
|
+
{
|
|
10419
|
+
GeneralIndex: 223
|
|
10420
|
+
}
|
|
10421
|
+
]
|
|
10422
|
+
}
|
|
10423
|
+
},
|
|
10392
10424
|
existentialDeposit: "10000"
|
|
10393
10425
|
},
|
|
10394
10426
|
{
|
|
10395
10427
|
assetId: "8",
|
|
10396
10428
|
symbol: "RMRK",
|
|
10397
10429
|
decimals: 10,
|
|
10398
|
-
|
|
10399
|
-
|
|
10400
|
-
|
|
10401
|
-
|
|
10402
|
-
|
|
10403
|
-
|
|
10404
|
-
|
|
10405
|
-
|
|
10406
|
-
|
|
10407
|
-
|
|
10408
|
-
|
|
10409
|
-
|
|
10410
|
-
|
|
10411
|
-
|
|
10430
|
+
multiLocation: {
|
|
10431
|
+
parents: 1,
|
|
10432
|
+
interior: {
|
|
10433
|
+
X3: [
|
|
10434
|
+
{
|
|
10435
|
+
Parachain: 1000
|
|
10436
|
+
},
|
|
10437
|
+
{
|
|
10438
|
+
PalletInstance: 50
|
|
10439
|
+
},
|
|
10440
|
+
{
|
|
10441
|
+
GeneralIndex: 8
|
|
10442
|
+
}
|
|
10443
|
+
]
|
|
10444
|
+
}
|
|
10445
|
+
},
|
|
10412
10446
|
existentialDeposit: "10000"
|
|
10413
10447
|
},
|
|
10414
10448
|
{
|
|
@@ -12774,7 +12808,7 @@ var NODES_WITH_RELAY_CHAINS_DOT_KSM = [].concat(NODE_NAMES_DOT_KSM, ['Polkadot',
|
|
|
12774
12808
|
var SUPPORTED_PALLETS = ['XTokens', 'OrmlXTokens', 'PolkadotXcm', 'RelayerXcm', 'XTransfer', 'XcmPallet'];
|
|
12775
12809
|
|
|
12776
12810
|
var isForeignAsset = function isForeignAsset(asset) {
|
|
12777
|
-
return _typeof(asset) === 'object' && asset !== null && ('assetId' in asset || 'multiLocation' in asset
|
|
12811
|
+
return _typeof(asset) === 'object' && asset !== null && ('assetId' in asset || 'multiLocation' in asset) && !('isNative' in asset);
|
|
12778
12812
|
};
|
|
12779
12813
|
|
|
12780
12814
|
var isSymbolSpecifier = function isSymbolSpecifier(currencySymbolValue) {
|
|
@@ -14576,11 +14610,6 @@ var buildMultiLocation = function buildMultiLocation(_ref) {
|
|
|
14576
14610
|
}
|
|
14577
14611
|
if (assetHubAsset.multiLocation) {
|
|
14578
14612
|
return assetHubAsset.multiLocation;
|
|
14579
|
-
} else if (assetHubAsset.xcmInterior) {
|
|
14580
|
-
return {
|
|
14581
|
-
parents: Parents.ONE,
|
|
14582
|
-
interior: _defineProperty({}, "X".concat(assetHubAsset.xcmInterior.length), assetHubAsset.xcmInterior)
|
|
14583
|
-
};
|
|
14584
14613
|
}
|
|
14585
14614
|
throw new InvalidCurrencyError("Asset ".concat(asset.symbol, " has no multiLocation"));
|
|
14586
14615
|
}
|
|
@@ -14604,11 +14633,6 @@ var buildMultiLocation = function buildMultiLocation(_ref) {
|
|
|
14604
14633
|
}
|
|
14605
14634
|
if (asset.multiLocation) {
|
|
14606
14635
|
return asset.multiLocation;
|
|
14607
|
-
} else if (asset.xcmInterior) {
|
|
14608
|
-
return {
|
|
14609
|
-
parents: Parents.ONE,
|
|
14610
|
-
interior: _defineProperty({}, "X".concat(asset.xcmInterior.length), asset.xcmInterior)
|
|
14611
|
-
};
|
|
14612
14636
|
} else {
|
|
14613
14637
|
return createDefaultMultiLocation(asset.assetId);
|
|
14614
14638
|
}
|
|
@@ -14771,18 +14795,21 @@ var generateAddressPayload = function generateAddressPayload(api, scenario, pall
|
|
|
14771
14795
|
});
|
|
14772
14796
|
};
|
|
14773
14797
|
|
|
14774
|
-
var createCustomXcmOnDest = function createCustomXcmOnDest(_ref, version) {
|
|
14798
|
+
var createCustomXcmOnDest = function createCustomXcmOnDest(_ref, version, messageId) {
|
|
14775
14799
|
var api = _ref.api,
|
|
14776
14800
|
address = _ref.address,
|
|
14777
14801
|
asset = _ref.asset,
|
|
14778
14802
|
scenario = _ref.scenario,
|
|
14779
|
-
|
|
14803
|
+
senderAddress = _ref.senderAddress;
|
|
14780
14804
|
if (!isForeignAsset(asset)) {
|
|
14781
14805
|
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
|
|
14782
14806
|
}
|
|
14783
14807
|
if (!asset.multiLocation) {
|
|
14784
14808
|
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multiLocation"));
|
|
14785
14809
|
}
|
|
14810
|
+
if (!senderAddress) {
|
|
14811
|
+
throw new InvalidCurrencyError("Please provide senderAddress");
|
|
14812
|
+
}
|
|
14786
14813
|
var ethAsset = findAssetByMultiLocation(getOtherAssets('Ethereum'), asset.multiLocation);
|
|
14787
14814
|
if (!ethAsset) {
|
|
14788
14815
|
throw new InvalidCurrencyError("Could not obtain Ethereum asset address for ".concat(JSON.stringify(asset)));
|
|
@@ -14793,7 +14820,7 @@ var createCustomXcmOnDest = function createCustomXcmOnDest(_ref, version) {
|
|
|
14793
14820
|
assets: {
|
|
14794
14821
|
Wild: 'All'
|
|
14795
14822
|
},
|
|
14796
|
-
beneficiary: Object.values(generateAddressPayload(api, scenario, 'PolkadotXcm',
|
|
14823
|
+
beneficiary: Object.values(generateAddressPayload(api, scenario, 'PolkadotXcm', senderAddress, version, undefined))[0]
|
|
14797
14824
|
}
|
|
14798
14825
|
}]
|
|
14799
14826
|
}, {
|
|
@@ -14851,11 +14878,39 @@ var createCustomXcmOnDest = function createCustomXcmOnDest(_ref, version) {
|
|
|
14851
14878
|
}
|
|
14852
14879
|
}
|
|
14853
14880
|
}
|
|
14881
|
+
}, {
|
|
14882
|
+
SetTopic: messageId
|
|
14854
14883
|
}]
|
|
14855
14884
|
}
|
|
14885
|
+
}, {
|
|
14886
|
+
SetTopic: messageId
|
|
14856
14887
|
}]);
|
|
14857
14888
|
};
|
|
14858
14889
|
|
|
14890
|
+
var generateMessageId = /*#__PURE__*/function () {
|
|
14891
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(api, senderAddress, sourceParaId, tokenAddress, recipientAddress, amount) {
|
|
14892
|
+
var accountNextId, sourceAccountHex, entropy;
|
|
14893
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
14894
|
+
while (1) switch (_context.prev = _context.next) {
|
|
14895
|
+
case 0:
|
|
14896
|
+
_context.next = 2;
|
|
14897
|
+
return api.getFromRpc('system', 'accountNextIndex', senderAddress);
|
|
14898
|
+
case 2:
|
|
14899
|
+
accountNextId = _context.sent;
|
|
14900
|
+
sourceAccountHex = api.accountToHex(senderAddress);
|
|
14901
|
+
entropy = new Uint8Array([].concat(_toConsumableArray(api.stringToUint8a(sourceParaId.toString())), _toConsumableArray(api.hexToUint8a(sourceAccountHex)), _toConsumableArray(api.stringToUint8a(accountNextId)), _toConsumableArray(api.hexToUint8a(tokenAddress)), _toConsumableArray(api.stringToUint8a(recipientAddress)), _toConsumableArray(api.stringToUint8a(amount.toString()))));
|
|
14902
|
+
return _context.abrupt("return", api.blake2AsHex(entropy));
|
|
14903
|
+
case 6:
|
|
14904
|
+
case "end":
|
|
14905
|
+
return _context.stop();
|
|
14906
|
+
}
|
|
14907
|
+
}, _callee);
|
|
14908
|
+
}));
|
|
14909
|
+
return function generateMessageId(_x, _x2, _x3, _x4, _x5, _x6) {
|
|
14910
|
+
return _ref.apply(this, arguments);
|
|
14911
|
+
};
|
|
14912
|
+
}();
|
|
14913
|
+
|
|
14859
14914
|
var supportsXTokens = function supportsXTokens(obj) {
|
|
14860
14915
|
return _typeof(obj) === 'object' && obj !== null && 'transferXTokens' in obj;
|
|
14861
14916
|
};
|
|
@@ -14908,11 +14963,11 @@ var ParachainNode = /*#__PURE__*/function () {
|
|
|
14908
14963
|
key: "transfer",
|
|
14909
14964
|
value: function () {
|
|
14910
14965
|
var _transfer = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
14911
|
-
var api, asset, address, destination, paraIdTo, overriddenAsset, version,
|
|
14966
|
+
var api, asset, address, destination, paraIdTo, overriddenAsset, version, senderAddress, pallet, method, isRelayDestination, scenario, paraId, versionOrDefault, isBifrostOrigin, isAssetHubDest, shouldUseMultiasset, input;
|
|
14912
14967
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
14913
14968
|
while (1) switch (_context.prev = _context.next) {
|
|
14914
14969
|
case 0:
|
|
14915
|
-
api = options.api, asset = options.asset, address = options.address, destination = options.destination, paraIdTo = options.paraIdTo, overriddenAsset = options.overriddenAsset, version = options.version,
|
|
14970
|
+
api = options.api, asset = options.asset, address = options.address, destination = options.destination, paraIdTo = options.paraIdTo, overriddenAsset = options.overriddenAsset, version = options.version, senderAddress = options.senderAddress, pallet = options.pallet, method = options.method;
|
|
14916
14971
|
isRelayDestination = !isTMultiLocation(destination) && isRelayChain(destination);
|
|
14917
14972
|
scenario = isRelayDestination ? 'ParaToRelay' : 'ParaToPara';
|
|
14918
14973
|
paraId = resolveParaId(paraIdTo, destination);
|
|
@@ -14983,7 +15038,7 @@ var ParachainNode = /*#__PURE__*/function () {
|
|
|
14983
15038
|
paraIdTo: paraId,
|
|
14984
15039
|
overriddenAsset: overriddenAsset,
|
|
14985
15040
|
version: version,
|
|
14986
|
-
|
|
15041
|
+
senderAddress: senderAddress,
|
|
14987
15042
|
pallet: pallet,
|
|
14988
15043
|
method: method
|
|
14989
15044
|
}));
|
|
@@ -15045,37 +15100,54 @@ var ParachainNode = /*#__PURE__*/function () {
|
|
|
15045
15100
|
key: "transferToEthereum",
|
|
15046
15101
|
value: function () {
|
|
15047
15102
|
var _transferToEthereum = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(input) {
|
|
15048
|
-
var api, asset, scenario, version, destination,
|
|
15103
|
+
var api, asset, scenario, version, destination, address, senderAddress, versionOrDefault, ethMultiAsset, ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee, executionFee, fee, ethAsset, messageId, call;
|
|
15049
15104
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
15050
15105
|
while (1) switch (_context2.prev = _context2.next) {
|
|
15051
15106
|
case 0:
|
|
15052
|
-
api = input.api, asset = input.asset, scenario = input.scenario, version = input.version, destination = input.destination,
|
|
15107
|
+
api = input.api, asset = input.asset, scenario = input.scenario, version = input.version, destination = input.destination, address = input.address, senderAddress = input.senderAddress;
|
|
15053
15108
|
if (isForeignAsset(asset)) {
|
|
15054
15109
|
_context2.next = 3;
|
|
15055
15110
|
break;
|
|
15056
15111
|
}
|
|
15057
15112
|
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
|
|
15058
15113
|
case 3:
|
|
15059
|
-
if (!(
|
|
15114
|
+
if (!(senderAddress === undefined)) {
|
|
15060
15115
|
_context2.next = 5;
|
|
15061
15116
|
break;
|
|
15062
15117
|
}
|
|
15063
|
-
throw new Error('
|
|
15118
|
+
throw new Error('Sender address is required for transfers to Ethereum');
|
|
15064
15119
|
case 5:
|
|
15120
|
+
if (!isTMultiLocation(address)) {
|
|
15121
|
+
_context2.next = 7;
|
|
15122
|
+
break;
|
|
15123
|
+
}
|
|
15124
|
+
throw new Error('Multi-location address is not supported for Ethereum transfers');
|
|
15125
|
+
case 7:
|
|
15065
15126
|
versionOrDefault = version !== null && version !== undefined ? version : Version.V4;
|
|
15066
15127
|
ethMultiAsset = Object.values(createCurrencySpec(asset.amount, versionOrDefault, Parents.TWO, asset.multiLocation))[0][0];
|
|
15067
|
-
_context2.next =
|
|
15128
|
+
_context2.next = 11;
|
|
15068
15129
|
return api.createApiForNode('AssetHubPolkadot');
|
|
15069
|
-
case
|
|
15130
|
+
case 11:
|
|
15070
15131
|
ahApi = _context2.sent;
|
|
15071
|
-
_context2.next =
|
|
15132
|
+
_context2.next = 14;
|
|
15072
15133
|
return getParaEthTransferFees(ahApi);
|
|
15073
|
-
case
|
|
15134
|
+
case 14:
|
|
15074
15135
|
_yield$getParaEthTran = _context2.sent;
|
|
15075
15136
|
_yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 2);
|
|
15076
15137
|
bridgeFee = _yield$getParaEthTran2[0];
|
|
15077
15138
|
executionFee = _yield$getParaEthTran2[1];
|
|
15078
15139
|
fee = (bridgeFee + executionFee).toString();
|
|
15140
|
+
ethAsset = findAssetByMultiLocation(getOtherAssets('Ethereum'), asset.multiLocation);
|
|
15141
|
+
if (!(!ethAsset || !ethAsset.assetId)) {
|
|
15142
|
+
_context2.next = 22;
|
|
15143
|
+
break;
|
|
15144
|
+
}
|
|
15145
|
+
throw new InvalidCurrencyError("Could not obtain Ethereum asset address for ".concat(JSON.stringify(asset)));
|
|
15146
|
+
case 22:
|
|
15147
|
+
_context2.next = 24;
|
|
15148
|
+
return generateMessageId(api, senderAddress, getParaId(this.node), ethAsset.assetId, address, asset.amount);
|
|
15149
|
+
case 24:
|
|
15150
|
+
messageId = _context2.sent;
|
|
15079
15151
|
call = {
|
|
15080
15152
|
module: 'PolkadotXcm',
|
|
15081
15153
|
section: 'transfer_assets_using_type_and_then',
|
|
@@ -15088,12 +15160,12 @@ var ParachainNode = /*#__PURE__*/function () {
|
|
|
15088
15160
|
interior: 'Here'
|
|
15089
15161
|
}),
|
|
15090
15162
|
fees_transfer_type: 'DestinationReserve',
|
|
15091
|
-
custom_xcm_on_dest: createCustomXcmOnDest(input, versionOrDefault),
|
|
15163
|
+
custom_xcm_on_dest: createCustomXcmOnDest(input, versionOrDefault, messageId),
|
|
15092
15164
|
weight_limit: 'Unlimited'
|
|
15093
15165
|
}
|
|
15094
15166
|
};
|
|
15095
15167
|
return _context2.abrupt("return", api.callTxMethod(call));
|
|
15096
|
-
case
|
|
15168
|
+
case 27:
|
|
15097
15169
|
case "end":
|
|
15098
15170
|
return _context2.stop();
|
|
15099
15171
|
}
|
|
@@ -17362,21 +17434,19 @@ var sanitizeMultiLocation = function sanitizeMultiLocation(multiLocation) {
|
|
|
17362
17434
|
return multiLocation.replace(/"(\d+),(\d+)"/g, '"$1$2"');
|
|
17363
17435
|
};
|
|
17364
17436
|
var compareMultiLocations = function compareMultiLocations(input, asset) {
|
|
17365
|
-
var _asset$multiLocation
|
|
17437
|
+
var _asset$multiLocation;
|
|
17366
17438
|
var sanitizedInput = sanitizeMultiLocation(input);
|
|
17367
17439
|
var assetMLStr = JSON.stringify((_asset$multiLocation = asset.multiLocation) !== null && _asset$multiLocation !== undefined ? _asset$multiLocation : '');
|
|
17368
|
-
var assetMLInteriorStr = JSON.stringify((_asset$xcmInterior = asset.xcmInterior) !== null && _asset$xcmInterior !== undefined ? _asset$xcmInterior : '');
|
|
17369
17440
|
var sanitizedAssetMLStr = sanitizeMultiLocation(assetMLStr);
|
|
17370
|
-
var sanitizedAssetMLInteriorStr = sanitizeMultiLocation(assetMLInteriorStr);
|
|
17371
17441
|
return (
|
|
17372
17442
|
// Compare sanitized input with sanitized asset values
|
|
17373
|
-
sanitizedInput === sanitizedAssetMLStr ||
|
|
17443
|
+
sanitizedInput === sanitizedAssetMLStr ||
|
|
17374
17444
|
// Compare original input with sanitized asset values
|
|
17375
|
-
input === sanitizedAssetMLStr ||
|
|
17445
|
+
input === sanitizedAssetMLStr ||
|
|
17376
17446
|
// Compare original input with original asset values
|
|
17377
|
-
input === assetMLStr ||
|
|
17447
|
+
input === assetMLStr ||
|
|
17378
17448
|
// Compare sanitized input with original asset values
|
|
17379
|
-
sanitizedInput === assetMLStr
|
|
17449
|
+
sanitizedInput === assetMLStr
|
|
17380
17450
|
);
|
|
17381
17451
|
};
|
|
17382
17452
|
|
|
@@ -17385,10 +17455,6 @@ var findAssetByMultiLocation = function findAssetByMultiLocation(foreignAssets,
|
|
|
17385
17455
|
return foreignAssets.find(function (asset) {
|
|
17386
17456
|
return compareMultiLocations(multiLocation, asset);
|
|
17387
17457
|
});
|
|
17388
|
-
} else if (Array.isArray(multiLocation)) {
|
|
17389
|
-
return foreignAssets.find(function (asset) {
|
|
17390
|
-
return _deepEqual(asset.xcmInterior, multiLocation);
|
|
17391
|
-
});
|
|
17392
17458
|
} else {
|
|
17393
17459
|
return foreignAssets.find(function (asset) {
|
|
17394
17460
|
return _deepEqual(asset.multiLocation, multiLocation);
|
|
@@ -17399,7 +17465,7 @@ var findAssetByMultiLocation = function findAssetByMultiLocation(foreignAssets,
|
|
|
17399
17465
|
var filterEthCompatibleAssets = function filterEthCompatibleAssets(assets) {
|
|
17400
17466
|
var ethAssets = getOtherAssets('Ethereum');
|
|
17401
17467
|
return assets.filter(function (asset) {
|
|
17402
|
-
var assetMultiLoc = asset.multiLocation
|
|
17468
|
+
var assetMultiLoc = asset.multiLocation;
|
|
17403
17469
|
if (!assetMultiLoc) return false;
|
|
17404
17470
|
return Boolean(findAssetByMultiLocation(ethAssets, assetMultiLoc));
|
|
17405
17471
|
});
|
|
@@ -17454,18 +17520,6 @@ var getAssetMultiLocation = function getAssetMultiLocation(node, currency) {
|
|
|
17454
17520
|
if (asset.multiLocation) {
|
|
17455
17521
|
return asset.multiLocation;
|
|
17456
17522
|
}
|
|
17457
|
-
if (asset.xcmInterior) {
|
|
17458
|
-
var _asset$xcmInterior$sl = asset.xcmInterior.slice(-2),
|
|
17459
|
-
_asset$xcmInterior$sl2 = _slicedToArray(_asset$xcmInterior$sl, 2),
|
|
17460
|
-
secondLast = _asset$xcmInterior$sl2[0],
|
|
17461
|
-
last = _asset$xcmInterior$sl2[1];
|
|
17462
|
-
return {
|
|
17463
|
-
parents: Parents.ZERO,
|
|
17464
|
-
interior: {
|
|
17465
|
-
X2: [secondLast, last]
|
|
17466
|
-
}
|
|
17467
|
-
};
|
|
17468
|
-
}
|
|
17469
17523
|
return null;
|
|
17470
17524
|
};
|
|
17471
17525
|
|
|
@@ -19139,9 +19193,9 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
19139
19193
|
*/
|
|
19140
19194
|
}, {
|
|
19141
19195
|
key: "address",
|
|
19142
|
-
value: function address(_address,
|
|
19196
|
+
value: function address(_address, senderAddress) {
|
|
19143
19197
|
this._address = _address;
|
|
19144
|
-
this.
|
|
19198
|
+
this._senderAddress = senderAddress;
|
|
19145
19199
|
return this;
|
|
19146
19200
|
}
|
|
19147
19201
|
/**
|
|
@@ -19180,7 +19234,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
19180
19234
|
destination: this._to,
|
|
19181
19235
|
paraIdTo: this._paraIdTo,
|
|
19182
19236
|
version: this._version,
|
|
19183
|
-
|
|
19237
|
+
senderAddress: this._senderAddress,
|
|
19184
19238
|
pallet: this._pallet,
|
|
19185
19239
|
method: this._method
|
|
19186
19240
|
};
|
|
@@ -19325,16 +19379,16 @@ var Builder = function Builder(api) {
|
|
|
19325
19379
|
var getOriginFeeDetailsInternal = /*#__PURE__*/function () {
|
|
19326
19380
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
19327
19381
|
var _getExistentialDeposi;
|
|
19328
|
-
var api, account, accountDestination,
|
|
19382
|
+
var api, account, accountDestination, currency, origin, destination, _ref$feeMarginPercent, feeMarginPercentage, tx, xcmFee, xcmFeeWithMargin, nativeBalance, existentialDeposit, sufficientForXCM;
|
|
19329
19383
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
19330
19384
|
while (1) switch (_context.prev = _context.next) {
|
|
19331
19385
|
case 0:
|
|
19332
|
-
api = _ref.api, account = _ref.account, accountDestination = _ref.accountDestination,
|
|
19386
|
+
api = _ref.api, account = _ref.account, accountDestination = _ref.accountDestination, currency = _ref.currency, origin = _ref.origin, destination = _ref.destination, _ref$feeMarginPercent = _ref.feeMarginPercentage, feeMarginPercentage = _ref$feeMarginPercent === undefined ? 10 : _ref$feeMarginPercent;
|
|
19333
19387
|
_context.next = 3;
|
|
19334
19388
|
return api.init(origin);
|
|
19335
19389
|
case 3:
|
|
19336
19390
|
_context.next = 5;
|
|
19337
|
-
return Builder(api).from(origin).to(destination).currency(currency).address(accountDestination,
|
|
19391
|
+
return Builder(api).from(origin).to(destination).currency(currency).address(accountDestination, account).build();
|
|
19338
19392
|
case 5:
|
|
19339
19393
|
tx = _context.sent;
|
|
19340
19394
|
_context.next = 8;
|
|
@@ -19755,6 +19809,75 @@ var getSupportedAssets = function getSupportedAssets(origin, destination) {
|
|
|
19755
19809
|
return supportedAssets;
|
|
19756
19810
|
};
|
|
19757
19811
|
|
|
19812
|
+
var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
|
|
19813
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
19814
|
+
var api, node, address, currency, ed, edBN, balance, originalAmount, fee, amountWithoutFee;
|
|
19815
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
19816
|
+
while (1) switch (_context.prev = _context.next) {
|
|
19817
|
+
case 0:
|
|
19818
|
+
api = _ref.api, node = _ref.node, address = _ref.address, currency = _ref.currency;
|
|
19819
|
+
validateAddress(address, node);
|
|
19820
|
+
ed = getExistentialDeposit(node, currency);
|
|
19821
|
+
if (!(ed === null)) {
|
|
19822
|
+
_context.next = 5;
|
|
19823
|
+
break;
|
|
19824
|
+
}
|
|
19825
|
+
throw new Error("Cannot get existential deposit for currency ".concat(JSON.stringify(currency)));
|
|
19826
|
+
case 5:
|
|
19827
|
+
edBN = BigInt(ed);
|
|
19828
|
+
_context.next = 8;
|
|
19829
|
+
return getAssetBalanceInternal({
|
|
19830
|
+
address: address,
|
|
19831
|
+
node: node,
|
|
19832
|
+
api: api,
|
|
19833
|
+
currency: currency
|
|
19834
|
+
});
|
|
19835
|
+
case 8:
|
|
19836
|
+
balance = _context.sent;
|
|
19837
|
+
originalAmount = BigInt(currency.amount);
|
|
19838
|
+
fee = originalAmount / BigInt(100);
|
|
19839
|
+
amountWithoutFee = originalAmount - fee;
|
|
19840
|
+
return _context.abrupt("return", balance + amountWithoutFee - edBN > 0);
|
|
19841
|
+
case 13:
|
|
19842
|
+
case "end":
|
|
19843
|
+
return _context.stop();
|
|
19844
|
+
}
|
|
19845
|
+
}, _callee);
|
|
19846
|
+
}));
|
|
19847
|
+
return function verifyEdOnDestinationInternal(_x) {
|
|
19848
|
+
return _ref2.apply(this, arguments);
|
|
19849
|
+
};
|
|
19850
|
+
}();
|
|
19851
|
+
|
|
19852
|
+
var verifyEdOnDestination = /*#__PURE__*/function () {
|
|
19853
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
19854
|
+
var api;
|
|
19855
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
19856
|
+
while (1) switch (_context.prev = _context.next) {
|
|
19857
|
+
case 0:
|
|
19858
|
+
api = options.api;
|
|
19859
|
+
_context.prev = 1;
|
|
19860
|
+
_context.next = 4;
|
|
19861
|
+
return verifyEdOnDestinationInternal(options);
|
|
19862
|
+
case 4:
|
|
19863
|
+
return _context.abrupt("return", _context.sent);
|
|
19864
|
+
case 5:
|
|
19865
|
+
_context.prev = 5;
|
|
19866
|
+
_context.next = 8;
|
|
19867
|
+
return api.disconnect();
|
|
19868
|
+
case 8:
|
|
19869
|
+
return _context.finish(5);
|
|
19870
|
+
case 9:
|
|
19871
|
+
case "end":
|
|
19872
|
+
return _context.stop();
|
|
19873
|
+
}
|
|
19874
|
+
}, _callee, null, [[1,, 5, 9]]);
|
|
19875
|
+
}));
|
|
19876
|
+
return function verifyEdOnDestination(_x) {
|
|
19877
|
+
return _ref.apply(this, arguments);
|
|
19878
|
+
};
|
|
19879
|
+
}();
|
|
19880
|
+
|
|
19758
19881
|
var isPrimitive = function isPrimitive(obj) {
|
|
19759
19882
|
return obj !== Object(obj);
|
|
19760
19883
|
};
|
|
@@ -20215,47 +20338,42 @@ var resolveOverriddenAsset = function resolveOverriddenAsset(options, isBridge,
|
|
|
20215
20338
|
|
|
20216
20339
|
var send = /*#__PURE__*/function () {
|
|
20217
20340
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
20218
|
-
var api, origin, currency, address, destination, paraIdTo, version,
|
|
20341
|
+
var api, origin, currency, address, destination, paraIdTo, version, senderAddress, pallet, method, isBridge, assetCheckEnabled, asset, overriddenAsset, resolvedAsset, originNode;
|
|
20219
20342
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
20220
20343
|
while (1) switch (_context.prev = _context.next) {
|
|
20221
20344
|
case 0:
|
|
20222
|
-
api = options.api, origin = options.origin, currency = options.currency, address = options.address, destination = options.destination, paraIdTo = options.paraIdTo, version = options.version,
|
|
20345
|
+
api = options.api, origin = options.origin, currency = options.currency, address = options.address, destination = options.destination, paraIdTo = options.paraIdTo, version = options.version, senderAddress = options.senderAddress, pallet = options.pallet, method = options.method;
|
|
20223
20346
|
validateCurrency(currency);
|
|
20224
20347
|
validateDestination(origin, destination);
|
|
20225
20348
|
validateDestinationAddress(address, destination);
|
|
20226
|
-
if (
|
|
20227
|
-
_context.next = 6;
|
|
20228
|
-
break;
|
|
20229
|
-
}
|
|
20230
|
-
throw new Error('AssetHub address needs to be in Substrate format');
|
|
20231
|
-
case 6:
|
|
20349
|
+
if (senderAddress) validateAddress(senderAddress, origin, false);
|
|
20232
20350
|
if (!(isRelayChain(origin) && !isTMultiLocation(destination) && isRelayChain(destination))) {
|
|
20233
|
-
_context.next =
|
|
20351
|
+
_context.next = 7;
|
|
20234
20352
|
break;
|
|
20235
20353
|
}
|
|
20236
20354
|
throw new Error('Relay chain to relay chain transfers are not supported.');
|
|
20237
|
-
case
|
|
20355
|
+
case 7:
|
|
20238
20356
|
isBridge = isBridgeTransfer(origin, destination);
|
|
20239
20357
|
assetCheckEnabled = determineAssetCheckEnabled(origin, currency, isBridge);
|
|
20240
20358
|
validateAssetSpecifiers(assetCheckEnabled, currency);
|
|
20241
20359
|
asset = resolveAsset(currency, origin, destination, assetCheckEnabled);
|
|
20242
20360
|
validateAssetSupport(options, assetCheckEnabled, isBridge, asset);
|
|
20243
20361
|
if (!isRelayChain(origin)) {
|
|
20244
|
-
_context.next =
|
|
20362
|
+
_context.next = 18;
|
|
20245
20363
|
break;
|
|
20246
20364
|
}
|
|
20247
20365
|
if (!(destination === 'Ethereum')) {
|
|
20248
|
-
_context.next =
|
|
20366
|
+
_context.next = 15;
|
|
20249
20367
|
break;
|
|
20250
20368
|
}
|
|
20251
20369
|
throw new Error('Transfers from relay chain to Ethereum are not supported.');
|
|
20252
|
-
case
|
|
20370
|
+
case 15:
|
|
20253
20371
|
if (asset) {
|
|
20254
|
-
_context.next =
|
|
20372
|
+
_context.next = 17;
|
|
20255
20373
|
break;
|
|
20256
20374
|
}
|
|
20257
20375
|
throw new Error('Asset is required for relay chain to relay chain transfers.');
|
|
20258
|
-
case
|
|
20376
|
+
case 17:
|
|
20259
20377
|
return _context.abrupt("return", transferRelayToPara({
|
|
20260
20378
|
api: api,
|
|
20261
20379
|
origin: origin,
|
|
@@ -20269,11 +20387,11 @@ var send = /*#__PURE__*/function () {
|
|
|
20269
20387
|
pallet: pallet,
|
|
20270
20388
|
method: method
|
|
20271
20389
|
}));
|
|
20272
|
-
case
|
|
20390
|
+
case 18:
|
|
20273
20391
|
overriddenAsset = resolveOverriddenAsset(options, isBridge, assetCheckEnabled);
|
|
20274
|
-
_context.next =
|
|
20392
|
+
_context.next = 21;
|
|
20275
20393
|
return api.init(origin);
|
|
20276
|
-
case
|
|
20394
|
+
case 21:
|
|
20277
20395
|
// In case asset check is disabled, we create asset object from currency symbol
|
|
20278
20396
|
resolvedAsset = asset !== null && asset !== undefined ? asset : {
|
|
20279
20397
|
symbol: 'symbol' in currency ? currency.symbol : undefined
|
|
@@ -20289,11 +20407,11 @@ var send = /*#__PURE__*/function () {
|
|
|
20289
20407
|
paraIdTo: paraIdTo,
|
|
20290
20408
|
overriddenAsset: overriddenAsset,
|
|
20291
20409
|
version: version,
|
|
20292
|
-
|
|
20410
|
+
senderAddress: senderAddress,
|
|
20293
20411
|
pallet: pallet,
|
|
20294
20412
|
method: method
|
|
20295
20413
|
}));
|
|
20296
|
-
case
|
|
20414
|
+
case 24:
|
|
20297
20415
|
case "end":
|
|
20298
20416
|
return _context.stop();
|
|
20299
20417
|
}
|
|
@@ -20368,7 +20486,7 @@ var getDestinationMultilocation = function getDestinationMultilocation(api, addr
|
|
|
20368
20486
|
return [1, paraId ? ["0x0000000".concat(paraId.toString(16)), acc] : [acc]];
|
|
20369
20487
|
};
|
|
20370
20488
|
|
|
20371
|
-
var abi = [
|
|
20489
|
+
var abi$1 = [
|
|
20372
20490
|
{
|
|
20373
20491
|
inputs: [
|
|
20374
20492
|
{
|
|
@@ -20489,8 +20607,8 @@ var transferMoonbeamEvm = /*#__PURE__*/function () {
|
|
|
20489
20607
|
}
|
|
20490
20608
|
throw new Error('Override multilocation is not supported for Evm transfers');
|
|
20491
20609
|
case 5:
|
|
20492
|
-
contract = isEthersSigner(signer) ? new Contract(CONTRACT_ADDRESS, abi, signer) : getContract({
|
|
20493
|
-
abi: abi,
|
|
20610
|
+
contract = isEthersSigner(signer) ? new Contract(CONTRACT_ADDRESS, abi$1, signer) : getContract({
|
|
20611
|
+
abi: abi$1,
|
|
20494
20612
|
address: CONTRACT_ADDRESS,
|
|
20495
20613
|
client: {
|
|
20496
20614
|
"public": createPublicClient({
|
|
@@ -20568,6 +20686,72 @@ var transferMoonbeamEvm = /*#__PURE__*/function () {
|
|
|
20568
20686
|
};
|
|
20569
20687
|
}();
|
|
20570
20688
|
|
|
20689
|
+
var abi = [
|
|
20690
|
+
{
|
|
20691
|
+
inputs: [
|
|
20692
|
+
{
|
|
20693
|
+
components: [
|
|
20694
|
+
{
|
|
20695
|
+
internalType: "uint8",
|
|
20696
|
+
name: "parents",
|
|
20697
|
+
type: "uint8"
|
|
20698
|
+
},
|
|
20699
|
+
{
|
|
20700
|
+
internalType: "bytes[]",
|
|
20701
|
+
name: "interior",
|
|
20702
|
+
type: "bytes[]"
|
|
20703
|
+
}
|
|
20704
|
+
],
|
|
20705
|
+
internalType: "struct XCM.Location",
|
|
20706
|
+
name: "dest",
|
|
20707
|
+
type: "tuple"
|
|
20708
|
+
},
|
|
20709
|
+
{
|
|
20710
|
+
components: [
|
|
20711
|
+
{
|
|
20712
|
+
internalType: "address",
|
|
20713
|
+
name: "asset",
|
|
20714
|
+
type: "address"
|
|
20715
|
+
},
|
|
20716
|
+
{
|
|
20717
|
+
internalType: "uint256",
|
|
20718
|
+
name: "amount",
|
|
20719
|
+
type: "uint256"
|
|
20720
|
+
}
|
|
20721
|
+
],
|
|
20722
|
+
internalType: "struct XCM.AssetAddressInfo[]",
|
|
20723
|
+
name: "assets",
|
|
20724
|
+
type: "tuple[]"
|
|
20725
|
+
},
|
|
20726
|
+
{
|
|
20727
|
+
internalType: "enum XCM.TransferType",
|
|
20728
|
+
name: "assetsTransferType",
|
|
20729
|
+
type: "uint8"
|
|
20730
|
+
},
|
|
20731
|
+
{
|
|
20732
|
+
internalType: "uint8",
|
|
20733
|
+
name: "remoteFeesIdIndex",
|
|
20734
|
+
type: "uint8"
|
|
20735
|
+
},
|
|
20736
|
+
{
|
|
20737
|
+
internalType: "enum XCM.TransferType",
|
|
20738
|
+
name: "feesTransferType",
|
|
20739
|
+
type: "uint8"
|
|
20740
|
+
},
|
|
20741
|
+
{
|
|
20742
|
+
internalType: "bytes",
|
|
20743
|
+
name: "customXcmOnDest",
|
|
20744
|
+
type: "bytes"
|
|
20745
|
+
}
|
|
20746
|
+
],
|
|
20747
|
+
name: "transferAssetsUsingTypeAndThenAddress",
|
|
20748
|
+
outputs: [
|
|
20749
|
+
],
|
|
20750
|
+
stateMutability: "nonpayable",
|
|
20751
|
+
type: "function"
|
|
20752
|
+
}
|
|
20753
|
+
];
|
|
20754
|
+
|
|
20571
20755
|
var getParaEthTransferFees = /*#__PURE__*/function () {
|
|
20572
20756
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(ahApi) {
|
|
20573
20757
|
var DEFAULT_FEE, feeStorageItem, leFeeHex, bytes, reversedHex, validReversedHex, leFee, transferBridgeFee, transferAssethubExecutionFee, finalBridgeFee, finalAssethubExecutionFee;
|
|
@@ -20576,7 +20760,7 @@ var getParaEthTransferFees = /*#__PURE__*/function () {
|
|
|
20576
20760
|
case 0:
|
|
20577
20761
|
DEFAULT_FEE = 2750872500000n;
|
|
20578
20762
|
_context.next = 3;
|
|
20579
|
-
return ahApi.
|
|
20763
|
+
return ahApi.getFromRpc('state', 'getStorage', '0x5fbc5c7ba58845ad1f1a9a7c5bc12fad');
|
|
20580
20764
|
case 3:
|
|
20581
20765
|
feeStorageItem = _context.sent;
|
|
20582
20766
|
leFeeHex = feeStorageItem.replace('0x', '');
|
|
@@ -20603,4 +20787,158 @@ var getParaEthTransferFees = /*#__PURE__*/function () {
|
|
|
20603
20787
|
};
|
|
20604
20788
|
}();
|
|
20605
20789
|
|
|
20606
|
-
|
|
20790
|
+
// https://github.com/moonbeam-foundation/moonbeam/blob/b2b1bde7ced13aad4bd2928effc415c521fd48cb/runtime/moonbeam/src/precompiles.rs#L281
|
|
20791
|
+
var xcmInterfacePrecompile = '0x000000000000000000000000000000000000081A';
|
|
20792
|
+
var XCDOT = '0xFfFFfFff1FcaCBd218EDc0EbA20Fc2308C778080';
|
|
20793
|
+
var transferMoonbeamToEth = /*#__PURE__*/function () {
|
|
20794
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
20795
|
+
var _signer$account;
|
|
20796
|
+
var api, from, to, signer, address, ahAddress, currency, foundAsset, ethAsset, contract, senderAddress, messageId, customXcm, customXcmOnDest, assetHubApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee, executionFee, transferFee, createTx, numberToHex32, tx;
|
|
20797
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
20798
|
+
while (1) switch (_context.prev = _context.next) {
|
|
20799
|
+
case 0:
|
|
20800
|
+
api = _ref.api, from = _ref.from, to = _ref.to, signer = _ref.signer, address = _ref.address, ahAddress = _ref.ahAddress, currency = _ref.currency;
|
|
20801
|
+
if (ahAddress) {
|
|
20802
|
+
_context.next = 3;
|
|
20803
|
+
break;
|
|
20804
|
+
}
|
|
20805
|
+
throw new Error('AssetHub address is required');
|
|
20806
|
+
case 3:
|
|
20807
|
+
if (!('multiasset' in currency)) {
|
|
20808
|
+
_context.next = 5;
|
|
20809
|
+
break;
|
|
20810
|
+
}
|
|
20811
|
+
throw new Error('Multiassets syntax is not supported for Evm transfers');
|
|
20812
|
+
case 5:
|
|
20813
|
+
if (!('multilocation' in currency && isOverrideMultiLocationSpecifier(currency.multilocation))) {
|
|
20814
|
+
_context.next = 7;
|
|
20815
|
+
break;
|
|
20816
|
+
}
|
|
20817
|
+
throw new Error('Override multilocation is not supported for Evm transfers');
|
|
20818
|
+
case 7:
|
|
20819
|
+
foundAsset = getAssetBySymbolOrId(from, currency, to);
|
|
20820
|
+
if (!(foundAsset === null)) {
|
|
20821
|
+
_context.next = 10;
|
|
20822
|
+
break;
|
|
20823
|
+
}
|
|
20824
|
+
throw new InvalidCurrencyError("Origin node ".concat(from, " does not support currency ").concat(JSON.stringify(currency), "."));
|
|
20825
|
+
case 10:
|
|
20826
|
+
if (!(!isForeignAsset(foundAsset) || !foundAsset.multiLocation)) {
|
|
20827
|
+
_context.next = 12;
|
|
20828
|
+
break;
|
|
20829
|
+
}
|
|
20830
|
+
throw new InvalidCurrencyError('Currency must be a foreign asset with valid multi-location');
|
|
20831
|
+
case 12:
|
|
20832
|
+
ethAsset = findAssetByMultiLocation(getOtherAssets('Ethereum'), foundAsset.multiLocation);
|
|
20833
|
+
if (!(!ethAsset || !ethAsset.assetId)) {
|
|
20834
|
+
_context.next = 15;
|
|
20835
|
+
break;
|
|
20836
|
+
}
|
|
20837
|
+
throw new InvalidCurrencyError("Could not obtain Ethereum asset address for ".concat(JSON.stringify(foundAsset)));
|
|
20838
|
+
case 15:
|
|
20839
|
+
contract = isEthersSigner(signer) ? new Contract(xcmInterfacePrecompile, abi, signer) : getContract({
|
|
20840
|
+
abi: abi,
|
|
20841
|
+
address: xcmInterfacePrecompile,
|
|
20842
|
+
client: {
|
|
20843
|
+
"public": createPublicClient({
|
|
20844
|
+
chain: signer.chain,
|
|
20845
|
+
transport: http()
|
|
20846
|
+
}),
|
|
20847
|
+
wallet: signer
|
|
20848
|
+
}
|
|
20849
|
+
});
|
|
20850
|
+
if (!isEthersSigner(signer)) {
|
|
20851
|
+
_context.next = 22;
|
|
20852
|
+
break;
|
|
20853
|
+
}
|
|
20854
|
+
_context.next = 19;
|
|
20855
|
+
return signer.getAddress();
|
|
20856
|
+
case 19:
|
|
20857
|
+
_context.t0 = _context.sent;
|
|
20858
|
+
_context.next = 23;
|
|
20859
|
+
break;
|
|
20860
|
+
case 22:
|
|
20861
|
+
_context.t0 = (_signer$account = signer.account) === null || _signer$account === undefined ? undefined : _signer$account.address;
|
|
20862
|
+
case 23:
|
|
20863
|
+
senderAddress = _context.t0;
|
|
20864
|
+
if (senderAddress) {
|
|
20865
|
+
_context.next = 26;
|
|
20866
|
+
break;
|
|
20867
|
+
}
|
|
20868
|
+
throw new Error('Unable to get sender address');
|
|
20869
|
+
case 26:
|
|
20870
|
+
_context.next = 28;
|
|
20871
|
+
return api.init(from);
|
|
20872
|
+
case 28:
|
|
20873
|
+
_context.next = 30;
|
|
20874
|
+
return generateMessageId(api, senderAddress, getParaId(from), ethAsset.assetId, address, currency.amount);
|
|
20875
|
+
case 30:
|
|
20876
|
+
messageId = _context.sent;
|
|
20877
|
+
customXcm = createCustomXcmOnDest({
|
|
20878
|
+
api: api,
|
|
20879
|
+
destination: to,
|
|
20880
|
+
address: address,
|
|
20881
|
+
scenario: 'ParaToPara',
|
|
20882
|
+
senderAddress: senderAddress,
|
|
20883
|
+
asset: _objectSpread2(_objectSpread2({}, foundAsset), {}, {
|
|
20884
|
+
amount: currency.amount
|
|
20885
|
+
}),
|
|
20886
|
+
header: {},
|
|
20887
|
+
currencySelection: {},
|
|
20888
|
+
addressSelection: {}
|
|
20889
|
+
}, Version.V4, messageId);
|
|
20890
|
+
_context.next = 34;
|
|
20891
|
+
return api.objectToHex(customXcm, 'XcmVersionedXcm');
|
|
20892
|
+
case 34:
|
|
20893
|
+
customXcmOnDest = _context.sent;
|
|
20894
|
+
_context.next = 37;
|
|
20895
|
+
return api.createApiForNode('AssetHubPolkadot');
|
|
20896
|
+
case 37:
|
|
20897
|
+
assetHubApi = _context.sent;
|
|
20898
|
+
_context.next = 40;
|
|
20899
|
+
return getParaEthTransferFees(assetHubApi);
|
|
20900
|
+
case 40:
|
|
20901
|
+
_yield$getParaEthTran = _context.sent;
|
|
20902
|
+
_yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 2);
|
|
20903
|
+
bridgeFee = _yield$getParaEthTran2[0];
|
|
20904
|
+
executionFee = _yield$getParaEthTran2[1];
|
|
20905
|
+
transferFee = (bridgeFee + executionFee).toString(); // Partially inspired by Moonbeam XCM-SDK
|
|
20906
|
+
// https://github.com/moonbeam-foundation/xcm-sdk/blob/ab835c15bf41612604b1c858d956a9f07705ed65/packages/sdk/src/contract/contracts/Xtokens/Xtokens.ts#L53
|
|
20907
|
+
createTx = function createTx(func, args) {
|
|
20908
|
+
if (isEthersContract(contract)) {
|
|
20909
|
+
return contract[func].apply(contract, _toConsumableArray(args));
|
|
20910
|
+
}
|
|
20911
|
+
return contract.write[func](args);
|
|
20912
|
+
};
|
|
20913
|
+
numberToHex32 = function numberToHex32(num) {
|
|
20914
|
+
return typeof num !== 'number' || isNaN(num) ? function () {
|
|
20915
|
+
throw new Error('Input must be a valid number');
|
|
20916
|
+
}() : "0x".concat((num >>> 0).toString(16).padStart(8, '0'));
|
|
20917
|
+
}; // Execute the custom XCM message with the precompile
|
|
20918
|
+
_context.next = 49;
|
|
20919
|
+
return createTx(isEthersSigner(signer) ? 'transferAssetsUsingTypeAndThenAddress((uint8,bytes[]),(address,uint256)[],uint8,uint8,uint8,bytes)' : 'transferAssetsUsingTypeAndThenAddress', [
|
|
20920
|
+
// This represents (1,X1(Parachain(1000)))
|
|
20921
|
+
[1, ['0x00' + numberToHex32(getParaId('AssetHubPolkadot')).slice(2)]],
|
|
20922
|
+
// Assets including fee and the ERC20 asset, with fee be the first
|
|
20923
|
+
[[XCDOT, transferFee], [ethAsset.assetId, currency.amount.toString()]],
|
|
20924
|
+
// The TransferType corresponding to asset being sent, 2 represents `DestinationReserve`
|
|
20925
|
+
2,
|
|
20926
|
+
// index for the fee
|
|
20927
|
+
0,
|
|
20928
|
+
// The TransferType corresponding to fee asset
|
|
20929
|
+
2, customXcmOnDest]);
|
|
20930
|
+
case 49:
|
|
20931
|
+
tx = _context.sent;
|
|
20932
|
+
return _context.abrupt("return", _typeof(tx) === 'object' ? tx.hash : tx);
|
|
20933
|
+
case 51:
|
|
20934
|
+
case "end":
|
|
20935
|
+
return _context.stop();
|
|
20936
|
+
}
|
|
20937
|
+
}, _callee);
|
|
20938
|
+
}));
|
|
20939
|
+
return function transferMoonbeamToEth(_x) {
|
|
20940
|
+
return _ref2.apply(this, arguments);
|
|
20941
|
+
};
|
|
20942
|
+
}();
|
|
20943
|
+
|
|
20944
|
+
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, 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, getParaEthTransferFees, getParaId, getRelayChainSymbol, getSupportedAssets, getSupportedPallets, getSupportedPalletsDetails, getTNode, getTransferInfo, getTransferableAmount, hasSupportForAsset, isEthersContract, isEthersSigner, isForeignAsset, isNodeEvm, isOverrideMultiLocationSpecifier, isRelayChain, isSymbolSpecifier, normalizeSymbol, resolveModuleError, resolveParaId, send, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, validateAddress, verifyEdOnDestination };
|