@rango-dev/queue-manager-rango-preset 0.5.1-next.2 → 0.5.1-next.20
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/dist/actions/checkStatus.d.ts.map +1 -1
- package/dist/actions/createTransaction.d.ts.map +1 -1
- package/dist/actions/scheduleNextStep.d.ts +1 -1
- package/dist/actions/scheduleNextStep.d.ts.map +1 -1
- package/dist/actions/start.d.ts +1 -1
- package/dist/actions/start.d.ts.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/helpers.d.ts +15 -10
- package/dist/helpers.d.ts.map +1 -1
- package/dist/hooks.d.ts +2 -1
- package/dist/hooks.d.ts.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/services/eventEmitter.d.ts +12 -0
- package/dist/services/eventEmitter.d.ts.map +1 -0
- package/dist/shared-errors.d.ts.map +1 -1
- package/dist/shared.d.ts +2 -5
- package/dist/shared.d.ts.map +1 -1
- package/dist/types.d.ts +109 -4
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/actions/checkStatus.ts +61 -21
- package/src/actions/createTransaction.ts +25 -4
- package/src/actions/scheduleNextStep.ts +34 -5
- package/src/actions/start.ts +7 -1
- package/src/constants.ts +2 -0
- package/src/helpers.ts +246 -111
- package/src/hooks.ts +7 -8
- package/src/index.ts +30 -3
- package/src/services/eventEmitter.ts +257 -0
- package/src/shared-errors.ts +9 -7
- package/src/shared.ts +3 -6
- package/src/types.ts +199 -4
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RemoveNameField, RouteExecutionEvents, StepEvent } from '../types';
|
|
2
|
+
import { PendingSwap, PendingSwapStep } from 'rango-types/lib';
|
|
3
|
+
type NotifierParams = {
|
|
4
|
+
swap: PendingSwap;
|
|
5
|
+
step: PendingSwapStep | null;
|
|
6
|
+
} & {
|
|
7
|
+
event: RemoveNameField<StepEvent, 'message' | 'messageSeverity'>;
|
|
8
|
+
};
|
|
9
|
+
export declare const eventEmitter: import("mitt").Emitter<RouteExecutionEvents>;
|
|
10
|
+
export declare function notifier(params: NotifierParams): void;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=eventEmitter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-errors.d.ts","sourceRoot":"","sources":["../src/shared-errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,IAAI,mBAAmB,EACvC,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"shared-errors.d.ts","sourceRoot":"","sources":["../src/shared-errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,IAAI,mBAAmB,EACvC,MAAM,aAAa,CAAC;AASrB,MAAM,MAAM,WAAW,GAAG;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC/C,qBAAqB,EAAE,mBAAmB,GAAG,YAAY,GAAG,IAAI,CAAC;CAClE,CAAC;AAMF,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;AAExD,qBAAa,WAAY,SAAQ,KAAK;IACpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAY;IAClC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAe;IAC9B,cAAc,UAAQ;gBAG3B,IAAI,EAAE,YAAY,EAClB,CAAC,EAAE,MAAM,EACT,IAAI,CAAC,EAAE,SAAS,EAChB,MAAM,CAAC,EAAE,MAAM;IAUjB,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,WAAW;IAOtD,cAAc,IAAI,WAAW;IAkB7B,MAAM,CAAC,eAAe,CAAC,CAAC,EAAE,MAAM,GAAG,WAAW;IAS9C,MAAM,CAAC,aAAa,CAClB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GAAG,MAAM,GAC1B,WAAW;IASd,MAAM,CAAC,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW;IASrD,MAAM,CAAC,aAAa,IAAI,WAAW;IASnC,MAAM,CAAC,iBAAiB,IAAI,WAAW;CAQxC;AAED,wBAAgB,8BAA8B,CAC5C,SAAS,EAAE,MAAM,GAAG,IAAI,GACvB,YAAY,CAoBd;AAED,eAAO,MAAM,oBAAoB,QAAS,OAAO,KAAG,WAsBnD,CAAC"}
|
package/dist/shared.d.ts
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import { Network, WalletType } from '@rango-dev/wallets-shared';
|
|
2
2
|
import { CosmosTransaction, EvmTransaction, SimulationResult, SolanaTransaction, StarknetTransaction, TronTransaction, Transfer as TransferTransaction, AmountRestrictionType, BestRouteResponse, MetaResponse, Token, SwapResult, BlockchainMeta } from 'rango-sdk';
|
|
3
3
|
import BigNumber from 'bignumber.js';
|
|
4
|
+
import { TonTransaction } from 'rango-types';
|
|
4
5
|
export interface PendingSwapWithQueueID {
|
|
5
6
|
id: string;
|
|
6
7
|
swap: PendingSwap;
|
|
7
8
|
}
|
|
8
|
-
export type SwapProgressNotification = {
|
|
9
|
-
eventType: EventType;
|
|
10
|
-
swap: PendingSwap | null;
|
|
11
|
-
step: PendingSwapStep | null;
|
|
12
|
-
};
|
|
13
9
|
export type WalletBalance = {
|
|
14
10
|
chain: Network;
|
|
15
11
|
symbol: string;
|
|
@@ -98,6 +94,7 @@ export type PendingSwapStep = {
|
|
|
98
94
|
tronTransaction: TronTransaction | null;
|
|
99
95
|
starknetApprovalTransaction: StarknetTransaction | null;
|
|
100
96
|
starknetTransaction: StarknetTransaction | null;
|
|
97
|
+
tonTransaction: TonTransaction | null;
|
|
101
98
|
swapperLogo: string | null;
|
|
102
99
|
swapperType: string | null;
|
|
103
100
|
fromBlockchainLogo: string | null;
|
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,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;
|
|
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,OAA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AAiB,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
|
@@ -2,8 +2,13 @@ import { QueueStorage, QueueDef } from '@rango-dev/queue-manager-core';
|
|
|
2
2
|
import { QueueContext } from '@rango-dev/queue-manager-core/dist/queue';
|
|
3
3
|
import { ConnectResult, Providers } from '@rango-dev/wallets-core';
|
|
4
4
|
import { Meta, Network, WalletState, WalletType } from '@rango-dev/wallets-shared';
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
5
|
+
import { APIErrorCode, EvmBlockchainMeta, SignerFactory } from 'rango-types';
|
|
6
|
+
import { Transaction } from 'rango-sdk';
|
|
7
|
+
import { PendingSwap, PendingSwapStep, Wallet } from './shared';
|
|
8
|
+
export type RemoveNameField<T, U extends string> = {
|
|
9
|
+
[Property in keyof T as Exclude<Property, U>]: T[Property];
|
|
10
|
+
};
|
|
11
|
+
export type ArrayElement<A> = A extends readonly (infer T)[] ? T : never;
|
|
7
12
|
export type SwapQueueDef = QueueDef<SwapStorage, SwapActionTypes, SwapQueueContext>;
|
|
8
13
|
export interface SwapStorage extends QueueStorage {
|
|
9
14
|
swapDetails: PendingSwap;
|
|
@@ -36,7 +41,6 @@ export interface SwapQueueContext extends QueueContext {
|
|
|
36
41
|
connect: (wallet: WalletType, network: Network) => Promise<ConnectResult> | undefined;
|
|
37
42
|
state: (type: WalletType) => WalletState;
|
|
38
43
|
isMobileWallet: (type: WalletType) => boolean;
|
|
39
|
-
notifier: (data: SwapProgressNotification) => void;
|
|
40
44
|
claimedBy?: string;
|
|
41
45
|
resetClaimedBy?: () => void;
|
|
42
46
|
}
|
|
@@ -45,7 +49,108 @@ export interface UseQueueManagerParams {
|
|
|
45
49
|
disconnectedWallet: WalletType | undefined;
|
|
46
50
|
clearDisconnectedWallet: () => void;
|
|
47
51
|
evmChains: EvmBlockchainMeta[];
|
|
48
|
-
notifier: SwapQueueContext['notifier'];
|
|
49
52
|
canSwitchNetworkTo: (type: WalletType, network: Network) => boolean;
|
|
50
53
|
}
|
|
54
|
+
export declare enum MainEvents {
|
|
55
|
+
RouteEvent = "routeEvent",
|
|
56
|
+
StepEvent = "stepEvent"
|
|
57
|
+
}
|
|
58
|
+
export type Step = Pick<PendingSwapStep, 'diagnosisUrl' | 'estimatedTimeInSeconds' | 'explorerUrl' | 'feeInUsd' | 'executedTransactionId' | 'executedTransactionTime' | 'expectedOutputAmountHumanReadable' | 'fromBlockchain' | 'toBlockchain' | 'fromSymbol' | 'toSymbol' | 'toSymbolAddress' | 'fromSymbolAddress' | 'swapperType' | 'outputAmount' | 'fromAmountMaxValue' | 'fromAmountMinValue' | 'fromAmountPrecision' | 'fromAmountRestrictionType' | 'fromDecimals' | 'status'> & {
|
|
59
|
+
swapperName: string;
|
|
60
|
+
transaction: Transaction | null;
|
|
61
|
+
};
|
|
62
|
+
export type Route = Pick<PendingSwap, 'creationTime' | 'finishTime' | 'requestId' | 'inputAmount' | 'status' | 'wallets'> & {
|
|
63
|
+
steps: Step[];
|
|
64
|
+
slippage: string;
|
|
65
|
+
infiniteApproval?: boolean;
|
|
66
|
+
};
|
|
67
|
+
export type SwapEvent = RouteEvent | StepEvent;
|
|
68
|
+
export declare enum RouteEventType {
|
|
69
|
+
STARTED = "started",
|
|
70
|
+
FAILED = "failed",
|
|
71
|
+
SUCCEEDED = "succeeded"
|
|
72
|
+
}
|
|
73
|
+
export declare enum StepExecutionEventStatus {
|
|
74
|
+
CREATE_TX = "create_tx",
|
|
75
|
+
SEND_TX = "send_tx",
|
|
76
|
+
TX_SENT = "tx_sent"
|
|
77
|
+
}
|
|
78
|
+
export declare enum StepExecutionBlockedEventStatus {
|
|
79
|
+
WAITING_FOR_QUEUE = "waiting_for_queue",
|
|
80
|
+
WAITING_FOR_WALLET_CONNECT = "waiting_for_wallet_connect",
|
|
81
|
+
WAITING_FOR_NETWORK_CHANGE = "waiting_for_network_change",
|
|
82
|
+
WAITING_FOR_CHANGE_WALLET_ACCOUNT = "waiting_for_change_wallet_account"
|
|
83
|
+
}
|
|
84
|
+
export declare enum StepEventType {
|
|
85
|
+
STARTED = "started",
|
|
86
|
+
FAILED = "failed",
|
|
87
|
+
SUCCEEDED = "succeeded",
|
|
88
|
+
TX_EXECUTION = "tx_execution",
|
|
89
|
+
TX_EXECUTION_BLOCKED = "tx_execution_blocked",
|
|
90
|
+
APPROVAL_TX_SUCCEEDED = "approval_tx_succeeded",
|
|
91
|
+
CHECK_STATUS = "check_status",
|
|
92
|
+
OUTPUT_REVEALED = "output_revealed"
|
|
93
|
+
}
|
|
94
|
+
export declare enum EventSeverity {
|
|
95
|
+
ERROR = "error",
|
|
96
|
+
SUCCESS = "success",
|
|
97
|
+
WARNING = "warning",
|
|
98
|
+
INFO = "info"
|
|
99
|
+
}
|
|
100
|
+
export type Event<T extends StepEventType | RouteEventType, U extends Record<string, unknown> = Record<string, unknown>> = {
|
|
101
|
+
type: T;
|
|
102
|
+
message: string;
|
|
103
|
+
messageSeverity: EventSeverity;
|
|
104
|
+
} & U;
|
|
105
|
+
export type FailedRouteEventPayload = {
|
|
106
|
+
reason?: string;
|
|
107
|
+
reasonCode: APIErrorCode;
|
|
108
|
+
};
|
|
109
|
+
export type FailedStepEventPayload = FailedRouteEventPayload;
|
|
110
|
+
export type SucceededRouteEventPayload = {
|
|
111
|
+
outputAmount: string;
|
|
112
|
+
};
|
|
113
|
+
export type SucceededStepEventPayload = SucceededRouteEventPayload;
|
|
114
|
+
export type OutputRevealedEventPayload = SucceededRouteEventPayload;
|
|
115
|
+
export type StepExecutionEventPayload = {
|
|
116
|
+
status: StepExecutionEventStatus.CREATE_TX | StepExecutionEventStatus.SEND_TX | StepExecutionEventStatus.TX_SENT;
|
|
117
|
+
};
|
|
118
|
+
export type StepBlockedEventPayload = {
|
|
119
|
+
status: StepExecutionBlockedEventStatus.WAITING_FOR_QUEUE;
|
|
120
|
+
} | {
|
|
121
|
+
status: StepExecutionBlockedEventStatus.WAITING_FOR_WALLET_CONNECT;
|
|
122
|
+
requiredWallet?: string;
|
|
123
|
+
requiredAccount?: string;
|
|
124
|
+
} | {
|
|
125
|
+
status: StepExecutionBlockedEventStatus.WAITING_FOR_CHANGE_WALLET_ACCOUNT;
|
|
126
|
+
requiredAccount?: string;
|
|
127
|
+
} | {
|
|
128
|
+
status: StepExecutionBlockedEventStatus.WAITING_FOR_NETWORK_CHANGE;
|
|
129
|
+
currentNetwork?: string;
|
|
130
|
+
requiredNetwork?: string;
|
|
131
|
+
};
|
|
132
|
+
export type RouteStartedEvent = Event<RouteEventType.STARTED>;
|
|
133
|
+
export type RouteFailedEvent = Event<RouteEventType.FAILED, FailedRouteEventPayload>;
|
|
134
|
+
export type RouteSucceededEvent = Event<RouteEventType.SUCCEEDED, SucceededRouteEventPayload>;
|
|
135
|
+
export type StepStartedEvent = Event<StepEventType.STARTED>;
|
|
136
|
+
export type StepSucceededEvent = Event<StepEventType.SUCCEEDED, SucceededStepEventPayload>;
|
|
137
|
+
export type StepFailedEvent = Event<StepEventType.FAILED, FailedStepEventPayload>;
|
|
138
|
+
export type StepTxExecutionUpdatedEvent = Event<StepEventType.TX_EXECUTION, StepExecutionEventPayload>;
|
|
139
|
+
export type StepTxExecutionBlockedEvent = Event<StepEventType.TX_EXECUTION_BLOCKED, StepBlockedEventPayload>;
|
|
140
|
+
export type StepCheckStatusEvent = Event<StepEventType.CHECK_STATUS>;
|
|
141
|
+
export type StepApprovalTxSucceededEvent = Event<StepEventType.APPROVAL_TX_SUCCEEDED>;
|
|
142
|
+
export type StepOutputRevealedEvent = Event<StepEventType.OUTPUT_REVEALED, OutputRevealedEventPayload>;
|
|
143
|
+
export type StepEvent = StepStartedEvent | StepSucceededEvent | StepFailedEvent | StepTxExecutionUpdatedEvent | StepTxExecutionBlockedEvent | StepCheckStatusEvent | StepApprovalTxSucceededEvent | StepOutputRevealedEvent;
|
|
144
|
+
export type RouteEvent = RouteStartedEvent | RouteSucceededEvent | RouteFailedEvent;
|
|
145
|
+
export type RouteExecutionEvents = {
|
|
146
|
+
[MainEvents.RouteEvent]: {
|
|
147
|
+
route: Route;
|
|
148
|
+
event: RouteEvent;
|
|
149
|
+
};
|
|
150
|
+
[MainEvents.StepEvent]: {
|
|
151
|
+
route: Route;
|
|
152
|
+
step: Step;
|
|
153
|
+
event: StepEvent;
|
|
154
|
+
};
|
|
155
|
+
};
|
|
51
156
|
//# sourceMappingURL=types.d.ts.map
|
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,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,yBAAyB,CAAC;AACnE,OAAO,EACL,IAAI,EACJ,OAAO,EACP,WAAW,EACX,UAAU,EACX,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,
|
|
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,yBAAyB,CAAC;AACnE,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,M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
3
|
+
"version": "0.5.1-next.20",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@sentry/browser": "^6.12.0",
|
|
40
|
-
"
|
|
40
|
+
"mitt": "^3.0.0",
|
|
41
|
+
"rango-types": "^0.1.45",
|
|
41
42
|
"uuid": "^9.0.0"
|
|
42
43
|
},
|
|
43
44
|
"publishConfig": {
|
|
@@ -2,13 +2,19 @@ import { ExecuterActions } from '@rango-dev/queue-manager-core';
|
|
|
2
2
|
import {
|
|
3
3
|
delay,
|
|
4
4
|
getCurrentStep,
|
|
5
|
+
getCurrentStepTx,
|
|
5
6
|
getCurrentStepTxType,
|
|
6
7
|
resetNetworkStatus,
|
|
7
8
|
setCurrentStepTx,
|
|
8
9
|
updateSwapStatus,
|
|
9
|
-
|
|
10
|
+
inMemoryTransactionsData,
|
|
10
11
|
} from '../helpers';
|
|
11
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
StepEventType,
|
|
14
|
+
SwapActionTypes,
|
|
15
|
+
SwapQueueContext,
|
|
16
|
+
SwapStorage,
|
|
17
|
+
} from '../types';
|
|
12
18
|
import {
|
|
13
19
|
getCurrentBlockchainOf,
|
|
14
20
|
getNextStep,
|
|
@@ -20,6 +26,8 @@ import { Transaction, TransactionStatusResponse } from 'rango-sdk';
|
|
|
20
26
|
import { httpService } from '../services';
|
|
21
27
|
import type { GenericSigner } from 'rango-types';
|
|
22
28
|
import { prettifyErrorMessage } from '../shared-errors';
|
|
29
|
+
import { notifier } from '../services/eventEmitter';
|
|
30
|
+
import { DEFAULT_ERROR_CODE } from '../constants';
|
|
23
31
|
|
|
24
32
|
const INTERVAL_FOR_CHECK = 5_000;
|
|
25
33
|
|
|
@@ -46,13 +54,14 @@ async function checkTransactionStatus({
|
|
|
46
54
|
const currentStep = getCurrentStep(swap)!;
|
|
47
55
|
|
|
48
56
|
if (!currentStep?.executedTransactionId) return;
|
|
57
|
+
const tx = getCurrentStepTx(currentStep);
|
|
49
58
|
let txId = currentStep.executedTransactionId;
|
|
50
59
|
|
|
51
60
|
let getTxReceiptFailed = false;
|
|
52
61
|
let status: TransactionStatusResponse | null = null;
|
|
53
62
|
let signer: GenericSigner<Transaction> | null = null;
|
|
54
63
|
const { getTransactionDataByHash, setTransactionDataByHash } =
|
|
55
|
-
|
|
64
|
+
inMemoryTransactionsData();
|
|
56
65
|
|
|
57
66
|
try {
|
|
58
67
|
const txType = getCurrentStepTxType(currentStep);
|
|
@@ -69,8 +78,11 @@ async function checkTransactionStatus({
|
|
|
69
78
|
const { response: txResponse, receiptReceived } =
|
|
70
79
|
getTransactionDataByHash(txId);
|
|
71
80
|
if (signer?.wait && !receiptReceived) {
|
|
81
|
+
const chainId =
|
|
82
|
+
(tx?.blockChain && meta.blockchains?.[tx?.blockChain]?.chainId) ||
|
|
83
|
+
undefined;
|
|
72
84
|
const { hash: updatedTxHash, response: updatedTxResponse } =
|
|
73
|
-
await signer.wait(txId, txResponse);
|
|
85
|
+
await signer.wait(txId, chainId, txResponse);
|
|
74
86
|
if (updatedTxHash !== txId) {
|
|
75
87
|
currentStep.executedTransactionId =
|
|
76
88
|
updatedTxHash || currentStep.executedTransactionId;
|
|
@@ -111,10 +123,16 @@ async function checkTransactionStatus({
|
|
|
111
123
|
details: extraMessageDetail,
|
|
112
124
|
errorCode: extraMessageErrorCode,
|
|
113
125
|
});
|
|
114
|
-
|
|
115
|
-
|
|
126
|
+
|
|
127
|
+
notifier({
|
|
128
|
+
event: {
|
|
129
|
+
type: StepEventType.FAILED,
|
|
130
|
+
reason: extraMessage,
|
|
131
|
+
reasonCode: updateResult.failureType ?? DEFAULT_ERROR_CODE,
|
|
132
|
+
},
|
|
116
133
|
...updateResult,
|
|
117
134
|
});
|
|
135
|
+
|
|
118
136
|
getTxReceiptFailed = true;
|
|
119
137
|
// We shouldn't return here, because we need to trigger check status job in backend.
|
|
120
138
|
// This is not a ui requirement but the backend one.
|
|
@@ -164,15 +182,15 @@ async function checkTransactionStatus({
|
|
|
164
182
|
}
|
|
165
183
|
|
|
166
184
|
if (prevOutputAmount === null && outputAmount !== null)
|
|
167
|
-
|
|
168
|
-
|
|
185
|
+
notifier({
|
|
186
|
+
event: { type: StepEventType.OUTPUT_REVEALED, outputAmount },
|
|
169
187
|
swap: swap,
|
|
170
188
|
step: currentStep,
|
|
171
189
|
});
|
|
172
190
|
else if (prevOutputAmount === null && outputAmount === null) {
|
|
173
191
|
// it is needed to set notification after reloading the page
|
|
174
|
-
|
|
175
|
-
|
|
192
|
+
notifier({
|
|
193
|
+
event: { type: StepEventType.CHECK_STATUS },
|
|
176
194
|
swap: swap,
|
|
177
195
|
step: currentStep,
|
|
178
196
|
});
|
|
@@ -184,6 +202,14 @@ async function checkTransactionStatus({
|
|
|
184
202
|
swap.extraMessage = nextStep
|
|
185
203
|
? `starting next step: ${nextStep.swapperId}: ${nextStep.fromBlockchain} -> ${nextStep.toBlockchain}`
|
|
186
204
|
: '';
|
|
205
|
+
notifier({
|
|
206
|
+
event: {
|
|
207
|
+
type: StepEventType.SUCCEEDED,
|
|
208
|
+
outputAmount: currentStep.outputAmount ?? '',
|
|
209
|
+
},
|
|
210
|
+
swap,
|
|
211
|
+
step: currentStep,
|
|
212
|
+
});
|
|
187
213
|
} else if (currentStep.status === 'failed') {
|
|
188
214
|
swap.extraMessage = 'Transaction failed in blockchain';
|
|
189
215
|
swap.extraMessageSeverity = MessageSeverity.error;
|
|
@@ -229,13 +255,14 @@ async function checkApprovalStatus({
|
|
|
229
255
|
const swap = getStorage().swapDetails as SwapStorage['swapDetails'];
|
|
230
256
|
const { meta } = context;
|
|
231
257
|
const { getTransactionDataByHash, setTransactionDataByHash } =
|
|
232
|
-
|
|
258
|
+
inMemoryTransactionsData();
|
|
233
259
|
|
|
234
260
|
const currentStep = getCurrentStep(swap);
|
|
235
261
|
if (!currentStep) {
|
|
236
262
|
console.log('ignore check status, current step is null');
|
|
237
263
|
return;
|
|
238
264
|
}
|
|
265
|
+
const tx = getCurrentStepTx(currentStep);
|
|
239
266
|
|
|
240
267
|
if (!currentStep?.executedTransactionId) return;
|
|
241
268
|
let txId = currentStep.executedTransactionId;
|
|
@@ -256,8 +283,11 @@ async function checkApprovalStatus({
|
|
|
256
283
|
getTransactionDataByHash(txId);
|
|
257
284
|
// if wallet is connected, try to get transaction reciept
|
|
258
285
|
if (signer?.wait && !receiptReceived) {
|
|
286
|
+
const chainId =
|
|
287
|
+
(tx?.blockChain && meta.blockchains?.[tx?.blockChain]?.chainId) ||
|
|
288
|
+
undefined;
|
|
259
289
|
const { hash: updatedTxHash, response: updatedTxResponse } =
|
|
260
|
-
await signer.wait(txId, txResponse);
|
|
290
|
+
await signer.wait(txId, chainId, txResponse);
|
|
261
291
|
if (updatedTxHash !== txId) {
|
|
262
292
|
currentStep.executedTransactionId =
|
|
263
293
|
updatedTxHash || currentStep.executedTransactionId;
|
|
@@ -298,8 +328,12 @@ async function checkApprovalStatus({
|
|
|
298
328
|
details: extraMessageDetail,
|
|
299
329
|
errorCode: extraMessageErrorCode,
|
|
300
330
|
});
|
|
301
|
-
|
|
302
|
-
|
|
331
|
+
notifier({
|
|
332
|
+
event: {
|
|
333
|
+
type: StepEventType.FAILED,
|
|
334
|
+
reason: extraMessage,
|
|
335
|
+
reasonCode: updateResult.failureType ?? DEFAULT_ERROR_CODE,
|
|
336
|
+
},
|
|
303
337
|
...updateResult,
|
|
304
338
|
});
|
|
305
339
|
return failed();
|
|
@@ -340,16 +374,22 @@ async function checkApprovalStatus({
|
|
|
340
374
|
message: message,
|
|
341
375
|
details: details,
|
|
342
376
|
});
|
|
343
|
-
|
|
344
|
-
|
|
377
|
+
|
|
378
|
+
notifier({
|
|
379
|
+
event: {
|
|
380
|
+
type: StepEventType.FAILED,
|
|
381
|
+
reason: message,
|
|
382
|
+
reasonCode: updateResult.failureType ?? DEFAULT_ERROR_CODE,
|
|
383
|
+
},
|
|
345
384
|
...updateResult,
|
|
346
385
|
});
|
|
386
|
+
|
|
347
387
|
failed();
|
|
348
388
|
} else if (!isApproved) {
|
|
349
389
|
// it is needed to set notification after reloading the page
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
swap
|
|
390
|
+
notifier({
|
|
391
|
+
event: { type: StepEventType.CHECK_STATUS },
|
|
392
|
+
swap,
|
|
353
393
|
step: currentStep,
|
|
354
394
|
});
|
|
355
395
|
}
|
|
@@ -372,8 +412,8 @@ async function checkApprovalStatus({
|
|
|
372
412
|
swapDetails: swap,
|
|
373
413
|
});
|
|
374
414
|
|
|
375
|
-
|
|
376
|
-
|
|
415
|
+
notifier({
|
|
416
|
+
event: { type: StepEventType.APPROVAL_TX_SUCCEEDED },
|
|
377
417
|
swap: swap,
|
|
378
418
|
step: currentStep,
|
|
379
419
|
});
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { ExecuterActions } from '@rango-dev/queue-manager-core';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
StepEventType,
|
|
4
|
+
SwapActionTypes,
|
|
5
|
+
SwapQueueContext,
|
|
6
|
+
SwapStorage,
|
|
7
|
+
StepExecutionEventStatus,
|
|
8
|
+
} from '../types';
|
|
3
9
|
import {
|
|
4
10
|
getCurrentStep,
|
|
5
11
|
updateSwapStatus,
|
|
@@ -10,6 +16,8 @@ import {
|
|
|
10
16
|
import { prettifyErrorMessage } from '../shared-errors';
|
|
11
17
|
import { CreateTransactionRequest } from 'rango-sdk';
|
|
12
18
|
import { httpService } from '../services';
|
|
19
|
+
import { notifier } from '../services/eventEmitter';
|
|
20
|
+
import { DEFAULT_ERROR_CODE } from '../constants';
|
|
13
21
|
|
|
14
22
|
/**
|
|
15
23
|
*
|
|
@@ -21,13 +29,21 @@ import { httpService } from '../services';
|
|
|
21
29
|
export async function createTransaction(
|
|
22
30
|
actions: ExecuterActions<SwapStorage, SwapActionTypes, SwapQueueContext>
|
|
23
31
|
): Promise<void> {
|
|
24
|
-
const { setStorage, getStorage, next, schedule
|
|
32
|
+
const { setStorage, getStorage, next, schedule } = actions;
|
|
25
33
|
const swap = getStorage().swapDetails;
|
|
26
34
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
27
35
|
const currentStep = getCurrentStep(swap)!;
|
|
28
36
|
const transaction = getCurrentStepTx(currentStep);
|
|
29
37
|
|
|
30
38
|
if (!transaction) {
|
|
39
|
+
notifier({
|
|
40
|
+
event: {
|
|
41
|
+
type: StepEventType.TX_EXECUTION,
|
|
42
|
+
status: StepExecutionEventStatus.CREATE_TX,
|
|
43
|
+
},
|
|
44
|
+
swap,
|
|
45
|
+
step: currentStep,
|
|
46
|
+
});
|
|
31
47
|
const request: CreateTransactionRequest = {
|
|
32
48
|
requestId: swap.requestId,
|
|
33
49
|
step: currentStep.id,
|
|
@@ -66,8 +82,13 @@ export async function createTransaction(
|
|
|
66
82
|
details: extraMessageDetail,
|
|
67
83
|
errorCode: 'FETCH_TX_FAILED',
|
|
68
84
|
});
|
|
69
|
-
|
|
70
|
-
|
|
85
|
+
|
|
86
|
+
notifier({
|
|
87
|
+
event: {
|
|
88
|
+
type: StepEventType.FAILED,
|
|
89
|
+
reason: extraMessage,
|
|
90
|
+
reasonCode: updateResult.failureType ?? DEFAULT_ERROR_CODE,
|
|
91
|
+
},
|
|
71
92
|
...updateResult,
|
|
72
93
|
});
|
|
73
94
|
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { ExecuterActions } from '@rango-dev/queue-manager-core';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
StepEventType,
|
|
4
|
+
SwapActionTypes,
|
|
5
|
+
SwapQueueContext,
|
|
6
|
+
SwapStorage,
|
|
7
|
+
} from '../types';
|
|
8
|
+
import {
|
|
9
|
+
getCurrentStep,
|
|
10
|
+
getLastSuccessfulStep,
|
|
11
|
+
isTxAlreadyCreated,
|
|
12
|
+
} from '../helpers';
|
|
13
|
+
import { notifier } from '../services/eventEmitter';
|
|
4
14
|
|
|
5
15
|
/**
|
|
6
16
|
*
|
|
@@ -17,7 +27,6 @@ export function scheduleNextStep({
|
|
|
17
27
|
failed,
|
|
18
28
|
setStorage,
|
|
19
29
|
getStorage,
|
|
20
|
-
context,
|
|
21
30
|
}: ExecuterActions<SwapStorage, SwapActionTypes, SwapQueueContext>): void {
|
|
22
31
|
const swap = getStorage().swapDetails;
|
|
23
32
|
const currentStep = getCurrentStep(swap);
|
|
@@ -38,6 +47,12 @@ export function scheduleNextStep({
|
|
|
38
47
|
|
|
39
48
|
setStorage({ ...getStorage(), swapDetails: swap });
|
|
40
49
|
|
|
50
|
+
notifier({
|
|
51
|
+
event: { type: StepEventType.STARTED },
|
|
52
|
+
swap,
|
|
53
|
+
step: currentStep,
|
|
54
|
+
});
|
|
55
|
+
|
|
41
56
|
schedule(SwapActionTypes.CREATE_TRANSACTION);
|
|
42
57
|
next();
|
|
43
58
|
} else {
|
|
@@ -49,8 +64,22 @@ export function scheduleNextStep({
|
|
|
49
64
|
swapDetails: swap,
|
|
50
65
|
});
|
|
51
66
|
|
|
52
|
-
|
|
53
|
-
|
|
67
|
+
notifier({
|
|
68
|
+
...(isFailed
|
|
69
|
+
? {
|
|
70
|
+
event: {
|
|
71
|
+
type: StepEventType.FAILED,
|
|
72
|
+
reason: swap.extraMessage ?? undefined,
|
|
73
|
+
reasonCode: 'CALL_OR_SEND_FAILED',
|
|
74
|
+
},
|
|
75
|
+
}
|
|
76
|
+
: {
|
|
77
|
+
event: {
|
|
78
|
+
type: StepEventType.SUCCEEDED,
|
|
79
|
+
outputAmount:
|
|
80
|
+
getLastSuccessfulStep(swap.steps)?.outputAmount ?? '',
|
|
81
|
+
},
|
|
82
|
+
}),
|
|
54
83
|
swap: swap,
|
|
55
84
|
step: null,
|
|
56
85
|
});
|
package/src/actions/start.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { ExecuterActions } from '@rango-dev/queue-manager-core';
|
|
2
|
-
import { SwapActionTypes, SwapStorage } from '../types';
|
|
2
|
+
import { StepEventType, SwapActionTypes, SwapStorage } from '../types';
|
|
3
|
+
import { notifier } from '../services/eventEmitter';
|
|
3
4
|
|
|
4
5
|
export function start({
|
|
5
6
|
schedule,
|
|
6
7
|
next,
|
|
8
|
+
getStorage,
|
|
7
9
|
}: ExecuterActions<SwapStorage, SwapActionTypes>): void {
|
|
10
|
+
const swap = getStorage().swapDetails;
|
|
11
|
+
|
|
12
|
+
notifier({ event: { type: StepEventType.STARTED }, swap, step: null });
|
|
13
|
+
|
|
8
14
|
schedule(SwapActionTypes.SCHEDULE_NEXT_STEP);
|
|
9
15
|
next();
|
|
10
16
|
}
|
package/src/constants.ts
CHANGED
|
@@ -17,3 +17,5 @@ export const ERROR_MESSAGE_WAIT_FOR_WALLET_DESCRIPTION = (
|
|
|
17
17
|
export const ERROR_MESSAGE_WAIT_FOR_CHANGE_NETWORK = (
|
|
18
18
|
network: string | null
|
|
19
19
|
): string => `Please change your network to ${network}.`;
|
|
20
|
+
|
|
21
|
+
export const DEFAULT_ERROR_CODE = 'CLIENT_UNEXPECTED_BEHAVIOUR';
|