Skip to content

Commit 72a6c00

Browse files
committed
chore: add actionId and originalTransactionId to polling args
history
1 parent 5be108a commit 72a6c00

File tree

3 files changed

+38
-26
lines changed

3 files changed

+38
-26
lines changed

packages/bridge-status-controller/src/bridge-status-controller.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,20 +1142,18 @@ export class BridgeStatusController extends StaticIntervalPollingController<Brid
11421142

11431143
// Add pre-submission history keyed by actionId
11441144
// This ensures we have quote data available if transaction fails during submission
1145-
this.#addTxToHistory(
1146-
{
1147-
accountAddress: selectedAccount.address,
1148-
quoteResponse,
1149-
slippagePercentage: 0,
1150-
isStxEnabled: isStxEnabledOnClient,
1151-
startTime,
1152-
approvalTxId,
1153-
location,
1154-
abTests,
1155-
activeAbTests,
1156-
},
1145+
this.#addTxToHistory({
1146+
accountAddress: selectedAccount.address,
1147+
quoteResponse,
1148+
slippagePercentage: 0,
1149+
isStxEnabled: isStxEnabledOnClient,
1150+
startTime,
1151+
approvalTxId,
1152+
location,
1153+
abTests,
1154+
activeAbTests,
11571155
actionId,
1158-
);
1156+
});
11591157

11601158
// Pass txFee when gasIncluded is true to use the quote's gas fees
11611159
// instead of re-estimating (which would fail for max native token swaps)

packages/bridge-status-controller/src/types.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ export type RefuelStatusResponse = object & StatusResponse;
109109
export type BridgeHistoryItem = {
110110
txMetaId?: string; // Optional: not available pre-submission or on sync failure
111111
actionId?: string; // Only for non-batch EVM transactions
112+
/**
113+
* @deprecated the txMeta or orderUid should be used instead
114+
*/
112115
originalTransactionId?: string; // Keep original transaction ID for intent transactions
113116
batchId?: string;
114117
quote: Quote;
@@ -211,7 +214,12 @@ export type QuoteMetadataSerialized = {
211214
};
212215

213216
export type StartPollingForBridgeTxStatusArgs = {
214-
bridgeTxMeta?: TransactionMeta;
217+
bridgeTxMeta?: Pick<TransactionMeta, 'id' | 'hash' | 'batchId'>;
218+
actionId?: string;
219+
/**
220+
* @deprecated the txMeta or orderUid should be used instead
221+
*/
222+
originalTransactionId?: string;
215223
quoteResponse: QuoteResponse & QuoteMetadata;
216224
startTime?: BridgeHistoryItem['startTime'];
217225
slippagePercentage: BridgeHistoryItem['slippagePercentage'];

packages/bridge-status-controller/src/utils/history.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,16 @@ export const rekeyHistoryItemInState = (
4242
*
4343
* @param actionId - The action ID used for pre-submission tracking
4444
* @param bridgeTxMetaId - The transaction meta ID from bridgeTxMeta
45+
* @param syntheticTransactionId - The transactionId of the intent's placeholder transaction
4546
* @returns The key to use for the history item
4647
* @throws Error if neither actionId nor bridgeTxMetaId is provided
4748
*/
4849
export function getHistoryKey(
4950
actionId: string | undefined,
5051
bridgeTxMetaId: string | undefined,
52+
syntheticTransactionId?: string,
5153
): string {
52-
const historyKey = actionId ?? bridgeTxMetaId;
54+
const historyKey = actionId ?? bridgeTxMetaId ?? syntheticTransactionId;
5355
if (!historyKey) {
5456
throw new Error(
5557
'Cannot add tx to history: either actionId or bridgeTxMeta.id must be provided',
@@ -59,7 +61,12 @@ export function getHistoryKey(
5961
}
6062

6163
export const getInitialHistoryItem = (
62-
{
64+
args: StartPollingForBridgeTxStatusArgsSerialized,
65+
): {
66+
historyKey: string;
67+
txHistoryItem: BridgeHistoryItem;
68+
} => {
69+
const {
6370
bridgeTxMeta,
6471
quoteResponse,
6572
startTime,
@@ -72,25 +79,24 @@ export const getInitialHistoryItem = (
7279
abTests,
7380
activeAbTests,
7481
accountAddress: selectedAddress,
75-
}: StartPollingForBridgeTxStatusArgsSerialized,
76-
actionId?: string,
77-
): {
78-
historyKey: string;
79-
txHistoryItem: BridgeHistoryItem;
80-
} => {
82+
originalTransactionId,
83+
actionId,
84+
} = args;
8185
// Determine the key for this history item:
8286
// - For pre-submission (non-batch EVM): use actionId
8387
// - For post-submission or other cases: use bridgeTxMeta.id
84-
const historyKey = getHistoryKey(actionId, bridgeTxMeta?.id);
88+
const historyKey = getHistoryKey(
89+
actionId,
90+
bridgeTxMeta?.id,
91+
originalTransactionId,
92+
);
8593

8694
// Write all non-status fields to state so we can reference the quote in Activity list without the Bridge API
8795
// We know it's in progress but not the exact status yet
8896
const txHistoryItem = {
8997
txMetaId: bridgeTxMeta?.id,
9098
actionId,
91-
originalTransactionId:
92-
(bridgeTxMeta as unknown as { originalTransactionId: string })
93-
?.originalTransactionId || bridgeTxMeta?.id, // Keep original for intent transactions
99+
originalTransactionId: originalTransactionId ?? bridgeTxMeta?.id, // Keep original for intent transactions
94100
batchId: bridgeTxMeta?.batchId,
95101
quote: quoteResponse.quote,
96102
startTime,

0 commit comments

Comments
 (0)