@paraspell/sdk-pjs 10.0.1 → 10.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -861,6 +861,11 @@ var PolkadotJsApi = /*#__PURE__*/function () {
861
861
  }
862
862
  return getBalanceAssetsPallet;
863
863
  }()
864
+ }, {
865
+ key: "getMethod",
866
+ value: function getMethod(tx) {
867
+ return tx.method.toString();
868
+ }
864
869
  }, {
865
870
  key: "getFromRpc",
866
871
  value: function () {
@@ -874,7 +879,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
874
879
  _context12.next = 3;
875
880
  break;
876
881
  }
877
- throw new Error("RPC method ".concat(module, ".").concat(method, " not available"));
882
+ throw new sdkCore.InvalidParameterError("RPC method ".concat(module, ".").concat(method, " not available"));
878
883
  case 3:
879
884
  _context12.next = 5;
880
885
  return rpcModule[method](key);
@@ -931,7 +936,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
931
936
  value: function () {
932
937
  var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee14(_ref4) {
933
938
  var _this$api$call$dryRun;
934
- var tx, address, node, supportsDryRunApi, needsVersionParam, DEFAULT_XCM_VERSION, response, result, resultJson, isSuccess, moduleError, failureReason, executionFee, fee, actualWeight, weight, forwardedXcms, destParaId;
939
+ var tx, address, node, supportsDryRunApi, nodesRequiringVersionParam, needsVersionParam, DEFAULT_XCM_VERSION, response, result, resultJson, isSuccess, moduleError, failureReason, executionFee, fee, actualWeight, weight, forwardedXcms, destParaId;
935
940
  return _regeneratorRuntime().wrap(function _callee14$(_context14) {
936
941
  while (1) switch (_context14.prev = _context14.next) {
937
942
  case 0:
@@ -943,21 +948,22 @@ var PolkadotJsApi = /*#__PURE__*/function () {
943
948
  }
944
949
  throw new sdkCore.NodeNotSupportedError("DryRunApi is not available on node ".concat(node));
945
950
  case 4:
946
- needsVersionParam = node === 'BifrostPolkadot' || node === 'BifrostKusama' || node === 'AssetHubKusama' || node === 'Kusama' || node === 'Polimec';
951
+ nodesRequiringVersionParam = ['BifrostPolkadot', 'BifrostKusama', 'AssetHubKusama', 'AssetHubPolkadot', 'Kusama', 'Polkadot', 'Polimec'];
952
+ needsVersionParam = nodesRequiringVersionParam.includes(node);
947
953
  DEFAULT_XCM_VERSION = 3;
948
- _context14.next = 8;
954
+ _context14.next = 9;
949
955
  return (_this$api$call$dryRun = this.api.call.dryRunApi).dryRunCall.apply(_this$api$call$dryRun, [{
950
956
  system: {
951
957
  Signed: address
952
958
  }
953
959
  }, tx].concat(_toConsumableArray(needsVersionParam ? [DEFAULT_XCM_VERSION] : [])));
954
- case 8:
960
+ case 9:
955
961
  response = _context14.sent;
956
962
  result = response.toHuman();
957
963
  resultJson = response.toJSON();
958
964
  isSuccess = result.Ok && result.Ok.executionResult.Ok;
959
965
  if (isSuccess) {
960
- _context14.next = 16;
966
+ _context14.next = 17;
961
967
  break;
962
968
  }
963
969
  moduleError = result.Ok.executionResult.Err.error.Module;
@@ -966,10 +972,10 @@ var PolkadotJsApi = /*#__PURE__*/function () {
966
972
  success: false,
967
973
  failureReason: failureReason
968
974
  });
969
- case 16:
970
- _context14.next = 18;
975
+ case 17:
976
+ _context14.next = 19;
971
977
  return this.calculateTransactionFee(tx, address);
972
- case 18:
978
+ case 19:
973
979
  executionFee = _context14.sent;
974
980
  fee = sdkCore.computeFeeFromDryRunPjs(result, node, executionFee);
975
981
  actualWeight = resultJson.ok.executionResult.ok.actualWeight;
@@ -988,7 +994,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
988
994
  forwardedXcms: forwardedXcms,
989
995
  destParaId: destParaId
990
996
  });
991
- case 25:
997
+ case 26:
992
998
  case "end":
993
999
  return _context14.stop();
994
1000
  }
@@ -1272,7 +1278,7 @@ var approveToken = /*#__PURE__*/function () {
1272
1278
  _context.next = 4;
1273
1279
  break;
1274
1280
  }
1275
- throw new Error("Token ".concat(symbol, " not supported"));
1281
+ throw new sdkCore.InvalidParameterError("Token ".concat(symbol, " not supported"));
1276
1282
  case 4:
1277
1283
  weth9 = contractTypes.WETH9__factory.connect(contract.address, signer);
1278
1284
  _context.next = 7;
@@ -1312,7 +1318,7 @@ var depositToken = /*#__PURE__*/function () {
1312
1318
  _context.next = 4;
1313
1319
  break;
1314
1320
  }
1315
- throw new Error("Token ".concat(symbol, " not supported"));
1321
+ throw new sdkCore.InvalidParameterError("Token ".concat(symbol, " not supported"));
1316
1322
  case 4:
1317
1323
  weth9 = contractTypes.WETH9__factory.connect(contract.address, signer);
1318
1324
  _context.next = 7;
@@ -1383,25 +1389,25 @@ var transferEthToPolkadot$1 = /*#__PURE__*/function () {
1383
1389
  _context.next = 3;
1384
1390
  break;
1385
1391
  }
1386
- throw new Error('Multiassets syntax is not supported for Evm transfers');
1392
+ throw new sdkCore.InvalidParameterError('Multiassets syntax is not supported for Evm transfers');
1387
1393
  case 3:
1388
1394
  if (!('multilocation' in currency && sdkCore.isOverrideMultiLocationSpecifier(currency.multilocation))) {
1389
1395
  _context.next = 5;
1390
1396
  break;
1391
1397
  }
1392
- throw new Error('Override multilocation is not supported for Evm transfers');
1398
+ throw new sdkCore.InvalidParameterError('Override multilocation is not supported for Evm transfers');
1393
1399
  case 5:
1394
1400
  if (provider) {
1395
1401
  _context.next = 7;
1396
1402
  break;
1397
1403
  }
1398
- throw new Error('provider parameter is required for Snowbridge transfers.');
1404
+ throw new sdkCore.InvalidParameterError('provider parameter is required for Snowbridge transfers.');
1399
1405
  case 7:
1400
1406
  if (sdkCore.isEthersSigner(signer)) {
1401
1407
  _context.next = 9;
1402
1408
  break;
1403
1409
  }
1404
- throw new Error('Snowbridge does not support Viem provider yet.');
1410
+ throw new sdkCore.InvalidParameterError('Snowbridge does not support Viem provider yet.');
1405
1411
  case 9:
1406
1412
  ethAsset = sdkCore.findAsset('Ethereum', currency, to);
1407
1413
  if (!(ethAsset === null)) {
@@ -1525,7 +1531,7 @@ var transferEthToPolkadot$1 = /*#__PURE__*/function () {
1525
1531
  _context.next = 76;
1526
1532
  break;
1527
1533
  }
1528
- throw Error("Validation failed with following errors: \n\n ".concat(validation.logs.filter(function (l) {
1534
+ throw new sdkCore.InvalidParameterError("Validation failed with following errors: \n\n ".concat(validation.logs.filter(function (l) {
1529
1535
  return l.kind == api$1.toPolkadotV2.ValidationKind.Error;
1530
1536
  }).map(function (l) {
1531
1537
  return l.message;
@@ -1544,7 +1550,7 @@ var transferEthToPolkadot$1 = /*#__PURE__*/function () {
1544
1550
  _context.next = 85;
1545
1551
  break;
1546
1552
  }
1547
- throw Error("Transaction ".concat(response.hash, " not included."));
1553
+ throw new sdkCore.InvalidParameterError("Transaction ".concat(response.hash, " not included."));
1548
1554
  case 85:
1549
1555
  _context.next = 87;
1550
1556
  return api$1.toPolkadotV2.getMessageReceipt(receipt);
@@ -1554,7 +1560,7 @@ var transferEthToPolkadot$1 = /*#__PURE__*/function () {
1554
1560
  _context.next = 90;
1555
1561
  break;
1556
1562
  }
1557
- throw Error("Transaction ".concat(receipt.hash, " did not emit a message."));
1563
+ throw new sdkCore.InvalidParameterError("Transaction ".concat(receipt.hash, " did not emit a message."));
1558
1564
  case 90:
1559
1565
  return _context.abrupt("return", {
1560
1566
  response: response,
@@ -1585,7 +1591,7 @@ var getTokenBalance = /*#__PURE__*/function () {
1585
1591
  _context.next = 4;
1586
1592
  break;
1587
1593
  }
1588
- throw new Error("Token ".concat(symbol, " not supported"));
1594
+ throw new sdkCore.InvalidParameterError("Token ".concat(symbol, " not supported"));
1589
1595
  case 4:
1590
1596
  weth9 = contractTypes.WETH9__factory.connect(contract.address, signer);
1591
1597
  _context.next = 7;
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { BatchMode, createApiInstanceForNode as createApiInstanceForNode$1, getNode, isForeignAsset, computeFeeFromDryRunPjs, resolveModuleError, getAssetsObject, NodeNotSupportedError, getBalanceNative as getBalanceNative$1, getBalanceForeign as getBalanceForeign$1, getAssetBalance as getAssetBalance$1, claimAssets as claimAssets$1, getOriginFeeDetails as getOriginFeeDetails$1, Foreign, ForeignAbstract, Native, Override, findAsset, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTNode, hasSupportForAsset, isNodeEvm, convertSs58 as convertSs58$1, getParaId, ETH_CHAIN_ID, InvalidCurrencyError, isEthersSigner, isOverrideMultiLocationSpecifier, validateAddress, transferMoonbeamToEth, transferMoonbeamEvm, Builder as Builder$1, getParaEthTransferFees as getParaEthTransferFees$1, DRY_RUN_CLIENT_TIMEOUT_MS, getBridgeStatus as getBridgeStatus$1, send as send$1, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1 } from '@paraspell/sdk-core';
1
+ import { BatchMode, createApiInstanceForNode as createApiInstanceForNode$1, getNode, isForeignAsset, InvalidParameterError, computeFeeFromDryRunPjs, resolveModuleError, getAssetsObject, NodeNotSupportedError, getBalanceNative as getBalanceNative$1, getBalanceForeign as getBalanceForeign$1, getAssetBalance as getAssetBalance$1, claimAssets as claimAssets$1, getOriginFeeDetails as getOriginFeeDetails$1, Foreign, ForeignAbstract, Native, Override, findAsset, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTNode, hasSupportForAsset, isNodeEvm, convertSs58 as convertSs58$1, getParaId, ETH_CHAIN_ID, InvalidCurrencyError, isEthersSigner, isOverrideMultiLocationSpecifier, validateAddress, transferMoonbeamToEth, transferMoonbeamEvm, Builder as Builder$1, getParaEthTransferFees as getParaEthTransferFees$1, DRY_RUN_CLIENT_TIMEOUT_MS, getBridgeStatus as getBridgeStatus$1, send as send$1, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1 } from '@paraspell/sdk-core';
2
2
  export * from '@paraspell/sdk-core';
3
3
  import { WsProvider, ApiPromise } from '@polkadot/api';
4
4
  import { u32 } from '@polkadot/types';
@@ -860,6 +860,11 @@ var PolkadotJsApi = /*#__PURE__*/function () {
860
860
  }
861
861
  return getBalanceAssetsPallet;
862
862
  }()
863
+ }, {
864
+ key: "getMethod",
865
+ value: function getMethod(tx) {
866
+ return tx.method.toString();
867
+ }
863
868
  }, {
864
869
  key: "getFromRpc",
865
870
  value: function () {
@@ -873,7 +878,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
873
878
  _context12.next = 3;
874
879
  break;
875
880
  }
876
- throw new Error("RPC method ".concat(module, ".").concat(method, " not available"));
881
+ throw new InvalidParameterError("RPC method ".concat(module, ".").concat(method, " not available"));
877
882
  case 3:
878
883
  _context12.next = 5;
879
884
  return rpcModule[method](key);
@@ -930,7 +935,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
930
935
  value: function () {
931
936
  var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee14(_ref4) {
932
937
  var _this$api$call$dryRun;
933
- var tx, address, node, supportsDryRunApi, needsVersionParam, DEFAULT_XCM_VERSION, response, result, resultJson, isSuccess, moduleError, failureReason, executionFee, fee, actualWeight, weight, forwardedXcms, destParaId;
938
+ var tx, address, node, supportsDryRunApi, nodesRequiringVersionParam, needsVersionParam, DEFAULT_XCM_VERSION, response, result, resultJson, isSuccess, moduleError, failureReason, executionFee, fee, actualWeight, weight, forwardedXcms, destParaId;
934
939
  return _regeneratorRuntime().wrap(function _callee14$(_context14) {
935
940
  while (1) switch (_context14.prev = _context14.next) {
936
941
  case 0:
@@ -942,21 +947,22 @@ var PolkadotJsApi = /*#__PURE__*/function () {
942
947
  }
943
948
  throw new NodeNotSupportedError("DryRunApi is not available on node ".concat(node));
944
949
  case 4:
945
- needsVersionParam = node === 'BifrostPolkadot' || node === 'BifrostKusama' || node === 'AssetHubKusama' || node === 'Kusama' || node === 'Polimec';
950
+ nodesRequiringVersionParam = ['BifrostPolkadot', 'BifrostKusama', 'AssetHubKusama', 'AssetHubPolkadot', 'Kusama', 'Polkadot', 'Polimec'];
951
+ needsVersionParam = nodesRequiringVersionParam.includes(node);
946
952
  DEFAULT_XCM_VERSION = 3;
947
- _context14.next = 8;
953
+ _context14.next = 9;
948
954
  return (_this$api$call$dryRun = this.api.call.dryRunApi).dryRunCall.apply(_this$api$call$dryRun, [{
949
955
  system: {
950
956
  Signed: address
951
957
  }
952
958
  }, tx].concat(_toConsumableArray(needsVersionParam ? [DEFAULT_XCM_VERSION] : [])));
953
- case 8:
959
+ case 9:
954
960
  response = _context14.sent;
955
961
  result = response.toHuman();
956
962
  resultJson = response.toJSON();
957
963
  isSuccess = result.Ok && result.Ok.executionResult.Ok;
958
964
  if (isSuccess) {
959
- _context14.next = 16;
965
+ _context14.next = 17;
960
966
  break;
961
967
  }
962
968
  moduleError = result.Ok.executionResult.Err.error.Module;
@@ -965,10 +971,10 @@ var PolkadotJsApi = /*#__PURE__*/function () {
965
971
  success: false,
966
972
  failureReason: failureReason
967
973
  });
968
- case 16:
969
- _context14.next = 18;
974
+ case 17:
975
+ _context14.next = 19;
970
976
  return this.calculateTransactionFee(tx, address);
971
- case 18:
977
+ case 19:
972
978
  executionFee = _context14.sent;
973
979
  fee = computeFeeFromDryRunPjs(result, node, executionFee);
974
980
  actualWeight = resultJson.ok.executionResult.ok.actualWeight;
@@ -987,7 +993,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
987
993
  forwardedXcms: forwardedXcms,
988
994
  destParaId: destParaId
989
995
  });
990
- case 25:
996
+ case 26:
991
997
  case "end":
992
998
  return _context14.stop();
993
999
  }
@@ -1271,7 +1277,7 @@ var approveToken = /*#__PURE__*/function () {
1271
1277
  _context.next = 4;
1272
1278
  break;
1273
1279
  }
1274
- throw new Error("Token ".concat(symbol, " not supported"));
1280
+ throw new InvalidParameterError("Token ".concat(symbol, " not supported"));
1275
1281
  case 4:
1276
1282
  weth9 = WETH9__factory.connect(contract.address, signer);
1277
1283
  _context.next = 7;
@@ -1311,7 +1317,7 @@ var depositToken = /*#__PURE__*/function () {
1311
1317
  _context.next = 4;
1312
1318
  break;
1313
1319
  }
1314
- throw new Error("Token ".concat(symbol, " not supported"));
1320
+ throw new InvalidParameterError("Token ".concat(symbol, " not supported"));
1315
1321
  case 4:
1316
1322
  weth9 = WETH9__factory.connect(contract.address, signer);
1317
1323
  _context.next = 7;
@@ -1382,25 +1388,25 @@ var transferEthToPolkadot$1 = /*#__PURE__*/function () {
1382
1388
  _context.next = 3;
1383
1389
  break;
1384
1390
  }
1385
- throw new Error('Multiassets syntax is not supported for Evm transfers');
1391
+ throw new InvalidParameterError('Multiassets syntax is not supported for Evm transfers');
1386
1392
  case 3:
1387
1393
  if (!('multilocation' in currency && isOverrideMultiLocationSpecifier(currency.multilocation))) {
1388
1394
  _context.next = 5;
1389
1395
  break;
1390
1396
  }
1391
- throw new Error('Override multilocation is not supported for Evm transfers');
1397
+ throw new InvalidParameterError('Override multilocation is not supported for Evm transfers');
1392
1398
  case 5:
1393
1399
  if (provider) {
1394
1400
  _context.next = 7;
1395
1401
  break;
1396
1402
  }
1397
- throw new Error('provider parameter is required for Snowbridge transfers.');
1403
+ throw new InvalidParameterError('provider parameter is required for Snowbridge transfers.');
1398
1404
  case 7:
1399
1405
  if (isEthersSigner(signer)) {
1400
1406
  _context.next = 9;
1401
1407
  break;
1402
1408
  }
1403
- throw new Error('Snowbridge does not support Viem provider yet.');
1409
+ throw new InvalidParameterError('Snowbridge does not support Viem provider yet.');
1404
1410
  case 9:
1405
1411
  ethAsset = findAsset('Ethereum', currency, to);
1406
1412
  if (!(ethAsset === null)) {
@@ -1524,7 +1530,7 @@ var transferEthToPolkadot$1 = /*#__PURE__*/function () {
1524
1530
  _context.next = 76;
1525
1531
  break;
1526
1532
  }
1527
- throw Error("Validation failed with following errors: \n\n ".concat(validation.logs.filter(function (l) {
1533
+ throw new InvalidParameterError("Validation failed with following errors: \n\n ".concat(validation.logs.filter(function (l) {
1528
1534
  return l.kind == toPolkadotV2.ValidationKind.Error;
1529
1535
  }).map(function (l) {
1530
1536
  return l.message;
@@ -1543,7 +1549,7 @@ var transferEthToPolkadot$1 = /*#__PURE__*/function () {
1543
1549
  _context.next = 85;
1544
1550
  break;
1545
1551
  }
1546
- throw Error("Transaction ".concat(response.hash, " not included."));
1552
+ throw new InvalidParameterError("Transaction ".concat(response.hash, " not included."));
1547
1553
  case 85:
1548
1554
  _context.next = 87;
1549
1555
  return toPolkadotV2.getMessageReceipt(receipt);
@@ -1553,7 +1559,7 @@ var transferEthToPolkadot$1 = /*#__PURE__*/function () {
1553
1559
  _context.next = 90;
1554
1560
  break;
1555
1561
  }
1556
- throw Error("Transaction ".concat(receipt.hash, " did not emit a message."));
1562
+ throw new InvalidParameterError("Transaction ".concat(receipt.hash, " did not emit a message."));
1557
1563
  case 90:
1558
1564
  return _context.abrupt("return", {
1559
1565
  response: response,
@@ -1584,7 +1590,7 @@ var getTokenBalance = /*#__PURE__*/function () {
1584
1590
  _context.next = 4;
1585
1591
  break;
1586
1592
  }
1587
- throw new Error("Token ".concat(symbol, " not supported"));
1593
+ throw new InvalidParameterError("Token ".concat(symbol, " not supported"));
1588
1594
  case 4:
1589
1595
  weth9 = WETH9__factory.connect(contract.address, signer);
1590
1596
  _context.next = 7;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-pjs",
3
- "version": "10.0.1",
3
+ "version": "10.1.0",
4
4
  "description": "Polkadot.js based SDK for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,7 +27,7 @@
27
27
  "@snowbridge/contract-types": "0.1.50",
28
28
  "ethers": "^6.13.7",
29
29
  "viem": "^2.28.1",
30
- "@paraspell/sdk-core": "10.0.1"
30
+ "@paraspell/sdk-core": "10.1.0"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "@polkadot/api": ">= 15.0 < 16",