@metamask-previews/bridge-status-controller 73.1.0-preview-e12e4a38f → 74.0.0-preview-4f9d41d
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 +9 -1
- package/dist/bridge-status-controller.cjs +167 -21
- package/dist/bridge-status-controller.cjs.map +1 -1
- package/dist/bridge-status-controller.d.cts +6 -1
- package/dist/bridge-status-controller.d.cts.map +1 -1
- package/dist/bridge-status-controller.d.mts +6 -1
- package/dist/bridge-status-controller.d.mts.map +1 -1
- package/dist/bridge-status-controller.mjs +167 -21
- package/dist/bridge-status-controller.mjs.map +1 -1
- package/dist/constants.cjs +1 -0
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.mts.map +1 -1
- package/dist/constants.mjs +1 -0
- package/dist/constants.mjs.map +1 -1
- package/dist/index.cjs +12 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +3 -0
- package/dist/index.mjs.map +1 -1
- package/dist/quote-status-manager/constants.cjs +181 -0
- package/dist/quote-status-manager/constants.cjs.map +1 -0
- package/dist/quote-status-manager/constants.d.cts +137 -0
- package/dist/quote-status-manager/constants.d.cts.map +1 -0
- package/dist/quote-status-manager/constants.d.mts +137 -0
- package/dist/quote-status-manager/constants.d.mts.map +1 -0
- package/dist/quote-status-manager/constants.mjs +178 -0
- package/dist/quote-status-manager/constants.mjs.map +1 -0
- package/dist/quote-status-manager/errors.cjs +51 -0
- package/dist/quote-status-manager/errors.cjs.map +1 -0
- package/dist/quote-status-manager/errors.d.cts +45 -0
- package/dist/quote-status-manager/errors.d.cts.map +1 -0
- package/dist/quote-status-manager/errors.d.mts +45 -0
- package/dist/quote-status-manager/errors.d.mts.map +1 -0
- package/dist/quote-status-manager/errors.mjs +46 -0
- package/dist/quote-status-manager/errors.mjs.map +1 -0
- package/dist/quote-status-manager/quote-status-api-service.cjs +241 -0
- package/dist/quote-status-manager/quote-status-api-service.cjs.map +1 -0
- package/dist/quote-status-manager/quote-status-api-service.d.cts +93 -0
- package/dist/quote-status-manager/quote-status-api-service.d.cts.map +1 -0
- package/dist/quote-status-manager/quote-status-api-service.d.mts +93 -0
- package/dist/quote-status-manager/quote-status-api-service.d.mts.map +1 -0
- package/dist/quote-status-manager/quote-status-api-service.mjs +237 -0
- package/dist/quote-status-manager/quote-status-api-service.mjs.map +1 -0
- package/dist/quote-status-manager/quote-status-entry-store.cjs +271 -0
- package/dist/quote-status-manager/quote-status-entry-store.cjs.map +1 -0
- package/dist/quote-status-manager/quote-status-entry-store.d.cts +144 -0
- package/dist/quote-status-manager/quote-status-entry-store.d.cts.map +1 -0
- package/dist/quote-status-manager/quote-status-entry-store.d.mts +144 -0
- package/dist/quote-status-manager/quote-status-entry-store.d.mts.map +1 -0
- package/dist/quote-status-manager/quote-status-entry-store.mjs +267 -0
- package/dist/quote-status-manager/quote-status-entry-store.mjs.map +1 -0
- package/dist/quote-status-manager/quote-status-get-with-retry-outcome.cjs +29 -0
- package/dist/quote-status-manager/quote-status-get-with-retry-outcome.cjs.map +1 -0
- package/dist/quote-status-manager/quote-status-get-with-retry-outcome.d.cts +32 -0
- package/dist/quote-status-manager/quote-status-get-with-retry-outcome.d.cts.map +1 -0
- package/dist/quote-status-manager/quote-status-get-with-retry-outcome.d.mts +32 -0
- package/dist/quote-status-manager/quote-status-get-with-retry-outcome.d.mts.map +1 -0
- package/dist/quote-status-manager/quote-status-get-with-retry-outcome.mjs +25 -0
- package/dist/quote-status-manager/quote-status-get-with-retry-outcome.mjs.map +1 -0
- package/dist/quote-status-manager/quote-status-state-fsm.cjs +107 -0
- package/dist/quote-status-manager/quote-status-state-fsm.cjs.map +1 -0
- package/dist/quote-status-manager/quote-status-state-fsm.d.cts +57 -0
- package/dist/quote-status-manager/quote-status-state-fsm.d.cts.map +1 -0
- package/dist/quote-status-manager/quote-status-state-fsm.d.mts +57 -0
- package/dist/quote-status-manager/quote-status-state-fsm.d.mts.map +1 -0
- package/dist/quote-status-manager/quote-status-state-fsm.mjs +103 -0
- package/dist/quote-status-manager/quote-status-state-fsm.mjs.map +1 -0
- package/dist/quote-status-manager/quote-status-update-with-retry-outcome.cjs +27 -0
- package/dist/quote-status-manager/quote-status-update-with-retry-outcome.cjs.map +1 -0
- package/dist/quote-status-manager/quote-status-update-with-retry-outcome.d.cts +30 -0
- package/dist/quote-status-manager/quote-status-update-with-retry-outcome.d.cts.map +1 -0
- package/dist/quote-status-manager/quote-status-update-with-retry-outcome.d.mts +30 -0
- package/dist/quote-status-manager/quote-status-update-with-retry-outcome.d.mts.map +1 -0
- package/dist/quote-status-manager/quote-status-update-with-retry-outcome.mjs +23 -0
- package/dist/quote-status-manager/quote-status-update-with-retry-outcome.mjs.map +1 -0
- package/dist/quote-status-manager/quotes-status-manager.cjs +477 -0
- package/dist/quote-status-manager/quotes-status-manager.cjs.map +1 -0
- package/dist/quote-status-manager/quotes-status-manager.d.cts +124 -0
- package/dist/quote-status-manager/quotes-status-manager.d.cts.map +1 -0
- package/dist/quote-status-manager/quotes-status-manager.d.mts +124 -0
- package/dist/quote-status-manager/quotes-status-manager.d.mts.map +1 -0
- package/dist/quote-status-manager/quotes-status-manager.mjs +473 -0
- package/dist/quote-status-manager/quotes-status-manager.mjs.map +1 -0
- package/dist/quote-status-manager/types.cjs +8 -0
- package/dist/quote-status-manager/types.cjs.map +1 -0
- package/dist/quote-status-manager/types.d.cts +145 -0
- package/dist/quote-status-manager/types.d.cts.map +1 -0
- package/dist/quote-status-manager/types.d.mts +145 -0
- package/dist/quote-status-manager/types.d.mts.map +1 -0
- package/dist/quote-status-manager/types.mjs +6 -0
- package/dist/quote-status-manager/types.mjs.map +1 -0
- package/dist/quote-status-manager/utils.cjs +11 -0
- package/dist/quote-status-manager/utils.cjs.map +1 -0
- package/dist/quote-status-manager/utils.d.cts +7 -0
- package/dist/quote-status-manager/utils.d.cts.map +1 -0
- package/dist/quote-status-manager/utils.d.mts +7 -0
- package/dist/quote-status-manager/utils.d.mts.map +1 -0
- package/dist/quote-status-manager/utils.mjs +7 -0
- package/dist/quote-status-manager/utils.mjs.map +1 -0
- package/dist/quote-status-manager/validators.cjs +44 -0
- package/dist/quote-status-manager/validators.cjs.map +1 -0
- package/dist/quote-status-manager/validators.d.cts +172 -0
- package/dist/quote-status-manager/validators.d.cts.map +1 -0
- package/dist/quote-status-manager/validators.d.mts +172 -0
- package/dist/quote-status-manager/validators.d.mts.map +1 -0
- package/dist/quote-status-manager/validators.mjs +39 -0
- package/dist/quote-status-manager/validators.mjs.map +1 -0
- package/dist/types.cjs +2 -0
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +15 -3
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +15 -3
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +2 -0
- package/dist/types.mjs.map +1 -1
- package/dist/utils/history.cjs +1 -0
- package/dist/utils/history.cjs.map +1 -1
- package/dist/utils/history.d.cts.map +1 -1
- package/dist/utils/history.d.mts.map +1 -1
- package/dist/utils/history.mjs +1 -0
- package/dist/utils/history.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QuoteStatusFetchWithRetryOutcomeType = exports.AllowedQuoteStatusStateTransitions = exports.QuoteStatusStateToBackendStatus = exports.QuoteStatusState = exports.QuoteStatusUpdateRetryableBackendTypes = exports.QuoteStatusUpdateBackendOnChainMismatchTypes = exports.QuoteStatusBackendValues = exports.BaseQuoteStatusUpdateErrorTypes = exports.QuoteStatusUpdateBackendErrorType = exports.QuoteStatusBackendStatus = exports.QUOTE_STATUS_UPDATE_ENTRY_TTL = exports.QUOTE_STATUS_UPDATE_RETRY_INTERVAL_MS = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* How often the manager re-processes entries that have not yet reached a
|
|
6
|
+
* terminal state (`Completed`/`Expired`).
|
|
7
|
+
*
|
|
8
|
+
* Drives the periodic retry timer in `QuoteStatusUpdateManager`: on each tick
|
|
9
|
+
* every non-terminal entry is re-sent to the backend until it is accepted or
|
|
10
|
+
* evicted. The timer only runs while there is outstanding work.
|
|
11
|
+
*/
|
|
12
|
+
exports.QUOTE_STATUS_UPDATE_RETRY_INTERVAL_MS = 30 * 60 * 1000; // 30 minutes
|
|
13
|
+
/**
|
|
14
|
+
* Maximum lifetime of a tracked quote-status entry, measured from when it was
|
|
15
|
+
* created.
|
|
16
|
+
*
|
|
17
|
+
* Once an entry is older than this it is considered `Expired`, evicted from the
|
|
18
|
+
* store on the next read, and never retried again. This bounds how long the
|
|
19
|
+
* manager keeps trying to report a status that the backend may never accept.
|
|
20
|
+
*/
|
|
21
|
+
exports.QUOTE_STATUS_UPDATE_ENTRY_TTL = 12 * 60 * 60 * 1000; // 12 hours
|
|
22
|
+
/**
|
|
23
|
+
* Quote lifecycle statuses as understood by the backend `quote/updateStatus`
|
|
24
|
+
* API. These are the values sent over the wire (and echoed back in error
|
|
25
|
+
* responses).
|
|
26
|
+
*/
|
|
27
|
+
var QuoteStatusBackendStatus;
|
|
28
|
+
(function (QuoteStatusBackendStatus) {
|
|
29
|
+
/**
|
|
30
|
+
* Quote was served to the client. Unused locally, kept for parity with the backend enum.
|
|
31
|
+
*/
|
|
32
|
+
QuoteStatusBackendStatus["Served"] = "SERVED";
|
|
33
|
+
/**
|
|
34
|
+
* User has submitted the source transaction.
|
|
35
|
+
*/
|
|
36
|
+
QuoteStatusBackendStatus["Submitted"] = "SUBMITTED";
|
|
37
|
+
/**
|
|
38
|
+
* Transaction finalized successfully on-chain.
|
|
39
|
+
*/
|
|
40
|
+
QuoteStatusBackendStatus["FinalizedSuccess"] = "FINALIZED_SUCCESS";
|
|
41
|
+
/**
|
|
42
|
+
* Transaction failed or reverted on-chain.
|
|
43
|
+
*/
|
|
44
|
+
QuoteStatusBackendStatus["FinalizedFailed"] = "FINALIZED_FAILED";
|
|
45
|
+
})(QuoteStatusBackendStatus || (exports.QuoteStatusBackendStatus = QuoteStatusBackendStatus = {}));
|
|
46
|
+
/**
|
|
47
|
+
* Machine-readable error `type` values returned by the backend
|
|
48
|
+
* `quote/updateStatus` API on non-2xx responses. The comments record the HTTP
|
|
49
|
+
* status the backend pairs with each type.
|
|
50
|
+
*/
|
|
51
|
+
var QuoteStatusUpdateBackendErrorType;
|
|
52
|
+
(function (QuoteStatusUpdateBackendErrorType) {
|
|
53
|
+
QuoteStatusUpdateBackendErrorType["QuoteNotFound"] = "QUOTE_NOT_FOUND";
|
|
54
|
+
QuoteStatusUpdateBackendErrorType["ConcurrentUpdate"] = "CONCURRENT_UPDATE";
|
|
55
|
+
QuoteStatusUpdateBackendErrorType["InvalidStatusTransaction"] = "INVALID_STATUS_TRANSITION";
|
|
56
|
+
QuoteStatusUpdateBackendErrorType["SrcTxHashRequiredForFinalized"] = "SRC_TX_HASH_REQUIRED_FOR_FINALIZED";
|
|
57
|
+
QuoteStatusUpdateBackendErrorType["PersistQuoteStatusFailed"] = "PERSIST_QUOTE_STATUS_FAILED";
|
|
58
|
+
QuoteStatusUpdateBackendErrorType["TransactionNotIndexed"] = "TRANSACTION_NOT_INDEXED";
|
|
59
|
+
QuoteStatusUpdateBackendErrorType["TxDataMissingHash"] = "TX_DATA_MISSING_HASH";
|
|
60
|
+
QuoteStatusUpdateBackendErrorType["TxDataMissingTrade"] = "TX_DATA_MISSING_TRADE";
|
|
61
|
+
/**
|
|
62
|
+
* On-chain tx payload does not match the served quote (EVM calldata, SVM message, TVM raw_data_hex).
|
|
63
|
+
*/
|
|
64
|
+
QuoteStatusUpdateBackendErrorType["TxDataMismatch"] = "TX_DATA_MISMATCH";
|
|
65
|
+
QuoteStatusUpdateBackendErrorType["SvmTradeDeserializeFailed"] = "SVM_TRADE_DESERIALIZE_FAILED";
|
|
66
|
+
/**
|
|
67
|
+
* Requested lifecycle status is inconsistent with observed on-chain tx status.
|
|
68
|
+
*/
|
|
69
|
+
QuoteStatusUpdateBackendErrorType["QuoteStatusOnChainMismatch"] = "QUOTE_STATUS_ONCHAIN_MISMATCH";
|
|
70
|
+
})(QuoteStatusUpdateBackendErrorType || (exports.QuoteStatusUpdateBackendErrorType = QuoteStatusUpdateBackendErrorType = {}));
|
|
71
|
+
/**
|
|
72
|
+
* Error types whose response payload carries no `currentStatus`. Used by the
|
|
73
|
+
* response validator to define the base (non-mismatch) error response schema.
|
|
74
|
+
*/
|
|
75
|
+
exports.BaseQuoteStatusUpdateErrorTypes = [
|
|
76
|
+
QuoteStatusUpdateBackendErrorType.QuoteNotFound,
|
|
77
|
+
QuoteStatusUpdateBackendErrorType.ConcurrentUpdate,
|
|
78
|
+
QuoteStatusUpdateBackendErrorType.SrcTxHashRequiredForFinalized,
|
|
79
|
+
QuoteStatusUpdateBackendErrorType.PersistQuoteStatusFailed,
|
|
80
|
+
QuoteStatusUpdateBackendErrorType.TransactionNotIndexed,
|
|
81
|
+
QuoteStatusUpdateBackendErrorType.TxDataMissingHash,
|
|
82
|
+
QuoteStatusUpdateBackendErrorType.TxDataMissingTrade,
|
|
83
|
+
QuoteStatusUpdateBackendErrorType.TxDataMismatch,
|
|
84
|
+
QuoteStatusUpdateBackendErrorType.SvmTradeDeserializeFailed,
|
|
85
|
+
];
|
|
86
|
+
/**
|
|
87
|
+
* The full set of valid backend status values. Used by the response validator
|
|
88
|
+
* to constrain the `currentStatus`/`newStatus` fields of error responses.
|
|
89
|
+
*/
|
|
90
|
+
exports.QuoteStatusBackendValues = [
|
|
91
|
+
QuoteStatusBackendStatus.Served,
|
|
92
|
+
QuoteStatusBackendStatus.Submitted,
|
|
93
|
+
QuoteStatusBackendStatus.FinalizedSuccess,
|
|
94
|
+
QuoteStatusBackendStatus.FinalizedFailed,
|
|
95
|
+
];
|
|
96
|
+
/**
|
|
97
|
+
* Error types whose response payload includes a `currentStatus` describing the
|
|
98
|
+
* backend's observed status. Used by the validator for the mismatch response
|
|
99
|
+
* schema and by the manager to reconcile local state with the backend.
|
|
100
|
+
*/
|
|
101
|
+
exports.QuoteStatusUpdateBackendOnChainMismatchTypes = [
|
|
102
|
+
QuoteStatusUpdateBackendErrorType.InvalidStatusTransaction,
|
|
103
|
+
QuoteStatusUpdateBackendErrorType.QuoteStatusOnChainMismatch,
|
|
104
|
+
];
|
|
105
|
+
/**
|
|
106
|
+
* Error types that represent transient backend conditions. A response with one
|
|
107
|
+
* of these types is retried by `updateQuoteStatusWithRetry`; any other error
|
|
108
|
+
* type is treated as non-retryable.
|
|
109
|
+
*/
|
|
110
|
+
exports.QuoteStatusUpdateRetryableBackendTypes = [
|
|
111
|
+
QuoteStatusUpdateBackendErrorType.ConcurrentUpdate,
|
|
112
|
+
QuoteStatusUpdateBackendErrorType.TransactionNotIndexed,
|
|
113
|
+
];
|
|
114
|
+
/**
|
|
115
|
+
* Local quote-status lifecycle states tracked by the state machine. These are
|
|
116
|
+
* the states the manager owns; a subset maps onto backend statuses while
|
|
117
|
+
* `Completed`/`Expired` are terminal, client-only states.
|
|
118
|
+
*/
|
|
119
|
+
var QuoteStatusState;
|
|
120
|
+
(function (QuoteStatusState) {
|
|
121
|
+
/** Source transaction submitted; awaiting finalization. */
|
|
122
|
+
QuoteStatusState["Submitted"] = "Submitted";
|
|
123
|
+
/** Transaction finalized successfully on-chain. */
|
|
124
|
+
QuoteStatusState["FinalizedSuccess"] = "FinalizedSuccess";
|
|
125
|
+
/** Transaction failed or reverted on-chain. */
|
|
126
|
+
QuoteStatusState["FinalizedFailed"] = "FinalizedFailed";
|
|
127
|
+
/** Terminal: the backend accepted the final status; nothing left to report. */
|
|
128
|
+
QuoteStatusState["Completed"] = "Completed";
|
|
129
|
+
/** Terminal: the entry outlived its TTL and was abandoned. */
|
|
130
|
+
QuoteStatusState["Expired"] = "Expired";
|
|
131
|
+
})(QuoteStatusState || (exports.QuoteStatusState = QuoteStatusState = {}));
|
|
132
|
+
/**
|
|
133
|
+
* Maps each local lifecycle state to the backend status to report for it, or
|
|
134
|
+
* `null` for terminal states that require no backend update. The manager uses a
|
|
135
|
+
* `null` mapping as the signal to remove the entry instead of calling the API.
|
|
136
|
+
*/
|
|
137
|
+
exports.QuoteStatusStateToBackendStatus = {
|
|
138
|
+
[QuoteStatusState.Submitted]: QuoteStatusBackendStatus.Submitted,
|
|
139
|
+
[QuoteStatusState.FinalizedSuccess]: QuoteStatusBackendStatus.FinalizedSuccess,
|
|
140
|
+
[QuoteStatusState.FinalizedFailed]: QuoteStatusBackendStatus.FinalizedFailed,
|
|
141
|
+
[QuoteStatusState.Completed]: null,
|
|
142
|
+
[QuoteStatusState.Expired]: null,
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Adjacency list defining the allowed forward-only transitions between
|
|
146
|
+
* lifecycle states. Enforced by `QuoteStatusStateFsm`; terminal states map to
|
|
147
|
+
* an empty array. Any state not present is treated as terminal.
|
|
148
|
+
*/
|
|
149
|
+
exports.AllowedQuoteStatusStateTransitions = {
|
|
150
|
+
[QuoteStatusState.Submitted]: [
|
|
151
|
+
QuoteStatusState.FinalizedFailed,
|
|
152
|
+
QuoteStatusState.FinalizedSuccess,
|
|
153
|
+
QuoteStatusState.Expired,
|
|
154
|
+
],
|
|
155
|
+
[QuoteStatusState.FinalizedFailed]: [
|
|
156
|
+
QuoteStatusState.Completed,
|
|
157
|
+
QuoteStatusState.Expired,
|
|
158
|
+
],
|
|
159
|
+
[QuoteStatusState.FinalizedSuccess]: [
|
|
160
|
+
QuoteStatusState.Completed,
|
|
161
|
+
QuoteStatusState.Expired,
|
|
162
|
+
],
|
|
163
|
+
[QuoteStatusState.Completed]: [],
|
|
164
|
+
[QuoteStatusState.Expired]: [],
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Outcome of a retrying status fetch call. Tells the
|
|
168
|
+
* manager how to proceed after an update attempt completes.
|
|
169
|
+
*/
|
|
170
|
+
var QuoteStatusFetchWithRetryOutcomeType;
|
|
171
|
+
(function (QuoteStatusFetchWithRetryOutcomeType) {
|
|
172
|
+
/** The backend accepted the update (2xx); the entry can be finalized/removed. */
|
|
173
|
+
QuoteStatusFetchWithRetryOutcomeType["Accepted"] = "accepted";
|
|
174
|
+
/** All retry attempts for a retryable error were used up; back off and try again later. */
|
|
175
|
+
QuoteStatusFetchWithRetryOutcomeType["RetryableExhausted"] = "retryableExhausted";
|
|
176
|
+
/** The backend returned a non-retryable error; the entry must be reconciled or evicted. */
|
|
177
|
+
QuoteStatusFetchWithRetryOutcomeType["NonRetryable"] = "nonRetryable";
|
|
178
|
+
/** The request was aborted (e.g. via abort signal) before completing. */
|
|
179
|
+
QuoteStatusFetchWithRetryOutcomeType["Interrupted"] = "interrupted";
|
|
180
|
+
})(QuoteStatusFetchWithRetryOutcomeType || (exports.QuoteStatusFetchWithRetryOutcomeType = QuoteStatusFetchWithRetryOutcomeType = {}));
|
|
181
|
+
//# sourceMappingURL=constants.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.cjs","sourceRoot":"","sources":["../../src/quote-status-manager/constants.ts"],"names":[],"mappings":"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","sourcesContent":["/**\n * How often the manager re-processes entries that have not yet reached a\n * terminal state (`Completed`/`Expired`).\n *\n * Drives the periodic retry timer in `QuoteStatusUpdateManager`: on each tick\n * every non-terminal entry is re-sent to the backend until it is accepted or\n * evicted. The timer only runs while there is outstanding work.\n */\nexport const QUOTE_STATUS_UPDATE_RETRY_INTERVAL_MS = 30 * 60 * 1000; // 30 minutes\n\n/**\n * Maximum lifetime of a tracked quote-status entry, measured from when it was\n * created.\n *\n * Once an entry is older than this it is considered `Expired`, evicted from the\n * store on the next read, and never retried again. This bounds how long the\n * manager keeps trying to report a status that the backend may never accept.\n */\nexport const QUOTE_STATUS_UPDATE_ENTRY_TTL = 12 * 60 * 60 * 1000; // 12 hours\n\n/**\n * Quote lifecycle statuses as understood by the backend `quote/updateStatus`\n * API. These are the values sent over the wire (and echoed back in error\n * responses).\n */\nexport enum QuoteStatusBackendStatus {\n /**\n * Quote was served to the client. Unused locally, kept for parity with the backend enum.\n */\n Served = 'SERVED',\n /**\n * User has submitted the source transaction.\n */\n Submitted = 'SUBMITTED',\n /**\n * Transaction finalized successfully on-chain.\n */\n FinalizedSuccess = 'FINALIZED_SUCCESS',\n /**\n * Transaction failed or reverted on-chain.\n */\n FinalizedFailed = 'FINALIZED_FAILED',\n}\n\n/**\n * Machine-readable error `type` values returned by the backend\n * `quote/updateStatus` API on non-2xx responses. The comments record the HTTP\n * status the backend pairs with each type.\n */\nexport enum QuoteStatusUpdateBackendErrorType {\n QuoteNotFound = 'QUOTE_NOT_FOUND', // Http status: 404\n ConcurrentUpdate = 'CONCURRENT_UPDATE', // Http status: 409\n InvalidStatusTransaction = 'INVALID_STATUS_TRANSITION', // Http status: 400\n SrcTxHashRequiredForFinalized = 'SRC_TX_HASH_REQUIRED_FOR_FINALIZED', // Http status: 400\n PersistQuoteStatusFailed = 'PERSIST_QUOTE_STATUS_FAILED', // Http status: 400\n TransactionNotIndexed = 'TRANSACTION_NOT_INDEXED', // Http status: 409\n TxDataMissingHash = 'TX_DATA_MISSING_HASH', // Http status: 400\n TxDataMissingTrade = 'TX_DATA_MISSING_TRADE', // Http status: 400\n /**\n * On-chain tx payload does not match the served quote (EVM calldata, SVM message, TVM raw_data_hex).\n */\n TxDataMismatch = 'TX_DATA_MISMATCH', // Http status: 400\n SvmTradeDeserializeFailed = 'SVM_TRADE_DESERIALIZE_FAILED', // Http status: 400\n /**\n * Requested lifecycle status is inconsistent with observed on-chain tx status.\n */\n QuoteStatusOnChainMismatch = 'QUOTE_STATUS_ONCHAIN_MISMATCH', // Http status: 400\n}\n\n/**\n * Error types whose response payload carries no `currentStatus`. Used by the\n * response validator to define the base (non-mismatch) error response schema.\n */\nexport const BaseQuoteStatusUpdateErrorTypes = [\n QuoteStatusUpdateBackendErrorType.QuoteNotFound,\n QuoteStatusUpdateBackendErrorType.ConcurrentUpdate,\n QuoteStatusUpdateBackendErrorType.SrcTxHashRequiredForFinalized,\n QuoteStatusUpdateBackendErrorType.PersistQuoteStatusFailed,\n QuoteStatusUpdateBackendErrorType.TransactionNotIndexed,\n QuoteStatusUpdateBackendErrorType.TxDataMissingHash,\n QuoteStatusUpdateBackendErrorType.TxDataMissingTrade,\n QuoteStatusUpdateBackendErrorType.TxDataMismatch,\n QuoteStatusUpdateBackendErrorType.SvmTradeDeserializeFailed,\n] as const;\n\n/**\n * The full set of valid backend status values. Used by the response validator\n * to constrain the `currentStatus`/`newStatus` fields of error responses.\n */\nexport const QuoteStatusBackendValues = [\n QuoteStatusBackendStatus.Served,\n QuoteStatusBackendStatus.Submitted,\n QuoteStatusBackendStatus.FinalizedSuccess,\n QuoteStatusBackendStatus.FinalizedFailed,\n] as const;\n\n/**\n * Error types whose response payload includes a `currentStatus` describing the\n * backend's observed status. Used by the validator for the mismatch response\n * schema and by the manager to reconcile local state with the backend.\n */\nexport const QuoteStatusUpdateBackendOnChainMismatchTypes = [\n QuoteStatusUpdateBackendErrorType.InvalidStatusTransaction,\n QuoteStatusUpdateBackendErrorType.QuoteStatusOnChainMismatch,\n] as const;\n\n/**\n * Error types that represent transient backend conditions. A response with one\n * of these types is retried by `updateQuoteStatusWithRetry`; any other error\n * type is treated as non-retryable.\n */\nexport const QuoteStatusUpdateRetryableBackendTypes = [\n QuoteStatusUpdateBackendErrorType.ConcurrentUpdate,\n QuoteStatusUpdateBackendErrorType.TransactionNotIndexed,\n];\n\n/**\n * Local quote-status lifecycle states tracked by the state machine. These are\n * the states the manager owns; a subset maps onto backend statuses while\n * `Completed`/`Expired` are terminal, client-only states.\n */\nexport enum QuoteStatusState {\n /** Source transaction submitted; awaiting finalization. */\n Submitted = 'Submitted',\n /** Transaction finalized successfully on-chain. */\n FinalizedSuccess = 'FinalizedSuccess',\n /** Transaction failed or reverted on-chain. */\n FinalizedFailed = 'FinalizedFailed',\n /** Terminal: the backend accepted the final status; nothing left to report. */\n Completed = 'Completed',\n /** Terminal: the entry outlived its TTL and was abandoned. */\n Expired = 'Expired',\n}\n\n/**\n * Maps each local lifecycle state to the backend status to report for it, or\n * `null` for terminal states that require no backend update. The manager uses a\n * `null` mapping as the signal to remove the entry instead of calling the API.\n */\nexport const QuoteStatusStateToBackendStatus = {\n [QuoteStatusState.Submitted]: QuoteStatusBackendStatus.Submitted,\n [QuoteStatusState.FinalizedSuccess]:\n QuoteStatusBackendStatus.FinalizedSuccess,\n [QuoteStatusState.FinalizedFailed]: QuoteStatusBackendStatus.FinalizedFailed,\n [QuoteStatusState.Completed]: null,\n [QuoteStatusState.Expired]: null,\n};\n\n/**\n * Adjacency list defining the allowed forward-only transitions between\n * lifecycle states. Enforced by `QuoteStatusStateFsm`; terminal states map to\n * an empty array. Any state not present is treated as terminal.\n */\nexport const AllowedQuoteStatusStateTransitions: Record<\n QuoteStatusState,\n readonly QuoteStatusState[]\n> = {\n [QuoteStatusState.Submitted]: [\n QuoteStatusState.FinalizedFailed,\n QuoteStatusState.FinalizedSuccess,\n QuoteStatusState.Expired,\n ],\n [QuoteStatusState.FinalizedFailed]: [\n QuoteStatusState.Completed,\n QuoteStatusState.Expired,\n ],\n [QuoteStatusState.FinalizedSuccess]: [\n QuoteStatusState.Completed,\n QuoteStatusState.Expired,\n ],\n [QuoteStatusState.Completed]: [],\n [QuoteStatusState.Expired]: [],\n};\n\n/**\n * Outcome of a retrying status fetch call. Tells the\n * manager how to proceed after an update attempt completes.\n */\nexport enum QuoteStatusFetchWithRetryOutcomeType {\n /** The backend accepted the update (2xx); the entry can be finalized/removed. */\n Accepted = 'accepted',\n /** All retry attempts for a retryable error were used up; back off and try again later. */\n RetryableExhausted = 'retryableExhausted',\n /** The backend returned a non-retryable error; the entry must be reconciled or evicted. */\n NonRetryable = 'nonRetryable',\n /** The request was aborted (e.g. via abort signal) before completing. */\n Interrupted = 'interrupted',\n}\n"]}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How often the manager re-processes entries that have not yet reached a
|
|
3
|
+
* terminal state (`Completed`/`Expired`).
|
|
4
|
+
*
|
|
5
|
+
* Drives the periodic retry timer in `QuoteStatusUpdateManager`: on each tick
|
|
6
|
+
* every non-terminal entry is re-sent to the backend until it is accepted or
|
|
7
|
+
* evicted. The timer only runs while there is outstanding work.
|
|
8
|
+
*/
|
|
9
|
+
export declare const QUOTE_STATUS_UPDATE_RETRY_INTERVAL_MS: number;
|
|
10
|
+
/**
|
|
11
|
+
* Maximum lifetime of a tracked quote-status entry, measured from when it was
|
|
12
|
+
* created.
|
|
13
|
+
*
|
|
14
|
+
* Once an entry is older than this it is considered `Expired`, evicted from the
|
|
15
|
+
* store on the next read, and never retried again. This bounds how long the
|
|
16
|
+
* manager keeps trying to report a status that the backend may never accept.
|
|
17
|
+
*/
|
|
18
|
+
export declare const QUOTE_STATUS_UPDATE_ENTRY_TTL: number;
|
|
19
|
+
/**
|
|
20
|
+
* Quote lifecycle statuses as understood by the backend `quote/updateStatus`
|
|
21
|
+
* API. These are the values sent over the wire (and echoed back in error
|
|
22
|
+
* responses).
|
|
23
|
+
*/
|
|
24
|
+
export declare enum QuoteStatusBackendStatus {
|
|
25
|
+
/**
|
|
26
|
+
* Quote was served to the client. Unused locally, kept for parity with the backend enum.
|
|
27
|
+
*/
|
|
28
|
+
Served = "SERVED",
|
|
29
|
+
/**
|
|
30
|
+
* User has submitted the source transaction.
|
|
31
|
+
*/
|
|
32
|
+
Submitted = "SUBMITTED",
|
|
33
|
+
/**
|
|
34
|
+
* Transaction finalized successfully on-chain.
|
|
35
|
+
*/
|
|
36
|
+
FinalizedSuccess = "FINALIZED_SUCCESS",
|
|
37
|
+
/**
|
|
38
|
+
* Transaction failed or reverted on-chain.
|
|
39
|
+
*/
|
|
40
|
+
FinalizedFailed = "FINALIZED_FAILED"
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Machine-readable error `type` values returned by the backend
|
|
44
|
+
* `quote/updateStatus` API on non-2xx responses. The comments record the HTTP
|
|
45
|
+
* status the backend pairs with each type.
|
|
46
|
+
*/
|
|
47
|
+
export declare enum QuoteStatusUpdateBackendErrorType {
|
|
48
|
+
QuoteNotFound = "QUOTE_NOT_FOUND",// Http status: 404
|
|
49
|
+
ConcurrentUpdate = "CONCURRENT_UPDATE",// Http status: 409
|
|
50
|
+
InvalidStatusTransaction = "INVALID_STATUS_TRANSITION",// Http status: 400
|
|
51
|
+
SrcTxHashRequiredForFinalized = "SRC_TX_HASH_REQUIRED_FOR_FINALIZED",// Http status: 400
|
|
52
|
+
PersistQuoteStatusFailed = "PERSIST_QUOTE_STATUS_FAILED",// Http status: 400
|
|
53
|
+
TransactionNotIndexed = "TRANSACTION_NOT_INDEXED",// Http status: 409
|
|
54
|
+
TxDataMissingHash = "TX_DATA_MISSING_HASH",// Http status: 400
|
|
55
|
+
TxDataMissingTrade = "TX_DATA_MISSING_TRADE",// Http status: 400
|
|
56
|
+
/**
|
|
57
|
+
* On-chain tx payload does not match the served quote (EVM calldata, SVM message, TVM raw_data_hex).
|
|
58
|
+
*/
|
|
59
|
+
TxDataMismatch = "TX_DATA_MISMATCH",// Http status: 400
|
|
60
|
+
SvmTradeDeserializeFailed = "SVM_TRADE_DESERIALIZE_FAILED",// Http status: 400
|
|
61
|
+
/**
|
|
62
|
+
* Requested lifecycle status is inconsistent with observed on-chain tx status.
|
|
63
|
+
*/
|
|
64
|
+
QuoteStatusOnChainMismatch = "QUOTE_STATUS_ONCHAIN_MISMATCH"
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Error types whose response payload carries no `currentStatus`. Used by the
|
|
68
|
+
* response validator to define the base (non-mismatch) error response schema.
|
|
69
|
+
*/
|
|
70
|
+
export declare const BaseQuoteStatusUpdateErrorTypes: readonly [QuoteStatusUpdateBackendErrorType.QuoteNotFound, QuoteStatusUpdateBackendErrorType.ConcurrentUpdate, QuoteStatusUpdateBackendErrorType.SrcTxHashRequiredForFinalized, QuoteStatusUpdateBackendErrorType.PersistQuoteStatusFailed, QuoteStatusUpdateBackendErrorType.TransactionNotIndexed, QuoteStatusUpdateBackendErrorType.TxDataMissingHash, QuoteStatusUpdateBackendErrorType.TxDataMissingTrade, QuoteStatusUpdateBackendErrorType.TxDataMismatch, QuoteStatusUpdateBackendErrorType.SvmTradeDeserializeFailed];
|
|
71
|
+
/**
|
|
72
|
+
* The full set of valid backend status values. Used by the response validator
|
|
73
|
+
* to constrain the `currentStatus`/`newStatus` fields of error responses.
|
|
74
|
+
*/
|
|
75
|
+
export declare const QuoteStatusBackendValues: readonly [QuoteStatusBackendStatus.Served, QuoteStatusBackendStatus.Submitted, QuoteStatusBackendStatus.FinalizedSuccess, QuoteStatusBackendStatus.FinalizedFailed];
|
|
76
|
+
/**
|
|
77
|
+
* Error types whose response payload includes a `currentStatus` describing the
|
|
78
|
+
* backend's observed status. Used by the validator for the mismatch response
|
|
79
|
+
* schema and by the manager to reconcile local state with the backend.
|
|
80
|
+
*/
|
|
81
|
+
export declare const QuoteStatusUpdateBackendOnChainMismatchTypes: readonly [QuoteStatusUpdateBackendErrorType.InvalidStatusTransaction, QuoteStatusUpdateBackendErrorType.QuoteStatusOnChainMismatch];
|
|
82
|
+
/**
|
|
83
|
+
* Error types that represent transient backend conditions. A response with one
|
|
84
|
+
* of these types is retried by `updateQuoteStatusWithRetry`; any other error
|
|
85
|
+
* type is treated as non-retryable.
|
|
86
|
+
*/
|
|
87
|
+
export declare const QuoteStatusUpdateRetryableBackendTypes: QuoteStatusUpdateBackendErrorType[];
|
|
88
|
+
/**
|
|
89
|
+
* Local quote-status lifecycle states tracked by the state machine. These are
|
|
90
|
+
* the states the manager owns; a subset maps onto backend statuses while
|
|
91
|
+
* `Completed`/`Expired` are terminal, client-only states.
|
|
92
|
+
*/
|
|
93
|
+
export declare enum QuoteStatusState {
|
|
94
|
+
/** Source transaction submitted; awaiting finalization. */
|
|
95
|
+
Submitted = "Submitted",
|
|
96
|
+
/** Transaction finalized successfully on-chain. */
|
|
97
|
+
FinalizedSuccess = "FinalizedSuccess",
|
|
98
|
+
/** Transaction failed or reverted on-chain. */
|
|
99
|
+
FinalizedFailed = "FinalizedFailed",
|
|
100
|
+
/** Terminal: the backend accepted the final status; nothing left to report. */
|
|
101
|
+
Completed = "Completed",
|
|
102
|
+
/** Terminal: the entry outlived its TTL and was abandoned. */
|
|
103
|
+
Expired = "Expired"
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Maps each local lifecycle state to the backend status to report for it, or
|
|
107
|
+
* `null` for terminal states that require no backend update. The manager uses a
|
|
108
|
+
* `null` mapping as the signal to remove the entry instead of calling the API.
|
|
109
|
+
*/
|
|
110
|
+
export declare const QuoteStatusStateToBackendStatus: {
|
|
111
|
+
Submitted: QuoteStatusBackendStatus;
|
|
112
|
+
FinalizedSuccess: QuoteStatusBackendStatus;
|
|
113
|
+
FinalizedFailed: QuoteStatusBackendStatus;
|
|
114
|
+
Completed: null;
|
|
115
|
+
Expired: null;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Adjacency list defining the allowed forward-only transitions between
|
|
119
|
+
* lifecycle states. Enforced by `QuoteStatusStateFsm`; terminal states map to
|
|
120
|
+
* an empty array. Any state not present is treated as terminal.
|
|
121
|
+
*/
|
|
122
|
+
export declare const AllowedQuoteStatusStateTransitions: Record<QuoteStatusState, readonly QuoteStatusState[]>;
|
|
123
|
+
/**
|
|
124
|
+
* Outcome of a retrying status fetch call. Tells the
|
|
125
|
+
* manager how to proceed after an update attempt completes.
|
|
126
|
+
*/
|
|
127
|
+
export declare enum QuoteStatusFetchWithRetryOutcomeType {
|
|
128
|
+
/** The backend accepted the update (2xx); the entry can be finalized/removed. */
|
|
129
|
+
Accepted = "accepted",
|
|
130
|
+
/** All retry attempts for a retryable error were used up; back off and try again later. */
|
|
131
|
+
RetryableExhausted = "retryableExhausted",
|
|
132
|
+
/** The backend returned a non-retryable error; the entry must be reconciled or evicted. */
|
|
133
|
+
NonRetryable = "nonRetryable",
|
|
134
|
+
/** The request was aborted (e.g. via abort signal) before completing. */
|
|
135
|
+
Interrupted = "interrupted"
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=constants.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.cts","sourceRoot":"","sources":["../../src/quote-status-manager/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,qCAAqC,QAAiB,CAAC;AAEpE;;;;;;;GAOG;AACH,eAAO,MAAM,6BAA6B,QAAsB,CAAC;AAEjE;;;;GAIG;AACH,oBAAY,wBAAwB;IAClC;;OAEG;IACH,MAAM,WAAW;IACjB;;OAEG;IACH,SAAS,cAAc;IACvB;;OAEG;IACH,gBAAgB,sBAAsB;IACtC;;OAEG;IACH,eAAe,qBAAqB;CACrC;AAED;;;;GAIG;AACH,oBAAY,iCAAiC;IAC3C,aAAa,oBAAoB,CAAE,mBAAmB;IACtD,gBAAgB,sBAAsB,CAAE,mBAAmB;IAC3D,wBAAwB,8BAA8B,CAAE,mBAAmB;IAC3E,6BAA6B,uCAAuC,CAAE,mBAAmB;IACzF,wBAAwB,gCAAgC,CAAE,mBAAmB;IAC7E,qBAAqB,4BAA4B,CAAE,mBAAmB;IACtE,iBAAiB,yBAAyB,CAAE,mBAAmB;IAC/D,kBAAkB,0BAA0B,CAAE,mBAAmB;IACjE;;OAEG;IACH,cAAc,qBAAqB,CAAE,mBAAmB;IACxD,yBAAyB,iCAAiC,CAAE,mBAAmB;IAC/E;;OAEG;IACH,0BAA0B,kCAAkC;CAC7D;AAED;;;GAGG;AACH,eAAO,MAAM,+BAA+B,ggBAUlC,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,wBAAwB,qKAK3B,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,4CAA4C,qIAG/C,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,sCAAsC,qCAGlD,CAAC;AAEF;;;;GAIG;AACH,oBAAY,gBAAgB;IAC1B,2DAA2D;IAC3D,SAAS,cAAc;IACvB,mDAAmD;IACnD,gBAAgB,qBAAqB;IACrC,+CAA+C;IAC/C,eAAe,oBAAoB;IACnC,+EAA+E;IAC/E,SAAS,cAAc;IACvB,8DAA8D;IAC9D,OAAO,YAAY;CACpB;AAED;;;;GAIG;AACH,eAAO,MAAM,+BAA+B;;;;;;CAO3C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kCAAkC,EAAE,MAAM,CACrD,gBAAgB,EAChB,SAAS,gBAAgB,EAAE,CAiB5B,CAAC;AAEF;;;GAGG;AACH,oBAAY,oCAAoC;IAC9C,iFAAiF;IACjF,QAAQ,aAAa;IACrB,2FAA2F;IAC3F,kBAAkB,uBAAuB;IACzC,2FAA2F;IAC3F,YAAY,iBAAiB;IAC7B,yEAAyE;IACzE,WAAW,gBAAgB;CAC5B"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How often the manager re-processes entries that have not yet reached a
|
|
3
|
+
* terminal state (`Completed`/`Expired`).
|
|
4
|
+
*
|
|
5
|
+
* Drives the periodic retry timer in `QuoteStatusUpdateManager`: on each tick
|
|
6
|
+
* every non-terminal entry is re-sent to the backend until it is accepted or
|
|
7
|
+
* evicted. The timer only runs while there is outstanding work.
|
|
8
|
+
*/
|
|
9
|
+
export declare const QUOTE_STATUS_UPDATE_RETRY_INTERVAL_MS: number;
|
|
10
|
+
/**
|
|
11
|
+
* Maximum lifetime of a tracked quote-status entry, measured from when it was
|
|
12
|
+
* created.
|
|
13
|
+
*
|
|
14
|
+
* Once an entry is older than this it is considered `Expired`, evicted from the
|
|
15
|
+
* store on the next read, and never retried again. This bounds how long the
|
|
16
|
+
* manager keeps trying to report a status that the backend may never accept.
|
|
17
|
+
*/
|
|
18
|
+
export declare const QUOTE_STATUS_UPDATE_ENTRY_TTL: number;
|
|
19
|
+
/**
|
|
20
|
+
* Quote lifecycle statuses as understood by the backend `quote/updateStatus`
|
|
21
|
+
* API. These are the values sent over the wire (and echoed back in error
|
|
22
|
+
* responses).
|
|
23
|
+
*/
|
|
24
|
+
export declare enum QuoteStatusBackendStatus {
|
|
25
|
+
/**
|
|
26
|
+
* Quote was served to the client. Unused locally, kept for parity with the backend enum.
|
|
27
|
+
*/
|
|
28
|
+
Served = "SERVED",
|
|
29
|
+
/**
|
|
30
|
+
* User has submitted the source transaction.
|
|
31
|
+
*/
|
|
32
|
+
Submitted = "SUBMITTED",
|
|
33
|
+
/**
|
|
34
|
+
* Transaction finalized successfully on-chain.
|
|
35
|
+
*/
|
|
36
|
+
FinalizedSuccess = "FINALIZED_SUCCESS",
|
|
37
|
+
/**
|
|
38
|
+
* Transaction failed or reverted on-chain.
|
|
39
|
+
*/
|
|
40
|
+
FinalizedFailed = "FINALIZED_FAILED"
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Machine-readable error `type` values returned by the backend
|
|
44
|
+
* `quote/updateStatus` API on non-2xx responses. The comments record the HTTP
|
|
45
|
+
* status the backend pairs with each type.
|
|
46
|
+
*/
|
|
47
|
+
export declare enum QuoteStatusUpdateBackendErrorType {
|
|
48
|
+
QuoteNotFound = "QUOTE_NOT_FOUND",// Http status: 404
|
|
49
|
+
ConcurrentUpdate = "CONCURRENT_UPDATE",// Http status: 409
|
|
50
|
+
InvalidStatusTransaction = "INVALID_STATUS_TRANSITION",// Http status: 400
|
|
51
|
+
SrcTxHashRequiredForFinalized = "SRC_TX_HASH_REQUIRED_FOR_FINALIZED",// Http status: 400
|
|
52
|
+
PersistQuoteStatusFailed = "PERSIST_QUOTE_STATUS_FAILED",// Http status: 400
|
|
53
|
+
TransactionNotIndexed = "TRANSACTION_NOT_INDEXED",// Http status: 409
|
|
54
|
+
TxDataMissingHash = "TX_DATA_MISSING_HASH",// Http status: 400
|
|
55
|
+
TxDataMissingTrade = "TX_DATA_MISSING_TRADE",// Http status: 400
|
|
56
|
+
/**
|
|
57
|
+
* On-chain tx payload does not match the served quote (EVM calldata, SVM message, TVM raw_data_hex).
|
|
58
|
+
*/
|
|
59
|
+
TxDataMismatch = "TX_DATA_MISMATCH",// Http status: 400
|
|
60
|
+
SvmTradeDeserializeFailed = "SVM_TRADE_DESERIALIZE_FAILED",// Http status: 400
|
|
61
|
+
/**
|
|
62
|
+
* Requested lifecycle status is inconsistent with observed on-chain tx status.
|
|
63
|
+
*/
|
|
64
|
+
QuoteStatusOnChainMismatch = "QUOTE_STATUS_ONCHAIN_MISMATCH"
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Error types whose response payload carries no `currentStatus`. Used by the
|
|
68
|
+
* response validator to define the base (non-mismatch) error response schema.
|
|
69
|
+
*/
|
|
70
|
+
export declare const BaseQuoteStatusUpdateErrorTypes: readonly [QuoteStatusUpdateBackendErrorType.QuoteNotFound, QuoteStatusUpdateBackendErrorType.ConcurrentUpdate, QuoteStatusUpdateBackendErrorType.SrcTxHashRequiredForFinalized, QuoteStatusUpdateBackendErrorType.PersistQuoteStatusFailed, QuoteStatusUpdateBackendErrorType.TransactionNotIndexed, QuoteStatusUpdateBackendErrorType.TxDataMissingHash, QuoteStatusUpdateBackendErrorType.TxDataMissingTrade, QuoteStatusUpdateBackendErrorType.TxDataMismatch, QuoteStatusUpdateBackendErrorType.SvmTradeDeserializeFailed];
|
|
71
|
+
/**
|
|
72
|
+
* The full set of valid backend status values. Used by the response validator
|
|
73
|
+
* to constrain the `currentStatus`/`newStatus` fields of error responses.
|
|
74
|
+
*/
|
|
75
|
+
export declare const QuoteStatusBackendValues: readonly [QuoteStatusBackendStatus.Served, QuoteStatusBackendStatus.Submitted, QuoteStatusBackendStatus.FinalizedSuccess, QuoteStatusBackendStatus.FinalizedFailed];
|
|
76
|
+
/**
|
|
77
|
+
* Error types whose response payload includes a `currentStatus` describing the
|
|
78
|
+
* backend's observed status. Used by the validator for the mismatch response
|
|
79
|
+
* schema and by the manager to reconcile local state with the backend.
|
|
80
|
+
*/
|
|
81
|
+
export declare const QuoteStatusUpdateBackendOnChainMismatchTypes: readonly [QuoteStatusUpdateBackendErrorType.InvalidStatusTransaction, QuoteStatusUpdateBackendErrorType.QuoteStatusOnChainMismatch];
|
|
82
|
+
/**
|
|
83
|
+
* Error types that represent transient backend conditions. A response with one
|
|
84
|
+
* of these types is retried by `updateQuoteStatusWithRetry`; any other error
|
|
85
|
+
* type is treated as non-retryable.
|
|
86
|
+
*/
|
|
87
|
+
export declare const QuoteStatusUpdateRetryableBackendTypes: QuoteStatusUpdateBackendErrorType[];
|
|
88
|
+
/**
|
|
89
|
+
* Local quote-status lifecycle states tracked by the state machine. These are
|
|
90
|
+
* the states the manager owns; a subset maps onto backend statuses while
|
|
91
|
+
* `Completed`/`Expired` are terminal, client-only states.
|
|
92
|
+
*/
|
|
93
|
+
export declare enum QuoteStatusState {
|
|
94
|
+
/** Source transaction submitted; awaiting finalization. */
|
|
95
|
+
Submitted = "Submitted",
|
|
96
|
+
/** Transaction finalized successfully on-chain. */
|
|
97
|
+
FinalizedSuccess = "FinalizedSuccess",
|
|
98
|
+
/** Transaction failed or reverted on-chain. */
|
|
99
|
+
FinalizedFailed = "FinalizedFailed",
|
|
100
|
+
/** Terminal: the backend accepted the final status; nothing left to report. */
|
|
101
|
+
Completed = "Completed",
|
|
102
|
+
/** Terminal: the entry outlived its TTL and was abandoned. */
|
|
103
|
+
Expired = "Expired"
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Maps each local lifecycle state to the backend status to report for it, or
|
|
107
|
+
* `null` for terminal states that require no backend update. The manager uses a
|
|
108
|
+
* `null` mapping as the signal to remove the entry instead of calling the API.
|
|
109
|
+
*/
|
|
110
|
+
export declare const QuoteStatusStateToBackendStatus: {
|
|
111
|
+
Submitted: QuoteStatusBackendStatus;
|
|
112
|
+
FinalizedSuccess: QuoteStatusBackendStatus;
|
|
113
|
+
FinalizedFailed: QuoteStatusBackendStatus;
|
|
114
|
+
Completed: null;
|
|
115
|
+
Expired: null;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Adjacency list defining the allowed forward-only transitions between
|
|
119
|
+
* lifecycle states. Enforced by `QuoteStatusStateFsm`; terminal states map to
|
|
120
|
+
* an empty array. Any state not present is treated as terminal.
|
|
121
|
+
*/
|
|
122
|
+
export declare const AllowedQuoteStatusStateTransitions: Record<QuoteStatusState, readonly QuoteStatusState[]>;
|
|
123
|
+
/**
|
|
124
|
+
* Outcome of a retrying status fetch call. Tells the
|
|
125
|
+
* manager how to proceed after an update attempt completes.
|
|
126
|
+
*/
|
|
127
|
+
export declare enum QuoteStatusFetchWithRetryOutcomeType {
|
|
128
|
+
/** The backend accepted the update (2xx); the entry can be finalized/removed. */
|
|
129
|
+
Accepted = "accepted",
|
|
130
|
+
/** All retry attempts for a retryable error were used up; back off and try again later. */
|
|
131
|
+
RetryableExhausted = "retryableExhausted",
|
|
132
|
+
/** The backend returned a non-retryable error; the entry must be reconciled or evicted. */
|
|
133
|
+
NonRetryable = "nonRetryable",
|
|
134
|
+
/** The request was aborted (e.g. via abort signal) before completing. */
|
|
135
|
+
Interrupted = "interrupted"
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=constants.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../../src/quote-status-manager/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,qCAAqC,QAAiB,CAAC;AAEpE;;;;;;;GAOG;AACH,eAAO,MAAM,6BAA6B,QAAsB,CAAC;AAEjE;;;;GAIG;AACH,oBAAY,wBAAwB;IAClC;;OAEG;IACH,MAAM,WAAW;IACjB;;OAEG;IACH,SAAS,cAAc;IACvB;;OAEG;IACH,gBAAgB,sBAAsB;IACtC;;OAEG;IACH,eAAe,qBAAqB;CACrC;AAED;;;;GAIG;AACH,oBAAY,iCAAiC;IAC3C,aAAa,oBAAoB,CAAE,mBAAmB;IACtD,gBAAgB,sBAAsB,CAAE,mBAAmB;IAC3D,wBAAwB,8BAA8B,CAAE,mBAAmB;IAC3E,6BAA6B,uCAAuC,CAAE,mBAAmB;IACzF,wBAAwB,gCAAgC,CAAE,mBAAmB;IAC7E,qBAAqB,4BAA4B,CAAE,mBAAmB;IACtE,iBAAiB,yBAAyB,CAAE,mBAAmB;IAC/D,kBAAkB,0BAA0B,CAAE,mBAAmB;IACjE;;OAEG;IACH,cAAc,qBAAqB,CAAE,mBAAmB;IACxD,yBAAyB,iCAAiC,CAAE,mBAAmB;IAC/E;;OAEG;IACH,0BAA0B,kCAAkC;CAC7D;AAED;;;GAGG;AACH,eAAO,MAAM,+BAA+B,ggBAUlC,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,wBAAwB,qKAK3B,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,4CAA4C,qIAG/C,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,sCAAsC,qCAGlD,CAAC;AAEF;;;;GAIG;AACH,oBAAY,gBAAgB;IAC1B,2DAA2D;IAC3D,SAAS,cAAc;IACvB,mDAAmD;IACnD,gBAAgB,qBAAqB;IACrC,+CAA+C;IAC/C,eAAe,oBAAoB;IACnC,+EAA+E;IAC/E,SAAS,cAAc;IACvB,8DAA8D;IAC9D,OAAO,YAAY;CACpB;AAED;;;;GAIG;AACH,eAAO,MAAM,+BAA+B;;;;;;CAO3C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kCAAkC,EAAE,MAAM,CACrD,gBAAgB,EAChB,SAAS,gBAAgB,EAAE,CAiB5B,CAAC;AAEF;;;GAGG;AACH,oBAAY,oCAAoC;IAC9C,iFAAiF;IACjF,QAAQ,aAAa;IACrB,2FAA2F;IAC3F,kBAAkB,uBAAuB;IACzC,2FAA2F;IAC3F,YAAY,iBAAiB;IAC7B,yEAAyE;IACzE,WAAW,gBAAgB;CAC5B"}
|