-
-
Notifications
You must be signed in to change notification settings - Fork 268
feat(bridge-status): add polling for Tron same-chain swaps #7697
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -15,6 +15,7 @@ import { | |||||
| UnifiedSwapBridgeEventName, | ||||||
| formatChainIdToCaip, | ||||||
| isCrossChain, | ||||||
| isTronChainId, | ||||||
| isEvmTxData, | ||||||
| isHardwareWallet, | ||||||
| MetricsActionType, | ||||||
|
|
@@ -362,13 +363,8 @@ export class BridgeStatusController extends StaticIntervalPollingController<Brid | |||||
| } | ||||||
| }); | ||||||
|
|
||||||
| // Restart polling if it was stopped and this is a bridge transaction | ||||||
| const isBridgeTx = isCrossChain( | ||||||
| historyItem.quote.srcChainId, | ||||||
| historyItem.quote.destChainId, | ||||||
| ); | ||||||
|
|
||||||
| if (isBridgeTx) { | ||||||
| // Restart polling if it was stopped and this tx still needs status updates | ||||||
| if (this.#shouldPollHistoryItem(historyItem, targetTxMetaId)) { | ||||||
| // Check if polling was stopped (no active polling token) | ||||||
| const existingPollingToken = | ||||||
| this.#pollingTokensByTxMetaId[targetTxMetaId]; | ||||||
|
|
@@ -412,13 +408,9 @@ export class BridgeStatusController extends StaticIntervalPollingController<Brid | |||||
| this.#pollingTokensByTxMetaId[historyItem.txMetaId]; | ||||||
| return !pollingToken; | ||||||
| }) | ||||||
| // Swap txs don't need to have their statuses polled | ||||||
| // Only restart polling for items that still require status updates | ||||||
| .filter((historyItem) => { | ||||||
| const isBridgeTx = isCrossChain( | ||||||
| historyItem.quote.srcChainId, | ||||||
| historyItem.quote.destChainId, | ||||||
| ); | ||||||
| return isBridgeTx; | ||||||
| return this.#shouldPollHistoryItem(historyItem, historyItem.txMetaId); | ||||||
| }); | ||||||
|
|
||||||
| incompleteHistoryItems.forEach((historyItem) => { | ||||||
|
|
@@ -507,16 +499,30 @@ export class BridgeStatusController extends StaticIntervalPollingController<Brid | |||||
| if (!txHistoryItem) { | ||||||
| return; | ||||||
| } | ||||||
| const { quote } = txHistoryItem; | ||||||
| const isIntent = txId.startsWith('intent:'); | ||||||
| const isBridgeTx = isCrossChain(quote.srcChainId, quote.destChainId); | ||||||
| if (isBridgeTx || isIntent) { | ||||||
| if (this.#shouldPollHistoryItem(txHistoryItem, txId)) { | ||||||
| this.#pollingTokensByTxMetaId[txId] = this.startPolling({ | ||||||
| bridgeTxMetaId: txId, | ||||||
| }); | ||||||
| } | ||||||
| }; | ||||||
|
|
||||||
| readonly #shouldPollHistoryItem = ( | ||||||
| historyItem: BridgeHistoryItem, | ||||||
| txMetaId: string, | ||||||
| ): boolean => { | ||||||
| const isIntent = txMetaId.startsWith('intent:'); | ||||||
| const isBridgeTx = isCrossChain( | ||||||
| historyItem.quote.srcChainId, | ||||||
| historyItem.quote.destChainId, | ||||||
| ); | ||||||
|
|
||||||
| // Tron same-chain swaps use async settlement and need polling | ||||||
| const isTronSameChainSwap = | ||||||
| !isBridgeTx && !isIntent && isTronChainId(historyItem.quote.srcChainId); | ||||||
|
Comment on lines
+519
to
+521
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Polling needs to be done for Tron bridge txs too so this should just check for isTronChainId |
||||||
|
|
||||||
| return isBridgeTx || isIntent || isTronSameChainSwap; | ||||||
| }; | ||||||
|
|
||||||
| /** | ||||||
| * @deprecated For EVM/Solana swap/bridge txs we add tx to history in submitTx() | ||||||
| * For Solana swap/bridge we start polling in submitTx() | ||||||
|
|
@@ -1390,6 +1396,8 @@ export class BridgeStatusController extends StaticIntervalPollingController<Brid | |||||
| quoteResponse.quote.srcChainId, | ||||||
| quoteResponse.quote.destChainId, | ||||||
| ); | ||||||
| const isTronSameChainSwap = | ||||||
| !isBridgeTx && isTronChainId(quoteResponse.quote.srcChainId); | ||||||
|
|
||||||
| // Submit non-EVM tx (Solana, BTC, Tron) | ||||||
| if (isNonEvmChainId(quoteResponse.quote.srcChainId)) { | ||||||
|
|
@@ -1570,7 +1578,7 @@ export class BridgeStatusController extends StaticIntervalPollingController<Brid | |||||
| // Start polling for bridge tx status | ||||||
| this.#startPollingForTxId(txMeta.id); | ||||||
| // Track non-EVM Swap completed event | ||||||
| if (!isBridgeTx) { | ||||||
| if (!isBridgeTx && !isTronSameChainSwap) { | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here - both swaps and bridges will be polled so the Completed event can't be published until we get a txStatus
Suggested change
|
||||||
| this.#trackUnifiedSwapBridgeEvent( | ||||||
| UnifiedSwapBridgeEventName.Completed, | ||||||
| txMeta.id, | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.