@paraspell/sdk 6.2.0 → 6.2.2

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 CHANGED
@@ -507,11 +507,11 @@ function _toPrimitive(t, r) {
507
507
  if ("object" != typeof t || !t) return t;
508
508
  var e = t[Symbol.toPrimitive];
509
509
  if (void 0 !== e) {
510
- var i = e.call(t, r || "default");
510
+ var i = e.call(t, r);
511
511
  if ("object" != typeof i) return i;
512
512
  throw new TypeError("@@toPrimitive must return a primitive value.");
513
513
  }
514
- return ("string" === r ? String : Number)(t);
514
+ return (String )(t);
515
515
  }
516
516
  function _toPropertyKey(t) {
517
517
  var i = _toPrimitive(t, "string");
@@ -1133,51 +1133,120 @@ var BifrostPolkadot$3 = {
1133
1133
  nativeAssetSymbol: "BNC",
1134
1134
  nativeAssets: [
1135
1135
  {
1136
- symbol: "ASG",
1137
- decimals: 18
1136
+ symbol: "vBNC",
1137
+ decimals: 12
1138
1138
  },
1139
1139
  {
1140
1140
  symbol: "BNC",
1141
1141
  decimals: 12
1142
+ }
1143
+ ],
1144
+ otherAssets: [
1145
+ {
1146
+ assetId: "6",
1147
+ symbol: "IBTC",
1148
+ decimals: 8
1142
1149
  },
1143
1150
  {
1144
- symbol: "KUSD",
1145
- decimals: 12
1151
+ assetId: "8",
1152
+ symbol: "MANTA",
1153
+ decimals: 18
1154
+ },
1155
+ {
1156
+ assetId: "7",
1157
+ symbol: "INTR",
1158
+ decimals: 10
1146
1159
  },
1147
1160
  {
1161
+ assetId: "13",
1162
+ symbol: "WETH",
1163
+ decimals: 18
1164
+ },
1165
+ {
1166
+ assetId: "2",
1167
+ symbol: "USDT",
1168
+ decimals: 6
1169
+ },
1170
+ {
1171
+ assetId: "5",
1172
+ symbol: "USDC",
1173
+ decimals: 6
1174
+ },
1175
+ {
1176
+ assetId: "0",
1148
1177
  symbol: "DOT",
1149
1178
  decimals: 10
1150
1179
  },
1151
1180
  {
1152
- symbol: "KSM",
1153
- decimals: 12
1181
+ assetId: "1",
1182
+ symbol: "GLMR",
1183
+ decimals: 18
1154
1184
  },
1155
1185
  {
1156
- symbol: "ETH",
1186
+ assetId: "1",
1187
+ symbol: "vGLMR",
1188
+ decimals: 18
1189
+ },
1190
+ {
1191
+ assetId: "14",
1192
+ symbol: "WAVE",
1193
+ decimals: 18
1194
+ },
1195
+ {
1196
+ assetId: "11",
1197
+ symbol: "DED",
1157
1198
  decimals: 10
1158
1199
  },
1159
1200
  {
1160
- symbol: "KAR",
1161
- decimals: 12
1201
+ assetId: "4",
1202
+ symbol: "vFIL",
1203
+ decimals: 18
1162
1204
  },
1163
1205
  {
1164
- symbol: "ZLK",
1206
+ assetId: "9",
1207
+ symbol: "BNCS",
1165
1208
  decimals: 12
1166
1209
  },
1167
1210
  {
1168
- symbol: "PHA",
1211
+ assetId: "10",
1212
+ symbol: "PINK",
1213
+ decimals: 10
1214
+ },
1215
+ {
1216
+ assetId: "4",
1217
+ symbol: "FIL",
1218
+ decimals: 18
1219
+ },
1220
+ {
1221
+ assetId: "8",
1222
+ symbol: "vMANTA",
1223
+ decimals: 18
1224
+ },
1225
+ {
1226
+ assetId: "12",
1227
+ symbol: "PEN",
1169
1228
  decimals: 12
1170
1229
  },
1171
1230
  {
1172
- symbol: "RMRK",
1231
+ assetId: "3",
1232
+ symbol: "vASTR",
1233
+ decimals: 18
1234
+ },
1235
+ {
1236
+ assetId: "0",
1237
+ symbol: "vDOT",
1173
1238
  decimals: 10
1174
1239
  },
1175
1240
  {
1176
- symbol: "MOVR",
1241
+ assetId: "3",
1242
+ symbol: "ASTR",
1177
1243
  decimals: 18
1244
+ },
1245
+ {
1246
+ assetId: "0",
1247
+ symbol: "vsDOT",
1248
+ decimals: 10
1178
1249
  }
1179
- ],
1180
- otherAssets: [
1181
1250
  ]
1182
1251
  };
1183
1252
  var Bitgreen$3 = {
@@ -4505,24 +4574,28 @@ var BifrostKusama$3 = {
4505
4574
  nativeAssetSymbol: "BNC",
4506
4575
  nativeAssets: [
4507
4576
  {
4508
- symbol: "BNC",
4577
+ symbol: "KSM",
4509
4578
  decimals: 12
4510
4579
  },
4511
4580
  {
4512
- symbol: "KUSD",
4581
+ symbol: "RMRK",
4582
+ decimals: 10
4583
+ },
4584
+ {
4585
+ symbol: "vBNC",
4513
4586
  decimals: 12
4514
4587
  },
4515
4588
  {
4516
- symbol: "DOT",
4517
- decimals: 10
4589
+ symbol: "vMOVR",
4590
+ decimals: 18
4518
4591
  },
4519
4592
  {
4520
- symbol: "KSM",
4593
+ symbol: "vKSM",
4521
4594
  decimals: 12
4522
4595
  },
4523
4596
  {
4524
- symbol: "KAR",
4525
- decimals: 12
4597
+ symbol: "MOVR",
4598
+ decimals: 18
4526
4599
  },
4527
4600
  {
4528
4601
  symbol: "ZLK",
@@ -4533,15 +4606,40 @@ var BifrostKusama$3 = {
4533
4606
  decimals: 12
4534
4607
  },
4535
4608
  {
4536
- symbol: "RMRK",
4537
- decimals: 10
4609
+ symbol: "KAR",
4610
+ decimals: 12
4538
4611
  },
4539
4612
  {
4540
- symbol: "MOVR",
4541
- decimals: 18
4613
+ symbol: "BNC",
4614
+ decimals: 12
4542
4615
  }
4543
4616
  ],
4544
4617
  otherAssets: [
4618
+ {
4619
+ assetId: "2",
4620
+ symbol: "KBTC",
4621
+ decimals: 8
4622
+ },
4623
+ {
4624
+ assetId: "0",
4625
+ symbol: "USDT",
4626
+ decimals: 6
4627
+ },
4628
+ {
4629
+ assetId: "1",
4630
+ symbol: "KINT",
4631
+ decimals: 12
4632
+ },
4633
+ {
4634
+ assetId: "4",
4635
+ symbol: "MGX",
4636
+ decimals: 18
4637
+ },
4638
+ {
4639
+ assetId: "3",
4640
+ symbol: "SDN",
4641
+ decimals: 18
4642
+ }
4545
4643
  ]
4546
4644
  };
4547
4645
  var Calamari$3 = {
@@ -8255,6 +8353,26 @@ var DuplicateAssetError = /*#__PURE__*/function (_Error) {
8255
8353
  return _createClass(DuplicateAssetError);
8256
8354
  }(/*#__PURE__*/_wrapNativeSuper(Error));
8257
8355
 
8356
+ /**
8357
+ * Error thrown when multiple assets with the same symbol are found.
8358
+ */
8359
+ var DuplicateAssetIdError = /*#__PURE__*/function (_Error) {
8360
+ /**
8361
+ * Constructs a new DuplicateAssetError.
8362
+ *
8363
+ * @param symbol - The symbol of the asset causing the duplication error.
8364
+ */
8365
+ function DuplicateAssetIdError(id) {
8366
+ var _this;
8367
+ _classCallCheck(this, DuplicateAssetIdError);
8368
+ _this = _callSuper(this, DuplicateAssetIdError, ["Multiple assets found with the same ID: ".concat(id, ". Please specify asset directly by symbol using .currency({symbol: <ASSET_SYMBOL>})")]);
8369
+ _this.name = 'DuplicateAssetId';
8370
+ return _this;
8371
+ }
8372
+ _inherits(DuplicateAssetIdError, _Error);
8373
+ return _createClass(DuplicateAssetIdError);
8374
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
8375
+
8258
8376
  var supportsXTokens = function supportsXTokens(obj) {
8259
8377
  return _typeof(obj) === 'object' && obj !== null && 'transferXTokens' in obj;
8260
8378
  };
@@ -8598,9 +8716,44 @@ var BifrostPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
8598
8716
  }
8599
8717
  _inherits(BifrostPolkadot, _ParachainNode);
8600
8718
  return _createClass(BifrostPolkadot, [{
8719
+ key: "getCurrencySelection",
8720
+ value: function getCurrencySelection(currency, currencyId) {
8721
+ var nativeAssetSymbol = this.getNativeAssetSymbol();
8722
+ if (currency === nativeAssetSymbol) {
8723
+ return {
8724
+ Native: nativeAssetSymbol
8725
+ };
8726
+ }
8727
+ var isVToken = currency.startsWith('v');
8728
+ var isVSToken = currency.startsWith('vs');
8729
+ if (!currencyId) {
8730
+ return isVToken ? {
8731
+ VToken: currency.substring(1)
8732
+ } : {
8733
+ Token: currency
8734
+ };
8735
+ }
8736
+ var id = Number(currencyId);
8737
+ if (isVSToken) {
8738
+ return {
8739
+ VSToken2: id
8740
+ };
8741
+ }
8742
+ return isVToken ? {
8743
+ VToken2: id
8744
+ } : {
8745
+ Token2: id
8746
+ };
8747
+ }
8748
+ }, {
8601
8749
  key: "transferXTokens",
8602
8750
  value: function transferXTokens(input) {
8603
- var currencySelection = _defineProperty({}, input.currency === this.getNativeAssetSymbol() ? 'Native' : 'Token', input.currency);
8751
+ var currency = input.currency,
8752
+ currencyID = input.currencyID;
8753
+ if (!currency) {
8754
+ throw new Error('Currency symbol is undefined');
8755
+ }
8756
+ var currencySelection = this.getCurrencySelection(currency, currencyID);
8604
8757
  return XTokensTransferImpl.transferXTokens(input, currencySelection);
8605
8758
  }
8606
8759
  }]);
@@ -8845,8 +8998,7 @@ var BifrostKusama$2 = /*#__PURE__*/function (_ParachainNode) {
8845
8998
  return _createClass(BifrostKusama, [{
8846
8999
  key: "transferXTokens",
8847
9000
  value: function transferXTokens(input) {
8848
- var currencySelection = _defineProperty({}, input.currency === this.getNativeAssetSymbol() ? 'Native' : 'Token', input.currency);
8849
- return XTokensTransferImpl.transferXTokens(input, currencySelection);
9001
+ return getNode('BifrostPolkadot').transferXTokens(input);
8850
9002
  }
8851
9003
  }]);
8852
9004
  }(ParachainNode);
@@ -10741,13 +10893,20 @@ var findAssetBySymbol = function findAssetBySymbol(node, destination, otherAsset
10741
10893
  }
10742
10894
  return otherAssetsMatches[0] || nativeAssetsMatches[0] || null;
10743
10895
  };
10744
-
10745
10896
  var findAssetById = function findAssetById(assets, assetId) {
10746
- return assets.find(function (_ref) {
10747
- var currentAssetId = _ref.assetId;
10897
+ var otherAssetsMatches = assets.filter(function (_ref4) {
10898
+ var currentAssetId = _ref4.assetId;
10748
10899
  return currentAssetId === assetId.toString();
10749
10900
  });
10901
+ if (otherAssetsMatches.length > 1) {
10902
+ throw new DuplicateAssetIdError(assetId.toString());
10903
+ }
10904
+ return assets.find(function (_ref5) {
10905
+ var currentAssetId = _ref5.assetId;
10906
+ return currentAssetId === assetId;
10907
+ });
10750
10908
  };
10909
+
10751
10910
  var getAssetBySymbolOrId = function getAssetBySymbolOrId(node, currency) {
10752
10911
  var isRelayDestination = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
10753
10912
  var destination = arguments.length > 3 ? arguments[3] : undefined;
@@ -12667,35 +12826,41 @@ var getTransferInfo = function getTransferInfo(origin, destination, accountOrigi
12667
12826
  destXcmFee = _yield$getOriginFeeDe.xcmFee;
12668
12827
  expectedBalanceAfterXCMDelivery = originBalance - destXcmFee;
12669
12828
  asset = getAssetBySymbolOrId(origin, currency);
12829
+ if (asset) {
12830
+ _context.next = 14;
12831
+ break;
12832
+ }
12833
+ throw new InvalidCurrencyError("Asset ".concat('symbol' in currency ? currency.symbol : currency.id, " not found on ").concat(origin));
12834
+ case 14:
12670
12835
  _context.t0 = {
12671
12836
  origin: origin,
12672
12837
  destination: destination,
12673
12838
  ecosystem: determineRelayChainSymbol(origin)
12674
12839
  };
12675
- _context.next = 15;
12840
+ _context.next = 17;
12676
12841
  return getAssetBalance(accountOrigin, origin, currency);
12677
- case 15:
12842
+ case 17:
12678
12843
  _context.t1 = _context.sent;
12679
12844
  _context.t2 = (_a = asset === null || asset === void 0 ? void 0 : asset.symbol) !== null && _a !== void 0 ? _a : '';
12680
12845
  _context.t3 = {
12681
12846
  balance: _context.t1,
12682
12847
  currency: _context.t2
12683
12848
  };
12684
- _context.next = 20;
12849
+ _context.next = 22;
12685
12850
  return getBalanceNative(accountOrigin, origin, originApi);
12686
- case 20:
12851
+ case 22:
12687
12852
  _context.t4 = _context.sent;
12688
12853
  _context.t5 = expectedBalanceAfterXCMDelivery;
12689
- _context.next = 24;
12854
+ _context.next = 26;
12690
12855
  return getOriginFeeDetails(origin, destination, currency, amount, accountOrigin, originApi);
12691
- case 24:
12856
+ case 26:
12692
12857
  _context.t6 = _context.sent;
12693
12858
  _context.t7 = BigInt((_b = getExistentialDeposit(origin)) !== null && _b !== void 0 ? _b : 0);
12694
12859
  _context.t8 = getNativeAssetSymbol(origin);
12695
12860
  _context.t9 = getMinNativeTransferableAmount(origin);
12696
- _context.next = 30;
12861
+ _context.next = 32;
12697
12862
  return getMaxNativeTransferableAmount(accountOrigin, origin);
12698
- case 30:
12863
+ case 32:
12699
12864
  _context.t10 = _context.sent;
12700
12865
  _context.t11 = {
12701
12866
  balance: _context.t4,
@@ -12706,9 +12871,9 @@ var getTransferInfo = function getTransferInfo(origin, destination, accountOrigi
12706
12871
  minNativeTransferableAmount: _context.t9,
12707
12872
  maxNativeTransferableAmount: _context.t10
12708
12873
  };
12709
- _context.next = 34;
12874
+ _context.next = 36;
12710
12875
  return getBalanceNative(accountDestination, destination);
12711
- case 34:
12876
+ case 36:
12712
12877
  _context.t12 = _context.sent;
12713
12878
  _context.t13 = getNativeAssetSymbol(destination);
12714
12879
  _context.t14 = getExistentialDeposit(destination);
@@ -12723,7 +12888,7 @@ var getTransferInfo = function getTransferInfo(origin, destination, accountOrigi
12723
12888
  originFeeBalance: _context.t11,
12724
12889
  destinationFeeBalance: _context.t15
12725
12890
  });
12726
- case 39:
12891
+ case 41:
12727
12892
  case "end":
12728
12893
  return _context.stop();
12729
12894
  }
@@ -13649,6 +13814,7 @@ var index = /*#__PURE__*/Object.freeze({
13649
13814
 
13650
13815
  exports.Builder = Builder;
13651
13816
  exports.DuplicateAssetError = DuplicateAssetError;
13817
+ exports.DuplicateAssetIdError = DuplicateAssetIdError;
13652
13818
  exports.EvmBuilder = EvmBuilder;
13653
13819
  exports.GeneralBuilder = GeneralBuilder;
13654
13820
  exports.IncompatibleNodesError = IncompatibleNodesError;
package/dist/index.d.ts CHANGED
@@ -44,6 +44,7 @@ declare class Crust extends ParachainNode implements IXTokensTransfer {
44
44
 
45
45
  declare class BifrostPolkadot extends ParachainNode implements IXTokensTransfer {
46
46
  constructor();
47
+ private getCurrencySelection;
47
48
  transferXTokens(input: XTokensTransferInput): TTransferReturn;
48
49
  }
49
50
 
@@ -307,7 +308,20 @@ type TOtherReserveAsset = {
307
308
  };
308
309
  type TSelfReserveAsset = 'SelfReserve';
309
310
  type TReserveAsset = TOtherReserveAsset | TSelfReserveAsset;
310
- type TXTokensCurrencySelection = TCurrencySelectionHeader | TCurrencySelectionHeaderArr | TForeignAsset | TForeignAssetId | TForeignOrTokenAsset | TXcmAsset | TMantaAsset | TOtherReserveAsset | string | undefined;
311
+ type TBifrostToken = {
312
+ Native: string;
313
+ } | {
314
+ VToken: string;
315
+ } | {
316
+ Token: string;
317
+ } | {
318
+ VSToken2: number;
319
+ } | {
320
+ VToken2: number;
321
+ } | {
322
+ Token2: number;
323
+ };
324
+ type TXTokensCurrencySelection = TCurrencySelectionHeader | TCurrencySelectionHeaderArr | TForeignAsset | TForeignAssetId | TForeignOrTokenAsset | TXcmAsset | TMantaAsset | TOtherReserveAsset | TBifrostToken | string | undefined;
311
325
 
312
326
  interface IPolkadotApi<TApi extends TApiType, TRes extends TResType> {
313
327
  init(api: TApi): void;
@@ -1488,4 +1502,16 @@ declare class DuplicateAssetError extends Error {
1488
1502
  constructor(symbol: string);
1489
1503
  }
1490
1504
 
1491
- export { BatchMode, Builder, type CheckKeepAliveOptions, DuplicateAssetError, EvmBuilder, type Extrinsic, GeneralBuilder, type HexString$1 as HexString, type IPolkadotXCMTransfer, type IXTokensTransfer, type IXTransferTransfer, IncompatibleNodesError, InvalidCurrencyError, type JunctionParachain, type JunctionType, type Junctions, NODES_WITH_RELAY_CHAINS, NODES_WITH_RELAY_CHAINS_DOT_KSM, NODE_NAMES, NODE_NAMES_DOT_KSM, NoXCMSupportImplementedError, NodeNotSupportedError, Parents, type PolkadotXCMTransferInput, type PolkadotXcmModule, type PolkadotXcmSection, SUPPORTED_PALLETS, ScenarioNotSupportedError, type TAddress, type TAmount, type TApiType, type TAsset, type TAssetDetails, type TAssetJsonMap, type TBatchOptions, type TCurrency, type TCurrencyCore, type TCurrencyInput, type TCurrencySelection, type TCurrencySelectionHeader, type TCurrencySelectionHeaderArr, type TCurrencySelectionV4, type TCurrencySymbol, type TDestWeight, type TDestination, type TEdJsonMap, type TEvmBuilderOptions, type TForeignAsset, type TForeignAssetId, type TForeignOrNativeAsset, type TForeignOrTokenAsset, type TJunction, type TMantaAsset, type TMultiAsset, type TMultiAssetV3, type TMultiAssetV4, type TMultiLocation, type TMultiLocationHeader, type TNativeAssetDetails, type TNativeTokenAsset, type TNode, type TNodeAssets, type TNodeDotKsmWithRelayChains, type TNodePolkadotKusama, type TNodeWithRelayChains, type TNodleAsset, type TOptionalEvmBuilderOptions, type TOriginFeeDetails, type TOtherReserveAsset, type TPallet, type TPalletJsonMap, type TPalletMap, type TRelayChainSymbol, type TRelayChainType, type TRelayToParaCommonOptions, type TRelayToParaInternalOptions, type TRelayToParaOptions, type TResType, type TReserveAsset, type TScenario, type TSelfReserveAsset, type TSendBaseOptions, type TSendInternalOptions, type TSendOptions, type TSendOptionsCommon, type TSerializeEthTransferOptions, type TSerializedApiCall, type TSerializedEthTransfer, type TTransferInfo, type TTransferReturn, type TVersionClaimAssets, type TXTokensCurrencySelection, type TXcmAsset, type TZeitgeistAsset, type UseKeepAliveFinalBuilder, Version, type XTokensModule, type XTokensSection, type XTokensTransferInput, type XTransferModule, type XTransferSection, type XTransferTransferInput, index as assets, buildEthTransferOptions, createApiInstanceForNode, determineRelayChain, getAllAssetsSymbols, getAllNodeProviders, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getBalanceForeign, getBalanceNative, getDefaultPallet, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getNode, getNodeEndpointOption, getNodeProvider, getOtherAssets, getParaId, getRelayChainSymbol, getSupportedAssets, getSupportedPallets, getTNode, getTransferInfo, hasSupportForAsset, isRelayChain, send, sendSerializedApiCall, transferRelayToPara, transferRelayToParaCommon, transferRelayToParaSerializedApiCall, index$1 as xcmPallet };
1505
+ /**
1506
+ * Error thrown when multiple assets with the same symbol are found.
1507
+ */
1508
+ declare class DuplicateAssetIdError extends Error {
1509
+ /**
1510
+ * Constructs a new DuplicateAssetError.
1511
+ *
1512
+ * @param symbol - The symbol of the asset causing the duplication error.
1513
+ */
1514
+ constructor(id: string);
1515
+ }
1516
+
1517
+ export { BatchMode, Builder, type CheckKeepAliveOptions, DuplicateAssetError, DuplicateAssetIdError, EvmBuilder, type Extrinsic, GeneralBuilder, type HexString$1 as HexString, type IPolkadotXCMTransfer, type IXTokensTransfer, type IXTransferTransfer, IncompatibleNodesError, InvalidCurrencyError, type JunctionParachain, type JunctionType, type Junctions, NODES_WITH_RELAY_CHAINS, NODES_WITH_RELAY_CHAINS_DOT_KSM, NODE_NAMES, NODE_NAMES_DOT_KSM, NoXCMSupportImplementedError, NodeNotSupportedError, Parents, type PolkadotXCMTransferInput, type PolkadotXcmModule, type PolkadotXcmSection, SUPPORTED_PALLETS, ScenarioNotSupportedError, type TAddress, type TAmount, type TApiType, type TAsset, type TAssetDetails, type TAssetJsonMap, type TBatchOptions, type TBifrostToken, type TCurrency, type TCurrencyCore, type TCurrencyInput, type TCurrencySelection, type TCurrencySelectionHeader, type TCurrencySelectionHeaderArr, type TCurrencySelectionV4, type TCurrencySymbol, type TDestWeight, type TDestination, type TEdJsonMap, type TEvmBuilderOptions, type TForeignAsset, type TForeignAssetId, type TForeignOrNativeAsset, type TForeignOrTokenAsset, type TJunction, type TMantaAsset, type TMultiAsset, type TMultiAssetV3, type TMultiAssetV4, type TMultiLocation, type TMultiLocationHeader, type TNativeAssetDetails, type TNativeTokenAsset, type TNode, type TNodeAssets, type TNodeDotKsmWithRelayChains, type TNodePolkadotKusama, type TNodeWithRelayChains, type TNodleAsset, type TOptionalEvmBuilderOptions, type TOriginFeeDetails, type TOtherReserveAsset, type TPallet, type TPalletJsonMap, type TPalletMap, type TRelayChainSymbol, type TRelayChainType, type TRelayToParaCommonOptions, type TRelayToParaInternalOptions, type TRelayToParaOptions, type TResType, type TReserveAsset, type TScenario, type TSelfReserveAsset, type TSendBaseOptions, type TSendInternalOptions, type TSendOptions, type TSendOptionsCommon, type TSerializeEthTransferOptions, type TSerializedApiCall, type TSerializedEthTransfer, type TTransferInfo, type TTransferReturn, type TVersionClaimAssets, type TXTokensCurrencySelection, type TXcmAsset, type TZeitgeistAsset, type UseKeepAliveFinalBuilder, Version, type XTokensModule, type XTokensSection, type XTokensTransferInput, type XTransferModule, type XTransferSection, type XTransferTransferInput, index as assets, buildEthTransferOptions, createApiInstanceForNode, determineRelayChain, getAllAssetsSymbols, getAllNodeProviders, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getBalanceForeign, getBalanceNative, getDefaultPallet, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getNode, getNodeEndpointOption, getNodeProvider, getOtherAssets, getParaId, getRelayChainSymbol, getSupportedAssets, getSupportedPallets, getTNode, getTransferInfo, hasSupportForAsset, isRelayChain, send, sendSerializedApiCall, transferRelayToPara, transferRelayToParaCommon, transferRelayToParaSerializedApiCall, index$1 as xcmPallet };
package/dist/index.mjs CHANGED
@@ -505,11 +505,11 @@ function _toPrimitive(t, r) {
505
505
  if ("object" != typeof t || !t) return t;
506
506
  var e = t[Symbol.toPrimitive];
507
507
  if (void 0 !== e) {
508
- var i = e.call(t, r || "default");
508
+ var i = e.call(t, r);
509
509
  if ("object" != typeof i) return i;
510
510
  throw new TypeError("@@toPrimitive must return a primitive value.");
511
511
  }
512
- return ("string" === r ? String : Number)(t);
512
+ return (String )(t);
513
513
  }
514
514
  function _toPropertyKey(t) {
515
515
  var i = _toPrimitive(t, "string");
@@ -1131,51 +1131,120 @@ var BifrostPolkadot$3 = {
1131
1131
  nativeAssetSymbol: "BNC",
1132
1132
  nativeAssets: [
1133
1133
  {
1134
- symbol: "ASG",
1135
- decimals: 18
1134
+ symbol: "vBNC",
1135
+ decimals: 12
1136
1136
  },
1137
1137
  {
1138
1138
  symbol: "BNC",
1139
1139
  decimals: 12
1140
+ }
1141
+ ],
1142
+ otherAssets: [
1143
+ {
1144
+ assetId: "6",
1145
+ symbol: "IBTC",
1146
+ decimals: 8
1140
1147
  },
1141
1148
  {
1142
- symbol: "KUSD",
1143
- decimals: 12
1149
+ assetId: "8",
1150
+ symbol: "MANTA",
1151
+ decimals: 18
1152
+ },
1153
+ {
1154
+ assetId: "7",
1155
+ symbol: "INTR",
1156
+ decimals: 10
1144
1157
  },
1145
1158
  {
1159
+ assetId: "13",
1160
+ symbol: "WETH",
1161
+ decimals: 18
1162
+ },
1163
+ {
1164
+ assetId: "2",
1165
+ symbol: "USDT",
1166
+ decimals: 6
1167
+ },
1168
+ {
1169
+ assetId: "5",
1170
+ symbol: "USDC",
1171
+ decimals: 6
1172
+ },
1173
+ {
1174
+ assetId: "0",
1146
1175
  symbol: "DOT",
1147
1176
  decimals: 10
1148
1177
  },
1149
1178
  {
1150
- symbol: "KSM",
1151
- decimals: 12
1179
+ assetId: "1",
1180
+ symbol: "GLMR",
1181
+ decimals: 18
1152
1182
  },
1153
1183
  {
1154
- symbol: "ETH",
1184
+ assetId: "1",
1185
+ symbol: "vGLMR",
1186
+ decimals: 18
1187
+ },
1188
+ {
1189
+ assetId: "14",
1190
+ symbol: "WAVE",
1191
+ decimals: 18
1192
+ },
1193
+ {
1194
+ assetId: "11",
1195
+ symbol: "DED",
1155
1196
  decimals: 10
1156
1197
  },
1157
1198
  {
1158
- symbol: "KAR",
1159
- decimals: 12
1199
+ assetId: "4",
1200
+ symbol: "vFIL",
1201
+ decimals: 18
1160
1202
  },
1161
1203
  {
1162
- symbol: "ZLK",
1204
+ assetId: "9",
1205
+ symbol: "BNCS",
1163
1206
  decimals: 12
1164
1207
  },
1165
1208
  {
1166
- symbol: "PHA",
1209
+ assetId: "10",
1210
+ symbol: "PINK",
1211
+ decimals: 10
1212
+ },
1213
+ {
1214
+ assetId: "4",
1215
+ symbol: "FIL",
1216
+ decimals: 18
1217
+ },
1218
+ {
1219
+ assetId: "8",
1220
+ symbol: "vMANTA",
1221
+ decimals: 18
1222
+ },
1223
+ {
1224
+ assetId: "12",
1225
+ symbol: "PEN",
1167
1226
  decimals: 12
1168
1227
  },
1169
1228
  {
1170
- symbol: "RMRK",
1229
+ assetId: "3",
1230
+ symbol: "vASTR",
1231
+ decimals: 18
1232
+ },
1233
+ {
1234
+ assetId: "0",
1235
+ symbol: "vDOT",
1171
1236
  decimals: 10
1172
1237
  },
1173
1238
  {
1174
- symbol: "MOVR",
1239
+ assetId: "3",
1240
+ symbol: "ASTR",
1175
1241
  decimals: 18
1242
+ },
1243
+ {
1244
+ assetId: "0",
1245
+ symbol: "vsDOT",
1246
+ decimals: 10
1176
1247
  }
1177
- ],
1178
- otherAssets: [
1179
1248
  ]
1180
1249
  };
1181
1250
  var Bitgreen$3 = {
@@ -4503,24 +4572,28 @@ var BifrostKusama$3 = {
4503
4572
  nativeAssetSymbol: "BNC",
4504
4573
  nativeAssets: [
4505
4574
  {
4506
- symbol: "BNC",
4575
+ symbol: "KSM",
4507
4576
  decimals: 12
4508
4577
  },
4509
4578
  {
4510
- symbol: "KUSD",
4579
+ symbol: "RMRK",
4580
+ decimals: 10
4581
+ },
4582
+ {
4583
+ symbol: "vBNC",
4511
4584
  decimals: 12
4512
4585
  },
4513
4586
  {
4514
- symbol: "DOT",
4515
- decimals: 10
4587
+ symbol: "vMOVR",
4588
+ decimals: 18
4516
4589
  },
4517
4590
  {
4518
- symbol: "KSM",
4591
+ symbol: "vKSM",
4519
4592
  decimals: 12
4520
4593
  },
4521
4594
  {
4522
- symbol: "KAR",
4523
- decimals: 12
4595
+ symbol: "MOVR",
4596
+ decimals: 18
4524
4597
  },
4525
4598
  {
4526
4599
  symbol: "ZLK",
@@ -4531,15 +4604,40 @@ var BifrostKusama$3 = {
4531
4604
  decimals: 12
4532
4605
  },
4533
4606
  {
4534
- symbol: "RMRK",
4535
- decimals: 10
4607
+ symbol: "KAR",
4608
+ decimals: 12
4536
4609
  },
4537
4610
  {
4538
- symbol: "MOVR",
4539
- decimals: 18
4611
+ symbol: "BNC",
4612
+ decimals: 12
4540
4613
  }
4541
4614
  ],
4542
4615
  otherAssets: [
4616
+ {
4617
+ assetId: "2",
4618
+ symbol: "KBTC",
4619
+ decimals: 8
4620
+ },
4621
+ {
4622
+ assetId: "0",
4623
+ symbol: "USDT",
4624
+ decimals: 6
4625
+ },
4626
+ {
4627
+ assetId: "1",
4628
+ symbol: "KINT",
4629
+ decimals: 12
4630
+ },
4631
+ {
4632
+ assetId: "4",
4633
+ symbol: "MGX",
4634
+ decimals: 18
4635
+ },
4636
+ {
4637
+ assetId: "3",
4638
+ symbol: "SDN",
4639
+ decimals: 18
4640
+ }
4543
4641
  ]
4544
4642
  };
4545
4643
  var Calamari$3 = {
@@ -8253,6 +8351,26 @@ var DuplicateAssetError = /*#__PURE__*/function (_Error) {
8253
8351
  return _createClass(DuplicateAssetError);
8254
8352
  }(/*#__PURE__*/_wrapNativeSuper(Error));
8255
8353
 
8354
+ /**
8355
+ * Error thrown when multiple assets with the same symbol are found.
8356
+ */
8357
+ var DuplicateAssetIdError = /*#__PURE__*/function (_Error) {
8358
+ /**
8359
+ * Constructs a new DuplicateAssetError.
8360
+ *
8361
+ * @param symbol - The symbol of the asset causing the duplication error.
8362
+ */
8363
+ function DuplicateAssetIdError(id) {
8364
+ var _this;
8365
+ _classCallCheck(this, DuplicateAssetIdError);
8366
+ _this = _callSuper(this, DuplicateAssetIdError, ["Multiple assets found with the same ID: ".concat(id, ". Please specify asset directly by symbol using .currency({symbol: <ASSET_SYMBOL>})")]);
8367
+ _this.name = 'DuplicateAssetId';
8368
+ return _this;
8369
+ }
8370
+ _inherits(DuplicateAssetIdError, _Error);
8371
+ return _createClass(DuplicateAssetIdError);
8372
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
8373
+
8256
8374
  var supportsXTokens = function supportsXTokens(obj) {
8257
8375
  return _typeof(obj) === 'object' && obj !== null && 'transferXTokens' in obj;
8258
8376
  };
@@ -8596,9 +8714,44 @@ var BifrostPolkadot$2 = /*#__PURE__*/function (_ParachainNode) {
8596
8714
  }
8597
8715
  _inherits(BifrostPolkadot, _ParachainNode);
8598
8716
  return _createClass(BifrostPolkadot, [{
8717
+ key: "getCurrencySelection",
8718
+ value: function getCurrencySelection(currency, currencyId) {
8719
+ var nativeAssetSymbol = this.getNativeAssetSymbol();
8720
+ if (currency === nativeAssetSymbol) {
8721
+ return {
8722
+ Native: nativeAssetSymbol
8723
+ };
8724
+ }
8725
+ var isVToken = currency.startsWith('v');
8726
+ var isVSToken = currency.startsWith('vs');
8727
+ if (!currencyId) {
8728
+ return isVToken ? {
8729
+ VToken: currency.substring(1)
8730
+ } : {
8731
+ Token: currency
8732
+ };
8733
+ }
8734
+ var id = Number(currencyId);
8735
+ if (isVSToken) {
8736
+ return {
8737
+ VSToken2: id
8738
+ };
8739
+ }
8740
+ return isVToken ? {
8741
+ VToken2: id
8742
+ } : {
8743
+ Token2: id
8744
+ };
8745
+ }
8746
+ }, {
8599
8747
  key: "transferXTokens",
8600
8748
  value: function transferXTokens(input) {
8601
- var currencySelection = _defineProperty({}, input.currency === this.getNativeAssetSymbol() ? 'Native' : 'Token', input.currency);
8749
+ var currency = input.currency,
8750
+ currencyID = input.currencyID;
8751
+ if (!currency) {
8752
+ throw new Error('Currency symbol is undefined');
8753
+ }
8754
+ var currencySelection = this.getCurrencySelection(currency, currencyID);
8602
8755
  return XTokensTransferImpl.transferXTokens(input, currencySelection);
8603
8756
  }
8604
8757
  }]);
@@ -8843,8 +8996,7 @@ var BifrostKusama$2 = /*#__PURE__*/function (_ParachainNode) {
8843
8996
  return _createClass(BifrostKusama, [{
8844
8997
  key: "transferXTokens",
8845
8998
  value: function transferXTokens(input) {
8846
- var currencySelection = _defineProperty({}, input.currency === this.getNativeAssetSymbol() ? 'Native' : 'Token', input.currency);
8847
- return XTokensTransferImpl.transferXTokens(input, currencySelection);
8999
+ return getNode('BifrostPolkadot').transferXTokens(input);
8848
9000
  }
8849
9001
  }]);
8850
9002
  }(ParachainNode);
@@ -10739,13 +10891,20 @@ var findAssetBySymbol = function findAssetBySymbol(node, destination, otherAsset
10739
10891
  }
10740
10892
  return otherAssetsMatches[0] || nativeAssetsMatches[0] || null;
10741
10893
  };
10742
-
10743
10894
  var findAssetById = function findAssetById(assets, assetId) {
10744
- return assets.find(function (_ref) {
10745
- var currentAssetId = _ref.assetId;
10895
+ var otherAssetsMatches = assets.filter(function (_ref4) {
10896
+ var currentAssetId = _ref4.assetId;
10746
10897
  return currentAssetId === assetId.toString();
10747
10898
  });
10899
+ if (otherAssetsMatches.length > 1) {
10900
+ throw new DuplicateAssetIdError(assetId.toString());
10901
+ }
10902
+ return assets.find(function (_ref5) {
10903
+ var currentAssetId = _ref5.assetId;
10904
+ return currentAssetId === assetId;
10905
+ });
10748
10906
  };
10907
+
10749
10908
  var getAssetBySymbolOrId = function getAssetBySymbolOrId(node, currency) {
10750
10909
  var isRelayDestination = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
10751
10910
  var destination = arguments.length > 3 ? arguments[3] : undefined;
@@ -12665,35 +12824,41 @@ var getTransferInfo = function getTransferInfo(origin, destination, accountOrigi
12665
12824
  destXcmFee = _yield$getOriginFeeDe.xcmFee;
12666
12825
  expectedBalanceAfterXCMDelivery = originBalance - destXcmFee;
12667
12826
  asset = getAssetBySymbolOrId(origin, currency);
12827
+ if (asset) {
12828
+ _context.next = 14;
12829
+ break;
12830
+ }
12831
+ throw new InvalidCurrencyError("Asset ".concat('symbol' in currency ? currency.symbol : currency.id, " not found on ").concat(origin));
12832
+ case 14:
12668
12833
  _context.t0 = {
12669
12834
  origin: origin,
12670
12835
  destination: destination,
12671
12836
  ecosystem: determineRelayChainSymbol(origin)
12672
12837
  };
12673
- _context.next = 15;
12838
+ _context.next = 17;
12674
12839
  return getAssetBalance(accountOrigin, origin, currency);
12675
- case 15:
12840
+ case 17:
12676
12841
  _context.t1 = _context.sent;
12677
12842
  _context.t2 = (_a = asset === null || asset === void 0 ? void 0 : asset.symbol) !== null && _a !== void 0 ? _a : '';
12678
12843
  _context.t3 = {
12679
12844
  balance: _context.t1,
12680
12845
  currency: _context.t2
12681
12846
  };
12682
- _context.next = 20;
12847
+ _context.next = 22;
12683
12848
  return getBalanceNative(accountOrigin, origin, originApi);
12684
- case 20:
12849
+ case 22:
12685
12850
  _context.t4 = _context.sent;
12686
12851
  _context.t5 = expectedBalanceAfterXCMDelivery;
12687
- _context.next = 24;
12852
+ _context.next = 26;
12688
12853
  return getOriginFeeDetails(origin, destination, currency, amount, accountOrigin, originApi);
12689
- case 24:
12854
+ case 26:
12690
12855
  _context.t6 = _context.sent;
12691
12856
  _context.t7 = BigInt((_b = getExistentialDeposit(origin)) !== null && _b !== void 0 ? _b : 0);
12692
12857
  _context.t8 = getNativeAssetSymbol(origin);
12693
12858
  _context.t9 = getMinNativeTransferableAmount(origin);
12694
- _context.next = 30;
12859
+ _context.next = 32;
12695
12860
  return getMaxNativeTransferableAmount(accountOrigin, origin);
12696
- case 30:
12861
+ case 32:
12697
12862
  _context.t10 = _context.sent;
12698
12863
  _context.t11 = {
12699
12864
  balance: _context.t4,
@@ -12704,9 +12869,9 @@ var getTransferInfo = function getTransferInfo(origin, destination, accountOrigi
12704
12869
  minNativeTransferableAmount: _context.t9,
12705
12870
  maxNativeTransferableAmount: _context.t10
12706
12871
  };
12707
- _context.next = 34;
12872
+ _context.next = 36;
12708
12873
  return getBalanceNative(accountDestination, destination);
12709
- case 34:
12874
+ case 36:
12710
12875
  _context.t12 = _context.sent;
12711
12876
  _context.t13 = getNativeAssetSymbol(destination);
12712
12877
  _context.t14 = getExistentialDeposit(destination);
@@ -12721,7 +12886,7 @@ var getTransferInfo = function getTransferInfo(origin, destination, accountOrigi
12721
12886
  originFeeBalance: _context.t11,
12722
12887
  destinationFeeBalance: _context.t15
12723
12888
  });
12724
- case 39:
12889
+ case 41:
12725
12890
  case "end":
12726
12891
  return _context.stop();
12727
12892
  }
@@ -13645,4 +13810,4 @@ var index = /*#__PURE__*/Object.freeze({
13645
13810
  transferRelayToParaSerializedApiCall: transferRelayToParaSerializedApiCall
13646
13811
  });
13647
13812
 
13648
- export { BatchMode, Builder, DuplicateAssetError, EvmBuilder, GeneralBuilder, IncompatibleNodesError, InvalidCurrencyError, NODES_WITH_RELAY_CHAINS, NODES_WITH_RELAY_CHAINS_DOT_KSM, NODE_NAMES, NODE_NAMES_DOT_KSM, NoXCMSupportImplementedError, NodeNotSupportedError, Parents, SUPPORTED_PALLETS, ScenarioNotSupportedError, Version, index$1 as assets, buildEthTransferOptions, createApiInstanceForNode, determineRelayChain, getAllAssetsSymbols, getAllNodeProviders, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getBalanceForeign, getBalanceNative, getDefaultPallet, getExistentialDeposit$1 as getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getNode, getNodeEndpointOption, getNodeProvider, getOtherAssets, getParaId, getRelayChainSymbol, getSupportedAssets, getSupportedPallets, getTNode, getTransferInfo, hasSupportForAsset, isRelayChain, send, sendSerializedApiCall, transferRelayToPara, transferRelayToParaCommon, transferRelayToParaSerializedApiCall, index as xcmPallet };
13813
+ export { BatchMode, Builder, DuplicateAssetError, DuplicateAssetIdError, EvmBuilder, GeneralBuilder, IncompatibleNodesError, InvalidCurrencyError, NODES_WITH_RELAY_CHAINS, NODES_WITH_RELAY_CHAINS_DOT_KSM, NODE_NAMES, NODE_NAMES_DOT_KSM, NoXCMSupportImplementedError, NodeNotSupportedError, Parents, SUPPORTED_PALLETS, ScenarioNotSupportedError, Version, index$1 as assets, buildEthTransferOptions, createApiInstanceForNode, determineRelayChain, getAllAssetsSymbols, getAllNodeProviders, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getBalanceForeign, getBalanceNative, getDefaultPallet, getExistentialDeposit$1 as getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getNode, getNodeEndpointOption, getNodeProvider, getOtherAssets, getParaId, getRelayChainSymbol, getSupportedAssets, getSupportedPallets, getTNode, getTransferInfo, hasSupportForAsset, isRelayChain, send, sendSerializedApiCall, transferRelayToPara, transferRelayToParaCommon, transferRelayToParaSerializedApiCall, index as xcmPallet };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk",
3
- "version": "6.2.0",
3
+ "version": "6.2.2",
4
4
  "description": "SDK for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": "@paraspell/sdk",
6
6
  "license": "MIT",