Skip to content

fix: fixes swap transactions showing up as bridge #30656

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

Merged
merged 6 commits into from
Mar 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 31 additions & 10 deletions ui/hooks/bridge/useSolanaBridgeTransactionMapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ export default function useSolanaBridgeTransactionMapping(
// The signature is in the id field for non-EVM transactions
const txSignature = tx.id;

// If the transaction type is explicitly 'swap', never mark it as a bridge
if (tx.type === 'swap') {
return {
...tx,
// Explicitly set to false to ensure it's never marked as a bridge
isBridgeTx: false,
};
}

// Check if this transaction signature matches a bridge transaction
if (
txSignature &&
Expand All @@ -77,20 +86,32 @@ export default function useSolanaBridgeTransactionMapping(
// @ts-expect-error WIP: Need to add index signature to bridgeTxSignatures
const matchingBridgeTx = bridgeTxSignatures[txSignature];

// Get source and destination chain IDs
const srcChainId = matchingBridgeTx.quote?.srcChainId;
const destChainId = matchingBridgeTx.quote?.destChainId;

// Only consider it a bridge if source and destination chains are different
const isBridgeTx =
srcChainId && destChainId && srcChainId !== destChainId;

// Return an enhanced version of the transaction with bridge info
return {
...tx,
// Change the type to bridge
type: 'bridge',
// Add bridge-specific flags
isBridgeTx: true,
// Change the type to bridge only if it's truly a bridge transaction
type: isBridgeTx ? 'bridge' : tx.type,
// Add bridge-specific flag based on chain comparison
isBridgeTx,
// Include destination chain details
bridgeInfo: {
destChainId: matchingBridgeTx.quote?.destChainId,
destChainName: getNetworkName(matchingBridgeTx.quote?.destChainId),
destAsset: matchingBridgeTx.quote?.destAsset,
destTokenAmount: matchingBridgeTx.quote?.destTokenAmount,
},
bridgeInfo: isBridgeTx
? {
destChainId: matchingBridgeTx.quote?.destChainId,
destChainName: getNetworkName(
matchingBridgeTx.quote?.destChainId,
),
destAsset: matchingBridgeTx.quote?.destAsset,
destTokenAmount: matchingBridgeTx.quote?.destTokenAmount,
}
: undefined,
};
}

Expand Down
Loading