Skip to content

Conversation

@micaelae
Copy link
Member

@micaelae micaelae commented Jan 7, 2026

Explanation

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Adds full intent-based swap/bridge flow and wiring across controllers.

  • Bridge Status: New submitIntent action, polling via IntentApiImpl (submit/getOrderStatus), maps intent statuses to bridge StatusTypes (incl. new SUBMITTED), records intentOrderId and aggregated srcTxHashes, updates TC tx status, event tracking adjustments; tests and snapshots added; coverage config tweaked
  • Bridge Controller/Types: Export Intent/IntentOrderLike; Quote now optionally includes intent; validators add IntentOrderSchema/IntentSchema and helpers
  • Transaction Controller: Support synthetic intent txs (skip publish/sign), convert legacy gasPrice to EIP-1559 when skipping estimates, exclude intent txs from pending tracker
  • New intent API util (utils/intent-api.ts) with validation and status mapping + tests
  • Changelogs updated; minor repo hygiene (.gitignore, suppressions).

Written by Cursor Bugbot for commit 06c1583. This will update automatically on new commits. Configure here.

khanti42 and others added 30 commits September 2, 2025 15:12
@micaelae micaelae requested review from a team as code owners January 7, 2026 00:53
@micaelae micaelae marked this pull request as draft January 7, 2026 00:53
@micaelae micaelae changed the base branch from main to wip/intent-swap-architecture-refactory January 7, 2026 00:54
Copy link

@cursor cursor bot left a 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

// 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

txHash: optional(StrictHexStruct),
metadata: type({
txHashes: optional(union([array(StrictHexStruct), StrictHexStruct])),
}),

Fix in Cursor Fix in Web


`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

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

].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;

Fix in Cursor Fix in Web


@oscarwroche oscarwroche force-pushed the wip/intent-swap-architecture-refactory branch from fdba719 to e530943 Compare January 7, 2026 15:20
Base automatically changed from wip/intent-swap-architecture-refactory to main January 9, 2026 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants