Skip to content

Commit

Permalink
fix: build issues from tx status
Browse files Browse the repository at this point in the history
  • Loading branch information
micaelae committed Nov 9, 2024
1 parent 63a3404 commit 01d4837
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ import {
FlexDirection,
TextColor,
} from '../../../helpers/constants/design-system';
import {
TransactionMeta,
TransactionStatus,
} from '@metamask/transaction-controller';
import Segment from './segment';

const getTxIndex = (
Expand Down
36 changes: 19 additions & 17 deletions ui/pages/bridge/transaction-details/bridge-step-description.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import * as React from 'react';
import { NetworkConfiguration } from '@metamask/network-controller';
import { BridgeHistoryItem } from '../../../../shared/types/bridge-status';
import { Step } from '../../../../shared/types/bridge-status';
import { ActionTypes } from '../../../../shared/types/bridge-status';
import { StatusTypes } from '../../../../shared/types/bridge-status';
import { Box, Text } from '../../../components/component-library';
import { Numeric } from '../../../../shared/modules/Numeric';
import { Hex } from '@metamask/utils';
import {
TransactionMeta,
Expand All @@ -31,6 +25,11 @@ import { useI18nContext } from '../../../hooks/useI18nContext';
* bridge actions will have step.srcChainId !== step.destChainId
* We cannot infer the status of the bridge action since 2 different chains are involved
* The best we can do is the bridgeHistoryItem.estimatedProcessingTimeInSeconds
*
* @param t
* @param stepStatus
* @param step
* @param networkConfigurationsByChainId
*/
const getBridgeActionText = (
t: Function,
Expand Down Expand Up @@ -65,6 +64,10 @@ const getBridgeActionStatus = (bridgeHistoryItem: BridgeHistoryItem) => {
* EITHER the quote.srcChainId or the quote.destChainId
* Despite not having any actual timestamp,we can infer the status of the swap action
* based on the status of the source chain tx if srcChainId and destChainId are the same*
*
* @param bridgeHistoryItem
* @param step
* @param srcChainTxMeta
*/
const getSwapActionStatus = (
bridgeHistoryItem: BridgeHistoryItem,
Expand All @@ -77,21 +80,20 @@ const getSwapActionStatus = (

if (isSrcAndDestChainSame && isSwapOnSrcChain) {
// if the swap action is on the src chain (i.e. step.srcChainId === step.destChainId === bridgeHistoryItem.quote.srcChainId),
//we check the source chain tx status, since we know when it's confirmed
// we check the source chain tx status, since we know when it's confirmed
const isSrcChainTxConfirmed =
srcChainTxMeta?.status === TransactionStatus.confirmed;
return isSrcChainTxConfirmed ? StatusTypes.COMPLETE : StatusTypes.PENDING;
} else {
// if the swap action is on the dest chain, we check the bridgeHistoryItem.status,
// since we don't know when the dest tx is confirmed
if (srcChainTxMeta?.status === TransactionStatus.confirmed) {
return bridgeHistoryItem.status ? bridgeHistoryItem.status.status : null;
}

// If the source chain tx is not confirmed, we know the swap hasn't started
// use null to represent this as we don't have an equivalent in StatusTypes
return null;
}
// if the swap action is on the dest chain, we check the bridgeHistoryItem.status,
// since we don't know when the dest tx is confirmed
if (srcChainTxMeta?.status === TransactionStatus.confirmed) {
return bridgeHistoryItem.status ? bridgeHistoryItem.status.status : null;
}

// If the source chain tx is not confirmed, we know the swap hasn't started
// use null to represent this as we don't have an equivalent in StatusTypes
return null;
};

const getSwapActionText = (
Expand Down

0 comments on commit 01d4837

Please sign in to comment.