@rango-dev/queue-manager-rango-preset 0.5.1-next.7 → 0.5.1-next.9
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 +14 -9
- 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 +0 -5
- package/dist/shared.d.ts.map +1 -1
- package/dist/types.d.ts +99 -4
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/actions/checkStatus.ts +47 -16
- 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 +174 -81
- package/src/hooks.ts +7 -8
- package/src/index.ts +19 -3
- package/src/services/eventEmitter.ts +258 -0
- package/src/shared-errors.ts +7 -7
- package/src/shared.ts +0 -6
- package/src/types.ts +150 -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,QAgG9C"}
|
|
@@ -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;IAQ9C,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,CAmBd;AAED,eAAO,MAAM,oBAAoB,QAAS,OAAO,KAAG,WAsBnD,CAAC"}
|
package/dist/shared.d.ts
CHANGED
|
@@ -5,11 +5,6 @@ export interface PendingSwapWithQueueID {
|
|
|
5
5
|
id: string;
|
|
6
6
|
swap: PendingSwap;
|
|
7
7
|
}
|
|
8
|
-
export type SwapProgressNotification = {
|
|
9
|
-
eventType: EventType;
|
|
10
|
-
swap: PendingSwap | null;
|
|
11
|
-
step: PendingSwapStep | null;
|
|
12
|
-
};
|
|
13
8
|
export type WalletBalance = {
|
|
14
9
|
chain: Network;
|
|
15
10
|
symbol: string;
|
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;AASrC,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,WAAW,CAAC;CACnB;AAED,MAAM,MAAM,
|
|
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;AASrC,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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a,WAChB,MAAM,WACL,OAAO;;MAEf,MAAM,GAAG,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,MAgBF,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,CAwFb"}
|
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,98 @@ 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 SucceededRouteEventPayload = {
|
|
110
|
+
outputAmount: string;
|
|
111
|
+
};
|
|
112
|
+
export type StepExecutionEventPayload = {
|
|
113
|
+
status: StepExecutionEventStatus.CREATE_TX | StepExecutionEventStatus.SEND_TX | StepExecutionEventStatus.TX_SENT;
|
|
114
|
+
};
|
|
115
|
+
export type StepBlockedEventPayload = {
|
|
116
|
+
status: StepExecutionBlockedEventStatus.WAITING_FOR_QUEUE;
|
|
117
|
+
} | {
|
|
118
|
+
status: StepExecutionBlockedEventStatus.WAITING_FOR_WALLET_CONNECT;
|
|
119
|
+
requiredWallet?: string;
|
|
120
|
+
requiredAccount?: string;
|
|
121
|
+
} | {
|
|
122
|
+
status: StepExecutionBlockedEventStatus.WAITING_FOR_CHANGE_WALLET_ACCOUNT;
|
|
123
|
+
requiredAccount?: string;
|
|
124
|
+
} | {
|
|
125
|
+
status: StepExecutionBlockedEventStatus.WAITING_FOR_NETWORK_CHANGE;
|
|
126
|
+
currentNetwork?: string;
|
|
127
|
+
requiredNetwork?: string;
|
|
128
|
+
};
|
|
129
|
+
export type StepEvent = Event<StepEventType.STARTED> | Event<StepEventType.SUCCEEDED, {
|
|
130
|
+
outputAmount: string;
|
|
131
|
+
}> | Event<StepEventType.FAILED, FailedRouteEventPayload> | Event<StepEventType.TX_EXECUTION, StepExecutionEventPayload> | Event<StepEventType.TX_EXECUTION_BLOCKED, StepBlockedEventPayload> | Event<StepEventType.CHECK_STATUS> | Event<StepEventType.APPROVAL_TX_SUCCEEDED> | Event<StepEventType.OUTPUT_REVEALED, {
|
|
132
|
+
outputAmount: string;
|
|
133
|
+
}>;
|
|
134
|
+
export type RouteEvent = Event<RouteEventType.STARTED> | Event<RouteEventType.FAILED, FailedRouteEventPayload> | Event<RouteEventType.SUCCEEDED, SucceededRouteEventPayload>;
|
|
135
|
+
export type RouteExecutionEvents = {
|
|
136
|
+
[MainEvents.RouteEvent]: {
|
|
137
|
+
route: Route;
|
|
138
|
+
event: RouteEvent;
|
|
139
|
+
};
|
|
140
|
+
[MainEvents.StepEvent]: {
|
|
141
|
+
route: Route;
|
|
142
|
+
step: Step;
|
|
143
|
+
event: StepEvent;
|
|
144
|
+
};
|
|
145
|
+
};
|
|
51
146
|
//# 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,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C,KAAK,CAAC,aAAa,CAAC,qBAAqB,CAAC,GAC1C,KAAK,CAAC,aAAa,CAAC,eAAe,EAAE;IAAE,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAEnE,MAAM,MAAM,UAAU,GAClB,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,GAC7B,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,uBAAuB,CAAC,GACrD,KAAK,CAAC,cAAc,CAAC,SAAS,EAAE,0BAA0B,CAAC,CAAC;AAEhE,MAAM,MAAM,oBAAoB,GAAG;IACjC,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;QAAE,KAAK,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,UAAU,CAAA;KAAE,CAAC;IAC7D,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;QAAE,KAAK,EAAE,KAAK,CAAC;QAAC,IAAI,EAAE,IAAI,CAAC;QAAC,KAAK,EAAE,SAAS,CAAA;KAAE,CAAC;CACxE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/queue-manager-rango-preset",
|
|
3
|
-
"version": "0.5.1-next.
|
|
3
|
+
"version": "0.5.1-next.9",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@sentry/browser": "^6.12.0",
|
|
40
|
+
"mitt": "^3.0.0",
|
|
40
41
|
"rango-types": "^0.1.39",
|
|
41
42
|
"uuid": "^9.0.0"
|
|
42
43
|
},
|
|
@@ -9,7 +9,12 @@ import {
|
|
|
9
9
|
updateSwapStatus,
|
|
10
10
|
inMemoryTransactionsData,
|
|
11
11
|
} from '../helpers';
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
StepEventType,
|
|
14
|
+
SwapActionTypes,
|
|
15
|
+
SwapQueueContext,
|
|
16
|
+
SwapStorage,
|
|
17
|
+
} from '../types';
|
|
13
18
|
import {
|
|
14
19
|
getCurrentBlockchainOf,
|
|
15
20
|
getNextStep,
|
|
@@ -21,6 +26,8 @@ import { Transaction, TransactionStatusResponse } from 'rango-sdk';
|
|
|
21
26
|
import { httpService } from '../services';
|
|
22
27
|
import type { GenericSigner } from 'rango-types';
|
|
23
28
|
import { prettifyErrorMessage } from '../shared-errors';
|
|
29
|
+
import { notifier } from '../services/eventEmitter';
|
|
30
|
+
import { DEFAULT_ERROR_CODE } from '../constants';
|
|
24
31
|
|
|
25
32
|
const INTERVAL_FOR_CHECK = 5_000;
|
|
26
33
|
|
|
@@ -116,10 +123,16 @@ async function checkTransactionStatus({
|
|
|
116
123
|
details: extraMessageDetail,
|
|
117
124
|
errorCode: extraMessageErrorCode,
|
|
118
125
|
});
|
|
119
|
-
|
|
120
|
-
|
|
126
|
+
|
|
127
|
+
notifier({
|
|
128
|
+
event: {
|
|
129
|
+
type: StepEventType.FAILED,
|
|
130
|
+
reason: extraMessage,
|
|
131
|
+
reasonCode: updateResult.failureType ?? DEFAULT_ERROR_CODE,
|
|
132
|
+
},
|
|
121
133
|
...updateResult,
|
|
122
134
|
});
|
|
135
|
+
|
|
123
136
|
getTxReceiptFailed = true;
|
|
124
137
|
// We shouldn't return here, because we need to trigger check status job in backend.
|
|
125
138
|
// This is not a ui requirement but the backend one.
|
|
@@ -169,15 +182,15 @@ async function checkTransactionStatus({
|
|
|
169
182
|
}
|
|
170
183
|
|
|
171
184
|
if (prevOutputAmount === null && outputAmount !== null)
|
|
172
|
-
|
|
173
|
-
|
|
185
|
+
notifier({
|
|
186
|
+
event: { type: StepEventType.OUTPUT_REVEALED, outputAmount },
|
|
174
187
|
swap: swap,
|
|
175
188
|
step: currentStep,
|
|
176
189
|
});
|
|
177
190
|
else if (prevOutputAmount === null && outputAmount === null) {
|
|
178
191
|
// it is needed to set notification after reloading the page
|
|
179
|
-
|
|
180
|
-
|
|
192
|
+
notifier({
|
|
193
|
+
event: { type: StepEventType.CHECK_STATUS },
|
|
181
194
|
swap: swap,
|
|
182
195
|
step: currentStep,
|
|
183
196
|
});
|
|
@@ -189,6 +202,14 @@ async function checkTransactionStatus({
|
|
|
189
202
|
swap.extraMessage = nextStep
|
|
190
203
|
? `starting next step: ${nextStep.swapperId}: ${nextStep.fromBlockchain} -> ${nextStep.toBlockchain}`
|
|
191
204
|
: '';
|
|
205
|
+
notifier({
|
|
206
|
+
event: {
|
|
207
|
+
type: StepEventType.SUCCEEDED,
|
|
208
|
+
outputAmount: currentStep.outputAmount ?? '',
|
|
209
|
+
},
|
|
210
|
+
swap,
|
|
211
|
+
step: currentStep,
|
|
212
|
+
});
|
|
192
213
|
} else if (currentStep.status === 'failed') {
|
|
193
214
|
swap.extraMessage = 'Transaction failed in blockchain';
|
|
194
215
|
swap.extraMessageSeverity = MessageSeverity.error;
|
|
@@ -307,8 +328,12 @@ async function checkApprovalStatus({
|
|
|
307
328
|
details: extraMessageDetail,
|
|
308
329
|
errorCode: extraMessageErrorCode,
|
|
309
330
|
});
|
|
310
|
-
|
|
311
|
-
|
|
331
|
+
notifier({
|
|
332
|
+
event: {
|
|
333
|
+
type: StepEventType.FAILED,
|
|
334
|
+
reason: extraMessage,
|
|
335
|
+
reasonCode: updateResult.failureType ?? DEFAULT_ERROR_CODE,
|
|
336
|
+
},
|
|
312
337
|
...updateResult,
|
|
313
338
|
});
|
|
314
339
|
return failed();
|
|
@@ -349,16 +374,22 @@ async function checkApprovalStatus({
|
|
|
349
374
|
message: message,
|
|
350
375
|
details: details,
|
|
351
376
|
});
|
|
352
|
-
|
|
353
|
-
|
|
377
|
+
|
|
378
|
+
notifier({
|
|
379
|
+
event: {
|
|
380
|
+
type: StepEventType.FAILED,
|
|
381
|
+
reason: message,
|
|
382
|
+
reasonCode: updateResult.failureType ?? DEFAULT_ERROR_CODE,
|
|
383
|
+
},
|
|
354
384
|
...updateResult,
|
|
355
385
|
});
|
|
386
|
+
|
|
356
387
|
failed();
|
|
357
388
|
} else if (!isApproved) {
|
|
358
389
|
// it is needed to set notification after reloading the page
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
swap
|
|
390
|
+
notifier({
|
|
391
|
+
event: { type: StepEventType.CHECK_STATUS },
|
|
392
|
+
swap,
|
|
362
393
|
step: currentStep,
|
|
363
394
|
});
|
|
364
395
|
}
|
|
@@ -381,8 +412,8 @@ async function checkApprovalStatus({
|
|
|
381
412
|
swapDetails: swap,
|
|
382
413
|
});
|
|
383
414
|
|
|
384
|
-
|
|
385
|
-
|
|
415
|
+
notifier({
|
|
416
|
+
event: { type: StepEventType.APPROVAL_TX_SUCCEEDED },
|
|
386
417
|
swap: swap,
|
|
387
418
|
step: currentStep,
|
|
388
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';
|