@rango-dev/queue-manager-rango-preset 0.1.10-next.94 → 0.1.10-next.95

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/queue-manager-rango-preset",
3
- "version": "0.1.10-next.94",
3
+ "version": "0.1.10-next.95",
4
4
  "license": "MIT",
5
5
  "module": "dist/queue-manager-rango-preset.esm.js",
6
6
  "main": "dist/index.js",
package/src/helpers.ts CHANGED
@@ -1107,7 +1107,10 @@ export function singTransaction(
1107
1107
  const notification = getSwapNotitfication('confirm_transfer', updateResult);
1108
1108
  notifier(notification);
1109
1109
 
1110
- if (notification.eventType !== 'transaction_expired') {
1110
+ if (notification.eventType === 'transaction_expired') {
1111
+ failed();
1112
+ onFinish();
1113
+ } else {
1111
1114
  walletSigners
1112
1115
  .getSigner(TransactionType.TRANSFER)
1113
1116
  .signAndSendTx(transferTransaction, walletAddress, null)
@@ -1161,7 +1164,10 @@ export function singTransaction(
1161
1164
  );
1162
1165
  notifier(notification);
1163
1166
 
1164
- if (notification.eventType !== 'transaction_expired') {
1167
+ if (notification.eventType === 'transaction_expired') {
1168
+ failed();
1169
+ onFinish();
1170
+ } else {
1165
1171
  walletSigners
1166
1172
  .getSigner(TransactionType.EVM)
1167
1173
  .signAndSendTx(evmTransaction, walletAddress, null)
@@ -1230,7 +1236,10 @@ export function singTransaction(
1230
1236
  );
1231
1237
  notifier(notification);
1232
1238
 
1233
- if (notification.eventType !== 'transaction_expired') {
1239
+ if (notification.eventType === 'transaction_expired') {
1240
+ failed();
1241
+ onFinish();
1242
+ } else {
1234
1243
  // If keplr wallet is executing contracts on terra, throw error. keplr doesn't support transfer or execute contracts. only IBC messages are supported
1235
1244
  if (
1236
1245
  (currentStep?.swapperId.toString() === 'TerraSwap' ||
@@ -1317,7 +1326,10 @@ export function singTransaction(
1317
1326
  );
1318
1327
  notifier(notification);
1319
1328
 
1320
- if (notification.eventType !== 'transaction_expired') {
1329
+ if (notification.eventType === 'transaction_expired') {
1330
+ failed();
1331
+ onFinish();
1332
+ } else {
1321
1333
  const tx = solanaTransaction;
1322
1334
  walletSigners
1323
1335
  .getSigner(TransactionType.SOLANA)
@@ -1360,120 +1372,146 @@ export function singTransaction(
1360
1372
  const updateResult = updateSwapStatus({
1361
1373
  getStorage,
1362
1374
  setStorage,
1363
- nextStepStatus: 'running',
1375
+ nextStepStatus: hasAlreadyProceededToSign ? 'failed' : 'running',
1376
+ nextStatus: hasAlreadyProceededToSign ? 'failed' : 'running',
1364
1377
  message: executeMessage,
1365
1378
  details: executeDetails,
1379
+ hasAlreadyProceededToSign,
1366
1380
  });
1367
- notifier({
1368
- eventType: 'calling_smart_contract',
1369
- ...updateResult,
1370
- });
1381
+ const notification = getSwapNotitfication(
1382
+ 'calling_smart_contract',
1383
+ updateResult
1384
+ );
1385
+ notifier(notification);
1371
1386
 
1372
- walletSigners
1373
- .getSigner(TransactionType.TRON)
1374
- .signAndSendTx(tronTransaction, walletAddress, null)
1375
- .then(
1376
- (id) => {
1377
- setStepTransactionIds(actions, id, 'smart_contract_called', notifier);
1378
- schedule(SwapActionTypes.CHECK_TRANSACTION_STATUS);
1379
- next();
1380
- onFinish();
1381
- },
1382
- (error) => {
1383
- if (swap.status === 'failed') return;
1384
- const { extraMessage, extraMessageDetail, extraMessageErrorCode } =
1385
- prettifyErrorMessage(error);
1386
- if (
1387
- error &&
1388
- error?.root &&
1389
- error?.root?.message &&
1390
- error?.root?.code &&
1391
- error?.root?.reason
1392
- ) {
1393
- logRPCError(
1394
- error.root,
1395
- swap,
1396
- currentStep,
1397
- sourceWallet?.walletType
1387
+ if (notification.eventType === 'transaction_expired') {
1388
+ failed();
1389
+ onFinish();
1390
+ } else {
1391
+ walletSigners
1392
+ .getSigner(TransactionType.TRON)
1393
+ .signAndSendTx(tronTransaction, walletAddress, null)
1394
+ .then(
1395
+ (id) => {
1396
+ setStepTransactionIds(
1397
+ actions,
1398
+ id,
1399
+ 'smart_contract_called',
1400
+ notifier
1398
1401
  );
1399
- }
1400
- const updateResult = updateSwapStatus({
1401
- getStorage,
1402
- setStorage,
1403
- nextStatus: 'failed',
1404
- nextStepStatus: 'failed',
1405
- message: extraMessage,
1406
- details: extraMessageDetail,
1407
- errorCode: extraMessageErrorCode,
1408
- });
1409
- notifier({
1410
- eventType: 'smart_contract_call_failed',
1411
- ...updateResult,
1412
- });
1402
+ schedule(SwapActionTypes.CHECK_TRANSACTION_STATUS);
1403
+ next();
1404
+ onFinish();
1405
+ },
1406
+ (error) => {
1407
+ if (swap.status === 'failed') return;
1408
+ const { extraMessage, extraMessageDetail, extraMessageErrorCode } =
1409
+ prettifyErrorMessage(error);
1410
+ if (
1411
+ error &&
1412
+ error?.root &&
1413
+ error?.root?.message &&
1414
+ error?.root?.code &&
1415
+ error?.root?.reason
1416
+ ) {
1417
+ logRPCError(
1418
+ error.root,
1419
+ swap,
1420
+ currentStep,
1421
+ sourceWallet?.walletType
1422
+ );
1423
+ }
1424
+ const updateResult = updateSwapStatus({
1425
+ getStorage,
1426
+ setStorage,
1427
+ nextStatus: 'failed',
1428
+ nextStepStatus: 'failed',
1429
+ message: extraMessage,
1430
+ details: extraMessageDetail,
1431
+ errorCode: extraMessageErrorCode,
1432
+ });
1433
+ notifier({
1434
+ eventType: 'smart_contract_call_failed',
1435
+ ...updateResult,
1436
+ });
1413
1437
 
1414
- failed();
1415
- onFinish();
1416
- }
1417
- );
1438
+ failed();
1439
+ onFinish();
1440
+ }
1441
+ );
1442
+ }
1418
1443
  } else if (!!starknetTransaction) {
1419
1444
  const updateResult = updateSwapStatus({
1420
1445
  getStorage,
1421
1446
  setStorage,
1422
- nextStepStatus: 'running',
1447
+ nextStepStatus: hasAlreadyProceededToSign ? 'failed' : 'running',
1448
+ nextStatus: hasAlreadyProceededToSign ? 'failed' : 'running',
1423
1449
  message: executeMessage,
1424
1450
  details: executeDetails,
1451
+ hasAlreadyProceededToSign,
1425
1452
  });
1426
- notifier({
1427
- eventType: 'calling_smart_contract',
1428
- ...updateResult,
1429
- });
1453
+ const notification = getSwapNotitfication(
1454
+ 'calling_smart_contract',
1455
+ updateResult
1456
+ );
1457
+ notifier(notification);
1430
1458
 
1431
- walletSigners
1432
- .getSigner(TransactionType.STARKNET)
1433
- .signAndSendTx(starknetTransaction, walletAddress, null)
1434
- .then(
1435
- (id) => {
1436
- setStepTransactionIds(actions, id, 'smart_contract_called', notifier);
1437
- schedule(SwapActionTypes.CHECK_TRANSACTION_STATUS);
1438
- next();
1439
- onFinish();
1440
- },
1441
- (error) => {
1442
- if (swap.status === 'failed') return;
1443
- const { extraMessage, extraMessageDetail, extraMessageErrorCode } =
1444
- prettifyErrorMessage(error);
1445
- if (
1446
- error &&
1447
- error?.root &&
1448
- error?.root?.message &&
1449
- error?.root?.code &&
1450
- error?.root?.reason
1451
- ) {
1452
- logRPCError(
1453
- error.root,
1454
- swap,
1455
- currentStep,
1456
- sourceWallet?.walletType
1459
+ if (notification.eventType === 'transaction_expired') {
1460
+ failed();
1461
+ onFinish();
1462
+ } else {
1463
+ walletSigners
1464
+ .getSigner(TransactionType.STARKNET)
1465
+ .signAndSendTx(starknetTransaction, walletAddress, null)
1466
+ .then(
1467
+ (id) => {
1468
+ setStepTransactionIds(
1469
+ actions,
1470
+ id,
1471
+ 'smart_contract_called',
1472
+ notifier
1457
1473
  );
1458
- }
1459
- const updateResult = updateSwapStatus({
1460
- getStorage,
1461
- setStorage,
1462
- nextStatus: 'failed',
1463
- nextStepStatus: 'failed',
1464
- message: extraMessage,
1465
- details: extraMessageDetail,
1466
- errorCode: extraMessageErrorCode,
1467
- });
1468
- notifier({
1469
- eventType: 'smart_contract_call_failed',
1470
- ...updateResult,
1471
- });
1474
+ schedule(SwapActionTypes.CHECK_TRANSACTION_STATUS);
1475
+ next();
1476
+ onFinish();
1477
+ },
1478
+ (error) => {
1479
+ if (swap.status === 'failed') return;
1480
+ const { extraMessage, extraMessageDetail, extraMessageErrorCode } =
1481
+ prettifyErrorMessage(error);
1482
+ if (
1483
+ error &&
1484
+ error?.root &&
1485
+ error?.root?.message &&
1486
+ error?.root?.code &&
1487
+ error?.root?.reason
1488
+ ) {
1489
+ logRPCError(
1490
+ error.root,
1491
+ swap,
1492
+ currentStep,
1493
+ sourceWallet?.walletType
1494
+ );
1495
+ }
1496
+ const updateResult = updateSwapStatus({
1497
+ getStorage,
1498
+ setStorage,
1499
+ nextStatus: 'failed',
1500
+ nextStepStatus: 'failed',
1501
+ message: extraMessage,
1502
+ details: extraMessageDetail,
1503
+ errorCode: extraMessageErrorCode,
1504
+ });
1505
+ notifier({
1506
+ eventType: 'smart_contract_call_failed',
1507
+ ...updateResult,
1508
+ });
1472
1509
 
1473
- failed();
1474
- onFinish();
1475
- }
1476
- );
1510
+ failed();
1511
+ onFinish();
1512
+ }
1513
+ );
1514
+ }
1477
1515
  }
1478
1516
  }
1479
1517