@paraspell/sdk-pjs 8.2.0 → 8.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -220,10 +220,10 @@ const result = await Builder(API /*optional*/)
220
220
  .to(NODE_2)
221
221
  .currency({id: currencyID, amount: amount} | {symbol: currencySymbol, amount: amount} | {symbol: Native('currencySymbol'), amount: amount} | {symbol: Foreign('currencySymbol'), amount: amount} | {symbol: ForeignAbstract('currencySymbol'), amount: amount} | {multilocation: AssetMultilocationString, amount: amount | AssetMultilocationJson, amount: amount} | {multilocation: Override('Custom Multilocation'), amount: amount} | {multiasset: {currencySelection, isFeeAsset?: true /* for example symbol: symbol or id: id, or multilocation: multilocation*/, amount: amount}})
222
222
  .address(ADDRESS)
223
- .dryRun()
223
+ .dryRun(SENDER_ADDRESS)
224
224
 
225
225
  //Function pattern
226
- getDryRun({api /*optional*/, node, address, tx /* Extrinsic object */})
226
+ getDryRun({api /*optional*/, node, address /*sender address*/, tx /* Extrinsic object */})
227
227
  ```
228
228
 
229
229
  ### Asset claim:
package/dist/index.cjs CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  var sdkCore = require('@paraspell/sdk-core');
4
4
  var api = require('@snowbridge/api');
5
+ var contractTypes = require('@snowbridge/contract-types');
5
6
  var api$1 = require('@polkadot/api');
6
7
  var types = require('@polkadot/types');
7
8
  var utilCrypto = require('@polkadot/util-crypto');
@@ -445,46 +446,23 @@ function _unsupportedIterableToArray(r, a) {
445
446
  }
446
447
  }
447
448
 
448
- var createContext = /*#__PURE__*/function () {
449
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(executionUrl, config) {
450
- return _regeneratorRuntime().wrap(function _callee$(_context) {
451
- while (1) switch (_context.prev = _context.next) {
452
- case 0:
453
- return _context.abrupt("return", api.contextFactory({
454
- ethereum: {
455
- execution_url: executionUrl,
456
- beacon_url: config.BEACON_HTTP_API
457
- },
458
- polkadot: {
459
- url: {
460
- bridgeHub: config.BRIDGE_HUB_URL,
461
- assetHub: config.ASSET_HUB_URL,
462
- relaychain: config.RELAY_CHAIN_URL,
463
- parachains: config.PARACHAINS
464
- }
465
- },
466
- appContracts: {
467
- gateway: config.GATEWAY_CONTRACT,
468
- beefy: config.BEEFY_CONTRACT
469
- }
470
- }));
471
- case 1:
472
- case "end":
473
- return _context.stop();
474
- }
475
- }, _callee);
476
- }));
477
- return function createContext(_x, _x2) {
478
- return _ref.apply(this, arguments);
479
- };
480
- }();
481
-
482
- var checkPlanFailure = function checkPlanFailure(plan) {
483
- if (plan.failure) {
484
- throw new Error("Failed to validate send: ".concat(plan.failure.errors.map(function (e) {
485
- return e.message;
486
- }).join('\n\n')));
487
- }
449
+ var createContext = function createContext(executionUrl, config) {
450
+ return new api.Context({
451
+ ethereum: {
452
+ execution_url: executionUrl,
453
+ beacon_url: config.BEACON_HTTP_API
454
+ },
455
+ polkadot: {
456
+ assetHubParaId: config.ASSET_HUB_PARAID,
457
+ bridgeHubParaId: config.BRIDGE_HUB_PARAID,
458
+ relaychain: config.RELAY_CHAIN_URL,
459
+ parachains: config.PARACHAINS
460
+ },
461
+ appContracts: {
462
+ gateway: config.GATEWAY_CONTRACT,
463
+ beefy: config.BEEFY_CONTRACT
464
+ }
465
+ });
488
466
  };
489
467
 
490
468
  var isEthersSigner = function isEthersSigner(signer) {
@@ -503,7 +481,7 @@ var isEthersSigner = function isEthersSigner(signer) {
503
481
  */
504
482
  var transferEthToPolkadot$1 = /*#__PURE__*/function () {
505
483
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
506
- var provider, signer, address, to, currency, ethAsset, env, context, destParaId, plan, result;
484
+ var provider, signer, address, to, currency, ethAsset, env, context, destParaId, overrides, registry, fee, sourceAddress, transfer, validation, tx, response, receipt, messageReceipt;
507
485
  return _regeneratorRuntime().wrap(function _callee$(_context) {
508
486
  while (1) switch (_context.prev = _context.next) {
509
487
  case 0:
@@ -540,31 +518,138 @@ var transferEthToPolkadot$1 = /*#__PURE__*/function () {
540
518
  throw new sdkCore.InvalidCurrencyError("Origin node Ethereum does not support currency ".concat(JSON.stringify(currency), "."));
541
519
  case 12:
542
520
  env = api.environment.SNOWBRIDGE_ENV['polkadot_mainnet'];
543
- _context.next = 15;
544
- return createContext(provider, env.config);
545
- case 15:
546
- context = _context.sent;
521
+ context = createContext(provider, env.config);
547
522
  destParaId = sdkCore.getParaId(to);
548
523
  if (!(!sdkCore.isForeignAsset(ethAsset) || ethAsset.assetId === undefined)) {
549
- _context.next = 19;
524
+ _context.next = 17;
550
525
  break;
551
526
  }
552
527
  throw new sdkCore.InvalidCurrencyError('Selected asset has no asset id');
553
- case 19:
554
- _context.next = 21;
555
- return api.toPolkadot.validateSend(context, signer, address, ethAsset.assetId, destParaId, BigInt(currency.amount), 0n);
556
- case 21:
557
- plan = _context.sent;
558
- checkPlanFailure(plan);
559
- _context.next = 25;
560
- return api.toPolkadot.send(context, signer, plan);
561
- case 25:
562
- result = _context.sent;
528
+ case 17:
529
+ overrides = {
530
+ precompiles: {
531
+ '2004': '0x000000000000000000000000000000000000081A'
532
+ },
533
+ destinationFeeOverrides: {
534
+ '3369': 500000000n
535
+ },
536
+ assetOverrides: {
537
+ '3369': [{
538
+ token: '0xba41ddf06b7ffd89d1267b5a93bfef2424eb2003'.toLowerCase(),
539
+ name: 'Mythos',
540
+ minimumBalance: 10000000000000000n,
541
+ symbol: 'MYTH',
542
+ decimals: 18,
543
+ isSufficient: true
544
+ }]
545
+ }
546
+ };
547
+ _context.t0 = api.assetsV2;
548
+ _context.t1 = _objectSpread2;
549
+ _context.t2 = _objectSpread2;
550
+ _context.t3 = {};
551
+ _context.next = 24;
552
+ return api.assetsV2.fromContext(context);
553
+ case 24:
554
+ _context.t4 = _context.sent;
555
+ _context.t5 = (0, _context.t2)(_context.t3, _context.t4);
556
+ _context.t6 = overrides;
557
+ _context.t7 = (0, _context.t1)(_context.t5, _context.t6);
558
+ _context.next = 30;
559
+ return _context.t0.buildRegistry.call(_context.t0, _context.t7);
560
+ case 30:
561
+ registry = _context.sent;
562
+ _context.next = 33;
563
+ return api.toPolkadotV2.getDeliveryFee(context.gateway(), registry, ethAsset.assetId, destParaId);
564
+ case 33:
565
+ fee = _context.sent;
566
+ _context.next = 36;
567
+ return signer.getAddress();
568
+ case 36:
569
+ sourceAddress = _context.sent;
570
+ _context.next = 39;
571
+ return api.toPolkadotV2.createTransfer(registry, sourceAddress, address, ethAsset.assetId, destParaId, BigInt(currency.amount), fee);
572
+ case 39:
573
+ transfer = _context.sent;
574
+ _context.t8 = api.toPolkadotV2;
575
+ _context.t9 = context.ethereum();
576
+ _context.t10 = context.gateway();
577
+ _context.next = 45;
578
+ return context.bridgeHub();
579
+ case 45:
580
+ _context.t11 = _context.sent;
581
+ _context.next = 48;
582
+ return context.assetHub();
583
+ case 48:
584
+ _context.t12 = _context.sent;
585
+ if (!(destParaId !== sdkCore.getParaId('AssetHubPolkadot'))) {
586
+ _context.next = 55;
587
+ break;
588
+ }
589
+ _context.next = 52;
590
+ return context.parachain(destParaId);
591
+ case 52:
592
+ _context.t13 = _context.sent;
593
+ _context.next = 56;
594
+ break;
595
+ case 55:
596
+ _context.t13 = undefined;
597
+ case 56:
598
+ _context.t14 = _context.t13;
599
+ _context.t15 = {
600
+ ethereum: _context.t9,
601
+ gateway: _context.t10,
602
+ bridgeHub: _context.t11,
603
+ assetHub: _context.t12,
604
+ destParachain: _context.t14
605
+ };
606
+ _context.t16 = transfer;
607
+ _context.next = 61;
608
+ return _context.t8.validateTransfer.call(_context.t8, _context.t15, _context.t16);
609
+ case 61:
610
+ validation = _context.sent;
611
+ if (!validation.logs.find(function (l) {
612
+ return l.kind == api.toPolkadotV2.ValidationKind.Error;
613
+ })) {
614
+ _context.next = 64;
615
+ break;
616
+ }
617
+ throw Error("Validation failed with following errors: \n\n ".concat(validation.logs.filter(function (l) {
618
+ return l.kind == api.toPolkadotV2.ValidationKind.Error;
619
+ }).map(function (l) {
620
+ return l.message;
621
+ }).join('\n\n')));
622
+ case 64:
623
+ tx = transfer.tx;
624
+ _context.next = 67;
625
+ return signer.sendTransaction(tx);
626
+ case 67:
627
+ response = _context.sent;
628
+ _context.next = 70;
629
+ return response.wait(1);
630
+ case 70:
631
+ receipt = _context.sent;
632
+ if (receipt) {
633
+ _context.next = 73;
634
+ break;
635
+ }
636
+ throw Error("Transaction ".concat(response.hash, " not included."));
637
+ case 73:
638
+ _context.next = 75;
639
+ return api.toPolkadotV2.getMessageReceipt(receipt);
640
+ case 75:
641
+ messageReceipt = _context.sent;
642
+ if (messageReceipt) {
643
+ _context.next = 78;
644
+ break;
645
+ }
646
+ throw Error("Transaction ".concat(receipt.hash, " did not emit a message."));
647
+ case 78:
563
648
  return _context.abrupt("return", {
564
- result: result,
565
- plan: plan
649
+ response: response,
650
+ messageReceipt: messageReceipt
566
651
  });
567
- case 27:
652
+ case 79:
568
653
  case "end":
569
654
  return _context.stop();
570
655
  }
@@ -575,76 +660,118 @@ var transferEthToPolkadot$1 = /*#__PURE__*/function () {
575
660
  };
576
661
  }();
577
662
 
578
- var buildEthTransferOptions = /*#__PURE__*/function () {
579
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
580
- var currency, to, address, destAddress, ethAsset, env, EXECUTION_URL, context, destParaId, signer, plan;
663
+ var depositToken = /*#__PURE__*/function () {
664
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(signer, amount, symbol) {
665
+ var env, contract, weth9, result, receipt;
581
666
  return _regeneratorRuntime().wrap(function _callee$(_context) {
582
667
  while (1) switch (_context.prev = _context.next) {
583
668
  case 0:
584
- currency = _ref.currency, to = _ref.to, address = _ref.address, destAddress = _ref.destAddress;
585
- if (!('multiasset' in currency)) {
586
- _context.next = 3;
587
- break;
588
- }
589
- throw new Error('Multiassets syntax is not supported for Evm transfers');
590
- case 3:
591
- if (!('multilocation' in currency && sdkCore.isOverrideMultiLocationSpecifier(currency.multilocation))) {
592
- _context.next = 5;
593
- break;
594
- }
595
- throw new Error('Override multilocation is not supported for Evm transfers');
596
- case 5:
597
- ethAsset = sdkCore.getAssetBySymbolOrId('Ethereum', currency, to);
598
- if (!(ethAsset === null)) {
599
- _context.next = 8;
600
- break;
601
- }
602
- throw new sdkCore.InvalidCurrencyError("Origin node Ethereum does not support currency ".concat(JSON.stringify(currency), "."));
603
- case 8:
604
669
  env = api.environment.SNOWBRIDGE_ENV['polkadot_mainnet'];
605
- EXECUTION_URL = 'https://eth.llamarpc.com';
606
- _context.next = 12;
607
- return createContext(EXECUTION_URL, env.config);
608
- case 12:
609
- context = _context.sent;
610
- destParaId = sdkCore.getParaId(to);
611
- signer = {
612
- getAddress: function getAddress() {
613
- return Promise.resolve(address);
614
- }
615
- };
616
- if (!(!sdkCore.isForeignAsset(ethAsset) || ethAsset.assetId === undefined)) {
617
- _context.next = 17;
670
+ contract = env.locations[0].erc20tokensReceivable.find(function (t) {
671
+ return t.id === symbol;
672
+ });
673
+ if (contract) {
674
+ _context.next = 4;
618
675
  break;
619
676
  }
620
- throw new sdkCore.InvalidCurrencyError('Selected asset has no asset id');
621
- case 17:
622
- _context.next = 19;
623
- return api.toPolkadot.validateSend(context, signer, destAddress, ethAsset.assetId, destParaId, BigInt(currency.amount), 0n);
624
- case 19:
625
- plan = _context.sent;
626
- checkPlanFailure(plan);
627
- if (plan.success) {
628
- _context.next = 23;
677
+ throw new Error("Token ".concat(symbol, " not supported"));
678
+ case 4:
679
+ weth9 = contractTypes.WETH9__factory.connect(contract.address, signer);
680
+ _context.next = 7;
681
+ return weth9.deposit({
682
+ value: amount
683
+ });
684
+ case 7:
685
+ result = _context.sent;
686
+ _context.next = 10;
687
+ return result.wait();
688
+ case 10:
689
+ receipt = _context.sent;
690
+ return _context.abrupt("return", {
691
+ result: result,
692
+ receipt: receipt
693
+ });
694
+ case 12:
695
+ case "end":
696
+ return _context.stop();
697
+ }
698
+ }, _callee);
699
+ }));
700
+ return function depositToken(_x, _x2, _x3) {
701
+ return _ref.apply(this, arguments);
702
+ };
703
+ }();
704
+
705
+ var approveToken = /*#__PURE__*/function () {
706
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(signer, amount, symbol) {
707
+ var env, contract, weth9, result, receipt;
708
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
709
+ while (1) switch (_context.prev = _context.next) {
710
+ case 0:
711
+ env = api.environment.SNOWBRIDGE_ENV['polkadot_mainnet'];
712
+ contract = env.locations[0].erc20tokensReceivable.find(function (t) {
713
+ return t.id === symbol;
714
+ });
715
+ if (contract) {
716
+ _context.next = 4;
629
717
  break;
630
718
  }
631
- throw new Error('Failed to validate send');
632
- case 23:
719
+ throw new Error("Token ".concat(symbol, " not supported"));
720
+ case 4:
721
+ weth9 = contractTypes.WETH9__factory.connect(contract.address, signer);
722
+ _context.next = 7;
723
+ return weth9.approve(env.config.GATEWAY_CONTRACT, amount);
724
+ case 7:
725
+ result = _context.sent;
726
+ _context.next = 10;
727
+ return result.wait();
728
+ case 10:
729
+ receipt = _context.sent;
633
730
  return _context.abrupt("return", {
634
- token: plan.success.token,
635
- destinationParaId: plan.success.destinationParaId,
636
- destinationFee: plan.success.destinationFee,
637
- amount: plan.success.amount,
638
- fee: plan.success.fee
731
+ result: result,
732
+ receipt: receipt
639
733
  });
640
- case 24:
734
+ case 12:
641
735
  case "end":
642
736
  return _context.stop();
643
737
  }
644
738
  }, _callee);
645
739
  }));
646
- return function buildEthTransferOptions(_x) {
647
- return _ref2.apply(this, arguments);
740
+ return function approveToken(_x, _x2, _x3) {
741
+ return _ref.apply(this, arguments);
742
+ };
743
+ }();
744
+
745
+ var getTokenBalance = /*#__PURE__*/function () {
746
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(signer, symbol) {
747
+ var env, contract, weth9, address;
748
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
749
+ while (1) switch (_context.prev = _context.next) {
750
+ case 0:
751
+ env = api.environment.SNOWBRIDGE_ENV['polkadot_mainnet'];
752
+ contract = env.locations[0].erc20tokensReceivable.find(function (t) {
753
+ return t.id === symbol;
754
+ });
755
+ if (contract) {
756
+ _context.next = 4;
757
+ break;
758
+ }
759
+ throw new Error("Token ".concat(symbol, " not supported"));
760
+ case 4:
761
+ weth9 = contractTypes.WETH9__factory.connect(contract.address, signer);
762
+ _context.next = 7;
763
+ return signer.getAddress();
764
+ case 7:
765
+ address = _context.sent;
766
+ return _context.abrupt("return", weth9.balanceOf(address));
767
+ case 9:
768
+ case "end":
769
+ return _context.stop();
770
+ }
771
+ }, _callee);
772
+ }));
773
+ return function getTokenBalance(_x, _x2) {
774
+ return _ref.apply(this, arguments);
648
775
  };
649
776
  }();
650
777
 
@@ -1254,8 +1381,10 @@ var transferEthToPolkadot = function transferEthToPolkadot(options) {
1254
1381
 
1255
1382
  var transfer = /*#__PURE__*/Object.freeze({
1256
1383
  __proto__: null,
1257
- buildEthTransferOptions: buildEthTransferOptions,
1384
+ approveToken: approveToken,
1385
+ depositToken: depositToken,
1258
1386
  getDryRun: getDryRun,
1387
+ getTokenBalance: getTokenBalance,
1259
1388
  send: send,
1260
1389
  transferEthToPolkadot: transferEthToPolkadot
1261
1390
  });
@@ -1400,8 +1529,7 @@ var EvmBuilderClass = /*#__PURE__*/function () {
1400
1529
  key: "build",
1401
1530
  value: (function () {
1402
1531
  var _build = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1403
- var _yield$transferEthToP, _yield$transferEthToP2;
1404
- var requiredParams, _i, _requiredParams, param;
1532
+ var requiredParams, _i, _requiredParams, param, _yield$transferEthToP, response;
1405
1533
  return _regeneratorRuntime().wrap(function _callee$(_context) {
1406
1534
  while (1) switch (_context.prev = _context.next) {
1407
1535
  case 0:
@@ -1435,44 +1563,10 @@ var EvmBuilderClass = /*#__PURE__*/function () {
1435
1563
  _context.next = 15;
1436
1564
  return transferEthToPolkadot$1(this._options);
1437
1565
  case 15:
1438
- _context.t2 = _yield$transferEthToP2 = _context.sent.result.success;
1439
- _context.t1 = _context.t2 === null;
1440
- if (_context.t1) {
1441
- _context.next = 19;
1442
- break;
1443
- }
1444
- _context.t1 = _yield$transferEthToP2 === undefined;
1445
- case 19:
1446
- if (!_context.t1) {
1447
- _context.next = 23;
1448
- break;
1449
- }
1450
- _context.t3 = undefined;
1451
- _context.next = 24;
1452
- break;
1453
- case 23:
1454
- _context.t3 = _yield$transferEthToP2.ethereum.blockHash;
1455
- case 24:
1456
- _context.t4 = _yield$transferEthToP = _context.t3;
1457
- _context.t0 = _context.t4 !== null;
1458
- if (!_context.t0) {
1459
- _context.next = 28;
1460
- break;
1461
- }
1462
- _context.t0 = _yield$transferEthToP !== undefined;
1463
- case 28:
1464
- if (!_context.t0) {
1465
- _context.next = 32;
1466
- break;
1467
- }
1468
- _context.t5 = _yield$transferEthToP;
1469
- _context.next = 33;
1470
- break;
1471
- case 32:
1472
- _context.t5 = '';
1473
- case 33:
1474
- return _context.abrupt("return", _context.t5);
1475
- case 34:
1566
+ _yield$transferEthToP = _context.sent;
1567
+ response = _yield$transferEthToP.response;
1568
+ return _context.abrupt("return", response.hash);
1569
+ case 18:
1476
1570
  case "end":
1477
1571
  return _context.stop();
1478
1572
  }
@@ -1515,10 +1609,11 @@ var EvmBuilder = function EvmBuilder(provider) {
1515
1609
  exports.Builder = Builder;
1516
1610
  exports.EvmBuilder = EvmBuilder;
1517
1611
  exports.GeneralBuilder = GeneralBuilder;
1612
+ exports.approveToken = approveToken;
1518
1613
  exports.assets = assets;
1519
- exports.buildEthTransferOptions = buildEthTransferOptions;
1520
1614
  exports.claimAssets = claimAssets;
1521
1615
  exports.createApiInstanceForNode = createApiInstanceForNode;
1616
+ exports.depositToken = depositToken;
1522
1617
  exports.getAssetBalance = getAssetBalance;
1523
1618
  exports.getBalanceForeign = getBalanceForeign;
1524
1619
  exports.getBalanceNative = getBalanceNative;
@@ -1526,6 +1621,7 @@ exports.getDryRun = getDryRun;
1526
1621
  exports.getMaxForeignTransferableAmount = getMaxForeignTransferableAmount;
1527
1622
  exports.getMaxNativeTransferableAmount = getMaxNativeTransferableAmount;
1528
1623
  exports.getOriginFeeDetails = getOriginFeeDetails;
1624
+ exports.getTokenBalance = getTokenBalance;
1529
1625
  exports.getTransferInfo = getTransferInfo;
1530
1626
  exports.getTransferableAmount = getTransferableAmount;
1531
1627
  exports.send = send;
package/dist/index.d.ts CHANGED
@@ -1,18 +1,29 @@
1
1
  import * as _paraspell_sdk_core from '@paraspell/sdk-core';
2
- import { TApiOrUrl, TSerializeEthTransferOptions, TSerializedEthTransfer, TEvmBuilderOptions, Foreign, ForeignAbstract, Native, Override, getAllAssetsSymbols, getAssetBySymbolOrId, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTNode, hasSupportForAsset, isNodeEvm, TOptionalEvmBuilderOptions, IPolkadotApi, TNodeDotKsmWithRelayChains, TCurrencyInputWithAmount, GeneralBuilder as GeneralBuilder$1, IFinalBuilderWithOptions as IFinalBuilderWithOptions$1 } from '@paraspell/sdk-core';
2
+ import { TApiOrUrl, TEvmBuilderOptions, Foreign, ForeignAbstract, Native, Override, getAllAssetsSymbols, getAssetBySymbolOrId, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTNode, hasSupportForAsset, isNodeEvm, TOptionalEvmBuilderOptions, IPolkadotApi, TNodeDotKsmWithRelayChains, TCurrencyInputWithAmount, GeneralBuilder as GeneralBuilder$1, IFinalBuilderWithOptions as IFinalBuilderWithOptions$1 } from '@paraspell/sdk-core';
3
3
  export * from '@paraspell/sdk-core';
4
- import * as _snowbridge_api_dist_toPolkadot from '@snowbridge/api/dist/toPolkadot';
4
+ import * as _snowbridge_api_dist_toPolkadot_v2 from '@snowbridge/api/dist/toPolkadot_v2';
5
+ import * as ethers from 'ethers';
6
+ import { Signer, AbstractProvider } from 'ethers';
5
7
  import { SubmittableExtrinsic } from '@polkadot/api/types';
6
8
  import * as _polkadot_api from '@polkadot/api';
7
9
  import { ApiPromise } from '@polkadot/api';
8
- import { AbstractProvider, Signer } from 'ethers';
9
10
  import { WalletClient } from 'viem';
10
11
 
11
12
  type TPjsApi = ApiPromise;
12
13
  type TPjsApiOrUrl = TApiOrUrl<TPjsApi>;
13
14
  type Extrinsic = SubmittableExtrinsic<'promise'>;
14
15
 
15
- declare const buildEthTransferOptions: ({ currency, to, address, destAddress }: TSerializeEthTransferOptions) => Promise<TSerializedEthTransfer>;
16
+ declare const depositToken: (signer: Signer, amount: bigint, symbol: string) => Promise<{
17
+ result: ethers.ContractTransactionResponse;
18
+ receipt: ethers.ContractTransactionReceipt | null;
19
+ }>;
20
+
21
+ declare const approveToken: (signer: Signer, amount: bigint, symbol: string) => Promise<{
22
+ result: ethers.ContractTransactionResponse;
23
+ receipt: ethers.ContractTransactionReceipt | null;
24
+ }>;
25
+
26
+ declare const getTokenBalance: (signer: Signer, symbol: string) => Promise<bigint>;
16
27
 
17
28
  /**
18
29
  * Transfers assets from parachain to another parachain or from/to relay chain.
@@ -29,16 +40,18 @@ declare const getDryRun: (options: _paraspell_sdk_core.TDryRunBaseOptions<Extrin
29
40
  api?: TPjsApiOrUrl;
30
41
  }) => Promise<_paraspell_sdk_core.TDryRunResult>;
31
42
  declare const transferEthToPolkadot: (options: Omit<TEvmBuilderOptions<TPjsApi, Extrinsic>, "api">) => Promise<{
32
- result: _snowbridge_api_dist_toPolkadot.SendResult;
33
- plan: _snowbridge_api_dist_toPolkadot.SendValidationResult;
43
+ response: ethers.TransactionResponse;
44
+ messageReceipt: _snowbridge_api_dist_toPolkadot_v2.MessageReceipt;
34
45
  }>;
35
46
 
36
- declare const transfer_buildEthTransferOptions: typeof buildEthTransferOptions;
47
+ declare const transfer_approveToken: typeof approveToken;
48
+ declare const transfer_depositToken: typeof depositToken;
37
49
  declare const transfer_getDryRun: typeof getDryRun;
50
+ declare const transfer_getTokenBalance: typeof getTokenBalance;
38
51
  declare const transfer_send: typeof send;
39
52
  declare const transfer_transferEthToPolkadot: typeof transferEthToPolkadot;
40
53
  declare namespace transfer {
41
- export { transfer_buildEthTransferOptions as buildEthTransferOptions, transfer_getDryRun as getDryRun, transfer_send as send, transfer_transferEthToPolkadot as transferEthToPolkadot };
54
+ export { transfer_approveToken as approveToken, transfer_depositToken as depositToken, transfer_getDryRun as getDryRun, transfer_getTokenBalance as getTokenBalance, transfer_send as send, transfer_transferEthToPolkadot as transferEthToPolkadot };
42
55
  }
43
56
 
44
57
  /**
@@ -195,4 +208,4 @@ type IFinalBuilderWithOptions = IFinalBuilderWithOptions$1<TPjsApi, Extrinsic>;
195
208
 
196
209
  declare const createApiInstanceForNode: (node: TNodeDotKsmWithRelayChains) => Promise<_polkadot_api.ApiPromise>;
197
210
 
198
- export { Builder, EvmBuilder, type Extrinsic, GeneralBuilder, type IFinalBuilderWithOptions, type TPjsApi, type TPjsApiOrUrl, assets, buildEthTransferOptions, claimAssets, createApiInstanceForNode, getAssetBalance, getBalanceForeign, getBalanceNative, getDryRun, getMaxForeignTransferableAmount, getMaxNativeTransferableAmount, getOriginFeeDetails, getTransferInfo, getTransferableAmount, send, transferEthToPolkadot, transfer as xcmPallet };
211
+ export { Builder, EvmBuilder, type Extrinsic, GeneralBuilder, type IFinalBuilderWithOptions, type TPjsApi, type TPjsApiOrUrl, approveToken, assets, claimAssets, createApiInstanceForNode, depositToken, getAssetBalance, getBalanceForeign, getBalanceNative, getDryRun, getMaxForeignTransferableAmount, getMaxNativeTransferableAmount, getOriginFeeDetails, getTokenBalance, getTransferInfo, getTransferableAmount, send, transferEthToPolkadot, transfer as xcmPallet };
package/dist/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import { getParaId, isForeignAsset, InvalidCurrencyError, getAssetBySymbolOrId, isOverrideMultiLocationSpecifier, BatchMode, createApiInstanceForNode as createApiInstanceForNode$1, getNode, computeFeeFromDryRunPjs, resolveModuleError, getAssetsObject, send as send$1, getDryRun as getDryRun$1, getBalanceNative as getBalanceNative$1, getBalanceForeign as getBalanceForeign$1, getTransferInfo as getTransferInfo$1, getAssetBalance as getAssetBalance$1, claimAssets as claimAssets$1, getOriginFeeDetails as getOriginFeeDetails$1, getMaxNativeTransferableAmount as getMaxNativeTransferableAmount$1, getMaxForeignTransferableAmount as getMaxForeignTransferableAmount$1, getTransferableAmount as getTransferableAmount$1, Foreign, ForeignAbstract, Native, Override, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTNode, hasSupportForAsset, isNodeEvm, transferMoonbeamEvm, Builder as Builder$1, GeneralBuilder as GeneralBuilder$1 } from '@paraspell/sdk-core';
2
2
  export * from '@paraspell/sdk-core';
3
- import { contextFactory, toPolkadot, environment } from '@snowbridge/api';
3
+ import { Context, toPolkadotV2, assetsV2, environment } from '@snowbridge/api';
4
+ import { WETH9__factory } from '@snowbridge/contract-types';
4
5
  import { WsProvider, ApiPromise } from '@polkadot/api';
5
6
  import { u32 } from '@polkadot/types';
6
7
  import { decodeAddress } from '@polkadot/util-crypto';
@@ -444,46 +445,23 @@ function _unsupportedIterableToArray(r, a) {
444
445
  }
445
446
  }
446
447
 
447
- var createContext = /*#__PURE__*/function () {
448
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(executionUrl, config) {
449
- return _regeneratorRuntime().wrap(function _callee$(_context) {
450
- while (1) switch (_context.prev = _context.next) {
451
- case 0:
452
- return _context.abrupt("return", contextFactory({
453
- ethereum: {
454
- execution_url: executionUrl,
455
- beacon_url: config.BEACON_HTTP_API
456
- },
457
- polkadot: {
458
- url: {
459
- bridgeHub: config.BRIDGE_HUB_URL,
460
- assetHub: config.ASSET_HUB_URL,
461
- relaychain: config.RELAY_CHAIN_URL,
462
- parachains: config.PARACHAINS
463
- }
464
- },
465
- appContracts: {
466
- gateway: config.GATEWAY_CONTRACT,
467
- beefy: config.BEEFY_CONTRACT
468
- }
469
- }));
470
- case 1:
471
- case "end":
472
- return _context.stop();
473
- }
474
- }, _callee);
475
- }));
476
- return function createContext(_x, _x2) {
477
- return _ref.apply(this, arguments);
478
- };
479
- }();
480
-
481
- var checkPlanFailure = function checkPlanFailure(plan) {
482
- if (plan.failure) {
483
- throw new Error("Failed to validate send: ".concat(plan.failure.errors.map(function (e) {
484
- return e.message;
485
- }).join('\n\n')));
486
- }
448
+ var createContext = function createContext(executionUrl, config) {
449
+ return new Context({
450
+ ethereum: {
451
+ execution_url: executionUrl,
452
+ beacon_url: config.BEACON_HTTP_API
453
+ },
454
+ polkadot: {
455
+ assetHubParaId: config.ASSET_HUB_PARAID,
456
+ bridgeHubParaId: config.BRIDGE_HUB_PARAID,
457
+ relaychain: config.RELAY_CHAIN_URL,
458
+ parachains: config.PARACHAINS
459
+ },
460
+ appContracts: {
461
+ gateway: config.GATEWAY_CONTRACT,
462
+ beefy: config.BEEFY_CONTRACT
463
+ }
464
+ });
487
465
  };
488
466
 
489
467
  var isEthersSigner = function isEthersSigner(signer) {
@@ -502,7 +480,7 @@ var isEthersSigner = function isEthersSigner(signer) {
502
480
  */
503
481
  var transferEthToPolkadot$1 = /*#__PURE__*/function () {
504
482
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
505
- var provider, signer, address, to, currency, ethAsset, env, context, destParaId, plan, result;
483
+ var provider, signer, address, to, currency, ethAsset, env, context, destParaId, overrides, registry, fee, sourceAddress, transfer, validation, tx, response, receipt, messageReceipt;
506
484
  return _regeneratorRuntime().wrap(function _callee$(_context) {
507
485
  while (1) switch (_context.prev = _context.next) {
508
486
  case 0:
@@ -539,31 +517,138 @@ var transferEthToPolkadot$1 = /*#__PURE__*/function () {
539
517
  throw new InvalidCurrencyError("Origin node Ethereum does not support currency ".concat(JSON.stringify(currency), "."));
540
518
  case 12:
541
519
  env = environment.SNOWBRIDGE_ENV['polkadot_mainnet'];
542
- _context.next = 15;
543
- return createContext(provider, env.config);
544
- case 15:
545
- context = _context.sent;
520
+ context = createContext(provider, env.config);
546
521
  destParaId = getParaId(to);
547
522
  if (!(!isForeignAsset(ethAsset) || ethAsset.assetId === undefined)) {
548
- _context.next = 19;
523
+ _context.next = 17;
549
524
  break;
550
525
  }
551
526
  throw new InvalidCurrencyError('Selected asset has no asset id');
552
- case 19:
553
- _context.next = 21;
554
- return toPolkadot.validateSend(context, signer, address, ethAsset.assetId, destParaId, BigInt(currency.amount), 0n);
555
- case 21:
556
- plan = _context.sent;
557
- checkPlanFailure(plan);
558
- _context.next = 25;
559
- return toPolkadot.send(context, signer, plan);
560
- case 25:
561
- result = _context.sent;
527
+ case 17:
528
+ overrides = {
529
+ precompiles: {
530
+ '2004': '0x000000000000000000000000000000000000081A'
531
+ },
532
+ destinationFeeOverrides: {
533
+ '3369': 500000000n
534
+ },
535
+ assetOverrides: {
536
+ '3369': [{
537
+ token: '0xba41ddf06b7ffd89d1267b5a93bfef2424eb2003'.toLowerCase(),
538
+ name: 'Mythos',
539
+ minimumBalance: 10000000000000000n,
540
+ symbol: 'MYTH',
541
+ decimals: 18,
542
+ isSufficient: true
543
+ }]
544
+ }
545
+ };
546
+ _context.t0 = assetsV2;
547
+ _context.t1 = _objectSpread2;
548
+ _context.t2 = _objectSpread2;
549
+ _context.t3 = {};
550
+ _context.next = 24;
551
+ return assetsV2.fromContext(context);
552
+ case 24:
553
+ _context.t4 = _context.sent;
554
+ _context.t5 = (0, _context.t2)(_context.t3, _context.t4);
555
+ _context.t6 = overrides;
556
+ _context.t7 = (0, _context.t1)(_context.t5, _context.t6);
557
+ _context.next = 30;
558
+ return _context.t0.buildRegistry.call(_context.t0, _context.t7);
559
+ case 30:
560
+ registry = _context.sent;
561
+ _context.next = 33;
562
+ return toPolkadotV2.getDeliveryFee(context.gateway(), registry, ethAsset.assetId, destParaId);
563
+ case 33:
564
+ fee = _context.sent;
565
+ _context.next = 36;
566
+ return signer.getAddress();
567
+ case 36:
568
+ sourceAddress = _context.sent;
569
+ _context.next = 39;
570
+ return toPolkadotV2.createTransfer(registry, sourceAddress, address, ethAsset.assetId, destParaId, BigInt(currency.amount), fee);
571
+ case 39:
572
+ transfer = _context.sent;
573
+ _context.t8 = toPolkadotV2;
574
+ _context.t9 = context.ethereum();
575
+ _context.t10 = context.gateway();
576
+ _context.next = 45;
577
+ return context.bridgeHub();
578
+ case 45:
579
+ _context.t11 = _context.sent;
580
+ _context.next = 48;
581
+ return context.assetHub();
582
+ case 48:
583
+ _context.t12 = _context.sent;
584
+ if (!(destParaId !== getParaId('AssetHubPolkadot'))) {
585
+ _context.next = 55;
586
+ break;
587
+ }
588
+ _context.next = 52;
589
+ return context.parachain(destParaId);
590
+ case 52:
591
+ _context.t13 = _context.sent;
592
+ _context.next = 56;
593
+ break;
594
+ case 55:
595
+ _context.t13 = undefined;
596
+ case 56:
597
+ _context.t14 = _context.t13;
598
+ _context.t15 = {
599
+ ethereum: _context.t9,
600
+ gateway: _context.t10,
601
+ bridgeHub: _context.t11,
602
+ assetHub: _context.t12,
603
+ destParachain: _context.t14
604
+ };
605
+ _context.t16 = transfer;
606
+ _context.next = 61;
607
+ return _context.t8.validateTransfer.call(_context.t8, _context.t15, _context.t16);
608
+ case 61:
609
+ validation = _context.sent;
610
+ if (!validation.logs.find(function (l) {
611
+ return l.kind == toPolkadotV2.ValidationKind.Error;
612
+ })) {
613
+ _context.next = 64;
614
+ break;
615
+ }
616
+ throw Error("Validation failed with following errors: \n\n ".concat(validation.logs.filter(function (l) {
617
+ return l.kind == toPolkadotV2.ValidationKind.Error;
618
+ }).map(function (l) {
619
+ return l.message;
620
+ }).join('\n\n')));
621
+ case 64:
622
+ tx = transfer.tx;
623
+ _context.next = 67;
624
+ return signer.sendTransaction(tx);
625
+ case 67:
626
+ response = _context.sent;
627
+ _context.next = 70;
628
+ return response.wait(1);
629
+ case 70:
630
+ receipt = _context.sent;
631
+ if (receipt) {
632
+ _context.next = 73;
633
+ break;
634
+ }
635
+ throw Error("Transaction ".concat(response.hash, " not included."));
636
+ case 73:
637
+ _context.next = 75;
638
+ return toPolkadotV2.getMessageReceipt(receipt);
639
+ case 75:
640
+ messageReceipt = _context.sent;
641
+ if (messageReceipt) {
642
+ _context.next = 78;
643
+ break;
644
+ }
645
+ throw Error("Transaction ".concat(receipt.hash, " did not emit a message."));
646
+ case 78:
562
647
  return _context.abrupt("return", {
563
- result: result,
564
- plan: plan
648
+ response: response,
649
+ messageReceipt: messageReceipt
565
650
  });
566
- case 27:
651
+ case 79:
567
652
  case "end":
568
653
  return _context.stop();
569
654
  }
@@ -574,76 +659,118 @@ var transferEthToPolkadot$1 = /*#__PURE__*/function () {
574
659
  };
575
660
  }();
576
661
 
577
- var buildEthTransferOptions = /*#__PURE__*/function () {
578
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
579
- var currency, to, address, destAddress, ethAsset, env, EXECUTION_URL, context, destParaId, signer, plan;
662
+ var depositToken = /*#__PURE__*/function () {
663
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(signer, amount, symbol) {
664
+ var env, contract, weth9, result, receipt;
580
665
  return _regeneratorRuntime().wrap(function _callee$(_context) {
581
666
  while (1) switch (_context.prev = _context.next) {
582
667
  case 0:
583
- currency = _ref.currency, to = _ref.to, address = _ref.address, destAddress = _ref.destAddress;
584
- if (!('multiasset' in currency)) {
585
- _context.next = 3;
586
- break;
587
- }
588
- throw new Error('Multiassets syntax is not supported for Evm transfers');
589
- case 3:
590
- if (!('multilocation' in currency && isOverrideMultiLocationSpecifier(currency.multilocation))) {
591
- _context.next = 5;
592
- break;
593
- }
594
- throw new Error('Override multilocation is not supported for Evm transfers');
595
- case 5:
596
- ethAsset = getAssetBySymbolOrId('Ethereum', currency, to);
597
- if (!(ethAsset === null)) {
598
- _context.next = 8;
599
- break;
600
- }
601
- throw new InvalidCurrencyError("Origin node Ethereum does not support currency ".concat(JSON.stringify(currency), "."));
602
- case 8:
603
668
  env = environment.SNOWBRIDGE_ENV['polkadot_mainnet'];
604
- EXECUTION_URL = 'https://eth.llamarpc.com';
605
- _context.next = 12;
606
- return createContext(EXECUTION_URL, env.config);
607
- case 12:
608
- context = _context.sent;
609
- destParaId = getParaId(to);
610
- signer = {
611
- getAddress: function getAddress() {
612
- return Promise.resolve(address);
613
- }
614
- };
615
- if (!(!isForeignAsset(ethAsset) || ethAsset.assetId === undefined)) {
616
- _context.next = 17;
669
+ contract = env.locations[0].erc20tokensReceivable.find(function (t) {
670
+ return t.id === symbol;
671
+ });
672
+ if (contract) {
673
+ _context.next = 4;
617
674
  break;
618
675
  }
619
- throw new InvalidCurrencyError('Selected asset has no asset id');
620
- case 17:
621
- _context.next = 19;
622
- return toPolkadot.validateSend(context, signer, destAddress, ethAsset.assetId, destParaId, BigInt(currency.amount), 0n);
623
- case 19:
624
- plan = _context.sent;
625
- checkPlanFailure(plan);
626
- if (plan.success) {
627
- _context.next = 23;
676
+ throw new Error("Token ".concat(symbol, " not supported"));
677
+ case 4:
678
+ weth9 = WETH9__factory.connect(contract.address, signer);
679
+ _context.next = 7;
680
+ return weth9.deposit({
681
+ value: amount
682
+ });
683
+ case 7:
684
+ result = _context.sent;
685
+ _context.next = 10;
686
+ return result.wait();
687
+ case 10:
688
+ receipt = _context.sent;
689
+ return _context.abrupt("return", {
690
+ result: result,
691
+ receipt: receipt
692
+ });
693
+ case 12:
694
+ case "end":
695
+ return _context.stop();
696
+ }
697
+ }, _callee);
698
+ }));
699
+ return function depositToken(_x, _x2, _x3) {
700
+ return _ref.apply(this, arguments);
701
+ };
702
+ }();
703
+
704
+ var approveToken = /*#__PURE__*/function () {
705
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(signer, amount, symbol) {
706
+ var env, contract, weth9, result, receipt;
707
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
708
+ while (1) switch (_context.prev = _context.next) {
709
+ case 0:
710
+ env = environment.SNOWBRIDGE_ENV['polkadot_mainnet'];
711
+ contract = env.locations[0].erc20tokensReceivable.find(function (t) {
712
+ return t.id === symbol;
713
+ });
714
+ if (contract) {
715
+ _context.next = 4;
628
716
  break;
629
717
  }
630
- throw new Error('Failed to validate send');
631
- case 23:
718
+ throw new Error("Token ".concat(symbol, " not supported"));
719
+ case 4:
720
+ weth9 = WETH9__factory.connect(contract.address, signer);
721
+ _context.next = 7;
722
+ return weth9.approve(env.config.GATEWAY_CONTRACT, amount);
723
+ case 7:
724
+ result = _context.sent;
725
+ _context.next = 10;
726
+ return result.wait();
727
+ case 10:
728
+ receipt = _context.sent;
632
729
  return _context.abrupt("return", {
633
- token: plan.success.token,
634
- destinationParaId: plan.success.destinationParaId,
635
- destinationFee: plan.success.destinationFee,
636
- amount: plan.success.amount,
637
- fee: plan.success.fee
730
+ result: result,
731
+ receipt: receipt
638
732
  });
639
- case 24:
733
+ case 12:
640
734
  case "end":
641
735
  return _context.stop();
642
736
  }
643
737
  }, _callee);
644
738
  }));
645
- return function buildEthTransferOptions(_x) {
646
- return _ref2.apply(this, arguments);
739
+ return function approveToken(_x, _x2, _x3) {
740
+ return _ref.apply(this, arguments);
741
+ };
742
+ }();
743
+
744
+ var getTokenBalance = /*#__PURE__*/function () {
745
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(signer, symbol) {
746
+ var env, contract, weth9, address;
747
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
748
+ while (1) switch (_context.prev = _context.next) {
749
+ case 0:
750
+ env = environment.SNOWBRIDGE_ENV['polkadot_mainnet'];
751
+ contract = env.locations[0].erc20tokensReceivable.find(function (t) {
752
+ return t.id === symbol;
753
+ });
754
+ if (contract) {
755
+ _context.next = 4;
756
+ break;
757
+ }
758
+ throw new Error("Token ".concat(symbol, " not supported"));
759
+ case 4:
760
+ weth9 = WETH9__factory.connect(contract.address, signer);
761
+ _context.next = 7;
762
+ return signer.getAddress();
763
+ case 7:
764
+ address = _context.sent;
765
+ return _context.abrupt("return", weth9.balanceOf(address));
766
+ case 9:
767
+ case "end":
768
+ return _context.stop();
769
+ }
770
+ }, _callee);
771
+ }));
772
+ return function getTokenBalance(_x, _x2) {
773
+ return _ref.apply(this, arguments);
647
774
  };
648
775
  }();
649
776
 
@@ -1253,8 +1380,10 @@ var transferEthToPolkadot = function transferEthToPolkadot(options) {
1253
1380
 
1254
1381
  var transfer = /*#__PURE__*/Object.freeze({
1255
1382
  __proto__: null,
1256
- buildEthTransferOptions: buildEthTransferOptions,
1383
+ approveToken: approveToken,
1384
+ depositToken: depositToken,
1257
1385
  getDryRun: getDryRun,
1386
+ getTokenBalance: getTokenBalance,
1258
1387
  send: send,
1259
1388
  transferEthToPolkadot: transferEthToPolkadot
1260
1389
  });
@@ -1399,8 +1528,7 @@ var EvmBuilderClass = /*#__PURE__*/function () {
1399
1528
  key: "build",
1400
1529
  value: (function () {
1401
1530
  var _build = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1402
- var _yield$transferEthToP, _yield$transferEthToP2;
1403
- var requiredParams, _i, _requiredParams, param;
1531
+ var requiredParams, _i, _requiredParams, param, _yield$transferEthToP, response;
1404
1532
  return _regeneratorRuntime().wrap(function _callee$(_context) {
1405
1533
  while (1) switch (_context.prev = _context.next) {
1406
1534
  case 0:
@@ -1434,44 +1562,10 @@ var EvmBuilderClass = /*#__PURE__*/function () {
1434
1562
  _context.next = 15;
1435
1563
  return transferEthToPolkadot$1(this._options);
1436
1564
  case 15:
1437
- _context.t2 = _yield$transferEthToP2 = _context.sent.result.success;
1438
- _context.t1 = _context.t2 === null;
1439
- if (_context.t1) {
1440
- _context.next = 19;
1441
- break;
1442
- }
1443
- _context.t1 = _yield$transferEthToP2 === undefined;
1444
- case 19:
1445
- if (!_context.t1) {
1446
- _context.next = 23;
1447
- break;
1448
- }
1449
- _context.t3 = undefined;
1450
- _context.next = 24;
1451
- break;
1452
- case 23:
1453
- _context.t3 = _yield$transferEthToP2.ethereum.blockHash;
1454
- case 24:
1455
- _context.t4 = _yield$transferEthToP = _context.t3;
1456
- _context.t0 = _context.t4 !== null;
1457
- if (!_context.t0) {
1458
- _context.next = 28;
1459
- break;
1460
- }
1461
- _context.t0 = _yield$transferEthToP !== undefined;
1462
- case 28:
1463
- if (!_context.t0) {
1464
- _context.next = 32;
1465
- break;
1466
- }
1467
- _context.t5 = _yield$transferEthToP;
1468
- _context.next = 33;
1469
- break;
1470
- case 32:
1471
- _context.t5 = '';
1472
- case 33:
1473
- return _context.abrupt("return", _context.t5);
1474
- case 34:
1565
+ _yield$transferEthToP = _context.sent;
1566
+ response = _yield$transferEthToP.response;
1567
+ return _context.abrupt("return", response.hash);
1568
+ case 18:
1475
1569
  case "end":
1476
1570
  return _context.stop();
1477
1571
  }
@@ -1511,4 +1605,4 @@ var EvmBuilder = function EvmBuilder(provider) {
1511
1605
  return EvmBuilder$1(pjsApi, provider);
1512
1606
  };
1513
1607
 
1514
- export { Builder, EvmBuilder, GeneralBuilder, assets, buildEthTransferOptions, claimAssets, createApiInstanceForNode, getAssetBalance, getBalanceForeign, getBalanceNative, getDryRun, getMaxForeignTransferableAmount, getMaxNativeTransferableAmount, getOriginFeeDetails, getTransferInfo, getTransferableAmount, send, transferEthToPolkadot, transfer as xcmPallet };
1608
+ export { Builder, EvmBuilder, GeneralBuilder, approveToken, assets, claimAssets, createApiInstanceForNode, depositToken, getAssetBalance, getBalanceForeign, getBalanceNative, getDryRun, getMaxForeignTransferableAmount, getMaxNativeTransferableAmount, getOriginFeeDetails, getTokenBalance, getTransferInfo, getTransferableAmount, send, transferEthToPolkadot, transfer as xcmPallet };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-pjs",
3
- "version": "8.2.0",
3
+ "version": "8.2.2",
4
4
  "description": "Polkadot.js based SDK for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,10 +23,11 @@
23
23
  "dist"
24
24
  ],
25
25
  "dependencies": {
26
- "@snowbridge/api": "^0.1.28",
26
+ "@snowbridge/api": "^0.1.32",
27
+ "@snowbridge/contract-types": "^0.1.32",
27
28
  "ethers": "^6.13.5",
28
29
  "viem": "^2.22.13",
29
- "@paraspell/sdk-core": "8.2.0"
30
+ "@paraspell/sdk-core": "8.2.2"
30
31
  },
31
32
  "peerDependencies": {
32
33
  "@polkadot/api": ">= 15.0 < 16",