@rango-dev/queue-manager-rango-preset 0.23.0 → 0.24.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 +1 -31
- package/dist/actions/checkStatus.d.ts +2 -3
- package/dist/actions/checkStatus.d.ts.map +1 -1
- package/dist/actions/executeTransaction.d.ts +2 -2
- package/dist/actions/executeTransaction.d.ts.map +1 -1
- package/dist/actions/scheduleNextStep.d.ts +2 -3
- package/dist/actions/scheduleNextStep.d.ts.map +1 -1
- package/dist/helpers.d.ts +25 -10
- 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 +2 -2
- 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 +100 -5
- package/dist/shared.d.ts.map +1 -1
- package/dist/types.d.ts +8 -7
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -5
- package/src/actions/checkStatus.ts +53 -71
- package/src/actions/executeTransaction.ts +26 -23
- package/src/actions/scheduleNextStep.ts +10 -13
- package/src/helpers.ts +123 -149
- package/src/index.ts +9 -1
- package/src/migration.ts +11 -11
- package/src/services/eventEmitter.ts +22 -39
- package/src/shared-sentry.ts +2 -3
- package/src/shared.ts +182 -103
- package/src/types.ts +8 -18
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":"AAYA;;;;GAIG;AACH,iBAAS,QAAQ,IAAI,OAAO,CAE3B;AAYD;;;;;GAKG;AACH,iBAAe,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC,CAoF3C;AAED,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { RemoveNameField, RouteExecutionEvents, StepEvent } from '../types';
|
|
2
|
+
import { PendingSwap, PendingSwapStep } from 'rango-types/lib';
|
|
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":"
|
|
1
|
+
{"version":3,"file":"eventEmitter.d.ts","sourceRoot":"","sources":["../../src/services/eventEmitter.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,eAAe,EAIf,oBAAoB,EAGpB,SAAS,EAIV,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAS/D,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;AA0GF,eAAO,MAAM,YAAY,8CAA+B,CAAC;AA0BzD,wBAAgB,QAAQ,CAAC,MAAM,EAAE,cAAc,QA+F9C"}
|
package/dist/shared-sentry.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { PendingSwap, PendingSwapStep } from './shared';
|
|
2
|
+
import { WalletType } from '@rango-dev/wallets-shared';
|
|
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":"AACA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD,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,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import type { PendingSwap, PendingSwapStep, SwapSavedSettings, WalletTypeAndAddress } from 'rango-types';
|
|
1
|
+
import { Network, WalletType } from '@rango-dev/wallets-shared';
|
|
2
|
+
import { CosmosTransaction, EvmTransaction, SimulationResult, SolanaTransaction, StarknetTransaction, TronTransaction, Transfer as TransferTransaction, AmountRestrictionType, BestRouteResponse, MetaResponse, Token, SwapResult, BlockchainMeta } from 'rango-sdk';
|
|
4
3
|
import BigNumber from 'bignumber.js';
|
|
4
|
+
import { TonTransaction } from 'rango-types';
|
|
5
5
|
export interface PendingSwapWithQueueID {
|
|
6
6
|
id: string;
|
|
7
7
|
swap: PendingSwap;
|
|
@@ -34,6 +34,77 @@ 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
|
+
};
|
|
37
108
|
export declare enum MessageSeverity {
|
|
38
109
|
error = "error",
|
|
39
110
|
warning = "warning",
|
|
@@ -41,6 +112,29 @@ export declare enum MessageSeverity {
|
|
|
41
112
|
success = "success"
|
|
42
113
|
}
|
|
43
114
|
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
|
+
};
|
|
44
138
|
export declare const getCurrentBlockchainOfOrNull: (swap: PendingSwap, step: PendingSwapStep) => Network | null;
|
|
45
139
|
export declare const getCurrentBlockchainOf: (swap: PendingSwap, step: PendingSwapStep) => Network;
|
|
46
140
|
export declare const getScannerUrl: (txHash: string, network: Network, blockchainMetaMap: {
|
|
@@ -52,10 +146,11 @@ export declare function getNextStep(swap: PendingSwap, currentStep: PendingSwapS
|
|
|
52
146
|
*/
|
|
53
147
|
export declare const getCurrentAddressOf: (swap: PendingSwap, step: PendingSwapStep) => string;
|
|
54
148
|
export declare function getRelatedWallet(swap: PendingSwap, currentStep: PendingSwapStep): WalletTypeAndAddress;
|
|
55
|
-
export declare function getRelatedWalletOrNull(swap: PendingSwap, currentStep: PendingSwapStep
|
|
149
|
+
export declare function getRelatedWalletOrNull(swap: PendingSwap, currentStep: PendingSwapStep): WalletTypeAndAddress | null;
|
|
56
150
|
export declare const getUsdPrice: (blockchain: string, symbol: string, address: string | null, allTokens: Token[]) => number | null;
|
|
57
151
|
export declare function getUsdFeeOfStep(step: SwapResult, allTokens: Token[]): BigNumber;
|
|
58
152
|
export declare function calculatePendingSwap(inputAmount: string, bestRoute: BestRouteResponse, wallets: {
|
|
59
153
|
[p: string]: WalletTypeAndAddress;
|
|
60
|
-
}, settings: SwapSavedSettings, validateBalanceOrFee: boolean, meta:
|
|
154
|
+
}, settings: SwapSavedSettings, validateBalanceOrFee: boolean, meta: MetaResponse | null): PendingSwap;
|
|
155
|
+
export {};
|
|
61
156
|
//# 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,
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,QAAQ,IAAI,mBAAmB,EAC/B,qBAAqB,EACrB,iBAAiB,EACjB,YAAY,EACZ,KAAK,EACL,UAAU,EACV,cAAc,EACf,MAAM,WAAW,CAAC;AAGnB,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,OAAO,EACL,cAAc,EAKf,MAAM,aAAa,CAAC;AAErB,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;IACvB,SAAS,EAAE,MAA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AG,SAOX,CAAC;AAEF,wBAAgB,WAAW,CACzB,IAAI,EAAE,WAAW,EACjB,WAAW,EAAE,eAAe,GAC3B,eAAe,GAAG,IAAI,CASxB;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,SACxB,WAAW,QACX,eAAe,KACpB,MAiBF,CAAC;AAEF,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,WAAW,EACjB,WAAW,EAAE,eAAe,GAC3B,oBAAoB,CAetB;AAED,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,WAAW,EACjB,WAAW,EAAE,eAAe,GAC3B,oBAAoB,GAAG,IAAI,CAM7B;AAED,eAAO,MAAM,WAAW,eACV,MAAM,UACV,MAAM,WACL,MAAM,GAAG,IAAI,aACX,KAAK,EAAE,KACjB,MAAM,GAAG,IAQX,CAAC;AAEF,wBAAgB,eAAe,CAC7B,IAAI,EAAE,UAAU,EAChB,SAAS,EAAE,KAAK,EAAE,GACjB,SAAS,CAkBX;AAED,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,iBAAiB,EAC5B,OAAO,EAAE;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,oBAAoB,CAAA;CAAE,EAC9C,QAAQ,EAAE,iBAAiB,EAC3B,oBAAoB,EAAE,OAAO,EAC7B,IAAI,EAAE,YAAY,GAAG,IAAI,GACxB,WAAW,CAyFb"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
1
|
+
import { QueueStorage, QueueDef } from '@rango-dev/queue-manager-core';
|
|
2
|
+
import { QueueContext } from '@rango-dev/queue-manager-core/dist/queue';
|
|
3
|
+
import { ConnectResult, Providers } from '@rango-dev/wallets-react';
|
|
4
|
+
import { Meta, Network, WalletState, WalletType } from '@rango-dev/wallets-shared';
|
|
5
|
+
import { APIErrorCode, EvmBlockchainMeta, SignerFactory } from 'rango-types';
|
|
6
|
+
import { Transaction } from 'rango-sdk';
|
|
7
|
+
import { PendingSwap, PendingSwapStep, Wallet } from './shared';
|
|
7
8
|
export type RemoveNameField<T, U extends string> = {
|
|
8
9
|
[Property in keyof T as Exclude<Property, U>]: T[Property];
|
|
9
10
|
};
|
|
@@ -35,7 +36,7 @@ export interface SwapQueueContext extends QueueContext {
|
|
|
35
36
|
wallets: Wallet | null;
|
|
36
37
|
providers: Providers;
|
|
37
38
|
getSigners: (type: WalletType) => SignerFactory;
|
|
38
|
-
switchNetwork: (wallet: WalletType, network: Network) => Promise<ConnectResult
|
|
39
|
+
switchNetwork: (wallet: WalletType, network: Network) => Promise<ConnectResult> | undefined;
|
|
39
40
|
canSwitchNetworkTo: (type: WalletType, network: Network) => boolean;
|
|
40
41
|
connect: (wallet: WalletType, network: Network) => Promise<ConnectResult> | undefined;
|
|
41
42
|
state: (type: WalletType) => WalletState;
|
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,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EACL,IAAI,EACJ,OAAO,EACP,WAAW,EACX,UAAU,EACX,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,EAA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
"
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
7
|
"main": "./dist/index.js",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": "./dist/index.js"
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
],
|
|
16
16
|
"scripts": {
|
|
17
17
|
"build": "node ../../scripts/build/command.mjs --path queue-manager/rango-preset",
|
|
18
|
-
"ts-check": "tsc --declaration --emitDeclarationOnly -p ./tsconfig.json",
|
|
19
18
|
"clean": "rimraf dist",
|
|
20
19
|
"format": "prettier --write '{.,src}/**/*.{ts,tsx}'",
|
|
21
20
|
"lint": "eslint \"**/*.{ts,tsx}\" --ignore-path ../../.eslintignore"
|
|
@@ -23,7 +22,7 @@
|
|
|
23
22
|
"peerDependencies": {
|
|
24
23
|
"@rango-dev/queue-manager-core": "*",
|
|
25
24
|
"@rango-dev/queue-manager-react": "*",
|
|
26
|
-
"@rango-dev/wallets-
|
|
25
|
+
"@rango-dev/wallets-react": "*",
|
|
27
26
|
"@rango-dev/wallets-shared": "*",
|
|
28
27
|
"@sentry/browser": "*",
|
|
29
28
|
"bignumber.js": "*",
|
|
@@ -37,7 +36,7 @@
|
|
|
37
36
|
"dependencies": {
|
|
38
37
|
"@sentry/browser": "^6.12.0",
|
|
39
38
|
"mitt": "^3.0.0",
|
|
40
|
-
"rango-types": "^0.1.
|
|
39
|
+
"rango-types": "^0.1.46",
|
|
41
40
|
"uuid": "^9.0.0"
|
|
42
41
|
},
|
|
43
42
|
"publishConfig": {
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
import
|
|
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';
|
|
1
|
+
import { ExecuterActions } from '@rango-dev/queue-manager-core';
|
|
7
2
|
import {
|
|
8
3
|
delay,
|
|
9
4
|
getCurrentStep,
|
|
10
5
|
getCurrentStepTx,
|
|
11
6
|
getCurrentStepTxType,
|
|
12
|
-
inMemoryTransactionsData,
|
|
13
7
|
resetNetworkStatus,
|
|
14
8
|
setCurrentStepTx,
|
|
15
9
|
updateSwapStatus,
|
|
10
|
+
inMemoryTransactionsData,
|
|
16
11
|
} from '../helpers';
|
|
17
|
-
import {
|
|
18
|
-
|
|
12
|
+
import {
|
|
13
|
+
StepEventType,
|
|
14
|
+
SwapActionTypes,
|
|
15
|
+
SwapQueueContext,
|
|
16
|
+
SwapStorage,
|
|
17
|
+
} from '../types';
|
|
19
18
|
import {
|
|
20
19
|
getCurrentBlockchainOf,
|
|
21
20
|
getNextStep,
|
|
@@ -23,11 +22,14 @@ import {
|
|
|
23
22
|
getScannerUrl,
|
|
24
23
|
MessageSeverity,
|
|
25
24
|
} from '../shared';
|
|
25
|
+
import { Transaction, TransactionStatusResponse } from 'rango-sdk';
|
|
26
|
+
import { httpService } from '../services';
|
|
27
|
+
import type { GenericSigner } from 'rango-types';
|
|
26
28
|
import { prettifyErrorMessage } from '../shared-errors';
|
|
27
|
-
import {
|
|
29
|
+
import { notifier } from '../services/eventEmitter';
|
|
30
|
+
import { DEFAULT_ERROR_CODE } from '../constants';
|
|
28
31
|
|
|
29
|
-
const
|
|
30
|
-
const INTERVAL_FOR_CHECK_APPROVAL = 2_000;
|
|
32
|
+
const INTERVAL_FOR_CHECK = 5_000;
|
|
31
33
|
|
|
32
34
|
/**
|
|
33
35
|
* Subscribe to status of swap transaction by checking from server periodically.
|
|
@@ -51,11 +53,10 @@ async function checkTransactionStatus({
|
|
|
51
53
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
52
54
|
const currentStep = getCurrentStep(swap)!;
|
|
53
55
|
|
|
54
|
-
if (!currentStep?.executedTransactionId)
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
56
|
+
if (!currentStep?.executedTransactionId) return;
|
|
57
57
|
const tx = getCurrentStepTx(currentStep);
|
|
58
58
|
let txId = currentStep.executedTransactionId;
|
|
59
|
+
let explorerUrlToUpdate = false;
|
|
59
60
|
let getTxReceiptFailed = false;
|
|
60
61
|
let status: TransactionStatusResponse | null = null;
|
|
61
62
|
let signer: GenericSigner<Transaction> | null = null;
|
|
@@ -65,14 +66,11 @@ async function checkTransactionStatus({
|
|
|
65
66
|
try {
|
|
66
67
|
const txType = getCurrentStepTxType(currentStep);
|
|
67
68
|
const sourceWallet = getRelatedWallet(swap, currentStep);
|
|
68
|
-
if (txType && sourceWallet)
|
|
69
|
+
if (txType && sourceWallet)
|
|
69
70
|
signer = context.getSigners(sourceWallet.walletType).getSigner(txType);
|
|
70
|
-
}
|
|
71
71
|
} catch (error) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
* no need to do anything
|
|
75
|
-
*/
|
|
72
|
+
// wallet is not connected yet
|
|
73
|
+
// no need to do anything
|
|
76
74
|
}
|
|
77
75
|
|
|
78
76
|
try {
|
|
@@ -85,6 +83,9 @@ async function checkTransactionStatus({
|
|
|
85
83
|
undefined;
|
|
86
84
|
const { hash: updatedTxHash, response: updatedTxResponse } =
|
|
87
85
|
await signer.wait(txId, chainId, txResponse);
|
|
86
|
+
if (updatedTxResponse?.isMultiSig) {
|
|
87
|
+
explorerUrlToUpdate = !updatedTxResponse.hashWasUpdated;
|
|
88
|
+
}
|
|
88
89
|
if (updatedTxHash !== txId) {
|
|
89
90
|
currentStep.executedTransactionId =
|
|
90
91
|
updatedTxHash || currentStep.executedTransactionId;
|
|
@@ -107,16 +108,17 @@ async function checkTransactionStatus({
|
|
|
107
108
|
}
|
|
108
109
|
}
|
|
109
110
|
txId = currentStep.executedTransactionId;
|
|
110
|
-
if (updatedTxHash && updatedTxResponse)
|
|
111
|
+
if (updatedTxHash && updatedTxResponse)
|
|
111
112
|
setTransactionDataByHash(updatedTxHash, {
|
|
112
113
|
response: updatedTxResponse,
|
|
113
114
|
});
|
|
114
|
-
}
|
|
115
115
|
} else {
|
|
116
116
|
setTransactionDataByHash(updatedTxHash, {
|
|
117
117
|
receiptReceived: true,
|
|
118
118
|
});
|
|
119
119
|
}
|
|
120
|
+
} else if (!signer) {
|
|
121
|
+
explorerUrlToUpdate = true;
|
|
120
122
|
}
|
|
121
123
|
} catch (error) {
|
|
122
124
|
const { extraMessage, extraMessageDetail, extraMessageErrorCode } =
|
|
@@ -141,10 +143,8 @@ async function checkTransactionStatus({
|
|
|
141
143
|
});
|
|
142
144
|
|
|
143
145
|
getTxReceiptFailed = true;
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
* This is not a ui requirement but the backend one.
|
|
147
|
-
*/
|
|
146
|
+
// We shouldn't return here, because we need to trigger check status job in backend.
|
|
147
|
+
// This is not a ui requirement but the backend one.
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
try {
|
|
@@ -155,22 +155,16 @@ async function checkTransactionStatus({
|
|
|
155
155
|
step: currentStep.id,
|
|
156
156
|
});
|
|
157
157
|
} catch (e) {
|
|
158
|
-
await delay(
|
|
158
|
+
await delay(INTERVAL_FOR_CHECK);
|
|
159
159
|
retry();
|
|
160
160
|
return;
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
if (getTxReceiptFailed) {
|
|
169
|
-
return failed();
|
|
170
|
-
}
|
|
171
|
-
if (currentStep?.status === 'failed') {
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
163
|
+
// If user cancel swap during check status api call,
|
|
164
|
+
// or getting transaction receipt failed,
|
|
165
|
+
// we should ignore check status response and return
|
|
166
|
+
if (getTxReceiptFailed) return failed();
|
|
167
|
+
if (currentStep?.status === 'failed') return;
|
|
174
168
|
|
|
175
169
|
const outputAmount: string | null =
|
|
176
170
|
status?.outputAmount ||
|
|
@@ -184,7 +178,9 @@ async function checkTransactionStatus({
|
|
|
184
178
|
currentStep.diagnosisUrl =
|
|
185
179
|
status?.diagnosisUrl || currentStep.diagnosisUrl || null;
|
|
186
180
|
currentStep.outputAmount = outputAmount || currentStep.outputAmount;
|
|
187
|
-
currentStep.explorerUrl =
|
|
181
|
+
currentStep.explorerUrl = !explorerUrlToUpdate
|
|
182
|
+
? status?.explorerUrl || currentStep.explorerUrl
|
|
183
|
+
: null;
|
|
188
184
|
currentStep.internalSteps = status?.steps || null;
|
|
189
185
|
|
|
190
186
|
const newTransaction = status?.newTx;
|
|
@@ -196,13 +192,13 @@ async function checkTransactionStatus({
|
|
|
196
192
|
setCurrentStepTx(currentStep, newTransaction);
|
|
197
193
|
}
|
|
198
194
|
|
|
199
|
-
if (prevOutputAmount === null && outputAmount !== null)
|
|
195
|
+
if (prevOutputAmount === null && outputAmount !== null)
|
|
200
196
|
notifier({
|
|
201
197
|
event: { type: StepEventType.OUTPUT_REVEALED, outputAmount },
|
|
202
198
|
swap: swap,
|
|
203
199
|
step: currentStep,
|
|
204
200
|
});
|
|
205
|
-
|
|
201
|
+
else if (prevOutputAmount === null && outputAmount === null) {
|
|
206
202
|
// it is needed to set notification after reloading the page
|
|
207
203
|
notifier({
|
|
208
204
|
event: { type: StepEventType.CHECK_STATUS },
|
|
@@ -245,7 +241,7 @@ async function checkTransactionStatus({
|
|
|
245
241
|
schedule(SwapActionTypes.SCHEDULE_NEXT_STEP);
|
|
246
242
|
next();
|
|
247
243
|
} else {
|
|
248
|
-
await delay(
|
|
244
|
+
await delay(INTERVAL_FOR_CHECK);
|
|
249
245
|
retry();
|
|
250
246
|
}
|
|
251
247
|
}
|
|
@@ -267,7 +263,7 @@ async function checkApprovalStatus({
|
|
|
267
263
|
SwapActionTypes,
|
|
268
264
|
SwapQueueContext
|
|
269
265
|
>): Promise<void> {
|
|
270
|
-
const swap = getStorage().swapDetails;
|
|
266
|
+
const swap = getStorage().swapDetails as SwapStorage['swapDetails'];
|
|
271
267
|
const { meta } = context;
|
|
272
268
|
const { getTransactionDataByHash, setTransactionDataByHash } =
|
|
273
269
|
inMemoryTransactionsData();
|
|
@@ -279,23 +275,18 @@ async function checkApprovalStatus({
|
|
|
279
275
|
}
|
|
280
276
|
const tx = getCurrentStepTx(currentStep);
|
|
281
277
|
|
|
282
|
-
if (!currentStep?.executedTransactionId)
|
|
283
|
-
return;
|
|
284
|
-
}
|
|
278
|
+
if (!currentStep?.executedTransactionId) return;
|
|
285
279
|
let txId = currentStep.executedTransactionId;
|
|
286
280
|
|
|
287
281
|
let signer: GenericSigner<Transaction> | null = null;
|
|
288
282
|
try {
|
|
289
283
|
const txType = getCurrentStepTxType(currentStep);
|
|
290
284
|
const sourceWallet = getRelatedWallet(swap, currentStep);
|
|
291
|
-
if (txType && sourceWallet)
|
|
285
|
+
if (txType && sourceWallet)
|
|
292
286
|
signer = context.getSigners(sourceWallet.walletType).getSigner(txType);
|
|
293
|
-
}
|
|
294
287
|
} catch (error) {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
* no need to do anything
|
|
298
|
-
*/
|
|
288
|
+
// wallet is not connected yet
|
|
289
|
+
// no need to do anything
|
|
299
290
|
}
|
|
300
291
|
|
|
301
292
|
try {
|
|
@@ -330,11 +321,10 @@ async function checkApprovalStatus({
|
|
|
330
321
|
}
|
|
331
322
|
}
|
|
332
323
|
txId = currentStep.executedTransactionId;
|
|
333
|
-
if (updatedTxHash && updatedTxResponse)
|
|
324
|
+
if (updatedTxHash && updatedTxResponse)
|
|
334
325
|
setTransactionDataByHash(updatedTxHash, {
|
|
335
326
|
response: updatedTxResponse,
|
|
336
327
|
});
|
|
337
|
-
}
|
|
338
328
|
} else {
|
|
339
329
|
setTransactionDataByHash(updatedTxHash, {
|
|
340
330
|
receiptReceived: true,
|
|
@@ -371,9 +361,7 @@ async function checkApprovalStatus({
|
|
|
371
361
|
currentStep.executedTransactionId
|
|
372
362
|
);
|
|
373
363
|
// If user cancel swap during check status api call, we should ignore check approval response
|
|
374
|
-
if (currentStep?.status === 'failed')
|
|
375
|
-
return;
|
|
376
|
-
}
|
|
364
|
+
if (currentStep?.status === 'failed') return;
|
|
377
365
|
|
|
378
366
|
isApproved = response.isApproved;
|
|
379
367
|
if (
|
|
@@ -386,16 +374,12 @@ async function checkApprovalStatus({
|
|
|
386
374
|
details = 'Smart contract approval tx failed in blockchain.';
|
|
387
375
|
} else {
|
|
388
376
|
message = 'Not enough approval';
|
|
389
|
-
if (response.requiredApprovedAmount && response.currentApprovedAmount)
|
|
377
|
+
if (response.requiredApprovedAmount && response.currentApprovedAmount)
|
|
390
378
|
details = `Required approval: ${response.requiredApprovedAmount}, current approval: ${response.currentApprovedAmount}`;
|
|
391
|
-
|
|
392
|
-
details = `You still don't have enough approval for this swap.`;
|
|
393
|
-
}
|
|
379
|
+
else details = `You still don't have enough approval for this swap.`;
|
|
394
380
|
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
* we should fail the whole swap
|
|
398
|
-
*/
|
|
381
|
+
// approve transaction failed on
|
|
382
|
+
// we should fail the whole swap
|
|
399
383
|
const updateResult = updateSwapStatus({
|
|
400
384
|
getStorage,
|
|
401
385
|
setStorage,
|
|
@@ -452,7 +436,7 @@ async function checkApprovalStatus({
|
|
|
452
436
|
schedule(SwapActionTypes.SCHEDULE_NEXT_STEP);
|
|
453
437
|
next();
|
|
454
438
|
} else {
|
|
455
|
-
await delay(
|
|
439
|
+
await delay(2000);
|
|
456
440
|
retry();
|
|
457
441
|
}
|
|
458
442
|
}
|
|
@@ -475,10 +459,8 @@ export async function checkStatus(
|
|
|
475
459
|
return;
|
|
476
460
|
}
|
|
477
461
|
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
* Because when check status is on `loading` or `failed` status, it shows previous message that isn't related to current state.
|
|
481
|
-
*/
|
|
462
|
+
// Reset network status
|
|
463
|
+
// Because when check status is on `loading` or `failed` status, it shows previous message that isn't related to current state.
|
|
482
464
|
resetNetworkStatus(actions);
|
|
483
465
|
|
|
484
466
|
if (currentStep.status === 'running') {
|
|
@@ -1,27 +1,29 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { ExecuterActions } from '@rango-dev/queue-manager-core';
|
|
3
|
-
|
|
4
|
-
import { PendingSwapNetworkStatus } from 'rango-types';
|
|
5
|
-
|
|
1
|
+
import { ExecuterActions } from '@rango-dev/queue-manager-core';
|
|
6
2
|
import {
|
|
7
3
|
ERROR_MESSAGE_DEPENDS_ON_OTHER_QUEUES,
|
|
8
4
|
ERROR_MESSAGE_WAIT_FOR_CHANGE_NETWORK,
|
|
9
5
|
ERROR_MESSAGE_WAIT_FOR_WALLET_DESCRIPTION,
|
|
10
6
|
ERROR_MESSAGE_WAIT_FOR_WALLET_DESCRIPTION_WRONG_WALLET,
|
|
11
7
|
} from '../constants';
|
|
8
|
+
|
|
12
9
|
import {
|
|
13
|
-
claimQueue,
|
|
14
10
|
getCurrentStep,
|
|
15
|
-
getRequiredWallet,
|
|
16
|
-
isNeedBlockQueueForParallel,
|
|
17
11
|
isNetworkMatchedForTransaction,
|
|
18
12
|
isRequiredWalletConnected,
|
|
19
|
-
resetNetworkStatus,
|
|
20
|
-
signTransaction,
|
|
21
13
|
updateNetworkStatus,
|
|
14
|
+
singTransaction,
|
|
15
|
+
resetNetworkStatus,
|
|
16
|
+
getRequiredWallet,
|
|
17
|
+
isNeedBlockQueueForParallel,
|
|
18
|
+
claimQueue,
|
|
22
19
|
} from '../helpers';
|
|
23
|
-
import { getCurrentBlockchainOf } from '../shared';
|
|
24
|
-
import {
|
|
20
|
+
import { getCurrentBlockchainOf, PendingSwapNetworkStatus } from '../shared';
|
|
21
|
+
import {
|
|
22
|
+
BlockReason,
|
|
23
|
+
SwapActionTypes,
|
|
24
|
+
SwapQueueContext,
|
|
25
|
+
SwapStorage,
|
|
26
|
+
} from '../types';
|
|
25
27
|
|
|
26
28
|
/**
|
|
27
29
|
* Excecute a created transaction.
|
|
@@ -103,18 +105,19 @@ export async function executeTransaction(
|
|
|
103
105
|
};
|
|
104
106
|
requestBlock(blockedFor);
|
|
105
107
|
return;
|
|
108
|
+
} else {
|
|
109
|
+
// Update network to mark it as network changed successfully.
|
|
110
|
+
updateNetworkStatus(actions, {
|
|
111
|
+
message: '',
|
|
112
|
+
details: 'Wallet network changed successfully',
|
|
113
|
+
status: PendingSwapNetworkStatus.NetworkChanged,
|
|
114
|
+
});
|
|
106
115
|
}
|
|
107
|
-
// Update network to mark it as network changed successfully.
|
|
108
|
-
updateNetworkStatus(actions, {
|
|
109
|
-
message: '',
|
|
110
|
-
details: 'Wallet network changed successfully',
|
|
111
|
-
status: PendingSwapNetworkStatus.NetworkChanged,
|
|
112
|
-
});
|
|
113
116
|
|
|
114
|
-
/*
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
117
|
+
/*
|
|
118
|
+
For avoiding conflict by making too many requests to wallet, we need to make sure
|
|
119
|
+
We only run one request at a time (In parallel mode).
|
|
120
|
+
*/
|
|
118
121
|
const needsToBlockQueue = isNeedBlockQueueForParallel(currentStep);
|
|
119
122
|
|
|
120
123
|
if (needsToBlockQueue && !isClaimed) {
|
|
@@ -128,5 +131,5 @@ export async function executeTransaction(
|
|
|
128
131
|
}
|
|
129
132
|
|
|
130
133
|
// All the conditions are met. We can safely send the tx to wallet for sign.
|
|
131
|
-
|
|
134
|
+
singTransaction(actions);
|
|
132
135
|
}
|