@rango-dev/queue-manager-rango-preset 0.1.10-next.77 → 0.1.10-next.78

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.
@@ -1,7 +1,9 @@
1
1
  import BigNumber$1, { BigNumber } from 'bignumber.js';
2
- import { WalletError, isWalletErrorCode, WalletErrorCode, TransactionType, getBlockChainNameFromId, WalletType, Network } from '@rango-dev/wallets-shared';
2
+ import { getBlockChainNameFromId, WalletType, Network } from '@rango-dev/wallets-shared';
3
3
  import { readAccountAddress } from '@rango-dev/wallets-core';
4
+ import { TransactionType } from 'rango-sdk';
4
5
  import { Status } from '@rango-dev/queue-manager-core';
6
+ import { SignerError, isSignerErrorCode, SignerErrorCode } from 'rango-types';
5
7
  import { captureException } from '@sentry/browser';
6
8
 
7
9
  var SwapActionTypes;
@@ -581,7 +583,7 @@ var prettifyErrorMessage = function prettifyErrorMessage(obj) {
581
583
  extraMessageErrorCode: null
582
584
  };
583
585
  if (obj instanceof PrettyError) return obj.getErrorDetail();
584
- if (obj instanceof WalletError) {
586
+ if (obj instanceof SignerError) {
585
587
  var t = obj.getErrorDetail();
586
588
  return {
587
589
  extraMessage: t.message,
@@ -792,9 +794,9 @@ function mapAppErrorCodesToAPIErrorCode(errorCode) {
792
794
  try {
793
795
  if (!errorCode) return defaultErrorCode;
794
796
  if (isAPIErrorCode(errorCode)) return errorCode;
795
- if (isWalletErrorCode(errorCode)) {
797
+ if (isSignerErrorCode(errorCode)) {
796
798
  var _t;
797
- var t = (_t = {}, _t[WalletErrorCode.REJECTED_BY_USER] = APIErrorCode.USER_REJECT, _t[WalletErrorCode.SIGN_TX_ERROR] = APIErrorCode.CALL_WALLET_FAILED, _t[WalletErrorCode.SEND_TX_ERROR] = APIErrorCode.SEND_TX_FAILED, _t[WalletErrorCode.NOT_IMPLEMENTED] = defaultErrorCode, _t[WalletErrorCode.OPERATION_UNSUPPORTED] = defaultErrorCode, _t[WalletErrorCode.UNEXPECTED_BEHAVIOUR] = defaultErrorCode, _t);
799
+ var t = (_t = {}, _t[SignerErrorCode.REJECTED_BY_USER] = APIErrorCode.USER_REJECT, _t[SignerErrorCode.SIGN_TX_ERROR] = APIErrorCode.CALL_WALLET_FAILED, _t[SignerErrorCode.SEND_TX_ERROR] = APIErrorCode.SEND_TX_FAILED, _t[SignerErrorCode.NOT_IMPLEMENTED] = defaultErrorCode, _t[SignerErrorCode.OPERATION_UNSUPPORTED] = defaultErrorCode, _t[SignerErrorCode.UNEXPECTED_BEHAVIOUR] = defaultErrorCode, _t);
798
800
  return t[errorCode];
799
801
  }
800
802
  return defaultErrorCode;
@@ -1231,7 +1233,7 @@ function getRelatedWallet(swap, currentStep) {
1231
1233
  var blockchain = (walletKV == null ? void 0 : walletKV.k) || null;
1232
1234
  var wallet = (walletKV == null ? void 0 : walletKV.v) || null;
1233
1235
  var walletType = wallet == null ? void 0 : wallet.walletType;
1234
- if (walletType === WalletType.UNKNOWN || wallet === null) throw PrettyError.AssertionFailed("Wallet for source " + blockchain + " not passed to transfer: walletType: " + walletType);
1236
+ if (walletType === WalletType.UNKNOWN || wallet === null) throw PrettyError.AssertionFailed("Wallet for source " + blockchain + " not passed: walletType: " + walletType);
1235
1237
  return wallet;
1236
1238
  }
1237
1239
  var isTxAlreadyCreated = function isTxAlreadyCreated(swap, step) {
@@ -1435,6 +1437,7 @@ function singTransaction(actions) {
1435
1437
  solanaTransaction = currentStep.solanaTransaction,
1436
1438
  transferTransaction = currentStep.transferTransaction;
1437
1439
  var sourceWallet = getRelatedWallet(swap, currentStep);
1440
+ var walletAddress = getCurrentAddressOf(swap, currentStep);
1438
1441
  var walletSigners = getSigners(sourceWallet.walletType);
1439
1442
  var onFinish = function onFinish() {
1440
1443
  if (actions.context.resetClaimedBy) {
@@ -1457,7 +1460,7 @@ function singTransaction(actions) {
1457
1460
  eventType: 'confirm_contract'
1458
1461
  }, updateResult));
1459
1462
  // Execute transaction
1460
- walletSigners.executeEvmTransaction(evmApprovalTransaction, meta).then(function (hash) {
1463
+ walletSigners.getSigner(TransactionType.EVM).signAndSendTx(evmApprovalTransaction, walletAddress, null).then(function (hash) {
1461
1464
  console.debug('transaction of approval minted successfully', hash);
1462
1465
  var approveUrl = getEvmApproveUrl(hash, getCurrentBlockchainOf(swap, currentStep), meta.evmBasedChains);
1463
1466
  currentStep.explorerUrl = [].concat(currentStep.explorerUrl || [], [{
@@ -1512,7 +1515,7 @@ function singTransaction(actions) {
1512
1515
  notifier(_extends({
1513
1516
  eventType: 'confirm_transfer'
1514
1517
  }, _updateResult));
1515
- walletSigners.executeTransfer(transferTransaction, meta).then(function (txId) {
1518
+ walletSigners.getSigner(TransactionType.TRANSFER).signAndSendTx(transferTransaction, walletAddress, null).then(function (txId) {
1516
1519
  setStepTransactionIds(actions, txId, 'transfer_confirmed', notifier);
1517
1520
  schedule(SwapActionTypes.CHECK_TRANSACTION_STATUS);
1518
1521
  next();
@@ -1549,7 +1552,7 @@ function singTransaction(actions) {
1549
1552
  notifier(_extends({
1550
1553
  eventType: 'calling_smart_contract'
1551
1554
  }, _updateResult2));
1552
- walletSigners.executeEvmTransaction(evmTransaction, meta).then(function (id) {
1555
+ walletSigners.getSigner(TransactionType.EVM).signAndSendTx(evmTransaction, walletAddress, null).then(function (id) {
1553
1556
  setStepTransactionIds(actions, id, 'smart_contract_called', notifier);
1554
1557
  schedule(SwapActionTypes.CHECK_TRANSACTION_STATUS);
1555
1558
  next();
@@ -1614,7 +1617,7 @@ function singTransaction(actions) {
1614
1617
  onFinish();
1615
1618
  return;
1616
1619
  }
1617
- walletSigners.executeCosmosMessage(cosmosTransaction, meta).then(
1620
+ walletSigners.getSigner(TransactionType.COSMOS).signAndSendTx(cosmosTransaction, walletAddress, null).then(
1618
1621
  // todo
1619
1622
  function (id) {
1620
1623
  setStepTransactionIds(actions, id, 'smart_contract_called', notifier);
@@ -1654,7 +1657,7 @@ function singTransaction(actions) {
1654
1657
  eventType: 'calling_smart_contract'
1655
1658
  }, _updateResult5));
1656
1659
  var tx = solanaTransaction;
1657
- walletSigners.executeSolanaTransaction(tx, swap.requestId).then(function (txId) {
1660
+ walletSigners.getSigner(TransactionType.SOLANA).signAndSendTx(tx, walletAddress, null).then(function (txId) {
1658
1661
  setStepTransactionIds(actions, txId, 'smart_contract_called', notifier);
1659
1662
  schedule(SwapActionTypes.CHECK_TRANSACTION_STATUS);
1660
1663
  next();