Skip to content

Commit ed591e4

Browse files
refactor: simplify bridge status state updates
1 parent aec31b1 commit ed591e4

File tree

1 file changed

+7
-32
lines changed

1 file changed

+7
-32
lines changed

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

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -199,15 +199,9 @@ export default class BridgeStatusController extends StaticIntervalPollingControl
199199
},
200200
hasApprovalTx: Boolean(quoteResponse.approval),
201201
};
202-
this.update((_state) => {
203-
_state.bridgeStatusState = {
204-
...bridgeStatusState,
205-
txHistory: {
206-
...bridgeStatusState.txHistory,
207-
// Use the txMeta.id as the key so we can reference the txMeta in TransactionController
208-
[bridgeTxMeta.id]: txHistoryItem,
209-
},
210-
};
202+
this.update((state) => {
203+
// Use the txMeta.id as the key so we can reference the txMeta in TransactionController
204+
state.bridgeStatusState.txHistory[bridgeTxMeta.id] = txHistoryItem;
211205
});
212206

213207
this.#pollingTokensByTxMetaId[bridgeTxMeta.id] = this.startPolling({
@@ -266,13 +260,8 @@ export default class BridgeStatusController extends StaticIntervalPollingControl
266260
// we need to keep track of the account that this is associated with as well so that we don't show it in Activity list for other accounts
267261
// First stab at this will not stop polling when you are on a different account
268262
this.update((state) => {
269-
state.bridgeStatusState = {
270-
...bridgeStatusState,
271-
txHistory: {
272-
...bridgeStatusState.txHistory,
273-
[bridgeTxMetaId]: newBridgeHistoryItem,
274-
},
275-
};
263+
state.bridgeStatusState.txHistory[bridgeTxMetaId] =
264+
newBridgeHistoryItem;
276265
});
277266

278267
const pollingToken = this.#pollingTokensByTxMetaId[bridgeTxMetaId];
@@ -330,22 +319,8 @@ export default class BridgeStatusController extends StaticIntervalPollingControl
330319
}
331320

332321
this.update((state) => {
333-
state.bridgeStatusState = {
334-
...bridgeStatusState,
335-
txHistory: {
336-
...bridgeStatusState.txHistory,
337-
[bridgeTxMetaId]: {
338-
...bridgeStatusState.txHistory[bridgeTxMetaId],
339-
status: {
340-
...bridgeStatusState.txHistory[bridgeTxMetaId].status,
341-
srcChain: {
342-
...bridgeStatusState.txHistory[bridgeTxMetaId].status.srcChain,
343-
txHash: srcTxHash,
344-
},
345-
},
346-
},
347-
},
348-
};
322+
state.bridgeStatusState.txHistory[bridgeTxMetaId].status.srcChain.txHash =
323+
srcTxHash;
349324
});
350325
};
351326

0 commit comments

Comments
 (0)