-
-
Notifications
You must be signed in to change notification settings - Fork 262
chore: populate swap intent metrics and rename txHistory keys #7564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
chore: populate swap intent metrics and rename txHistory keys #7564
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Single string `txHashes` in metadata is silently discarded
Medium Severity
The IntentOrderResponseSchema at line 78 in validators.ts allows metadata.txHashes to be either an array of hex strings or a single hex string via union([array(StrictHexStruct), StrictHexStruct]). However, the code at line 770-772 only handles the array case: when txHashes is a single string, Array.isArray() returns false, causing metadataTxHashes to become an empty array and silently discarding the hash value. If txHash is also undefined, transaction hashes could be lost entirely.
packages/bridge-status-controller/src/bridge-status-controller.ts#L769-L772
core/packages/bridge-status-controller/src/bridge-status-controller.ts
Lines 769 to 772 in 06c1583
| // Check metadata for additional transaction hashes | |
| const metadataTxHashes = Array.isArray(intentOrder.metadata.txHashes) | |
| ? intentOrder.metadata.txHashes | |
| : []; |
packages/bridge-status-controller/src/utils/validators.ts#L76-L79
core/packages/bridge-status-controller/src/utils/validators.ts
Lines 76 to 79 in 06c1583
| txHash: optional(StrictHexStruct), | |
| metadata: type({ | |
| txHashes: optional(union([array(StrictHexStruct), StrictHexStruct])), | |
| }), |
`CANCELLED` intent status incorrectly maps to `submitted` instead of `failed`
Medium Severity
The IntentOrderStatus.CANCELLED enum value is defined but not handled in the status mapping logic. In mapIntentOrderStatusToTransactionStatus, a cancelled order falls through to the default case and incorrectly returns TransactionStatus.submitted. Similarly, in #updateHistoryAndTxFromIntentOrder, cancelled orders fall through to StatusTypes.UNKNOWN. A cancelled intent order is a terminal failed state and should map to failed status, like EXPIRED does, rather than appearing as an active or unknown transaction.
packages/bridge-status-controller/src/utils/intent-api.ts#L102-L118
core/packages/bridge-status-controller/src/utils/intent-api.ts
Lines 102 to 118 in 06c1583
| export function mapIntentOrderStatusToTransactionStatus( | |
| intentStatus: IntentOrderStatus, | |
| ): TransactionStatus { | |
| switch (intentStatus) { | |
| case IntentOrderStatus.PENDING: | |
| case IntentOrderStatus.SUBMITTED: | |
| return TransactionStatus.submitted; | |
| case IntentOrderStatus.CONFIRMED: | |
| case IntentOrderStatus.COMPLETED: | |
| return TransactionStatus.confirmed; | |
| case IntentOrderStatus.FAILED: | |
| case IntentOrderStatus.EXPIRED: | |
| return TransactionStatus.failed; | |
| default: | |
| return TransactionStatus.submitted; | |
| } |
packages/bridge-status-controller/src/bridge-status-controller.ts#L745-L764
core/packages/bridge-status-controller/src/bridge-status-controller.ts
Lines 745 to 764 in 06c1583
| ].includes(intentOrder.status); | |
| const isFailed = [ | |
| IntentOrderStatus.FAILED, | |
| IntentOrderStatus.EXPIRED, | |
| ].includes(intentOrder.status); | |
| const isPending = [IntentOrderStatus.PENDING].includes(intentOrder.status); | |
| const isSubmitted = [IntentOrderStatus.SUBMITTED].includes( | |
| intentOrder.status, | |
| ); | |
| if (isComplete) { | |
| statusType = StatusTypes.COMPLETE; | |
| } else if (isFailed) { | |
| statusType = StatusTypes.FAILED; | |
| } else if (isPending) { | |
| statusType = StatusTypes.PENDING; | |
| } else if (isSubmitted) { | |
| statusType = StatusTypes.SUBMITTED; | |
| } else { | |
| statusType = StatusTypes.UNKNOWN; |
fdba719 to
e530943
Compare
…-swap-architecture-refactory-txHistory-metrics
…-swap-architecture-refactory-txHistory-metrics
…-swap-architecture-refactory-txHistory-metrics
Explanation
References
Checklist
Note
Adds full intent-based swap/bridge flow and wiring across controllers.
submitIntentaction, polling viaIntentApiImpl(submit/getOrderStatus), maps intent statuses to bridgeStatusTypes(incl. newSUBMITTED), recordsintentOrderIdand aggregatedsrcTxHashes, updates TC tx status, event tracking adjustments; tests and snapshots added; coverage config tweakedIntent/IntentOrderLike;Quotenow optionally includesintent; validators addIntentOrderSchema/IntentSchemaand helpersutils/intent-api.ts) with validation and status mapping + testsWritten by Cursor Bugbot for commit 06c1583. This will update automatically on new commits. Configure here.