@paraspell/sdk-core 8.15.1 → 8.16.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
@@ -1,8 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var sdkCommon = require('@paraspell/sdk-common');
3
+ var blake2 = require('@noble/hashes/blake2');
4
4
  var assets = require('@paraspell/assets');
5
+ var base = require('@scure/base');
5
6
  var ethers = require('ethers');
7
+ var sdkCommon = require('@paraspell/sdk-common');
6
8
  var pallets = require('@paraspell/pallets');
7
9
  var viem = require('viem');
8
10
 
@@ -569,6 +571,232 @@ function _wrapNativeSuper(t) {
569
571
  }, _wrapNativeSuper(t);
570
572
  }
571
573
 
574
+ /**
575
+ * Error thrown when the Ethereum bridge is halted.
576
+ */
577
+ var BridgeHaltedError = /*#__PURE__*/function (_Error) {
578
+ /**
579
+ * Constructs a new BridgeHaltedError.
580
+ *
581
+ * @param message - Optional custom error message.
582
+ */
583
+ function BridgeHaltedError() {
584
+ var _this;
585
+ _classCallCheck(this, BridgeHaltedError);
586
+ _this = _callSuper(this, BridgeHaltedError, ['Bridge operations have been paused by onchain governance.']);
587
+ _this.name = 'BridgeHaltedError';
588
+ return _this;
589
+ }
590
+ _inherits(BridgeHaltedError, _Error);
591
+ return _createClass(BridgeHaltedError);
592
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
593
+
594
+ /**
595
+ * Error thrown when the Dry Run fails.
596
+ */
597
+ var DryRunFailedError = /*#__PURE__*/function (_Error) {
598
+ /**
599
+ * Constructs a new DryRunFailedError.
600
+ *
601
+ * @param message - Optional custom error message.
602
+ */
603
+ function DryRunFailedError(reason) {
604
+ var _this;
605
+ _classCallCheck(this, DryRunFailedError);
606
+ _this = _callSuper(this, DryRunFailedError, ["Dry run failed: ".concat(reason)]);
607
+ _this.name = 'DryRunFailedError';
608
+ return _this;
609
+ }
610
+ _inherits(DryRunFailedError, _Error);
611
+ return _createClass(DryRunFailedError);
612
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
613
+
614
+ /**
615
+ * Error thrown when nodes from different relay chains are incompatible.
616
+ */
617
+ var IncompatibleNodesError = /*#__PURE__*/function (_Error) {
618
+ /**
619
+ * Constructs a new IncompatibleNodesError.
620
+ *
621
+ * @param message - Optional custom error message.
622
+ */
623
+ function IncompatibleNodesError(message) {
624
+ var _this;
625
+ _classCallCheck(this, IncompatibleNodesError);
626
+ _this = _callSuper(this, IncompatibleNodesError, [message !== null && message !== void 0 ? message : 'Transactions between nodes on different relaychains are not yet possible.']);
627
+ _this.name = 'IncompatibleNodes';
628
+ return _this;
629
+ }
630
+ _inherits(IncompatibleNodesError, _Error);
631
+ return _createClass(IncompatibleNodesError);
632
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
633
+
634
+ /**
635
+ * Error thrown when an invalid address is provided.
636
+ */
637
+ var InvalidAddressError = /*#__PURE__*/function (_Error) {
638
+ /**
639
+ * Constructs a new InvalidAddressError.
640
+ *
641
+ * @param message - The error message.
642
+ */
643
+ function InvalidAddressError(message) {
644
+ var _this;
645
+ _classCallCheck(this, InvalidAddressError);
646
+ _this = _callSuper(this, InvalidAddressError, [message]);
647
+ _this.name = 'InvalidAddressError';
648
+ return _this;
649
+ }
650
+ _inherits(InvalidAddressError, _Error);
651
+ return _createClass(InvalidAddressError);
652
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
653
+
654
+ /**
655
+ * Error thrown when the Dry Run fails.
656
+ */
657
+ var InvalidParameterError = /*#__PURE__*/function (_Error) {
658
+ /**
659
+ * Constructs a new InvalidParameterError.
660
+ *
661
+ * @param message - Required error message.
662
+ */
663
+ function InvalidParameterError(message) {
664
+ var _this;
665
+ _classCallCheck(this, InvalidParameterError);
666
+ _this = _callSuper(this, InvalidParameterError, [message]);
667
+ _this.name = 'InvalidParameterError';
668
+ return _this;
669
+ }
670
+ _inherits(InvalidParameterError, _Error);
671
+ return _createClass(InvalidParameterError);
672
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
673
+
674
+ /**
675
+ * Used to inform user, that Parachain they wish to use is not supported yet
676
+ */
677
+ var NodeNotSupportedError = /*#__PURE__*/function (_Error) {
678
+ /**
679
+ * Constructs a new NodeNotSupportedError.
680
+ *
681
+ * @param message - Optional custom error message.
682
+ */
683
+ function NodeNotSupportedError(message) {
684
+ var _this;
685
+ _classCallCheck(this, NodeNotSupportedError);
686
+ _this = _callSuper(this, NodeNotSupportedError, [message !== null && message !== void 0 ? message : 'These nodes do not support XCM transfers from Relay / to Relay chain.']);
687
+ _this.name = 'NodeNotSupported';
688
+ return _this;
689
+ }
690
+ _inherits(NodeNotSupportedError, _Error);
691
+ return _createClass(NodeNotSupportedError);
692
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
693
+
694
+ /**
695
+ * Used to inform user, that Parachain they wish to use has not yet implemented full XCM Support
696
+ */
697
+ var NoXCMSupportImplementedError = /*#__PURE__*/function (_Error) {
698
+ /**
699
+ * Constructs a new NoXCMSupportImplementedError.
700
+ *
701
+ * @param node - The node for which XCM support is not implemented.
702
+ */
703
+ function NoXCMSupportImplementedError(node) {
704
+ var _this;
705
+ _classCallCheck(this, NoXCMSupportImplementedError);
706
+ _this = _callSuper(this, NoXCMSupportImplementedError, ["No XCM support implemented for ".concat(node, " node yet.")]);
707
+ _this.name = 'NoXCMSupportImplemented';
708
+ return _this;
709
+ }
710
+ _inherits(NoXCMSupportImplementedError, _Error);
711
+ return _createClass(NoXCMSupportImplementedError);
712
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
713
+
714
+ /**
715
+ * Used to inform user, that Parachain they wish to use does not support scenario they wish to use yet
716
+ */
717
+ var ScenarioNotSupportedError = /*#__PURE__*/function (_Error) {
718
+ /**
719
+ * Constructs a new ScenarioNotSupportedError.
720
+ *
721
+ * @param node - The node where the scenario is not supported.
722
+ * @param scenario - The scenario that is not supported.
723
+ * @param message - Optional custom error message.
724
+ */
725
+ function ScenarioNotSupportedError(node, scenario, message) {
726
+ var _this;
727
+ _classCallCheck(this, ScenarioNotSupportedError);
728
+ _this = _callSuper(this, ScenarioNotSupportedError, [message !== null && message !== void 0 ? message : "Scenario ".concat(scenario, " not supported for node ").concat(node)]);
729
+ _this.name = 'ScenarioNotSupported';
730
+ return _this;
731
+ }
732
+ _inherits(ScenarioNotSupportedError, _Error);
733
+ return _createClass(ScenarioNotSupportedError);
734
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
735
+
736
+ // Inspired by Talisman Society’s SS58 encoder:
737
+ // https://github.com/TalismanSociety/talisman/blob/dev/packages/crypto/src/address/encoding/ss58.ts
738
+ var blake2b256 = function blake2b256(msg) {
739
+ return blake2.blake2b(msg, {
740
+ dkLen: 32
741
+ });
742
+ };
743
+ var blake2b512 = function blake2b512(msg) {
744
+ return blake2.blake2b(msg, {
745
+ dkLen: 64
746
+ });
747
+ };
748
+ var ALLOWED_PUBKEY_BYTES = new Set([32, 33]);
749
+ var deriveAccountId = function deriveAccountId(raw) {
750
+ if (!ALLOWED_PUBKEY_BYTES.has(raw.length)) {
751
+ throw new Error('public key length is invalid');
752
+ }
753
+ return raw.length === 33 ? blake2b256(raw) : raw;
754
+ };
755
+ var SS58_HARD_PREFIX = new TextEncoder().encode('SS58PRE');
756
+ var CHECKSUM_BYTES = 2;
757
+ var VALID_ADDR_PAYLOAD = new Set([32, 33]);
758
+ var networkToBytes = function networkToBytes(net) {
759
+ if (net < 64) {
760
+ return Uint8Array.of(net);
761
+ }
762
+ // Two-byte form: see https://docs.substrate.io/reference/address-formats/
763
+ var first = net >> 2 & 63 | 64;
764
+ var second = net >> 8 & 0xff | (net & 3) << 6;
765
+ return Uint8Array.of(first, second);
766
+ };
767
+ var encodeSs58 = function encodeSs58(payload, network) {
768
+ if (!VALID_ADDR_PAYLOAD.has(payload.length)) {
769
+ throw new Error('unexpected payload length for SS58 address');
770
+ }
771
+ var netBytes = networkToBytes(network);
772
+ var chkInput = new Uint8Array(SS58_HARD_PREFIX.length + netBytes.length + payload.length);
773
+ chkInput.set(SS58_HARD_PREFIX, 0);
774
+ chkInput.set(netBytes, SS58_HARD_PREFIX.length);
775
+ chkInput.set(payload, SS58_HARD_PREFIX.length + netBytes.length);
776
+ var checksum = blake2b512(chkInput).subarray(0, CHECKSUM_BYTES);
777
+ var addressBytes = new Uint8Array(netBytes.length + payload.length + CHECKSUM_BYTES);
778
+ addressBytes.set(netBytes, 0);
779
+ addressBytes.set(payload, netBytes.length);
780
+ addressBytes.set(checksum, netBytes.length + payload.length);
781
+ return base.base58.encode(addressBytes);
782
+ };
783
+ var convertSs58 = function convertSs58(api, address, node) {
784
+ var isEvmAddress = ethers.ethers.isAddress(address);
785
+ if (isEvmAddress && assets.isNodeEvm(node)) {
786
+ return address;
787
+ }
788
+ if (isEvmAddress) {
789
+ throw new InvalidParameterError("Cannot convert EVM address to SS58.");
790
+ }
791
+ if (assets.isNodeEvm(node)) {
792
+ throw new InvalidParameterError("Cannot convert SS58 address to EVM.");
793
+ }
794
+ var _getAssetsObject = assets.getAssetsObject(node),
795
+ ss58Prefix = _getAssetsObject.ss58Prefix;
796
+ var publicKey = api.accountToUint8a(address);
797
+ return encodeSs58(deriveAccountId(publicKey), ss58Prefix);
798
+ };
799
+
572
800
  var DEFAULT_FEE_ASSET = 0;
573
801
  var ETH_PARA_ID = 1;
574
802
  var ETH_CHAIN_ID = BigInt(ETH_PARA_ID);
@@ -842,14 +1070,14 @@ var Centrifuge$1 = {
842
1070
  info: "centrifuge",
843
1071
  paraId: 2031,
844
1072
  providers: [
845
- {
846
- name: "LuckyFriday",
847
- endpoint: "wss://rpc-centrifuge.luckyfriday.io"
848
- },
849
1073
  {
850
1074
  name: "Centrifuge",
851
1075
  endpoint: "wss://fullnode.centrifuge.io"
852
1076
  },
1077
+ {
1078
+ name: "LuckyFriday",
1079
+ endpoint: "wss://rpc-centrifuge.luckyfriday.io"
1080
+ },
853
1081
  {
854
1082
  name: "OnFinality",
855
1083
  endpoint: "wss://centrifuge-parachain.api.onfinality.io/public-ws"
@@ -944,14 +1172,6 @@ var Moonbeam$1 = {
944
1172
  info: "moonbeam",
945
1173
  paraId: 2004,
946
1174
  providers: [
947
- {
948
- name: "IBP1",
949
- endpoint: "wss://moonbeam.ibp.network"
950
- },
951
- {
952
- name: "RadiumBlock",
953
- endpoint: "wss://moonbeam.public.curie.radiumblock.co/ws"
954
- },
955
1175
  {
956
1176
  name: "Allnodes",
957
1177
  endpoint: "wss://moonbeam-rpc.publicnode.com"
@@ -960,6 +1180,14 @@ var Moonbeam$1 = {
960
1180
  name: "Blast",
961
1181
  endpoint: "wss://moonbeam.public.blastapi.io"
962
1182
  },
1183
+ {
1184
+ name: "Dwellir",
1185
+ endpoint: "wss://moonbeam-rpc.n.dwellir.com"
1186
+ },
1187
+ {
1188
+ name: "IBP1",
1189
+ endpoint: "wss://moonbeam.ibp.network"
1190
+ },
963
1191
  {
964
1192
  name: "IBP2",
965
1193
  endpoint: "wss://moonbeam.dotters.network"
@@ -972,6 +1200,10 @@ var Moonbeam$1 = {
972
1200
  name: "OnFinality",
973
1201
  endpoint: "wss://moonbeam.api.onfinality.io/public-ws"
974
1202
  },
1203
+ {
1204
+ name: "RadiumBlock",
1205
+ endpoint: "wss://moonbeam.public.curie.radiumblock.co/ws"
1206
+ },
975
1207
  {
976
1208
  name: "UnitedBloc",
977
1209
  endpoint: "wss://moonbeam.unitedbloc.com"
@@ -1455,10 +1687,6 @@ var Unique$1 = {
1455
1687
  info: "unique",
1456
1688
  paraId: 2037,
1457
1689
  providers: [
1458
- {
1459
- name: "Dwellir",
1460
- endpoint: "wss://unique-rpc.n.dwellir.com"
1461
- },
1462
1690
  {
1463
1691
  name: "Geo Load Balancer",
1464
1692
  endpoint: "wss://ws.unique.network"
@@ -2486,168 +2714,6 @@ var resolveParaId = function resolveParaId(paraId, destination) {
2486
2714
  return paraId !== null && paraId !== void 0 ? paraId : getParaId(destination);
2487
2715
  };
2488
2716
 
2489
- /**
2490
- * Error thrown when the Ethereum bridge is halted.
2491
- */
2492
- var BridgeHaltedError = /*#__PURE__*/function (_Error) {
2493
- /**
2494
- * Constructs a new BridgeHaltedError.
2495
- *
2496
- * @param message - Optional custom error message.
2497
- */
2498
- function BridgeHaltedError() {
2499
- var _this;
2500
- _classCallCheck(this, BridgeHaltedError);
2501
- _this = _callSuper(this, BridgeHaltedError, ['Bridge operations have been paused by onchain governance.']);
2502
- _this.name = 'BridgeHaltedError';
2503
- return _this;
2504
- }
2505
- _inherits(BridgeHaltedError, _Error);
2506
- return _createClass(BridgeHaltedError);
2507
- }(/*#__PURE__*/_wrapNativeSuper(Error));
2508
-
2509
- /**
2510
- * Error thrown when the Dry Run fails.
2511
- */
2512
- var DryRunFailedError = /*#__PURE__*/function (_Error) {
2513
- /**
2514
- * Constructs a new DryRunFailedError.
2515
- *
2516
- * @param message - Optional custom error message.
2517
- */
2518
- function DryRunFailedError(reason) {
2519
- var _this;
2520
- _classCallCheck(this, DryRunFailedError);
2521
- _this = _callSuper(this, DryRunFailedError, ["Dry run failed: ".concat(reason)]);
2522
- _this.name = 'DryRunFailedError';
2523
- return _this;
2524
- }
2525
- _inherits(DryRunFailedError, _Error);
2526
- return _createClass(DryRunFailedError);
2527
- }(/*#__PURE__*/_wrapNativeSuper(Error));
2528
-
2529
- /**
2530
- * Error thrown when nodes from different relay chains are incompatible.
2531
- */
2532
- var IncompatibleNodesError = /*#__PURE__*/function (_Error) {
2533
- /**
2534
- * Constructs a new IncompatibleNodesError.
2535
- *
2536
- * @param message - Optional custom error message.
2537
- */
2538
- function IncompatibleNodesError(message) {
2539
- var _this;
2540
- _classCallCheck(this, IncompatibleNodesError);
2541
- _this = _callSuper(this, IncompatibleNodesError, [message !== null && message !== void 0 ? message : 'Transactions between nodes on different relaychains are not yet possible.']);
2542
- _this.name = 'IncompatibleNodes';
2543
- return _this;
2544
- }
2545
- _inherits(IncompatibleNodesError, _Error);
2546
- return _createClass(IncompatibleNodesError);
2547
- }(/*#__PURE__*/_wrapNativeSuper(Error));
2548
-
2549
- /**
2550
- * Error thrown when an invalid address is provided.
2551
- */
2552
- var InvalidAddressError = /*#__PURE__*/function (_Error) {
2553
- /**
2554
- * Constructs a new InvalidAddressError.
2555
- *
2556
- * @param message - The error message.
2557
- */
2558
- function InvalidAddressError(message) {
2559
- var _this;
2560
- _classCallCheck(this, InvalidAddressError);
2561
- _this = _callSuper(this, InvalidAddressError, [message]);
2562
- _this.name = 'InvalidAddressError';
2563
- return _this;
2564
- }
2565
- _inherits(InvalidAddressError, _Error);
2566
- return _createClass(InvalidAddressError);
2567
- }(/*#__PURE__*/_wrapNativeSuper(Error));
2568
-
2569
- /**
2570
- * Error thrown when the Dry Run fails.
2571
- */
2572
- var InvalidParameterError = /*#__PURE__*/function (_Error) {
2573
- /**
2574
- * Constructs a new InvalidParameterError.
2575
- *
2576
- * @param message - Required error message.
2577
- */
2578
- function InvalidParameterError(message) {
2579
- var _this;
2580
- _classCallCheck(this, InvalidParameterError);
2581
- _this = _callSuper(this, InvalidParameterError, [message]);
2582
- _this.name = 'InvalidParameterError';
2583
- return _this;
2584
- }
2585
- _inherits(InvalidParameterError, _Error);
2586
- return _createClass(InvalidParameterError);
2587
- }(/*#__PURE__*/_wrapNativeSuper(Error));
2588
-
2589
- /**
2590
- * Used to inform user, that Parachain they wish to use is not supported yet
2591
- */
2592
- var NodeNotSupportedError = /*#__PURE__*/function (_Error) {
2593
- /**
2594
- * Constructs a new NodeNotSupportedError.
2595
- *
2596
- * @param message - Optional custom error message.
2597
- */
2598
- function NodeNotSupportedError(message) {
2599
- var _this;
2600
- _classCallCheck(this, NodeNotSupportedError);
2601
- _this = _callSuper(this, NodeNotSupportedError, [message !== null && message !== void 0 ? message : 'These nodes do not support XCM transfers from Relay / to Relay chain.']);
2602
- _this.name = 'NodeNotSupported';
2603
- return _this;
2604
- }
2605
- _inherits(NodeNotSupportedError, _Error);
2606
- return _createClass(NodeNotSupportedError);
2607
- }(/*#__PURE__*/_wrapNativeSuper(Error));
2608
-
2609
- /**
2610
- * Used to inform user, that Parachain they wish to use has not yet implemented full XCM Support
2611
- */
2612
- var NoXCMSupportImplementedError = /*#__PURE__*/function (_Error) {
2613
- /**
2614
- * Constructs a new NoXCMSupportImplementedError.
2615
- *
2616
- * @param node - The node for which XCM support is not implemented.
2617
- */
2618
- function NoXCMSupportImplementedError(node) {
2619
- var _this;
2620
- _classCallCheck(this, NoXCMSupportImplementedError);
2621
- _this = _callSuper(this, NoXCMSupportImplementedError, ["No XCM support implemented for ".concat(node, " node yet.")]);
2622
- _this.name = 'NoXCMSupportImplemented';
2623
- return _this;
2624
- }
2625
- _inherits(NoXCMSupportImplementedError, _Error);
2626
- return _createClass(NoXCMSupportImplementedError);
2627
- }(/*#__PURE__*/_wrapNativeSuper(Error));
2628
-
2629
- /**
2630
- * Used to inform user, that Parachain they wish to use does not support scenario they wish to use yet
2631
- */
2632
- var ScenarioNotSupportedError = /*#__PURE__*/function (_Error) {
2633
- /**
2634
- * Constructs a new ScenarioNotSupportedError.
2635
- *
2636
- * @param node - The node where the scenario is not supported.
2637
- * @param scenario - The scenario that is not supported.
2638
- * @param message - Optional custom error message.
2639
- */
2640
- function ScenarioNotSupportedError(node, scenario, message) {
2641
- var _this;
2642
- _classCallCheck(this, ScenarioNotSupportedError);
2643
- _this = _callSuper(this, ScenarioNotSupportedError, [message !== null && message !== void 0 ? message : "Scenario ".concat(scenario, " not supported for node ").concat(node)]);
2644
- _this.name = 'ScenarioNotSupported';
2645
- return _this;
2646
- }
2647
- _inherits(ScenarioNotSupportedError, _Error);
2648
- return _createClass(ScenarioNotSupportedError);
2649
- }(/*#__PURE__*/_wrapNativeSuper(Error));
2650
-
2651
2717
  var validateAddress = function validateAddress(address, node) {
2652
2718
  var isDestination = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
2653
2719
  var isEvm = assets.isNodeEvm(node);
@@ -9103,16 +9169,16 @@ var getAssetBalance = /*#__PURE__*/function () {
9103
9169
  var getOriginFeeDetailsInternal = /*#__PURE__*/function () {
9104
9170
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
9105
9171
  var _getExistentialDeposi;
9106
- var api, account, accountDestination, currency, origin, destination, _ref$feeMarginPercent, feeMarginPercentage, tx, xcmFee, xcmFeeWithMargin, nativeBalance, existentialDeposit, sufficientForXCM;
9172
+ var api, account, accountDestination, ahAddress, currency, origin, destination, _ref$feeMarginPercent, feeMarginPercentage, tx, xcmFee, xcmFeeWithMargin, nativeBalance, existentialDeposit, sufficientForXCM;
9107
9173
  return _regeneratorRuntime().wrap(function _callee$(_context) {
9108
9174
  while (1) switch (_context.prev = _context.next) {
9109
9175
  case 0:
9110
- 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 === void 0 ? 10 : _ref$feeMarginPercent;
9176
+ api = _ref.api, account = _ref.account, accountDestination = _ref.accountDestination, ahAddress = _ref.ahAddress, currency = _ref.currency, origin = _ref.origin, destination = _ref.destination, _ref$feeMarginPercent = _ref.feeMarginPercentage, feeMarginPercentage = _ref$feeMarginPercent === void 0 ? 10 : _ref$feeMarginPercent;
9111
9177
  _context.next = 3;
9112
9178
  return api.init(origin);
9113
9179
  case 3:
9114
9180
  _context.next = 5;
9115
- return Builder(api).from(origin).to(destination).currency(currency).address(accountDestination).senderAddress(account).build();
9181
+ return Builder(api).from(origin).to(destination).currency(currency).address(accountDestination).senderAddress(account).ahAddress(ahAddress).build();
9116
9182
  case 5:
9117
9183
  tx = _context.sent;
9118
9184
  _context.next = 8;
@@ -9612,16 +9678,21 @@ exports.NoXCMSupportImplementedError = NoXCMSupportImplementedError;
9612
9678
  exports.NodeNotSupportedError = NodeNotSupportedError;
9613
9679
  exports.ScenarioNotSupportedError = ScenarioNotSupportedError;
9614
9680
  exports.TX_CLIENT_TIMEOUT_MS = TX_CLIENT_TIMEOUT_MS;
9681
+ exports.blake2b256 = blake2b256;
9682
+ exports.blake2b512 = blake2b512;
9615
9683
  exports.claimAssets = claimAssets;
9616
9684
  exports.computeFeeFromDryRun = computeFeeFromDryRun;
9617
9685
  exports.computeFeeFromDryRunPjs = computeFeeFromDryRunPjs;
9686
+ exports.convertSs58 = convertSs58;
9618
9687
  exports.createApiInstanceForNode = createApiInstanceForNode;
9619
9688
  exports.createBeneficiaryMultiLocation = createBeneficiaryMultiLocation;
9620
9689
  exports.createVersionedBeneficiary = createVersionedBeneficiary;
9621
9690
  exports.createX1Payload = createX1Payload;
9691
+ exports.deriveAccountId = deriveAccountId;
9622
9692
  exports.determineRelayChain = determineRelayChain;
9623
9693
  exports.dryRun = dryRun;
9624
9694
  exports.dryRunOrigin = dryRunOrigin;
9695
+ exports.encodeSs58 = encodeSs58;
9625
9696
  exports.generateAddressMultiLocationV4 = generateAddressMultiLocationV4;
9626
9697
  exports.getAssetBalance = getAssetBalance;
9627
9698
  exports.getAssetBalanceInternal = getAssetBalanceInternal;
@@ -9659,16 +9730,16 @@ exports.transferRelayToPara = transferRelayToPara;
9659
9730
  exports.transformMultiLocation = transformMultiLocation;
9660
9731
  exports.validateAddress = validateAddress;
9661
9732
  exports.verifyEdOnDestination = verifyEdOnDestination;
9662
- Object.keys(sdkCommon).forEach(function (k) {
9733
+ Object.keys(assets).forEach(function (k) {
9663
9734
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
9664
9735
  enumerable: true,
9665
- get: function () { return sdkCommon[k]; }
9736
+ get: function () { return assets[k]; }
9666
9737
  });
9667
9738
  });
9668
- Object.keys(assets).forEach(function (k) {
9739
+ Object.keys(sdkCommon).forEach(function (k) {
9669
9740
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
9670
9741
  enumerable: true,
9671
- get: function () { return assets[k]; }
9742
+ get: function () { return sdkCommon[k]; }
9672
9743
  });
9673
9744
  });
9674
9745
  Object.keys(pallets).forEach(function (k) {
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import * as _paraspell_assets from '@paraspell/assets';
2
- import { TMultiAsset, TCurrencyInputWithAmount, TCurrencyInput, WithAmount, TAsset, TMultiAssetWithFee, TCurrencyCore, TAmount } from '@paraspell/assets';
3
- export * from '@paraspell/assets';
4
1
  import * as _paraspell_sdk_common from '@paraspell/sdk-common';
5
2
  import { TMultiLocation, TNodeDotKsmWithRelayChains, TNodeWithRelayChains, TNodePolkadotKusama, TNode, TJunction, TEcosystemType, TJunctions } from '@paraspell/sdk-common';
6
3
  export * from '@paraspell/sdk-common';
4
+ import * as _paraspell_assets from '@paraspell/assets';
5
+ import { TMultiAsset, TCurrencyInputWithAmount, TCurrencyInput, WithAmount, TAsset, TMultiAssetWithFee, TCurrencyCore, TAmount } from '@paraspell/assets';
6
+ export * from '@paraspell/assets';
7
7
  import { TPallet } from '@paraspell/pallets';
8
8
  export * from '@paraspell/pallets';
9
9
  import { Signer, AbstractProvider, Contract } from 'ethers';
@@ -352,6 +352,10 @@ type TGetOriginFeeDetailsOptionsBase = {
352
352
  * The destination account.
353
353
  */
354
354
  accountDestination: string;
355
+ /**
356
+ * The address of the account.
357
+ */
358
+ ahAddress?: string;
355
359
  /**
356
360
  * The fee margin percentage.
357
361
  */
@@ -729,6 +733,7 @@ interface IPolkadotApi<TApi, TRes> {
729
733
  init(node: TNodeWithRelayChains, clientTtlMs?: number): Promise<void>;
730
734
  createApiInstance: (wsUrl: string | string[]) => Promise<TApi>;
731
735
  accountToHex(address: string, isPrefixed?: boolean): string;
736
+ accountToUint8a(address: string): Uint8Array;
732
737
  callTxMethod(serializedCall: TSerializedApiCall): TRes;
733
738
  callBatchMethod(calls: TRes[], mode: BatchMode): TRes;
734
739
  objectToHex(obj: unknown, typeName: string): Promise<string>;
@@ -757,6 +762,12 @@ interface IPolkadotApi<TApi, TRes> {
757
762
  disconnect(force?: boolean): Promise<void>;
758
763
  }
759
764
 
765
+ declare const blake2b256: (msg: Uint8Array) => Uint8Array<ArrayBufferLike>;
766
+ declare const blake2b512: (msg: Uint8Array) => Uint8Array<ArrayBufferLike>;
767
+ declare const deriveAccountId: (raw: Uint8Array) => Uint8Array;
768
+ declare const encodeSs58: (payload: Uint8Array, network: number) => string;
769
+ declare const convertSs58: <TApi, TRes>(api: IPolkadotApi<TApi, TRes>, address: string, node: TNodeDotKsmWithRelayChains) => string;
770
+
760
771
  /**
761
772
  * Builder class for constructing asset claim transactions.
762
773
  */
@@ -1659,7 +1670,7 @@ declare const getBalanceForeign: <TApi, TRes>(options: TGetBalanceForeignOptions
1659
1670
  declare const getBalanceNativeInternal: <TApi, TRes>({ address, node, api, currency }: TGetBalanceNativeOptions<TApi, TRes>) => Promise<bigint>;
1660
1671
  declare const getBalanceNative: <TApi, TRes>(options: TGetBalanceNativeOptions<TApi, TRes>) => Promise<bigint>;
1661
1672
 
1662
- declare const getOriginFeeDetailsInternal: <TApi, TRes>({ api, account, accountDestination, currency, origin, destination, feeMarginPercentage }: TGetOriginFeeDetailsOptions<TApi, TRes>) => Promise<TOriginFeeDetails>;
1673
+ declare const getOriginFeeDetailsInternal: <TApi, TRes>({ api, account, accountDestination, ahAddress, currency, origin, destination, feeMarginPercentage }: TGetOriginFeeDetailsOptions<TApi, TRes>) => Promise<TOriginFeeDetails>;
1663
1674
  declare const getOriginFeeDetails: <TApi, TRes>(options: TGetOriginFeeDetailsOptions<TApi, TRes>) => Promise<TOriginFeeDetails>;
1664
1675
 
1665
1676
  declare const getMaxNativeTransferableAmountInternal: <TApi, TRes>({ api, address, node, currency }: TGetMaxNativeTransferableAmountOptions<TApi, TRes>) => Promise<bigint>;
@@ -1743,5 +1754,5 @@ declare const validateAddress: (address: TAddress, node: TNodeWithRelayChains, i
1743
1754
  */
1744
1755
  declare const determineRelayChain: (node: TNodeWithRelayChains) => TRelaychain;
1745
1756
 
1746
- export { AssetClaimBuilder, BatchMode, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleNodesError, InvalidAddressError, InvalidParameterError, NoXCMSupportImplementedError, NodeNotSupportedError, PolkadotXcmError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, Version, XTokensError, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, createApiInstanceForNode, createBeneficiaryMultiLocation, createVersionedBeneficiary, createX1Payload, determineRelayChain, dryRun, dryRunOrigin, generateAddressMultiLocationV4, getAssetBalance, getAssetBalanceInternal, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getFees, getMaxForeignTransferableAmount, getMaxForeignTransferableAmountInternal, getMaxNativeTransferableAmount, getMaxNativeTransferableAmountInternal, getNode, getNodeConfig, getNodeProviders, getOriginFeeDetails, getOriginFeeDetailsInternal, getParaEthTransferFees, getParaId, getTNode, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, isEthersContract, isEthersSigner, resolveModuleError, resolveParaId, send, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, transformMultiLocation, validateAddress, verifyEdOnDestination };
1757
+ export { AssetClaimBuilder, BatchMode, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleNodesError, InvalidAddressError, InvalidParameterError, NoXCMSupportImplementedError, NodeNotSupportedError, PolkadotXcmError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, Version, XTokensError, blake2b256, blake2b512, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, convertSs58, createApiInstanceForNode, createBeneficiaryMultiLocation, createVersionedBeneficiary, createX1Payload, deriveAccountId, determineRelayChain, dryRun, dryRunOrigin, encodeSs58, generateAddressMultiLocationV4, getAssetBalance, getAssetBalanceInternal, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getFees, getMaxForeignTransferableAmount, getMaxForeignTransferableAmountInternal, getMaxNativeTransferableAmount, getMaxNativeTransferableAmountInternal, getNode, getNodeConfig, getNodeProviders, getOriginFeeDetails, getOriginFeeDetailsInternal, getParaEthTransferFees, getParaId, getTNode, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, isEthersContract, isEthersSigner, resolveModuleError, resolveParaId, send, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, transformMultiLocation, validateAddress, verifyEdOnDestination };
1747
1758
  export type { IPolkadotApi, IPolkadotXCMTransfer, IXTokensTransfer, IXTransferTransfer, OneKey, TAddress, TApiOrUrl, TAssetClaimOptions, TAssetClaimOptionsBase, TBalanceResponse, TBatchOptions, TBifrostToken, TBridgeStatus, TCreateBeneficiaryOptions, TDestWeight, TDestination, TDryRunBaseOptions, TDryRunCallBaseOptions, TDryRunCallOptions, TDryRunNodeFailure, TDryRunNodeResult, TDryRunNodeResultInternal, TDryRunNodeSuccess, TDryRunOptions, TDryRunResult, TDryRunXcmBaseOptions, TDryRunXcmOptions, TEdJsonMap, TEvmBuilderOptions, TEvmBuilderOptionsBase, TEvmNodeFrom, TFeeType, TForeignAssetId, TForeignOrNativeAsset, TForeignOrTokenAsset, TGetAssetBalanceOptions, TGetAssetBalanceOptionsBase, TGetBalanceForeignOptions, TGetBalanceForeignOptionsBase, TGetBalanceNativeOptions, TGetBalanceNativeOptionsBase, TGetFeeForDestNodeBaseOptions, TGetFeeForDestNodeOptions, TGetFeeForOriginNodeBaseOptions, TGetFeeForOriginNodeOptions, TGetMaxForeignTransferableAmountOptions, TGetMaxForeignTransferableAmountOptionsBase, TGetMaxNativeTransferableAmountOptions, TGetMaxNativeTransferableAmountOptionsBase, TGetOriginFeeDetailsOptions, TGetOriginFeeDetailsOptionsBase, TGetTransferInfoOptions, TGetTransferInfoOptionsBase, TGetTransferableAmountOptions, TGetTransferableAmountOptionsBase, TGetXcmFeeBaseOptions, TGetXcmFeeBuilderOptions, TGetXcmFeeEstimateDetail, TGetXcmFeeEstimateOptions, TGetXcmFeeEstimateResult, TGetXcmFeeOptions, TGetXcmFeeResult, THubKey, TMantaAsset, TModuleError, TNativeTokenAsset, TNodeConfig, TNodeConfigMap, TNodleAsset, TOriginFeeDetails, TOtherReserveAsset, TPolkadotXCMTransferOptions, TPolkadotXcmSection, TProviderEntry, TRelayToParaDestination, TRelayToParaOptions, TRelayToParaOverrides, TRelaychain, TReserveAsset, TScenario, TSelfReserveAsset, TSendBaseOptions, TSendBaseOptionsWithSenderAddress, TSendInternalOptions, TSendOptions, TSerializeEthTransferOptions, TSerializedApiCall, TSerializedEthTransfer, TTransferInfo, TTransferLocalOptions, TVerifyEdOnDestinationOptions, TVerifyEdOnDestinationOptionsBase, TVersionClaimAssets, TWeight, TXTokensCurrencySelection, TXTokensSection, TXTokensTransferOptions, TXTransferSection, TXTransferTransferOptions, TXcmAsset, TXcmFeeDetail, TXcmForeignAsset, TXcmPalletSection, TXcmVersioned, TZeitgeistAsset, WithApi };
package/dist/index.mjs CHANGED
@@ -1,8 +1,10 @@
1
- import { Parents, isTMultiLocation, NODE_NAMES_DOT_KSM, isRelayChain, deepEqual, hasJunction } from '@paraspell/sdk-common';
2
- export * from '@paraspell/sdk-common';
3
- import { InvalidCurrencyError, getNativeAssetSymbol, getOtherAssets, isNodeEvm, getRelayChainSymbol, isForeignAsset, hasDryRunSupport, findAsset, getAssetsObject, isOverrideMultiLocationSpecifier, findAssetByMultiLocation, isTMultiAsset, isSymbolSpecifier, getNativeAssets, hasSupportForAsset, extractMultiAssetLoc, isAssetEqual, getAssetId, getExistentialDeposit } from '@paraspell/assets';
1
+ import { blake2b } from '@noble/hashes/blake2';
2
+ import { isNodeEvm, getAssetsObject, InvalidCurrencyError, getNativeAssetSymbol, getOtherAssets, getRelayChainSymbol, isForeignAsset, hasDryRunSupport, findAsset, isOverrideMultiLocationSpecifier, findAssetByMultiLocation, isTMultiAsset, isSymbolSpecifier, getNativeAssets, hasSupportForAsset, extractMultiAssetLoc, isAssetEqual, getAssetId, getExistentialDeposit } from '@paraspell/assets';
4
3
  export * from '@paraspell/assets';
4
+ import { base58 } from '@scure/base';
5
5
  import { ethers, Contract } from 'ethers';
6
+ import { Parents, isTMultiLocation, NODE_NAMES_DOT_KSM, isRelayChain, deepEqual, hasJunction } from '@paraspell/sdk-common';
7
+ export * from '@paraspell/sdk-common';
6
8
  import { getSupportedPalletsDetails, getDefaultPallet } from '@paraspell/pallets';
7
9
  export * from '@paraspell/pallets';
8
10
  import { getContract, createPublicClient, http } from 'viem';
@@ -570,6 +572,232 @@ function _wrapNativeSuper(t) {
570
572
  }, _wrapNativeSuper(t);
571
573
  }
572
574
 
575
+ /**
576
+ * Error thrown when the Ethereum bridge is halted.
577
+ */
578
+ var BridgeHaltedError = /*#__PURE__*/function (_Error) {
579
+ /**
580
+ * Constructs a new BridgeHaltedError.
581
+ *
582
+ * @param message - Optional custom error message.
583
+ */
584
+ function BridgeHaltedError() {
585
+ var _this;
586
+ _classCallCheck(this, BridgeHaltedError);
587
+ _this = _callSuper(this, BridgeHaltedError, ['Bridge operations have been paused by onchain governance.']);
588
+ _this.name = 'BridgeHaltedError';
589
+ return _this;
590
+ }
591
+ _inherits(BridgeHaltedError, _Error);
592
+ return _createClass(BridgeHaltedError);
593
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
594
+
595
+ /**
596
+ * Error thrown when the Dry Run fails.
597
+ */
598
+ var DryRunFailedError = /*#__PURE__*/function (_Error) {
599
+ /**
600
+ * Constructs a new DryRunFailedError.
601
+ *
602
+ * @param message - Optional custom error message.
603
+ */
604
+ function DryRunFailedError(reason) {
605
+ var _this;
606
+ _classCallCheck(this, DryRunFailedError);
607
+ _this = _callSuper(this, DryRunFailedError, ["Dry run failed: ".concat(reason)]);
608
+ _this.name = 'DryRunFailedError';
609
+ return _this;
610
+ }
611
+ _inherits(DryRunFailedError, _Error);
612
+ return _createClass(DryRunFailedError);
613
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
614
+
615
+ /**
616
+ * Error thrown when nodes from different relay chains are incompatible.
617
+ */
618
+ var IncompatibleNodesError = /*#__PURE__*/function (_Error) {
619
+ /**
620
+ * Constructs a new IncompatibleNodesError.
621
+ *
622
+ * @param message - Optional custom error message.
623
+ */
624
+ function IncompatibleNodesError(message) {
625
+ var _this;
626
+ _classCallCheck(this, IncompatibleNodesError);
627
+ _this = _callSuper(this, IncompatibleNodesError, [message !== null && message !== void 0 ? message : 'Transactions between nodes on different relaychains are not yet possible.']);
628
+ _this.name = 'IncompatibleNodes';
629
+ return _this;
630
+ }
631
+ _inherits(IncompatibleNodesError, _Error);
632
+ return _createClass(IncompatibleNodesError);
633
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
634
+
635
+ /**
636
+ * Error thrown when an invalid address is provided.
637
+ */
638
+ var InvalidAddressError = /*#__PURE__*/function (_Error) {
639
+ /**
640
+ * Constructs a new InvalidAddressError.
641
+ *
642
+ * @param message - The error message.
643
+ */
644
+ function InvalidAddressError(message) {
645
+ var _this;
646
+ _classCallCheck(this, InvalidAddressError);
647
+ _this = _callSuper(this, InvalidAddressError, [message]);
648
+ _this.name = 'InvalidAddressError';
649
+ return _this;
650
+ }
651
+ _inherits(InvalidAddressError, _Error);
652
+ return _createClass(InvalidAddressError);
653
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
654
+
655
+ /**
656
+ * Error thrown when the Dry Run fails.
657
+ */
658
+ var InvalidParameterError = /*#__PURE__*/function (_Error) {
659
+ /**
660
+ * Constructs a new InvalidParameterError.
661
+ *
662
+ * @param message - Required error message.
663
+ */
664
+ function InvalidParameterError(message) {
665
+ var _this;
666
+ _classCallCheck(this, InvalidParameterError);
667
+ _this = _callSuper(this, InvalidParameterError, [message]);
668
+ _this.name = 'InvalidParameterError';
669
+ return _this;
670
+ }
671
+ _inherits(InvalidParameterError, _Error);
672
+ return _createClass(InvalidParameterError);
673
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
674
+
675
+ /**
676
+ * Used to inform user, that Parachain they wish to use is not supported yet
677
+ */
678
+ var NodeNotSupportedError = /*#__PURE__*/function (_Error) {
679
+ /**
680
+ * Constructs a new NodeNotSupportedError.
681
+ *
682
+ * @param message - Optional custom error message.
683
+ */
684
+ function NodeNotSupportedError(message) {
685
+ var _this;
686
+ _classCallCheck(this, NodeNotSupportedError);
687
+ _this = _callSuper(this, NodeNotSupportedError, [message !== null && message !== void 0 ? message : 'These nodes do not support XCM transfers from Relay / to Relay chain.']);
688
+ _this.name = 'NodeNotSupported';
689
+ return _this;
690
+ }
691
+ _inherits(NodeNotSupportedError, _Error);
692
+ return _createClass(NodeNotSupportedError);
693
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
694
+
695
+ /**
696
+ * Used to inform user, that Parachain they wish to use has not yet implemented full XCM Support
697
+ */
698
+ var NoXCMSupportImplementedError = /*#__PURE__*/function (_Error) {
699
+ /**
700
+ * Constructs a new NoXCMSupportImplementedError.
701
+ *
702
+ * @param node - The node for which XCM support is not implemented.
703
+ */
704
+ function NoXCMSupportImplementedError(node) {
705
+ var _this;
706
+ _classCallCheck(this, NoXCMSupportImplementedError);
707
+ _this = _callSuper(this, NoXCMSupportImplementedError, ["No XCM support implemented for ".concat(node, " node yet.")]);
708
+ _this.name = 'NoXCMSupportImplemented';
709
+ return _this;
710
+ }
711
+ _inherits(NoXCMSupportImplementedError, _Error);
712
+ return _createClass(NoXCMSupportImplementedError);
713
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
714
+
715
+ /**
716
+ * Used to inform user, that Parachain they wish to use does not support scenario they wish to use yet
717
+ */
718
+ var ScenarioNotSupportedError = /*#__PURE__*/function (_Error) {
719
+ /**
720
+ * Constructs a new ScenarioNotSupportedError.
721
+ *
722
+ * @param node - The node where the scenario is not supported.
723
+ * @param scenario - The scenario that is not supported.
724
+ * @param message - Optional custom error message.
725
+ */
726
+ function ScenarioNotSupportedError(node, scenario, message) {
727
+ var _this;
728
+ _classCallCheck(this, ScenarioNotSupportedError);
729
+ _this = _callSuper(this, ScenarioNotSupportedError, [message !== null && message !== void 0 ? message : "Scenario ".concat(scenario, " not supported for node ").concat(node)]);
730
+ _this.name = 'ScenarioNotSupported';
731
+ return _this;
732
+ }
733
+ _inherits(ScenarioNotSupportedError, _Error);
734
+ return _createClass(ScenarioNotSupportedError);
735
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
736
+
737
+ // Inspired by Talisman Society’s SS58 encoder:
738
+ // https://github.com/TalismanSociety/talisman/blob/dev/packages/crypto/src/address/encoding/ss58.ts
739
+ var blake2b256 = function blake2b256(msg) {
740
+ return blake2b(msg, {
741
+ dkLen: 32
742
+ });
743
+ };
744
+ var blake2b512 = function blake2b512(msg) {
745
+ return blake2b(msg, {
746
+ dkLen: 64
747
+ });
748
+ };
749
+ var ALLOWED_PUBKEY_BYTES = new Set([32, 33]);
750
+ var deriveAccountId = function deriveAccountId(raw) {
751
+ if (!ALLOWED_PUBKEY_BYTES.has(raw.length)) {
752
+ throw new Error('public key length is invalid');
753
+ }
754
+ return raw.length === 33 ? blake2b256(raw) : raw;
755
+ };
756
+ var SS58_HARD_PREFIX = new TextEncoder().encode('SS58PRE');
757
+ var CHECKSUM_BYTES = 2;
758
+ var VALID_ADDR_PAYLOAD = new Set([32, 33]);
759
+ var networkToBytes = function networkToBytes(net) {
760
+ if (net < 64) {
761
+ return Uint8Array.of(net);
762
+ }
763
+ // Two-byte form: see https://docs.substrate.io/reference/address-formats/
764
+ var first = net >> 2 & 63 | 64;
765
+ var second = net >> 8 & 0xff | (net & 3) << 6;
766
+ return Uint8Array.of(first, second);
767
+ };
768
+ var encodeSs58 = function encodeSs58(payload, network) {
769
+ if (!VALID_ADDR_PAYLOAD.has(payload.length)) {
770
+ throw new Error('unexpected payload length for SS58 address');
771
+ }
772
+ var netBytes = networkToBytes(network);
773
+ var chkInput = new Uint8Array(SS58_HARD_PREFIX.length + netBytes.length + payload.length);
774
+ chkInput.set(SS58_HARD_PREFIX, 0);
775
+ chkInput.set(netBytes, SS58_HARD_PREFIX.length);
776
+ chkInput.set(payload, SS58_HARD_PREFIX.length + netBytes.length);
777
+ var checksum = blake2b512(chkInput).subarray(0, CHECKSUM_BYTES);
778
+ var addressBytes = new Uint8Array(netBytes.length + payload.length + CHECKSUM_BYTES);
779
+ addressBytes.set(netBytes, 0);
780
+ addressBytes.set(payload, netBytes.length);
781
+ addressBytes.set(checksum, netBytes.length + payload.length);
782
+ return base58.encode(addressBytes);
783
+ };
784
+ var convertSs58 = function convertSs58(api, address, node) {
785
+ var isEvmAddress = ethers.isAddress(address);
786
+ if (isEvmAddress && isNodeEvm(node)) {
787
+ return address;
788
+ }
789
+ if (isEvmAddress) {
790
+ throw new InvalidParameterError("Cannot convert EVM address to SS58.");
791
+ }
792
+ if (isNodeEvm(node)) {
793
+ throw new InvalidParameterError("Cannot convert SS58 address to EVM.");
794
+ }
795
+ var _getAssetsObject = getAssetsObject(node),
796
+ ss58Prefix = _getAssetsObject.ss58Prefix;
797
+ var publicKey = api.accountToUint8a(address);
798
+ return encodeSs58(deriveAccountId(publicKey), ss58Prefix);
799
+ };
800
+
573
801
  var DEFAULT_FEE_ASSET = 0;
574
802
  var ETH_PARA_ID = 1;
575
803
  var ETH_CHAIN_ID = BigInt(ETH_PARA_ID);
@@ -843,14 +1071,14 @@ var Centrifuge$1 = {
843
1071
  info: "centrifuge",
844
1072
  paraId: 2031,
845
1073
  providers: [
846
- {
847
- name: "LuckyFriday",
848
- endpoint: "wss://rpc-centrifuge.luckyfriday.io"
849
- },
850
1074
  {
851
1075
  name: "Centrifuge",
852
1076
  endpoint: "wss://fullnode.centrifuge.io"
853
1077
  },
1078
+ {
1079
+ name: "LuckyFriday",
1080
+ endpoint: "wss://rpc-centrifuge.luckyfriday.io"
1081
+ },
854
1082
  {
855
1083
  name: "OnFinality",
856
1084
  endpoint: "wss://centrifuge-parachain.api.onfinality.io/public-ws"
@@ -945,14 +1173,6 @@ var Moonbeam$1 = {
945
1173
  info: "moonbeam",
946
1174
  paraId: 2004,
947
1175
  providers: [
948
- {
949
- name: "IBP1",
950
- endpoint: "wss://moonbeam.ibp.network"
951
- },
952
- {
953
- name: "RadiumBlock",
954
- endpoint: "wss://moonbeam.public.curie.radiumblock.co/ws"
955
- },
956
1176
  {
957
1177
  name: "Allnodes",
958
1178
  endpoint: "wss://moonbeam-rpc.publicnode.com"
@@ -961,6 +1181,14 @@ var Moonbeam$1 = {
961
1181
  name: "Blast",
962
1182
  endpoint: "wss://moonbeam.public.blastapi.io"
963
1183
  },
1184
+ {
1185
+ name: "Dwellir",
1186
+ endpoint: "wss://moonbeam-rpc.n.dwellir.com"
1187
+ },
1188
+ {
1189
+ name: "IBP1",
1190
+ endpoint: "wss://moonbeam.ibp.network"
1191
+ },
964
1192
  {
965
1193
  name: "IBP2",
966
1194
  endpoint: "wss://moonbeam.dotters.network"
@@ -973,6 +1201,10 @@ var Moonbeam$1 = {
973
1201
  name: "OnFinality",
974
1202
  endpoint: "wss://moonbeam.api.onfinality.io/public-ws"
975
1203
  },
1204
+ {
1205
+ name: "RadiumBlock",
1206
+ endpoint: "wss://moonbeam.public.curie.radiumblock.co/ws"
1207
+ },
976
1208
  {
977
1209
  name: "UnitedBloc",
978
1210
  endpoint: "wss://moonbeam.unitedbloc.com"
@@ -1456,10 +1688,6 @@ var Unique$1 = {
1456
1688
  info: "unique",
1457
1689
  paraId: 2037,
1458
1690
  providers: [
1459
- {
1460
- name: "Dwellir",
1461
- endpoint: "wss://unique-rpc.n.dwellir.com"
1462
- },
1463
1691
  {
1464
1692
  name: "Geo Load Balancer",
1465
1693
  endpoint: "wss://ws.unique.network"
@@ -2487,168 +2715,6 @@ var resolveParaId = function resolveParaId(paraId, destination) {
2487
2715
  return paraId !== null && paraId !== void 0 ? paraId : getParaId(destination);
2488
2716
  };
2489
2717
 
2490
- /**
2491
- * Error thrown when the Ethereum bridge is halted.
2492
- */
2493
- var BridgeHaltedError = /*#__PURE__*/function (_Error) {
2494
- /**
2495
- * Constructs a new BridgeHaltedError.
2496
- *
2497
- * @param message - Optional custom error message.
2498
- */
2499
- function BridgeHaltedError() {
2500
- var _this;
2501
- _classCallCheck(this, BridgeHaltedError);
2502
- _this = _callSuper(this, BridgeHaltedError, ['Bridge operations have been paused by onchain governance.']);
2503
- _this.name = 'BridgeHaltedError';
2504
- return _this;
2505
- }
2506
- _inherits(BridgeHaltedError, _Error);
2507
- return _createClass(BridgeHaltedError);
2508
- }(/*#__PURE__*/_wrapNativeSuper(Error));
2509
-
2510
- /**
2511
- * Error thrown when the Dry Run fails.
2512
- */
2513
- var DryRunFailedError = /*#__PURE__*/function (_Error) {
2514
- /**
2515
- * Constructs a new DryRunFailedError.
2516
- *
2517
- * @param message - Optional custom error message.
2518
- */
2519
- function DryRunFailedError(reason) {
2520
- var _this;
2521
- _classCallCheck(this, DryRunFailedError);
2522
- _this = _callSuper(this, DryRunFailedError, ["Dry run failed: ".concat(reason)]);
2523
- _this.name = 'DryRunFailedError';
2524
- return _this;
2525
- }
2526
- _inherits(DryRunFailedError, _Error);
2527
- return _createClass(DryRunFailedError);
2528
- }(/*#__PURE__*/_wrapNativeSuper(Error));
2529
-
2530
- /**
2531
- * Error thrown when nodes from different relay chains are incompatible.
2532
- */
2533
- var IncompatibleNodesError = /*#__PURE__*/function (_Error) {
2534
- /**
2535
- * Constructs a new IncompatibleNodesError.
2536
- *
2537
- * @param message - Optional custom error message.
2538
- */
2539
- function IncompatibleNodesError(message) {
2540
- var _this;
2541
- _classCallCheck(this, IncompatibleNodesError);
2542
- _this = _callSuper(this, IncompatibleNodesError, [message !== null && message !== void 0 ? message : 'Transactions between nodes on different relaychains are not yet possible.']);
2543
- _this.name = 'IncompatibleNodes';
2544
- return _this;
2545
- }
2546
- _inherits(IncompatibleNodesError, _Error);
2547
- return _createClass(IncompatibleNodesError);
2548
- }(/*#__PURE__*/_wrapNativeSuper(Error));
2549
-
2550
- /**
2551
- * Error thrown when an invalid address is provided.
2552
- */
2553
- var InvalidAddressError = /*#__PURE__*/function (_Error) {
2554
- /**
2555
- * Constructs a new InvalidAddressError.
2556
- *
2557
- * @param message - The error message.
2558
- */
2559
- function InvalidAddressError(message) {
2560
- var _this;
2561
- _classCallCheck(this, InvalidAddressError);
2562
- _this = _callSuper(this, InvalidAddressError, [message]);
2563
- _this.name = 'InvalidAddressError';
2564
- return _this;
2565
- }
2566
- _inherits(InvalidAddressError, _Error);
2567
- return _createClass(InvalidAddressError);
2568
- }(/*#__PURE__*/_wrapNativeSuper(Error));
2569
-
2570
- /**
2571
- * Error thrown when the Dry Run fails.
2572
- */
2573
- var InvalidParameterError = /*#__PURE__*/function (_Error) {
2574
- /**
2575
- * Constructs a new InvalidParameterError.
2576
- *
2577
- * @param message - Required error message.
2578
- */
2579
- function InvalidParameterError(message) {
2580
- var _this;
2581
- _classCallCheck(this, InvalidParameterError);
2582
- _this = _callSuper(this, InvalidParameterError, [message]);
2583
- _this.name = 'InvalidParameterError';
2584
- return _this;
2585
- }
2586
- _inherits(InvalidParameterError, _Error);
2587
- return _createClass(InvalidParameterError);
2588
- }(/*#__PURE__*/_wrapNativeSuper(Error));
2589
-
2590
- /**
2591
- * Used to inform user, that Parachain they wish to use is not supported yet
2592
- */
2593
- var NodeNotSupportedError = /*#__PURE__*/function (_Error) {
2594
- /**
2595
- * Constructs a new NodeNotSupportedError.
2596
- *
2597
- * @param message - Optional custom error message.
2598
- */
2599
- function NodeNotSupportedError(message) {
2600
- var _this;
2601
- _classCallCheck(this, NodeNotSupportedError);
2602
- _this = _callSuper(this, NodeNotSupportedError, [message !== null && message !== void 0 ? message : 'These nodes do not support XCM transfers from Relay / to Relay chain.']);
2603
- _this.name = 'NodeNotSupported';
2604
- return _this;
2605
- }
2606
- _inherits(NodeNotSupportedError, _Error);
2607
- return _createClass(NodeNotSupportedError);
2608
- }(/*#__PURE__*/_wrapNativeSuper(Error));
2609
-
2610
- /**
2611
- * Used to inform user, that Parachain they wish to use has not yet implemented full XCM Support
2612
- */
2613
- var NoXCMSupportImplementedError = /*#__PURE__*/function (_Error) {
2614
- /**
2615
- * Constructs a new NoXCMSupportImplementedError.
2616
- *
2617
- * @param node - The node for which XCM support is not implemented.
2618
- */
2619
- function NoXCMSupportImplementedError(node) {
2620
- var _this;
2621
- _classCallCheck(this, NoXCMSupportImplementedError);
2622
- _this = _callSuper(this, NoXCMSupportImplementedError, ["No XCM support implemented for ".concat(node, " node yet.")]);
2623
- _this.name = 'NoXCMSupportImplemented';
2624
- return _this;
2625
- }
2626
- _inherits(NoXCMSupportImplementedError, _Error);
2627
- return _createClass(NoXCMSupportImplementedError);
2628
- }(/*#__PURE__*/_wrapNativeSuper(Error));
2629
-
2630
- /**
2631
- * Used to inform user, that Parachain they wish to use does not support scenario they wish to use yet
2632
- */
2633
- var ScenarioNotSupportedError = /*#__PURE__*/function (_Error) {
2634
- /**
2635
- * Constructs a new ScenarioNotSupportedError.
2636
- *
2637
- * @param node - The node where the scenario is not supported.
2638
- * @param scenario - The scenario that is not supported.
2639
- * @param message - Optional custom error message.
2640
- */
2641
- function ScenarioNotSupportedError(node, scenario, message) {
2642
- var _this;
2643
- _classCallCheck(this, ScenarioNotSupportedError);
2644
- _this = _callSuper(this, ScenarioNotSupportedError, [message !== null && message !== void 0 ? message : "Scenario ".concat(scenario, " not supported for node ").concat(node)]);
2645
- _this.name = 'ScenarioNotSupported';
2646
- return _this;
2647
- }
2648
- _inherits(ScenarioNotSupportedError, _Error);
2649
- return _createClass(ScenarioNotSupportedError);
2650
- }(/*#__PURE__*/_wrapNativeSuper(Error));
2651
-
2652
2718
  var validateAddress = function validateAddress(address, node) {
2653
2719
  var isDestination = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
2654
2720
  var isEvm = isNodeEvm(node);
@@ -9104,16 +9170,16 @@ var getAssetBalance = /*#__PURE__*/function () {
9104
9170
  var getOriginFeeDetailsInternal = /*#__PURE__*/function () {
9105
9171
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
9106
9172
  var _getExistentialDeposi;
9107
- var api, account, accountDestination, currency, origin, destination, _ref$feeMarginPercent, feeMarginPercentage, tx, xcmFee, xcmFeeWithMargin, nativeBalance, existentialDeposit, sufficientForXCM;
9173
+ var api, account, accountDestination, ahAddress, currency, origin, destination, _ref$feeMarginPercent, feeMarginPercentage, tx, xcmFee, xcmFeeWithMargin, nativeBalance, existentialDeposit, sufficientForXCM;
9108
9174
  return _regeneratorRuntime().wrap(function _callee$(_context) {
9109
9175
  while (1) switch (_context.prev = _context.next) {
9110
9176
  case 0:
9111
- 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 === void 0 ? 10 : _ref$feeMarginPercent;
9177
+ api = _ref.api, account = _ref.account, accountDestination = _ref.accountDestination, ahAddress = _ref.ahAddress, currency = _ref.currency, origin = _ref.origin, destination = _ref.destination, _ref$feeMarginPercent = _ref.feeMarginPercentage, feeMarginPercentage = _ref$feeMarginPercent === void 0 ? 10 : _ref$feeMarginPercent;
9112
9178
  _context.next = 3;
9113
9179
  return api.init(origin);
9114
9180
  case 3:
9115
9181
  _context.next = 5;
9116
- return Builder(api).from(origin).to(destination).currency(currency).address(accountDestination).senderAddress(account).build();
9182
+ return Builder(api).from(origin).to(destination).currency(currency).address(accountDestination).senderAddress(account).ahAddress(ahAddress).build();
9117
9183
  case 5:
9118
9184
  tx = _context.sent;
9119
9185
  _context.next = 8;
@@ -9598,4 +9664,4 @@ var verifyEdOnDestination = /*#__PURE__*/function () {
9598
9664
  };
9599
9665
  }();
9600
9666
 
9601
- export { AssetClaimBuilder, BatchMode, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleNodesError, InvalidAddressError, InvalidParameterError, NoXCMSupportImplementedError, NodeNotSupportedError, PolkadotXcmError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, Version, XTokensError, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, createApiInstanceForNode, createBeneficiaryMultiLocation, createVersionedBeneficiary, createX1Payload, determineRelayChain, dryRun, dryRunOrigin, generateAddressMultiLocationV4, getAssetBalance, getAssetBalanceInternal, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getFees, getMaxForeignTransferableAmount, getMaxForeignTransferableAmountInternal, getMaxNativeTransferableAmount, getMaxNativeTransferableAmountInternal, getNode, getNodeConfig, getNodeProviders, getOriginFeeDetails, getOriginFeeDetailsInternal, getParaEthTransferFees, getParaId, getTNode, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, isEthersContract, isEthersSigner, resolveModuleError, resolveParaId, send, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, transformMultiLocation, validateAddress, verifyEdOnDestination };
9667
+ export { AssetClaimBuilder, BatchMode, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleNodesError, InvalidAddressError, InvalidParameterError, NoXCMSupportImplementedError, NodeNotSupportedError, PolkadotXcmError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, Version, XTokensError, blake2b256, blake2b512, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, convertSs58, createApiInstanceForNode, createBeneficiaryMultiLocation, createVersionedBeneficiary, createX1Payload, deriveAccountId, determineRelayChain, dryRun, dryRunOrigin, encodeSs58, generateAddressMultiLocationV4, getAssetBalance, getAssetBalanceInternal, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getFees, getMaxForeignTransferableAmount, getMaxForeignTransferableAmountInternal, getMaxNativeTransferableAmount, getMaxNativeTransferableAmountInternal, getNode, getNodeConfig, getNodeProviders, getOriginFeeDetails, getOriginFeeDetailsInternal, getParaEthTransferFees, getParaId, getTNode, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, isEthersContract, isEthersSigner, resolveModuleError, resolveParaId, send, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, transformMultiLocation, validateAddress, verifyEdOnDestination };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-core",
3
- "version": "8.15.1",
3
+ "version": "8.16.0",
4
4
  "description": "SDK core for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,11 +23,13 @@
23
23
  "dist"
24
24
  ],
25
25
  "dependencies": {
26
+ "@noble/hashes": "^1.8.0",
27
+ "@scure/base": "^1.2.5",
26
28
  "ethers": "^6.13.7",
27
29
  "viem": "^2.28.1",
28
- "@paraspell/pallets": "8.15.1",
29
- "@paraspell/sdk-common": "8.15.1",
30
- "@paraspell/assets": "8.15.1"
30
+ "@paraspell/assets": "8.16.0",
31
+ "@paraspell/pallets": "8.16.0",
32
+ "@paraspell/sdk-common": "8.16.0"
31
33
  },
32
34
  "devDependencies": {
33
35
  "@babel/plugin-syntax-import-attributes": "^7.27.1",