@rango-dev/queue-manager-rango-preset 0.22.1-next.8 → 0.23.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/CHANGELOG.md +34 -0
- package/dist/actions/checkStatus.d.ts +3 -2
- package/dist/actions/checkStatus.d.ts.map +1 -1
- package/dist/actions/executeTransaction.d.ts.map +1 -1
- package/dist/actions/scheduleNextStep.d.ts +3 -2
- package/dist/actions/scheduleNextStep.d.ts.map +1 -1
- package/dist/helpers.d.ts +4 -21
- package/dist/helpers.d.ts.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/migration.d.ts.map +1 -1
- package/dist/services/eventEmitter.d.ts +1 -1
- package/dist/services/eventEmitter.d.ts.map +1 -1
- package/dist/shared-sentry.d.ts +2 -2
- package/dist/shared-sentry.d.ts.map +1 -1
- package/dist/shared.d.ts +3 -98
- package/dist/shared.d.ts.map +1 -1
- package/dist/types.d.ts +5 -6
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/actions/checkStatus.ts +71 -53
- package/src/actions/executeTransaction.ts +3 -1
- package/src/actions/scheduleNextStep.ts +13 -10
- package/src/helpers.ts +17 -55
- package/src/index.ts +1 -9
- package/src/migration.ts +11 -11
- package/src/services/eventEmitter.ts +1 -1
- package/src/shared-sentry.ts +3 -2
- package/src/shared.ts +66 -166
- package/src/types.ts +10 -4
package/dist/migration.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../src/migration.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../src/migration.ts"],"names":[],"mappings":"AAUA;;;;GAIG;AACH,iBAAS,QAAQ,IAAI,OAAO,CAE3B;AAYD;;;;;GAKG;AACH,iBAAe,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC,CAsF3C;AAED,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RemoveNameField, RouteExecutionEvents, StepEvent } from '../types';
|
|
2
|
-
import type { PendingSwap, PendingSwapStep } from 'rango-types
|
|
2
|
+
import type { PendingSwap, PendingSwapStep } from 'rango-types';
|
|
3
3
|
type NotifierParams = {
|
|
4
4
|
swap: PendingSwap;
|
|
5
5
|
step: PendingSwapStep | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventEmitter.d.ts","sourceRoot":"","sources":["../../src/services/eventEmitter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EAGf,oBAAoB,EAEpB,SAAS,EACV,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"eventEmitter.d.ts","sourceRoot":"","sources":["../../src/services/eventEmitter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EAGf,oBAAoB,EAEpB,SAAS,EACV,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAoBhE,KAAK,cAAc,GAAG;IACpB,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,eAAe,GAAG,IAAI,CAAC;CAC9B,GAAG;IACF,KAAK,EAAE,eAAe,CAAC,SAAS,EAAE,SAAS,GAAG,iBAAiB,CAAC,CAAC;CAClE,CAAC;AA+GF,eAAO,MAAM,YAAY,8CAA+B,CAAC;AA2BzD,wBAAgB,QAAQ,CAAC,MAAM,EAAE,cAAc,QAsG9C"}
|
package/dist/shared-sentry.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { WalletType } from '@rango-dev/wallets-shared';
|
|
2
|
+
import type { PendingSwap, PendingSwapStep } from 'rango-types';
|
|
3
3
|
export declare function logRPCError(error: unknown, swap: PendingSwap, currentStep: PendingSwapStep | undefined, walletType: WalletType | undefined): void;
|
|
4
4
|
//# sourceMappingURL=shared-sentry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-sentry.d.ts","sourceRoot":"","sources":["../src/shared-sentry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shared-sentry.d.ts","sourceRoot":"","sources":["../src/shared-sentry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAIhE,wBAAgB,WAAW,CACzB,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,WAAW,EACjB,WAAW,EAAE,eAAe,GAAG,SAAS,EACxC,UAAU,EAAE,UAAU,GAAG,SAAS,GACjC,IAAI,CAcN"}
|
package/dist/shared.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Network, WalletType } from '@rango-dev/wallets-shared';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
2
|
+
import type { BestRouteResponse, BlockchainMeta, MetaResponse, SwapResult, Token } from 'rango-sdk';
|
|
3
|
+
import type { PendingSwap, PendingSwapStep, SwapSavedSettings, WalletTypeAndAddress } from 'rango-types';
|
|
4
4
|
import BigNumber from 'bignumber.js';
|
|
5
5
|
export interface PendingSwapWithQueueID {
|
|
6
6
|
id: string;
|
|
@@ -34,77 +34,6 @@ export type Wallet = {
|
|
|
34
34
|
blockchains: Blockchain[];
|
|
35
35
|
};
|
|
36
36
|
export type EventType = 'swap_started' | 'confirm_contract' | 'confirm_transfer' | 'task_failed' | 'task_completed' | 'task_canceled' | 'task_paused' | 'contract_confirmed' | 'confirm_approve_contract' | 'contract_rejected' | 'check_tx_status' | 'check_approve_tx_status' | 'transfer_rejected' | 'transfer_failed' | 'calling_smart_contract' | 'smart_contract_called' | 'smart_contract_call_failed' | 'step_completed_with_output' | 'waiting_for_network_change' | 'waiting_for_connecting_wallet' | 'waiting_for_change_wallet_account' | 'network_changed' | 'not_enough_balance' | 'not_enough_approval' | 'waiting_for_queue' | 'check_fee_failed' | 'route_failed_to_find' | 'transaction_expired';
|
|
37
|
-
export type SwapSavedSettings = {
|
|
38
|
-
slippage: string;
|
|
39
|
-
disabledSwappersIds?: string[];
|
|
40
|
-
disabledSwappersGroups?: string[];
|
|
41
|
-
infiniteApprove?: boolean;
|
|
42
|
-
};
|
|
43
|
-
type InternalStepState = 'PENDING' | 'CREATED' | 'WAITING' | 'SIGNED' | 'SUCCESSED' | 'FAILED';
|
|
44
|
-
export type SwapperStatusStep = {
|
|
45
|
-
name: string;
|
|
46
|
-
state: InternalStepState;
|
|
47
|
-
current: boolean;
|
|
48
|
-
};
|
|
49
|
-
export declare enum PendingSwapNetworkStatus {
|
|
50
|
-
WaitingForConnectingWallet = "waitingForConnectingWallet",
|
|
51
|
-
WaitingForQueue = "waitingForQueue",
|
|
52
|
-
WaitingForNetworkChange = "waitingForNetworkChange",
|
|
53
|
-
NetworkChanged = "networkChanged"
|
|
54
|
-
}
|
|
55
|
-
export type SwapExplorerUrl = {
|
|
56
|
-
url: string;
|
|
57
|
-
description: string | null;
|
|
58
|
-
};
|
|
59
|
-
export type StepStatus = 'created' | 'running' | 'failed' | 'success' | 'waitingForApproval' | 'approved';
|
|
60
|
-
export type PendingSwapStep = {
|
|
61
|
-
id: number;
|
|
62
|
-
fromBlockchain: string;
|
|
63
|
-
fromSymbol: string;
|
|
64
|
-
fromSymbolAddress: string | null;
|
|
65
|
-
fromDecimals: number;
|
|
66
|
-
fromAmountPrecision: string | null;
|
|
67
|
-
fromAmountMinValue: string | null;
|
|
68
|
-
fromAmountMaxValue: string | null;
|
|
69
|
-
fromAmountRestrictionType: AmountRestrictionType | null;
|
|
70
|
-
fromLogo: string;
|
|
71
|
-
toBlockchain: string;
|
|
72
|
-
toSymbol: string;
|
|
73
|
-
toSymbolAddress: string | null;
|
|
74
|
-
toDecimals: number;
|
|
75
|
-
toLogo: string;
|
|
76
|
-
swapperId: string;
|
|
77
|
-
expectedOutputAmountHumanReadable: string | null;
|
|
78
|
-
startTransactionTime: number;
|
|
79
|
-
internalSteps: SwapperStatusStep[] | null;
|
|
80
|
-
estimatedTimeInSeconds: number | null;
|
|
81
|
-
status: StepStatus;
|
|
82
|
-
networkStatus: PendingSwapNetworkStatus | null;
|
|
83
|
-
executedTransactionId: string | null;
|
|
84
|
-
executedTransactionTime: string | null;
|
|
85
|
-
explorerUrl: SwapExplorerUrl[] | null;
|
|
86
|
-
diagnosisUrl: string | null;
|
|
87
|
-
outputAmount: string | null;
|
|
88
|
-
cosmosTransaction: CosmosTransaction | null;
|
|
89
|
-
transferTransaction: TransferTransaction | null;
|
|
90
|
-
solanaTransaction: SolanaTransaction | null;
|
|
91
|
-
evmApprovalTransaction: EvmTransaction | null;
|
|
92
|
-
evmTransaction: EvmTransaction | null;
|
|
93
|
-
tronApprovalTransaction: TronTransaction | null;
|
|
94
|
-
tronTransaction: TronTransaction | null;
|
|
95
|
-
starknetApprovalTransaction: StarknetTransaction | null;
|
|
96
|
-
starknetTransaction: StarknetTransaction | null;
|
|
97
|
-
tonTransaction: TonTransaction | null;
|
|
98
|
-
swapperLogo: string | null;
|
|
99
|
-
swapperType: string | null;
|
|
100
|
-
fromBlockchainLogo: string | null;
|
|
101
|
-
toBlockchainLogo: string | null;
|
|
102
|
-
feeInUsd: string | null;
|
|
103
|
-
};
|
|
104
|
-
export type WalletTypeAndAddress = {
|
|
105
|
-
walletType: WalletType;
|
|
106
|
-
address: string;
|
|
107
|
-
};
|
|
108
37
|
export declare enum MessageSeverity {
|
|
109
38
|
error = "error",
|
|
110
39
|
warning = "warning",
|
|
@@ -112,29 +41,6 @@ export declare enum MessageSeverity {
|
|
|
112
41
|
success = "success"
|
|
113
42
|
}
|
|
114
43
|
export type SwapStatus = 'running' | 'failed' | 'success';
|
|
115
|
-
export type PendingSwap = {
|
|
116
|
-
creationTime: string;
|
|
117
|
-
finishTime: string | null;
|
|
118
|
-
requestId: string;
|
|
119
|
-
inputAmount: string;
|
|
120
|
-
status: SwapStatus;
|
|
121
|
-
isPaused: boolean;
|
|
122
|
-
extraMessage: string | null;
|
|
123
|
-
extraMessageSeverity: MessageSeverity | null;
|
|
124
|
-
extraMessageErrorCode: string | null;
|
|
125
|
-
extraMessageDetail: string | null | undefined;
|
|
126
|
-
networkStatusExtraMessage: string | null;
|
|
127
|
-
networkStatusExtraMessageDetail: string | null;
|
|
128
|
-
lastNotificationTime: string | null;
|
|
129
|
-
wallets: {
|
|
130
|
-
[p: string]: WalletTypeAndAddress;
|
|
131
|
-
};
|
|
132
|
-
settings: SwapSavedSettings;
|
|
133
|
-
steps: PendingSwapStep[];
|
|
134
|
-
simulationResult: SimulationResult;
|
|
135
|
-
validateBalanceOrFee: boolean;
|
|
136
|
-
hasAlreadyProceededToSign?: boolean | null;
|
|
137
|
-
};
|
|
138
44
|
export declare const getCurrentBlockchainOfOrNull: (swap: PendingSwap, step: PendingSwapStep) => Network | null;
|
|
139
45
|
export declare const getCurrentBlockchainOf: (swap: PendingSwap, step: PendingSwapStep) => Network;
|
|
140
46
|
export declare const getScannerUrl: (txHash: string, network: Network, blockchainMetaMap: {
|
|
@@ -146,11 +52,10 @@ export declare function getNextStep(swap: PendingSwap, currentStep: PendingSwapS
|
|
|
146
52
|
*/
|
|
147
53
|
export declare const getCurrentAddressOf: (swap: PendingSwap, step: PendingSwapStep) => string;
|
|
148
54
|
export declare function getRelatedWallet(swap: PendingSwap, currentStep: PendingSwapStep): WalletTypeAndAddress;
|
|
149
|
-
export declare function getRelatedWalletOrNull(swap: PendingSwap, currentStep: PendingSwapStep): WalletTypeAndAddress | null;
|
|
55
|
+
export declare function getRelatedWalletOrNull(swap: PendingSwap, currentStep: PendingSwapStep | null): WalletTypeAndAddress | null;
|
|
150
56
|
export declare const getUsdPrice: (blockchain: string, symbol: string, address: string | null, allTokens: Token[]) => number | null;
|
|
151
57
|
export declare function getUsdFeeOfStep(step: SwapResult, allTokens: Token[]): BigNumber;
|
|
152
58
|
export declare function calculatePendingSwap(inputAmount: string, bestRoute: BestRouteResponse, wallets: {
|
|
153
59
|
[p: string]: WalletTypeAndAddress;
|
|
154
60
|
}, settings: SwapSavedSettings, validateBalanceOrFee: boolean, meta: Pick<MetaResponse, 'blockchains' | 'tokens'> | null): PendingSwap;
|
|
155
|
-
export {};
|
|
156
61
|
//# sourceMappingURL=shared.d.ts.map
|
package/dist/shared.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,UAAU,EACV,KAAK,EACN,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EACV,WAAW,EACX,eAAe,EACf,iBAAiB,EAEjB,oBAAoB,EACrB,MAAM,aAAa,CAAC;AAErB,OAAO,SAAS,MAAM,cAAc,CAAC;AAWrC,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,WAAW,CAAC;CACnB;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;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-
import type {
|
|
2
|
-
import type { QueueDef, QueueStorage } from '@rango-dev/queue-manager-core';
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type { Meta, Network, WalletState, WalletType } from '@rango-dev/wallets-shared';
|
|
1
|
+
import type { Wallet } from './shared';
|
|
2
|
+
import type { QueueContext, QueueDef, QueueStorage } from '@rango-dev/queue-manager-core';
|
|
3
|
+
import type { ConnectResult } from '@rango-dev/wallets-core';
|
|
4
|
+
import type { Meta, Network, Providers, WalletState, WalletType } from '@rango-dev/wallets-shared';
|
|
6
5
|
import type { Transaction } from 'rango-sdk';
|
|
7
|
-
import type { APIErrorCode, EvmBlockchainMeta, SignerFactory } from 'rango-types';
|
|
6
|
+
import type { APIErrorCode, EvmBlockchainMeta, PendingSwap, PendingSwapStep, SignerFactory } from 'rango-types';
|
|
8
7
|
export type RemoveNameField<T, U extends string> = {
|
|
9
8
|
[Property in keyof T as Exclude<Property, U>]: T[Property];
|
|
10
9
|
};
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EACV,YAAY,EACZ,QAAQ,EACR,YAAY,EACb,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EACV,IAAI,EACJ,OAAO,EACP,SAAS,EACT,WAAW,EACX,UAAU,EACX,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,WAAW,EACX,e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|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"@rango-dev/queue-manager-core": "*",
|
|
25
25
|
"@rango-dev/queue-manager-react": "*",
|
|
26
|
-
"@rango-dev/wallets-
|
|
26
|
+
"@rango-dev/wallets-core": "*",
|
|
27
27
|
"@rango-dev/wallets-shared": "*",
|
|
28
28
|
"@sentry/browser": "*",
|
|
29
29
|
"bignumber.js": "*",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@sentry/browser": "^6.12.0",
|
|
39
39
|
"mitt": "^3.0.0",
|
|
40
|
-
"rango-types": "^0.1.
|
|
40
|
+
"rango-types": "^0.1.57",
|
|
41
41
|
"uuid": "^9.0.0"
|
|
42
42
|
},
|
|
43
43
|
"publishConfig": {
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { SwapQueueContext, SwapStorage } from '../types';
|
|
2
|
+
import type { ExecuterActions } from '@rango-dev/queue-manager-core';
|
|
3
|
+
import type { Transaction, TransactionStatusResponse } from 'rango-sdk';
|
|
4
|
+
import type { GenericSigner } from 'rango-types';
|
|
5
|
+
|
|
6
|
+
import { DEFAULT_ERROR_CODE } from '../constants';
|
|
2
7
|
import {
|
|
3
8
|
delay,
|
|
4
9
|
getCurrentStep,
|
|
5
10
|
getCurrentStepTx,
|
|
6
11
|
getCurrentStepTxType,
|
|
12
|
+
inMemoryTransactionsData,
|
|
7
13
|
resetNetworkStatus,
|
|
8
14
|
setCurrentStepTx,
|
|
9
15
|
updateSwapStatus,
|
|
10
|
-
inMemoryTransactionsData,
|
|
11
16
|
} from '../helpers';
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
SwapActionTypes,
|
|
15
|
-
SwapQueueContext,
|
|
16
|
-
SwapStorage,
|
|
17
|
-
} from '../types';
|
|
17
|
+
import { httpService } from '../services';
|
|
18
|
+
import { notifier } from '../services/eventEmitter';
|
|
18
19
|
import {
|
|
19
20
|
getCurrentBlockchainOf,
|
|
20
21
|
getNextStep,
|
|
@@ -22,14 +23,11 @@ import {
|
|
|
22
23
|
getScannerUrl,
|
|
23
24
|
MessageSeverity,
|
|
24
25
|
} from '../shared';
|
|
25
|
-
import { Transaction, TransactionStatusResponse } from 'rango-sdk';
|
|
26
|
-
import { httpService } from '../services';
|
|
27
|
-
import type { GenericSigner } from 'rango-types';
|
|
28
26
|
import { prettifyErrorMessage } from '../shared-errors';
|
|
29
|
-
import {
|
|
30
|
-
import { DEFAULT_ERROR_CODE } from '../constants';
|
|
27
|
+
import { StepEventType, SwapActionTypes } from '../types';
|
|
31
28
|
|
|
32
|
-
const
|
|
29
|
+
const INTERVAL_FOR_CHECK_STATUS = 5_000;
|
|
30
|
+
const INTERVAL_FOR_CHECK_APPROVAL = 2_000;
|
|
33
31
|
|
|
34
32
|
/**
|
|
35
33
|
* Subscribe to status of swap transaction by checking from server periodically.
|
|
@@ -53,10 +51,11 @@ async function checkTransactionStatus({
|
|
|
53
51
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
54
52
|
const currentStep = getCurrentStep(swap)!;
|
|
55
53
|
|
|
56
|
-
if (!currentStep?.executedTransactionId)
|
|
54
|
+
if (!currentStep?.executedTransactionId) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
57
|
const tx = getCurrentStepTx(currentStep);
|
|
58
58
|
let txId = currentStep.executedTransactionId;
|
|
59
|
-
let explorerUrlToUpdate = false;
|
|
60
59
|
let getTxReceiptFailed = false;
|
|
61
60
|
let status: TransactionStatusResponse | null = null;
|
|
62
61
|
let signer: GenericSigner<Transaction> | null = null;
|
|
@@ -66,11 +65,14 @@ async function checkTransactionStatus({
|
|
|
66
65
|
try {
|
|
67
66
|
const txType = getCurrentStepTxType(currentStep);
|
|
68
67
|
const sourceWallet = getRelatedWallet(swap, currentStep);
|
|
69
|
-
if (txType && sourceWallet)
|
|
68
|
+
if (txType && sourceWallet) {
|
|
70
69
|
signer = context.getSigners(sourceWallet.walletType).getSigner(txType);
|
|
70
|
+
}
|
|
71
71
|
} catch (error) {
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
/*
|
|
73
|
+
* wallet is not connected yet
|
|
74
|
+
* no need to do anything
|
|
75
|
+
*/
|
|
74
76
|
}
|
|
75
77
|
|
|
76
78
|
try {
|
|
@@ -83,9 +85,6 @@ async function checkTransactionStatus({
|
|
|
83
85
|
undefined;
|
|
84
86
|
const { hash: updatedTxHash, response: updatedTxResponse } =
|
|
85
87
|
await signer.wait(txId, chainId, txResponse);
|
|
86
|
-
if (updatedTxResponse?.isMultiSig) {
|
|
87
|
-
explorerUrlToUpdate = !updatedTxResponse.hashWasUpdated;
|
|
88
|
-
}
|
|
89
88
|
if (updatedTxHash !== txId) {
|
|
90
89
|
currentStep.executedTransactionId =
|
|
91
90
|
updatedTxHash || currentStep.executedTransactionId;
|
|
@@ -108,17 +107,16 @@ async function checkTransactionStatus({
|
|
|
108
107
|
}
|
|
109
108
|
}
|
|
110
109
|
txId = currentStep.executedTransactionId;
|
|
111
|
-
if (updatedTxHash && updatedTxResponse)
|
|
110
|
+
if (updatedTxHash && updatedTxResponse) {
|
|
112
111
|
setTransactionDataByHash(updatedTxHash, {
|
|
113
112
|
response: updatedTxResponse,
|
|
114
113
|
});
|
|
114
|
+
}
|
|
115
115
|
} else {
|
|
116
116
|
setTransactionDataByHash(updatedTxHash, {
|
|
117
117
|
receiptReceived: true,
|
|
118
118
|
});
|
|
119
119
|
}
|
|
120
|
-
} else if (!signer) {
|
|
121
|
-
explorerUrlToUpdate = true;
|
|
122
120
|
}
|
|
123
121
|
} catch (error) {
|
|
124
122
|
const { extraMessage, extraMessageDetail, extraMessageErrorCode } =
|
|
@@ -143,8 +141,10 @@ async function checkTransactionStatus({
|
|
|
143
141
|
});
|
|
144
142
|
|
|
145
143
|
getTxReceiptFailed = true;
|
|
146
|
-
|
|
147
|
-
|
|
144
|
+
/*
|
|
145
|
+
* We shouldn't return here, because we need to trigger check status job in backend.
|
|
146
|
+
* This is not a ui requirement but the backend one.
|
|
147
|
+
*/
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
try {
|
|
@@ -155,16 +155,22 @@ async function checkTransactionStatus({
|
|
|
155
155
|
step: currentStep.id,
|
|
156
156
|
});
|
|
157
157
|
} catch (e) {
|
|
158
|
-
await delay(
|
|
158
|
+
await delay(INTERVAL_FOR_CHECK_STATUS);
|
|
159
159
|
retry();
|
|
160
160
|
return;
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
163
|
+
/*
|
|
164
|
+
* If user cancel swap during check status api call,
|
|
165
|
+
* or getting transaction receipt failed,
|
|
166
|
+
* we should ignore check status response and return
|
|
167
|
+
*/
|
|
168
|
+
if (getTxReceiptFailed) {
|
|
169
|
+
return failed();
|
|
170
|
+
}
|
|
171
|
+
if (currentStep?.status === 'failed') {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
168
174
|
|
|
169
175
|
const outputAmount: string | null =
|
|
170
176
|
status?.outputAmount ||
|
|
@@ -178,9 +184,7 @@ async function checkTransactionStatus({
|
|
|
178
184
|
currentStep.diagnosisUrl =
|
|
179
185
|
status?.diagnosisUrl || currentStep.diagnosisUrl || null;
|
|
180
186
|
currentStep.outputAmount = outputAmount || currentStep.outputAmount;
|
|
181
|
-
currentStep.explorerUrl =
|
|
182
|
-
? status?.explorerUrl || currentStep.explorerUrl
|
|
183
|
-
: null;
|
|
187
|
+
currentStep.explorerUrl = status?.explorerUrl || currentStep.explorerUrl;
|
|
184
188
|
currentStep.internalSteps = status?.steps || null;
|
|
185
189
|
|
|
186
190
|
const newTransaction = status?.newTx;
|
|
@@ -192,13 +196,13 @@ async function checkTransactionStatus({
|
|
|
192
196
|
setCurrentStepTx(currentStep, newTransaction);
|
|
193
197
|
}
|
|
194
198
|
|
|
195
|
-
if (prevOutputAmount === null && outputAmount !== null)
|
|
199
|
+
if (prevOutputAmount === null && outputAmount !== null) {
|
|
196
200
|
notifier({
|
|
197
201
|
event: { type: StepEventType.OUTPUT_REVEALED, outputAmount },
|
|
198
202
|
swap: swap,
|
|
199
203
|
step: currentStep,
|
|
200
204
|
});
|
|
201
|
-
else if (prevOutputAmount === null && outputAmount === null) {
|
|
205
|
+
} else if (prevOutputAmount === null && outputAmount === null) {
|
|
202
206
|
// it is needed to set notification after reloading the page
|
|
203
207
|
notifier({
|
|
204
208
|
event: { type: StepEventType.CHECK_STATUS },
|
|
@@ -241,7 +245,7 @@ async function checkTransactionStatus({
|
|
|
241
245
|
schedule(SwapActionTypes.SCHEDULE_NEXT_STEP);
|
|
242
246
|
next();
|
|
243
247
|
} else {
|
|
244
|
-
await delay(
|
|
248
|
+
await delay(INTERVAL_FOR_CHECK_STATUS);
|
|
245
249
|
retry();
|
|
246
250
|
}
|
|
247
251
|
}
|
|
@@ -263,7 +267,7 @@ async function checkApprovalStatus({
|
|
|
263
267
|
SwapActionTypes,
|
|
264
268
|
SwapQueueContext
|
|
265
269
|
>): Promise<void> {
|
|
266
|
-
const swap = getStorage().swapDetails
|
|
270
|
+
const swap = getStorage().swapDetails;
|
|
267
271
|
const { meta } = context;
|
|
268
272
|
const { getTransactionDataByHash, setTransactionDataByHash } =
|
|
269
273
|
inMemoryTransactionsData();
|
|
@@ -275,18 +279,23 @@ async function checkApprovalStatus({
|
|
|
275
279
|
}
|
|
276
280
|
const tx = getCurrentStepTx(currentStep);
|
|
277
281
|
|
|
278
|
-
if (!currentStep?.executedTransactionId)
|
|
282
|
+
if (!currentStep?.executedTransactionId) {
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
279
285
|
let txId = currentStep.executedTransactionId;
|
|
280
286
|
|
|
281
287
|
let signer: GenericSigner<Transaction> | null = null;
|
|
282
288
|
try {
|
|
283
289
|
const txType = getCurrentStepTxType(currentStep);
|
|
284
290
|
const sourceWallet = getRelatedWallet(swap, currentStep);
|
|
285
|
-
if (txType && sourceWallet)
|
|
291
|
+
if (txType && sourceWallet) {
|
|
286
292
|
signer = context.getSigners(sourceWallet.walletType).getSigner(txType);
|
|
293
|
+
}
|
|
287
294
|
} catch (error) {
|
|
288
|
-
|
|
289
|
-
|
|
295
|
+
/*
|
|
296
|
+
* wallet is not connected yet
|
|
297
|
+
* no need to do anything
|
|
298
|
+
*/
|
|
290
299
|
}
|
|
291
300
|
|
|
292
301
|
try {
|
|
@@ -321,10 +330,11 @@ async function checkApprovalStatus({
|
|
|
321
330
|
}
|
|
322
331
|
}
|
|
323
332
|
txId = currentStep.executedTransactionId;
|
|
324
|
-
if (updatedTxHash && updatedTxResponse)
|
|
333
|
+
if (updatedTxHash && updatedTxResponse) {
|
|
325
334
|
setTransactionDataByHash(updatedTxHash, {
|
|
326
335
|
response: updatedTxResponse,
|
|
327
336
|
});
|
|
337
|
+
}
|
|
328
338
|
} else {
|
|
329
339
|
setTransactionDataByHash(updatedTxHash, {
|
|
330
340
|
receiptReceived: true,
|
|
@@ -361,7 +371,9 @@ async function checkApprovalStatus({
|
|
|
361
371
|
currentStep.executedTransactionId
|
|
362
372
|
);
|
|
363
373
|
// If user cancel swap during check status api call, we should ignore check approval response
|
|
364
|
-
if (currentStep?.status === 'failed')
|
|
374
|
+
if (currentStep?.status === 'failed') {
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
365
377
|
|
|
366
378
|
isApproved = response.isApproved;
|
|
367
379
|
if (
|
|
@@ -374,12 +386,16 @@ async function checkApprovalStatus({
|
|
|
374
386
|
details = 'Smart contract approval tx failed in blockchain.';
|
|
375
387
|
} else {
|
|
376
388
|
message = 'Not enough approval';
|
|
377
|
-
if (response.requiredApprovedAmount && response.currentApprovedAmount)
|
|
389
|
+
if (response.requiredApprovedAmount && response.currentApprovedAmount) {
|
|
378
390
|
details = `Required approval: ${response.requiredApprovedAmount}, current approval: ${response.currentApprovedAmount}`;
|
|
379
|
-
else
|
|
391
|
+
} else {
|
|
392
|
+
details = `You still don't have enough approval for this swap.`;
|
|
393
|
+
}
|
|
380
394
|
}
|
|
381
|
-
|
|
382
|
-
|
|
395
|
+
/*
|
|
396
|
+
* approve transaction failed on
|
|
397
|
+
* we should fail the whole swap
|
|
398
|
+
*/
|
|
383
399
|
const updateResult = updateSwapStatus({
|
|
384
400
|
getStorage,
|
|
385
401
|
setStorage,
|
|
@@ -436,7 +452,7 @@ async function checkApprovalStatus({
|
|
|
436
452
|
schedule(SwapActionTypes.SCHEDULE_NEXT_STEP);
|
|
437
453
|
next();
|
|
438
454
|
} else {
|
|
439
|
-
await delay(
|
|
455
|
+
await delay(INTERVAL_FOR_CHECK_APPROVAL);
|
|
440
456
|
retry();
|
|
441
457
|
}
|
|
442
458
|
}
|
|
@@ -459,8 +475,10 @@ export async function checkStatus(
|
|
|
459
475
|
return;
|
|
460
476
|
}
|
|
461
477
|
|
|
462
|
-
|
|
463
|
-
|
|
478
|
+
/*
|
|
479
|
+
* Reset network status
|
|
480
|
+
* Because when check status is on `loading` or `failed` status, it shows previous message that isn't related to current state.
|
|
481
|
+
*/
|
|
464
482
|
resetNetworkStatus(actions);
|
|
465
483
|
|
|
466
484
|
if (currentStep.status === 'running') {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { SwapActionTypes, SwapQueueContext, SwapStorage } from '../types';
|
|
2
2
|
import type { ExecuterActions } from '@rango-dev/queue-manager-core';
|
|
3
3
|
|
|
4
|
+
import { PendingSwapNetworkStatus } from 'rango-types';
|
|
5
|
+
|
|
4
6
|
import {
|
|
5
7
|
ERROR_MESSAGE_DEPENDS_ON_OTHER_QUEUES,
|
|
6
8
|
ERROR_MESSAGE_WAIT_FOR_CHANGE_NETWORK,
|
|
@@ -18,7 +20,7 @@ import {
|
|
|
18
20
|
signTransaction,
|
|
19
21
|
updateNetworkStatus,
|
|
20
22
|
} from '../helpers';
|
|
21
|
-
import { getCurrentBlockchainOf
|
|
23
|
+
import { getCurrentBlockchainOf } from '../shared';
|
|
22
24
|
import { BlockReason } from '../types';
|
|
23
25
|
|
|
24
26
|
/**
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
SwapQueueContext,
|
|
6
|
-
SwapStorage,
|
|
7
|
-
} from '../types';
|
|
1
|
+
import type { SwapQueueContext, SwapStorage } from '../types';
|
|
2
|
+
import type { ExecuterActions } from '@rango-dev/queue-manager-core';
|
|
3
|
+
import type { PendingSwapStep } from 'rango-types';
|
|
4
|
+
|
|
8
5
|
import {
|
|
9
6
|
getCurrentStep,
|
|
10
7
|
getLastSuccessfulStep,
|
|
11
8
|
isTxAlreadyCreated,
|
|
12
9
|
} from '../helpers';
|
|
13
10
|
import { notifier } from '../services/eventEmitter';
|
|
11
|
+
import { StepEventType, SwapActionTypes } from '../types';
|
|
14
12
|
|
|
15
13
|
/**
|
|
16
14
|
*
|
|
@@ -30,7 +28,9 @@ export function scheduleNextStep({
|
|
|
30
28
|
}: ExecuterActions<SwapStorage, SwapActionTypes, SwapQueueContext>): void {
|
|
31
29
|
const swap = getStorage().swapDetails;
|
|
32
30
|
const currentStep = getCurrentStep(swap);
|
|
33
|
-
const isFailed = swap.steps.find(
|
|
31
|
+
const isFailed = swap.steps.find(
|
|
32
|
+
(step: PendingSwapStep) => step.status === 'failed'
|
|
33
|
+
);
|
|
34
34
|
|
|
35
35
|
if (!!currentStep && !isFailed) {
|
|
36
36
|
if (isTxAlreadyCreated(swap, currentStep)) {
|
|
@@ -84,7 +84,10 @@ export function scheduleNextStep({
|
|
|
84
84
|
step: null,
|
|
85
85
|
});
|
|
86
86
|
|
|
87
|
-
if (isFailed)
|
|
88
|
-
|
|
87
|
+
if (isFailed) {
|
|
88
|
+
failed();
|
|
89
|
+
} else {
|
|
90
|
+
next();
|
|
91
|
+
}
|
|
89
92
|
}
|
|
90
93
|
}
|