@paraspell/sdk-core 10.1.7 → 10.3.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
@@ -3,10 +3,10 @@
3
3
  var blake2 = require('@noble/hashes/blake2');
4
4
  var assets = require('@paraspell/assets');
5
5
  var base = require('@scure/base');
6
- var ethers = require('ethers');
6
+ var viem = require('viem');
7
7
  var sdkCommon = require('@paraspell/sdk-common');
8
8
  var pallets = require('@paraspell/pallets');
9
- var viem = require('viem');
9
+ var chains = require('viem/chains');
10
10
 
11
11
  function _arrayLikeToArray(r, a) {
12
12
  (null == a || a > r.length) && (a = r.length);
@@ -821,7 +821,7 @@ var encodeSs58 = function encodeSs58(payload, network) {
821
821
  return base.base58.encode(addressBytes);
822
822
  };
823
823
  var convertSs58 = function convertSs58(api, address, node) {
824
- var isEvmAddress = ethers.ethers.isAddress(address);
824
+ var isEvmAddress = viem.isAddress(address);
825
825
  if (isEvmAddress && assets.isNodeEvm(node)) {
826
826
  return address;
827
827
  }
@@ -2464,7 +2464,7 @@ var createBeneficiaryMultiLocation = function createBeneficiaryMultiLocation(_re
2464
2464
  if (sdkCommon.isTMultiLocation(recipientAddress)) {
2465
2465
  return recipientAddress;
2466
2466
  }
2467
- var isEthAddress = ethers.ethers.isAddress(recipientAddress);
2467
+ var isEthAddress = viem.isAddress(recipientAddress);
2468
2468
  var getAccountPayload = function getAccountPayload(allowNetwork) {
2469
2469
  if (isEthAddress) {
2470
2470
  return {
@@ -2739,7 +2739,7 @@ var generateAddressMultiLocationV4 = function generateAddressMultiLocationV4(api
2739
2739
  if (isMultiLocation) {
2740
2740
  return _defineProperty({}, exports.Version.V4, address);
2741
2741
  }
2742
- var isEthAddress = ethers.ethers.isAddress(address);
2742
+ var isEthAddress = viem.isAddress(address);
2743
2743
  return addXcmVersionHeader({
2744
2744
  parents: sdkCommon.Parents.ZERO,
2745
2745
  interior: {
@@ -2790,8 +2790,9 @@ var resolveParaId = function resolveParaId(paraId, destination) {
2790
2790
 
2791
2791
  var validateAddress = function validateAddress(address, node) {
2792
2792
  var isDestination = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
2793
+ if (sdkCommon.isTMultiLocation(address)) return;
2793
2794
  var isEvm = assets.isNodeEvm(node);
2794
- var isEthereumAddress = ethers.ethers.isAddress(address);
2795
+ var isEthereumAddress = viem.isAddress(address);
2795
2796
  if (isEvm) {
2796
2797
  if (!isEthereumAddress) {
2797
2798
  throw new InvalidAddressError("".concat(isDestination ? 'Destination node' : 'Node', " is an EVM chain, but the address provided is not a valid Ethereum address."));
@@ -3012,42 +3013,49 @@ var formatAssetIdToERC20 = function formatAssetIdToERC20(id) {
3012
3013
  return "0xffffffff".concat(BigInt(id).toString(16).padStart(32, '0'));
3013
3014
  };
3014
3015
 
3015
- var MOONBEAM_RPC = 'https://rpc.api.moonbeam.network';
3016
- var MOONBEAM_ID = 1284;
3017
- var MOONRIVER_RPC = 'https://rpc.api.moonriver.moonbeam.network';
3018
- var MOONRIVER_ID = 1285;
3019
- var ERC20_ABI$1 = ['function balanceOf(address) view returns (uint256)'];
3020
- function getMoonbeamErc20Balance(_x, _x2, _x3) {
3021
- return _getMoonbeamErc20Balance.apply(this, arguments);
3022
- }
3023
- function _getMoonbeamErc20Balance() {
3024
- _getMoonbeamErc20Balance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(node, assetId, address) {
3025
- var _ref, rpc, id, provider, addr, token;
3016
+ var ERC20_ABI$1 = [{
3017
+ type: 'function',
3018
+ name: 'balanceOf',
3019
+ stateMutability: 'view',
3020
+ inputs: [{
3021
+ name: 'account',
3022
+ type: 'address'
3023
+ }],
3024
+ outputs: [{
3025
+ name: '',
3026
+ type: 'uint256'
3027
+ }]
3028
+ }];
3029
+ var getMoonbeamErc20Balance = /*#__PURE__*/function () {
3030
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(node, assetId, address) {
3031
+ var client, tokenAddress;
3026
3032
  return _regeneratorRuntime().wrap(function _callee$(_context) {
3027
3033
  while (1) switch (_context.prev = _context.next) {
3028
3034
  case 0:
3029
- _ref = node === 'Moonbeam' ? {
3030
- rpc: MOONBEAM_RPC,
3031
- id: MOONBEAM_ID
3032
- } : {
3033
- rpc: MOONRIVER_RPC,
3034
- id: MOONRIVER_ID
3035
- }, rpc = _ref.rpc, id = _ref.id;
3036
- provider = new ethers.ethers.JsonRpcProvider(rpc, id);
3037
- addr = formatAssetIdToERC20(assetId);
3038
- token = new ethers.ethers.Contract(addr, ERC20_ABI$1, provider);
3039
- _context.next = 6;
3040
- return token.balanceOf(address);
3041
- case 6:
3035
+ client = viem.createPublicClient({
3036
+ chain: node === 'Moonbeam' ? chains.moonbeam : chains.moonriver,
3037
+ transport: viem.http()
3038
+ });
3039
+ tokenAddress = formatAssetIdToERC20(assetId);
3040
+ _context.next = 4;
3041
+ return client.readContract({
3042
+ address: tokenAddress,
3043
+ abi: ERC20_ABI$1,
3044
+ functionName: 'balanceOf',
3045
+ args: [address]
3046
+ });
3047
+ case 4:
3042
3048
  return _context.abrupt("return", _context.sent);
3043
- case 7:
3049
+ case 5:
3044
3050
  case "end":
3045
3051
  return _context.stop();
3046
3052
  }
3047
3053
  }, _callee);
3048
3054
  }));
3049
- return _getMoonbeamErc20Balance.apply(this, arguments);
3050
- }
3055
+ return function getMoonbeamErc20Balance(_x, _x2, _x3) {
3056
+ return _ref.apply(this, arguments);
3057
+ };
3058
+ }();
3051
3059
 
3052
3060
  var getBalanceForeignPolkadotXcm = /*#__PURE__*/function () {
3053
3061
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(api, node, address, asset) {
@@ -3394,13 +3402,6 @@ var getAssetBalance = /*#__PURE__*/function () {
3394
3402
  };
3395
3403
  }();
3396
3404
 
3397
- var isEthersSigner = function isEthersSigner(signer) {
3398
- return _typeof(signer) === 'object' && signer !== null && 'provider' in signer;
3399
- };
3400
- var isEthersContract = function isEthersContract(contract) {
3401
- return !('abi' in contract);
3402
- };
3403
-
3404
3405
  var abi$1 = [
3405
3406
  {
3406
3407
  inputs: [
@@ -3535,7 +3536,7 @@ var transferMoonbeamEvm = /*#__PURE__*/function () {
3535
3536
  }
3536
3537
  throw new InvalidParameterError('Override multilocation is not supported for Evm transfers');
3537
3538
  case 5:
3538
- contract = isEthersSigner(signer) ? new ethers.Contract(CONTRACT_ADDRESS, abi$1, signer) : viem.getContract({
3539
+ contract = viem.getContract({
3539
3540
  abi: abi$1,
3540
3541
  address: CONTRACT_ADDRESS,
3541
3542
  client: {
@@ -3573,9 +3574,7 @@ var transferMoonbeamEvm = /*#__PURE__*/function () {
3573
3574
  weight = U_64_MAX; // Partially inspired by Moonbeam XCM-SDK
3574
3575
  // https://github.com/moonbeam-foundation/xcm-sdk/blob/ab835c15bf41612604b1c858d956a9f07705ed65/packages/sdk/src/contract/contracts/Xtokens/Xtokens.ts#L53
3575
3576
  createTx = function createTx(func, args) {
3576
- if (isEthersContract(contract)) {
3577
- return contract[func].apply(contract, _toConsumableArray(args));
3578
- }
3577
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
3579
3578
  return contract.write[func](args);
3580
3579
  };
3581
3580
  multiCurrencySymbols = ['xcPINK', 'xcDED', 'xcSTINK', 'xcWIFD', 'xcNCTR'];
@@ -3602,7 +3601,7 @@ var transferMoonbeamEvm = /*#__PURE__*/function () {
3602
3601
  _context.t0 = _context.sent;
3603
3602
  case 31:
3604
3603
  tx = _context.t0;
3605
- return _context.abrupt("return", _typeof(tx) === 'object' ? tx.hash : tx);
3604
+ return _context.abrupt("return", tx);
3606
3605
  case 33:
3607
3606
  case "end":
3608
3607
  return _context.stop();
@@ -3898,7 +3897,7 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
3898
3897
  }
3899
3898
  throw new assets.InvalidCurrencyError("Could not obtain Ethereum asset address for ".concat(JSON.stringify(foundAsset)));
3900
3899
  case 20:
3901
- contract = isEthersSigner(signer) ? new ethers.Contract(xcmInterfacePrecompile, abi, signer) : viem.getContract({
3900
+ contract = viem.getContract({
3902
3901
  abi: abi,
3903
3902
  address: xcmInterfacePrecompile,
3904
3903
  client: {
@@ -3909,32 +3908,19 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
3909
3908
  wallet: signer
3910
3909
  }
3911
3910
  });
3912
- if (!isEthersSigner(signer)) {
3913
- _context.next = 27;
3914
- break;
3915
- }
3916
- _context.next = 24;
3917
- return signer.getAddress();
3918
- case 24:
3919
- _context.t0 = _context.sent;
3920
- _context.next = 28;
3921
- break;
3922
- case 27:
3923
- _context.t0 = (_signer$account = signer.account) === null || _signer$account === void 0 ? void 0 : _signer$account.address;
3924
- case 28:
3925
- senderAddress = _context.t0;
3911
+ senderAddress = (_signer$account = signer.account) === null || _signer$account === void 0 ? void 0 : _signer$account.address;
3926
3912
  if (senderAddress) {
3927
- _context.next = 31;
3913
+ _context.next = 24;
3928
3914
  break;
3929
3915
  }
3930
3916
  throw new InvalidParameterError('Unable to get sender address');
3931
- case 31:
3932
- _context.next = 33;
3917
+ case 24:
3918
+ _context.next = 26;
3933
3919
  return api.init(from, TX_CLIENT_TIMEOUT_MS);
3934
- case 33:
3935
- _context.next = 35;
3920
+ case 26:
3921
+ _context.next = 28;
3936
3922
  return generateMessageId(api, senderAddress, getParaId(from), ethAsset.assetId, address, currency.amount);
3937
- case 35:
3923
+ case 28:
3938
3924
  messageId = _context.sent;
3939
3925
  customXcm = createCustomXcmOnDest({
3940
3926
  api: api,
@@ -3945,17 +3931,17 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
3945
3931
  asset: _objectSpread2(_objectSpread2({}, foundAsset), {}, {
3946
3932
  amount: currency.amount
3947
3933
  })}, from, exports.Version.V4, messageId);
3948
- _context.next = 39;
3934
+ _context.next = 32;
3949
3935
  return api.objectToHex(customXcm, 'XcmVersionedXcm');
3950
- case 39:
3936
+ case 32:
3951
3937
  customXcmOnDest = _context.sent;
3952
- _context.next = 42;
3938
+ _context.next = 35;
3953
3939
  return api.createApiForNode('AssetHubPolkadot');
3954
- case 42:
3940
+ case 35:
3955
3941
  assetHubApi = _context.sent;
3956
- _context.next = 45;
3942
+ _context.next = 38;
3957
3943
  return getParaEthTransferFees(assetHubApi);
3958
- case 45:
3944
+ case 38:
3959
3945
  _yield$getParaEthTran = _context.sent;
3960
3946
  _yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 2);
3961
3947
  bridgeFee = _yield$getParaEthTran2[0];
@@ -3963,9 +3949,6 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
3963
3949
  transferFee = (bridgeFee + executionFee).toString(); // Partially inspired by Moonbeam XCM-SDK
3964
3950
  // https://github.com/moonbeam-foundation/xcm-sdk/blob/ab835c15bf41612604b1c858d956a9f07705ed65/packages/sdk/src/contract/contracts/Xtokens/Xtokens.ts#L53
3965
3951
  createTx = function createTx(func, args) {
3966
- if (isEthersContract(contract)) {
3967
- return contract[func].apply(contract, _toConsumableArray(args));
3968
- }
3969
3952
  return contract.write[func](args);
3970
3953
  };
3971
3954
  numberToHex32 = function numberToHex32(num) {
@@ -3973,8 +3956,8 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
3973
3956
  throw new InvalidParameterError('Input must be a valid number');
3974
3957
  }() : "0x".concat((num >>> 0).toString(16).padStart(8, '0'));
3975
3958
  }; // Execute the custom XCM message with the precompile
3976
- _context.next = 54;
3977
- return createTx(isEthersSigner(signer) ? 'transferAssetsUsingTypeAndThenAddress((uint8,bytes[]),(address,uint256)[],uint8,uint8,uint8,bytes)' : 'transferAssetsUsingTypeAndThenAddress', [
3959
+ _context.next = 47;
3960
+ return createTx('transferAssetsUsingTypeAndThenAddress', [
3978
3961
  // This represents (1,X1(Parachain(1000)))
3979
3962
  [1, ['0x00' + numberToHex32(getParaId('AssetHubPolkadot')).slice(2)]],
3980
3963
  // Assets including fee and the ERC20 asset, with fee be the first
@@ -3985,10 +3968,10 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
3985
3968
  0,
3986
3969
  // The TransferType corresponding to fee asset
3987
3970
  2, customXcmOnDest]);
3988
- case 54:
3971
+ case 47:
3989
3972
  tx = _context.sent;
3990
- return _context.abrupt("return", _typeof(tx) === 'object' ? tx.hash : tx);
3991
- case 56:
3973
+ return _context.abrupt("return", tx);
3974
+ case 49:
3992
3975
  case "end":
3993
3976
  return _context.stop();
3994
3977
  }
@@ -6332,30 +6315,24 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
6332
6315
  }
6333
6316
  throw new BridgeHaltedError();
6334
6317
  case 6:
6335
- if (ethers.ethers.isAddress(address)) {
6336
- _context2.next = 8;
6337
- break;
6338
- }
6339
- throw new InvalidParameterError('Only Ethereum addresses are supported for Ethereum transfers');
6340
- case 8:
6341
6318
  if (assets.isForeignAsset(asset)) {
6342
- _context2.next = 10;
6319
+ _context2.next = 8;
6343
6320
  break;
6344
6321
  }
6345
6322
  throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
6346
- case 10:
6323
+ case 8:
6347
6324
  if (asset.multiLocation) {
6348
- _context2.next = 12;
6325
+ _context2.next = 10;
6349
6326
  break;
6350
6327
  }
6351
6328
  throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multiLocation"));
6352
- case 12:
6329
+ case 10:
6353
6330
  if (!(asset.symbol === this.getNativeAssetSymbol() || asset.symbol === assets.getNativeAssetSymbol('Kusama'))) {
6354
- _context2.next = 14;
6331
+ _context2.next = 12;
6355
6332
  break;
6356
6333
  }
6357
6334
  return _context2.abrupt("return", this.handleEthBridgeNativeTransfer(input));
6358
- case 14:
6335
+ case 12:
6359
6336
  modifiedInput = _objectSpread2(_objectSpread2({}, input), {}, {
6360
6337
  header: createVersionedDestination(scenario, this.version, destination, paraIdTo, ETHEREUM_JUNCTION, sdkCommon.Parents.TWO),
6361
6338
  addressSelection: createVersionedBeneficiary({
@@ -6369,7 +6346,7 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
6369
6346
  currencySelection: createVersionedMultiAssets(exports.Version.V3, asset.amount, asset.multiLocation)
6370
6347
  });
6371
6348
  return _context2.abrupt("return", PolkadotXCMTransferImpl.transferPolkadotXCM(modifiedInput, 'transfer_assets', 'Unlimited'));
6372
- case 16:
6349
+ case 14:
6373
6350
  case "end":
6374
6351
  return _context2.stop();
6375
6352
  }
@@ -8188,7 +8165,7 @@ var getDestination = function getDestination(_ref) {
8188
8165
  if (isMultiLocation) {
8189
8166
  return recipientAddress;
8190
8167
  }
8191
- var isEthAddress = ethers.ethers.isAddress(recipientAddress);
8168
+ var isEthAddress = viem.isAddress(recipientAddress);
8192
8169
  var addressJunction = isEthAddress ? {
8193
8170
  AccountKey20: {
8194
8171
  key: recipientAddress
@@ -8604,7 +8581,7 @@ var buildBeneficiaryInput = function buildBeneficiaryInput(api, address) {
8604
8581
  if (sdkCommon.isTMultiLocation(address)) {
8605
8582
  return address;
8606
8583
  }
8607
- var isEthAddress = ethers.ethers.isAddress(address);
8584
+ var isEthAddress = viem.isAddress(address);
8608
8585
  return {
8609
8586
  parents: sdkCommon.Parents.ZERO,
8610
8587
  interior: {
@@ -8920,22 +8897,29 @@ var getTransferableAmount = /*#__PURE__*/function () {
8920
8897
  };
8921
8898
  }();
8922
8899
 
8923
- var ETH_RPC = 'https://ethereum.publicnode.com/';
8924
- var ETH_ID = 1;
8925
- var ERC20_ABI = ['function balanceOf(address) view returns (uint256)'];
8926
- function getEthErc20Balance(_x, _x2) {
8927
- return _getEthErc20Balance.apply(this, arguments);
8928
- }
8929
- function _getEthErc20Balance() {
8930
- _getEthErc20Balance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(currency, address) {
8931
- var _rpc$id, rpc, id, asset, provider, tokenAddress, token;
8900
+ var ERC20_ABI = [{
8901
+ type: 'function',
8902
+ name: 'balanceOf',
8903
+ stateMutability: 'view',
8904
+ inputs: [{
8905
+ name: 'account',
8906
+ type: 'address'
8907
+ }],
8908
+ outputs: [{
8909
+ name: '',
8910
+ type: 'uint256'
8911
+ }]
8912
+ }];
8913
+ var getEthErc20Balance = /*#__PURE__*/function () {
8914
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(currency, address) {
8915
+ var client, asset;
8932
8916
  return _regeneratorRuntime().wrap(function _callee$(_context) {
8933
8917
  while (1) switch (_context.prev = _context.next) {
8934
8918
  case 0:
8935
- _rpc$id = {
8936
- rpc: ETH_RPC,
8937
- id: ETH_ID
8938
- }, rpc = _rpc$id.rpc, id = _rpc$id.id;
8919
+ client = viem.createPublicClient({
8920
+ chain: chains.mainnet,
8921
+ transport: viem.http('https://ethereum.publicnode.com/')
8922
+ });
8939
8923
  asset = assets.findAssetForNodeOrThrow('Ethereum', currency, null);
8940
8924
  if (!(!assets.isForeignAsset(asset) || !asset.assetId)) {
8941
8925
  _context.next = 4;
@@ -8943,30 +8927,36 @@ function _getEthErc20Balance() {
8943
8927
  }
8944
8928
  throw new InvalidParameterError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset."));
8945
8929
  case 4:
8946
- provider = new ethers.ethers.JsonRpcProvider(rpc, id);
8947
8930
  if (!(asset.symbol === 'ETH')) {
8948
- _context.next = 9;
8931
+ _context.next = 8;
8949
8932
  break;
8950
8933
  }
8951
- _context.next = 8;
8952
- return provider.getBalance(address);
8953
- case 8:
8934
+ _context.next = 7;
8935
+ return client.getBalance({
8936
+ address: address
8937
+ });
8938
+ case 7:
8954
8939
  return _context.abrupt("return", _context.sent);
8955
- case 9:
8956
- tokenAddress = asset.assetId;
8957
- token = new ethers.ethers.Contract(tokenAddress, ERC20_ABI, provider);
8958
- _context.next = 13;
8959
- return token.balanceOf(address);
8960
- case 13:
8940
+ case 8:
8941
+ _context.next = 10;
8942
+ return client.readContract({
8943
+ address: asset.assetId,
8944
+ abi: ERC20_ABI,
8945
+ functionName: 'balanceOf',
8946
+ args: [address]
8947
+ });
8948
+ case 10:
8961
8949
  return _context.abrupt("return", _context.sent);
8962
- case 14:
8950
+ case 11:
8963
8951
  case "end":
8964
8952
  return _context.stop();
8965
8953
  }
8966
8954
  }, _callee);
8967
8955
  }));
8968
- return _getEthErc20Balance.apply(this, arguments);
8969
- }
8956
+ return function getEthErc20Balance(_x, _x2) {
8957
+ return _ref.apply(this, arguments);
8958
+ };
8959
+ }();
8970
8960
 
8971
8961
  var buildDestInfo = /*#__PURE__*/function () {
8972
8962
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
@@ -10341,8 +10331,6 @@ exports.getTransferableAmount = getTransferableAmount;
10341
10331
  exports.getTransferableAmountInternal = getTransferableAmountInternal;
10342
10332
  exports.getXcmFee = getXcmFee;
10343
10333
  exports.getXcmFeeEstimate = getXcmFeeEstimate;
10344
- exports.isEthersContract = isEthersContract;
10345
- exports.isEthersSigner = isEthersSigner;
10346
10334
  exports.replaceBigInt = replaceBigInt;
10347
10335
  exports.resolveModuleError = resolveModuleError;
10348
10336
  exports.resolveParaId = resolveParaId;
package/dist/index.d.ts CHANGED
@@ -6,8 +6,7 @@ import { TMultiAsset, TCurrencyInputWithAmount, TCurrencyInput, WithAmount, TAss
6
6
  export * from '@paraspell/assets';
7
7
  import { TPallet } from '@paraspell/pallets';
8
8
  export * from '@paraspell/pallets';
9
- import { Signer, AbstractProvider, Contract } from 'ethers';
10
- import { WalletClient, GetContractReturnType, Abi } from 'viem';
9
+ import { WalletClient } from 'viem';
11
10
 
12
11
  type WithApi<TBase, TApi, TRes> = TBase & {
13
12
  api: IPolkadotApi<TApi, TRes>;
@@ -475,11 +474,9 @@ type TEvmBuilderOptionsBase = {
475
474
  /**
476
475
  * The Ethereum signer.
477
476
  */
478
- signer: Signer | WalletClient;
479
- };
480
- type TEvmBuilderOptions<TApi, TRes> = WithApi<TEvmBuilderOptionsBase, TApi, TRes> & {
481
- provider?: AbstractProvider;
477
+ signer: WalletClient;
482
478
  };
479
+ type TEvmBuilderOptions<TApi, TRes> = WithApi<TEvmBuilderOptionsBase, TApi, TRes>;
483
480
  type TSerializeEthTransferOptions = Omit<TEvmBuilderOptionsBase, 'signer'> & {
484
481
  destAddress: string;
485
482
  };
@@ -1778,10 +1775,7 @@ declare const getParaEthTransferFees: <TApi, TRes>(ahApi: IPolkadotApi<TApi, TRe
1778
1775
 
1779
1776
  declare const transferMoonbeamEvm: <TApi, TRes>({ api, from, to, signer, address, currency }: TEvmBuilderOptions<TApi, TRes>) => Promise<string>;
1780
1777
 
1781
- declare const transferMoonbeamToEth: <TApi, TRes>({ api, from, to, signer, address, ahAddress, currency }: TEvmBuilderOptions<TApi, TRes>) => Promise<string>;
1782
-
1783
- declare const isEthersSigner: (signer: Signer | WalletClient) => signer is Signer;
1784
- declare const isEthersContract: (contract: Contract | GetContractReturnType<Abi | readonly unknown[]>) => contract is Contract;
1778
+ declare const transferMoonbeamToEth: <TApi, TRes>({ api, from, to, signer, address, ahAddress, currency }: TEvmBuilderOptions<TApi, TRes>) => Promise<`0x${string}`>;
1785
1779
 
1786
1780
  declare const getOriginXcmFee: <TApi, TRes>({ api, tx, origin, destination, senderAddress, disableFallback, feeAsset, currency }: TGetOriginXcmFeeOptions<TApi, TRes>) => Promise<TXcmFeeDetail & {
1787
1781
  forwardedXcms?: any;
@@ -1851,5 +1845,5 @@ declare const validateAddress: (address: TAddress, node: TNodeWithRelayChains, i
1851
1845
  */
1852
1846
  declare const determineRelayChain: (node: TNodeWithRelayChains) => TRelaychain;
1853
1847
 
1854
- 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, TransferToAhNotSupported, UnableToComputeError, 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, getNode, getNodeConfig, getNodeProviders, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getParaEthTransferFees, getParaId, getTNode, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, isEthersContract, isEthersSigner, replaceBigInt, resolveModuleError, resolveParaId, reverseTransformMultiLocation, send, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, transformMultiLocation, validateAddress, verifyEdOnDestination };
1848
+ 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, TransferToAhNotSupported, UnableToComputeError, 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, getNode, getNodeConfig, getNodeProviders, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getParaEthTransferFees, getParaId, getTNode, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, replaceBigInt, resolveModuleError, resolveParaId, reverseTransformMultiLocation, send, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, transformMultiLocation, validateAddress, verifyEdOnDestination };
1855
1849
  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, TGetMaxForeignTransferableAmountOptions, TGetMaxForeignTransferableAmountOptionsBase, TGetMaxNativeTransferableAmountOptions, TGetMaxNativeTransferableAmountOptionsBase, TGetOriginFeeDetailsOptions, TGetOriginFeeDetailsOptionsBase, TGetOriginXcmFeeBaseOptions, TGetOriginXcmFeeEstimateOptions, TGetOriginXcmFeeOptions, TGetReverseTxFeeOptions, 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, TXcmFeeBase, TXcmFeeDetail, TXcmForeignAsset, TXcmPalletSection, TXcmVersioned, TZeitgeistAsset, WithApi, WithRequiredSenderAddress };
package/dist/index.mjs CHANGED
@@ -2,12 +2,12 @@ import { blake2b } from '@noble/hashes/blake2';
2
2
  import { isNodeEvm, getAssetsObject, InvalidCurrencyError, getNativeAssetSymbol, getOtherAssets, getRelayChainSymbol, isForeignAsset, findAssetForNodeOrThrow, findAsset, isOverrideMultiLocationSpecifier, findAssetByMultiLocation, isTMultiAsset, hasDryRunSupport, findAssetOnDestOrThrow, hasSupportForAsset, extractMultiAssetLoc, isAssetEqual, isSymbolSpecifier, getAssetId, getExistentialDeposit, normalizeSymbol } from '@paraspell/assets';
3
3
  export * from '@paraspell/assets';
4
4
  import { base58 } from '@scure/base';
5
- import { ethers, Contract } from 'ethers';
5
+ import { isAddress, createPublicClient, http, getContract } from 'viem';
6
6
  import { Parents, isTMultiLocation, NODE_NAMES_DOT_KSM, isRelayChain, hasJunction, deepEqual, isDotKsmBridge } from '@paraspell/sdk-common';
7
7
  export * from '@paraspell/sdk-common';
8
8
  import { getSupportedPalletsDetails, getDefaultPallet } from '@paraspell/pallets';
9
9
  export * from '@paraspell/pallets';
10
- import { getContract, createPublicClient, http } from 'viem';
10
+ import { moonbeam, moonriver, mainnet } from 'viem/chains';
11
11
 
12
12
  function _arrayLikeToArray(r, a) {
13
13
  (null == a || a > r.length) && (a = r.length);
@@ -822,7 +822,7 @@ var encodeSs58 = function encodeSs58(payload, network) {
822
822
  return base58.encode(addressBytes);
823
823
  };
824
824
  var convertSs58 = function convertSs58(api, address, node) {
825
- var isEvmAddress = ethers.isAddress(address);
825
+ var isEvmAddress = isAddress(address);
826
826
  if (isEvmAddress && isNodeEvm(node)) {
827
827
  return address;
828
828
  }
@@ -2465,7 +2465,7 @@ var createBeneficiaryMultiLocation = function createBeneficiaryMultiLocation(_re
2465
2465
  if (isTMultiLocation(recipientAddress)) {
2466
2466
  return recipientAddress;
2467
2467
  }
2468
- var isEthAddress = ethers.isAddress(recipientAddress);
2468
+ var isEthAddress = isAddress(recipientAddress);
2469
2469
  var getAccountPayload = function getAccountPayload(allowNetwork) {
2470
2470
  if (isEthAddress) {
2471
2471
  return {
@@ -2740,7 +2740,7 @@ var generateAddressMultiLocationV4 = function generateAddressMultiLocationV4(api
2740
2740
  if (isMultiLocation) {
2741
2741
  return _defineProperty({}, Version.V4, address);
2742
2742
  }
2743
- var isEthAddress = ethers.isAddress(address);
2743
+ var isEthAddress = isAddress(address);
2744
2744
  return addXcmVersionHeader({
2745
2745
  parents: Parents.ZERO,
2746
2746
  interior: {
@@ -2791,8 +2791,9 @@ var resolveParaId = function resolveParaId(paraId, destination) {
2791
2791
 
2792
2792
  var validateAddress = function validateAddress(address, node) {
2793
2793
  var isDestination = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
2794
+ if (isTMultiLocation(address)) return;
2794
2795
  var isEvm = isNodeEvm(node);
2795
- var isEthereumAddress = ethers.isAddress(address);
2796
+ var isEthereumAddress = isAddress(address);
2796
2797
  if (isEvm) {
2797
2798
  if (!isEthereumAddress) {
2798
2799
  throw new InvalidAddressError("".concat(isDestination ? 'Destination node' : 'Node', " is an EVM chain, but the address provided is not a valid Ethereum address."));
@@ -3013,42 +3014,49 @@ var formatAssetIdToERC20 = function formatAssetIdToERC20(id) {
3013
3014
  return "0xffffffff".concat(BigInt(id).toString(16).padStart(32, '0'));
3014
3015
  };
3015
3016
 
3016
- var MOONBEAM_RPC = 'https://rpc.api.moonbeam.network';
3017
- var MOONBEAM_ID = 1284;
3018
- var MOONRIVER_RPC = 'https://rpc.api.moonriver.moonbeam.network';
3019
- var MOONRIVER_ID = 1285;
3020
- var ERC20_ABI$1 = ['function balanceOf(address) view returns (uint256)'];
3021
- function getMoonbeamErc20Balance(_x, _x2, _x3) {
3022
- return _getMoonbeamErc20Balance.apply(this, arguments);
3023
- }
3024
- function _getMoonbeamErc20Balance() {
3025
- _getMoonbeamErc20Balance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(node, assetId, address) {
3026
- var _ref, rpc, id, provider, addr, token;
3017
+ var ERC20_ABI$1 = [{
3018
+ type: 'function',
3019
+ name: 'balanceOf',
3020
+ stateMutability: 'view',
3021
+ inputs: [{
3022
+ name: 'account',
3023
+ type: 'address'
3024
+ }],
3025
+ outputs: [{
3026
+ name: '',
3027
+ type: 'uint256'
3028
+ }]
3029
+ }];
3030
+ var getMoonbeamErc20Balance = /*#__PURE__*/function () {
3031
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(node, assetId, address) {
3032
+ var client, tokenAddress;
3027
3033
  return _regeneratorRuntime().wrap(function _callee$(_context) {
3028
3034
  while (1) switch (_context.prev = _context.next) {
3029
3035
  case 0:
3030
- _ref = node === 'Moonbeam' ? {
3031
- rpc: MOONBEAM_RPC,
3032
- id: MOONBEAM_ID
3033
- } : {
3034
- rpc: MOONRIVER_RPC,
3035
- id: MOONRIVER_ID
3036
- }, rpc = _ref.rpc, id = _ref.id;
3037
- provider = new ethers.JsonRpcProvider(rpc, id);
3038
- addr = formatAssetIdToERC20(assetId);
3039
- token = new ethers.Contract(addr, ERC20_ABI$1, provider);
3040
- _context.next = 6;
3041
- return token.balanceOf(address);
3042
- case 6:
3036
+ client = createPublicClient({
3037
+ chain: node === 'Moonbeam' ? moonbeam : moonriver,
3038
+ transport: http()
3039
+ });
3040
+ tokenAddress = formatAssetIdToERC20(assetId);
3041
+ _context.next = 4;
3042
+ return client.readContract({
3043
+ address: tokenAddress,
3044
+ abi: ERC20_ABI$1,
3045
+ functionName: 'balanceOf',
3046
+ args: [address]
3047
+ });
3048
+ case 4:
3043
3049
  return _context.abrupt("return", _context.sent);
3044
- case 7:
3050
+ case 5:
3045
3051
  case "end":
3046
3052
  return _context.stop();
3047
3053
  }
3048
3054
  }, _callee);
3049
3055
  }));
3050
- return _getMoonbeamErc20Balance.apply(this, arguments);
3051
- }
3056
+ return function getMoonbeamErc20Balance(_x, _x2, _x3) {
3057
+ return _ref.apply(this, arguments);
3058
+ };
3059
+ }();
3052
3060
 
3053
3061
  var getBalanceForeignPolkadotXcm = /*#__PURE__*/function () {
3054
3062
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(api, node, address, asset) {
@@ -3395,13 +3403,6 @@ var getAssetBalance = /*#__PURE__*/function () {
3395
3403
  };
3396
3404
  }();
3397
3405
 
3398
- var isEthersSigner = function isEthersSigner(signer) {
3399
- return _typeof(signer) === 'object' && signer !== null && 'provider' in signer;
3400
- };
3401
- var isEthersContract = function isEthersContract(contract) {
3402
- return !('abi' in contract);
3403
- };
3404
-
3405
3406
  var abi$1 = [
3406
3407
  {
3407
3408
  inputs: [
@@ -3536,7 +3537,7 @@ var transferMoonbeamEvm = /*#__PURE__*/function () {
3536
3537
  }
3537
3538
  throw new InvalidParameterError('Override multilocation is not supported for Evm transfers');
3538
3539
  case 5:
3539
- contract = isEthersSigner(signer) ? new Contract(CONTRACT_ADDRESS, abi$1, signer) : getContract({
3540
+ contract = getContract({
3540
3541
  abi: abi$1,
3541
3542
  address: CONTRACT_ADDRESS,
3542
3543
  client: {
@@ -3574,9 +3575,7 @@ var transferMoonbeamEvm = /*#__PURE__*/function () {
3574
3575
  weight = U_64_MAX; // Partially inspired by Moonbeam XCM-SDK
3575
3576
  // https://github.com/moonbeam-foundation/xcm-sdk/blob/ab835c15bf41612604b1c858d956a9f07705ed65/packages/sdk/src/contract/contracts/Xtokens/Xtokens.ts#L53
3576
3577
  createTx = function createTx(func, args) {
3577
- if (isEthersContract(contract)) {
3578
- return contract[func].apply(contract, _toConsumableArray(args));
3579
- }
3578
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
3580
3579
  return contract.write[func](args);
3581
3580
  };
3582
3581
  multiCurrencySymbols = ['xcPINK', 'xcDED', 'xcSTINK', 'xcWIFD', 'xcNCTR'];
@@ -3603,7 +3602,7 @@ var transferMoonbeamEvm = /*#__PURE__*/function () {
3603
3602
  _context.t0 = _context.sent;
3604
3603
  case 31:
3605
3604
  tx = _context.t0;
3606
- return _context.abrupt("return", _typeof(tx) === 'object' ? tx.hash : tx);
3605
+ return _context.abrupt("return", tx);
3607
3606
  case 33:
3608
3607
  case "end":
3609
3608
  return _context.stop();
@@ -3899,7 +3898,7 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
3899
3898
  }
3900
3899
  throw new InvalidCurrencyError("Could not obtain Ethereum asset address for ".concat(JSON.stringify(foundAsset)));
3901
3900
  case 20:
3902
- contract = isEthersSigner(signer) ? new Contract(xcmInterfacePrecompile, abi, signer) : getContract({
3901
+ contract = getContract({
3903
3902
  abi: abi,
3904
3903
  address: xcmInterfacePrecompile,
3905
3904
  client: {
@@ -3910,32 +3909,19 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
3910
3909
  wallet: signer
3911
3910
  }
3912
3911
  });
3913
- if (!isEthersSigner(signer)) {
3914
- _context.next = 27;
3915
- break;
3916
- }
3917
- _context.next = 24;
3918
- return signer.getAddress();
3919
- case 24:
3920
- _context.t0 = _context.sent;
3921
- _context.next = 28;
3922
- break;
3923
- case 27:
3924
- _context.t0 = (_signer$account = signer.account) === null || _signer$account === void 0 ? void 0 : _signer$account.address;
3925
- case 28:
3926
- senderAddress = _context.t0;
3912
+ senderAddress = (_signer$account = signer.account) === null || _signer$account === void 0 ? void 0 : _signer$account.address;
3927
3913
  if (senderAddress) {
3928
- _context.next = 31;
3914
+ _context.next = 24;
3929
3915
  break;
3930
3916
  }
3931
3917
  throw new InvalidParameterError('Unable to get sender address');
3932
- case 31:
3933
- _context.next = 33;
3918
+ case 24:
3919
+ _context.next = 26;
3934
3920
  return api.init(from, TX_CLIENT_TIMEOUT_MS);
3935
- case 33:
3936
- _context.next = 35;
3921
+ case 26:
3922
+ _context.next = 28;
3937
3923
  return generateMessageId(api, senderAddress, getParaId(from), ethAsset.assetId, address, currency.amount);
3938
- case 35:
3924
+ case 28:
3939
3925
  messageId = _context.sent;
3940
3926
  customXcm = createCustomXcmOnDest({
3941
3927
  api: api,
@@ -3946,17 +3932,17 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
3946
3932
  asset: _objectSpread2(_objectSpread2({}, foundAsset), {}, {
3947
3933
  amount: currency.amount
3948
3934
  })}, from, Version.V4, messageId);
3949
- _context.next = 39;
3935
+ _context.next = 32;
3950
3936
  return api.objectToHex(customXcm, 'XcmVersionedXcm');
3951
- case 39:
3937
+ case 32:
3952
3938
  customXcmOnDest = _context.sent;
3953
- _context.next = 42;
3939
+ _context.next = 35;
3954
3940
  return api.createApiForNode('AssetHubPolkadot');
3955
- case 42:
3941
+ case 35:
3956
3942
  assetHubApi = _context.sent;
3957
- _context.next = 45;
3943
+ _context.next = 38;
3958
3944
  return getParaEthTransferFees(assetHubApi);
3959
- case 45:
3945
+ case 38:
3960
3946
  _yield$getParaEthTran = _context.sent;
3961
3947
  _yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 2);
3962
3948
  bridgeFee = _yield$getParaEthTran2[0];
@@ -3964,9 +3950,6 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
3964
3950
  transferFee = (bridgeFee + executionFee).toString(); // Partially inspired by Moonbeam XCM-SDK
3965
3951
  // https://github.com/moonbeam-foundation/xcm-sdk/blob/ab835c15bf41612604b1c858d956a9f07705ed65/packages/sdk/src/contract/contracts/Xtokens/Xtokens.ts#L53
3966
3952
  createTx = function createTx(func, args) {
3967
- if (isEthersContract(contract)) {
3968
- return contract[func].apply(contract, _toConsumableArray(args));
3969
- }
3970
3953
  return contract.write[func](args);
3971
3954
  };
3972
3955
  numberToHex32 = function numberToHex32(num) {
@@ -3974,8 +3957,8 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
3974
3957
  throw new InvalidParameterError('Input must be a valid number');
3975
3958
  }() : "0x".concat((num >>> 0).toString(16).padStart(8, '0'));
3976
3959
  }; // Execute the custom XCM message with the precompile
3977
- _context.next = 54;
3978
- return createTx(isEthersSigner(signer) ? 'transferAssetsUsingTypeAndThenAddress((uint8,bytes[]),(address,uint256)[],uint8,uint8,uint8,bytes)' : 'transferAssetsUsingTypeAndThenAddress', [
3960
+ _context.next = 47;
3961
+ return createTx('transferAssetsUsingTypeAndThenAddress', [
3979
3962
  // This represents (1,X1(Parachain(1000)))
3980
3963
  [1, ['0x00' + numberToHex32(getParaId('AssetHubPolkadot')).slice(2)]],
3981
3964
  // Assets including fee and the ERC20 asset, with fee be the first
@@ -3986,10 +3969,10 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
3986
3969
  0,
3987
3970
  // The TransferType corresponding to fee asset
3988
3971
  2, customXcmOnDest]);
3989
- case 54:
3972
+ case 47:
3990
3973
  tx = _context.sent;
3991
- return _context.abrupt("return", _typeof(tx) === 'object' ? tx.hash : tx);
3992
- case 56:
3974
+ return _context.abrupt("return", tx);
3975
+ case 49:
3993
3976
  case "end":
3994
3977
  return _context.stop();
3995
3978
  }
@@ -6333,30 +6316,24 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
6333
6316
  }
6334
6317
  throw new BridgeHaltedError();
6335
6318
  case 6:
6336
- if (ethers.isAddress(address)) {
6337
- _context2.next = 8;
6338
- break;
6339
- }
6340
- throw new InvalidParameterError('Only Ethereum addresses are supported for Ethereum transfers');
6341
- case 8:
6342
6319
  if (isForeignAsset(asset)) {
6343
- _context2.next = 10;
6320
+ _context2.next = 8;
6344
6321
  break;
6345
6322
  }
6346
6323
  throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
6347
- case 10:
6324
+ case 8:
6348
6325
  if (asset.multiLocation) {
6349
- _context2.next = 12;
6326
+ _context2.next = 10;
6350
6327
  break;
6351
6328
  }
6352
6329
  throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multiLocation"));
6353
- case 12:
6330
+ case 10:
6354
6331
  if (!(asset.symbol === this.getNativeAssetSymbol() || asset.symbol === getNativeAssetSymbol('Kusama'))) {
6355
- _context2.next = 14;
6332
+ _context2.next = 12;
6356
6333
  break;
6357
6334
  }
6358
6335
  return _context2.abrupt("return", this.handleEthBridgeNativeTransfer(input));
6359
- case 14:
6336
+ case 12:
6360
6337
  modifiedInput = _objectSpread2(_objectSpread2({}, input), {}, {
6361
6338
  header: createVersionedDestination(scenario, this.version, destination, paraIdTo, ETHEREUM_JUNCTION, Parents.TWO),
6362
6339
  addressSelection: createVersionedBeneficiary({
@@ -6370,7 +6347,7 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
6370
6347
  currencySelection: createVersionedMultiAssets(Version.V3, asset.amount, asset.multiLocation)
6371
6348
  });
6372
6349
  return _context2.abrupt("return", PolkadotXCMTransferImpl.transferPolkadotXCM(modifiedInput, 'transfer_assets', 'Unlimited'));
6373
- case 16:
6350
+ case 14:
6374
6351
  case "end":
6375
6352
  return _context2.stop();
6376
6353
  }
@@ -8189,7 +8166,7 @@ var getDestination = function getDestination(_ref) {
8189
8166
  if (isMultiLocation) {
8190
8167
  return recipientAddress;
8191
8168
  }
8192
- var isEthAddress = ethers.isAddress(recipientAddress);
8169
+ var isEthAddress = isAddress(recipientAddress);
8193
8170
  var addressJunction = isEthAddress ? {
8194
8171
  AccountKey20: {
8195
8172
  key: recipientAddress
@@ -8605,7 +8582,7 @@ var buildBeneficiaryInput = function buildBeneficiaryInput(api, address) {
8605
8582
  if (isTMultiLocation(address)) {
8606
8583
  return address;
8607
8584
  }
8608
- var isEthAddress = ethers.isAddress(address);
8585
+ var isEthAddress = isAddress(address);
8609
8586
  return {
8610
8587
  parents: Parents.ZERO,
8611
8588
  interior: {
@@ -8921,22 +8898,29 @@ var getTransferableAmount = /*#__PURE__*/function () {
8921
8898
  };
8922
8899
  }();
8923
8900
 
8924
- var ETH_RPC = 'https://ethereum.publicnode.com/';
8925
- var ETH_ID = 1;
8926
- var ERC20_ABI = ['function balanceOf(address) view returns (uint256)'];
8927
- function getEthErc20Balance(_x, _x2) {
8928
- return _getEthErc20Balance.apply(this, arguments);
8929
- }
8930
- function _getEthErc20Balance() {
8931
- _getEthErc20Balance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(currency, address) {
8932
- var _rpc$id, rpc, id, asset, provider, tokenAddress, token;
8901
+ var ERC20_ABI = [{
8902
+ type: 'function',
8903
+ name: 'balanceOf',
8904
+ stateMutability: 'view',
8905
+ inputs: [{
8906
+ name: 'account',
8907
+ type: 'address'
8908
+ }],
8909
+ outputs: [{
8910
+ name: '',
8911
+ type: 'uint256'
8912
+ }]
8913
+ }];
8914
+ var getEthErc20Balance = /*#__PURE__*/function () {
8915
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(currency, address) {
8916
+ var client, asset;
8933
8917
  return _regeneratorRuntime().wrap(function _callee$(_context) {
8934
8918
  while (1) switch (_context.prev = _context.next) {
8935
8919
  case 0:
8936
- _rpc$id = {
8937
- rpc: ETH_RPC,
8938
- id: ETH_ID
8939
- }, rpc = _rpc$id.rpc, id = _rpc$id.id;
8920
+ client = createPublicClient({
8921
+ chain: mainnet,
8922
+ transport: http('https://ethereum.publicnode.com/')
8923
+ });
8940
8924
  asset = findAssetForNodeOrThrow('Ethereum', currency, null);
8941
8925
  if (!(!isForeignAsset(asset) || !asset.assetId)) {
8942
8926
  _context.next = 4;
@@ -8944,30 +8928,36 @@ function _getEthErc20Balance() {
8944
8928
  }
8945
8929
  throw new InvalidParameterError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset."));
8946
8930
  case 4:
8947
- provider = new ethers.JsonRpcProvider(rpc, id);
8948
8931
  if (!(asset.symbol === 'ETH')) {
8949
- _context.next = 9;
8932
+ _context.next = 8;
8950
8933
  break;
8951
8934
  }
8952
- _context.next = 8;
8953
- return provider.getBalance(address);
8954
- case 8:
8935
+ _context.next = 7;
8936
+ return client.getBalance({
8937
+ address: address
8938
+ });
8939
+ case 7:
8955
8940
  return _context.abrupt("return", _context.sent);
8956
- case 9:
8957
- tokenAddress = asset.assetId;
8958
- token = new ethers.Contract(tokenAddress, ERC20_ABI, provider);
8959
- _context.next = 13;
8960
- return token.balanceOf(address);
8961
- case 13:
8941
+ case 8:
8942
+ _context.next = 10;
8943
+ return client.readContract({
8944
+ address: asset.assetId,
8945
+ abi: ERC20_ABI,
8946
+ functionName: 'balanceOf',
8947
+ args: [address]
8948
+ });
8949
+ case 10:
8962
8950
  return _context.abrupt("return", _context.sent);
8963
- case 14:
8951
+ case 11:
8964
8952
  case "end":
8965
8953
  return _context.stop();
8966
8954
  }
8967
8955
  }, _callee);
8968
8956
  }));
8969
- return _getEthErc20Balance.apply(this, arguments);
8970
- }
8957
+ return function getEthErc20Balance(_x, _x2) {
8958
+ return _ref.apply(this, arguments);
8959
+ };
8960
+ }();
8971
8961
 
8972
8962
  var buildDestInfo = /*#__PURE__*/function () {
8973
8963
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
@@ -10286,4 +10276,4 @@ var Builder = function Builder(api) {
10286
10276
  return new GeneralBuilder(api, new BatchTransactionManager());
10287
10277
  };
10288
10278
 
10289
- 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, TransferToAhNotSupported, UnableToComputeError, 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, getNode, getNodeConfig, getNodeProviders, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getParaEthTransferFees, getParaId, getTNode, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, isEthersContract, isEthersSigner, replaceBigInt, resolveModuleError, resolveParaId, reverseTransformMultiLocation, send, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, transformMultiLocation, validateAddress, verifyEdOnDestination };
10279
+ 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, TransferToAhNotSupported, UnableToComputeError, 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, getNode, getNodeConfig, getNodeProviders, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getParaEthTransferFees, getParaId, getTNode, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, replaceBigInt, resolveModuleError, resolveParaId, reverseTransformMultiLocation, 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": "10.1.7",
3
+ "version": "10.3.0",
4
4
  "description": "SDK core for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,11 +25,10 @@
25
25
  "dependencies": {
26
26
  "@noble/hashes": "^1.8.0",
27
27
  "@scure/base": "^1.2.5",
28
- "ethers": "^6.13.7",
29
28
  "viem": "^2.28.1",
30
- "@paraspell/assets": "10.1.7",
31
- "@paraspell/pallets": "10.1.7",
32
- "@paraspell/sdk-common": "10.1.7"
29
+ "@paraspell/assets": "10.3.0",
30
+ "@paraspell/sdk-common": "10.3.0",
31
+ "@paraspell/pallets": "10.3.0"
33
32
  },
34
33
  "devDependencies": {
35
34
  "@babel/plugin-syntax-import-attributes": "^7.27.1",