Skip to content

Commit

Permalink
Merge pull request #1020 from airswap/develop
Browse files Browse the repository at this point in the history
Dev -> Main
  • Loading branch information
dmosites authored Dec 30, 2024
2 parents 58ca4d7 + dbf33cb commit e003031
Show file tree
Hide file tree
Showing 20 changed files with 141 additions and 284 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"prepare": "husky install"
},
"dependencies": {
"@airswap/libraries": "5.0.3",
"@airswap/libraries": "5.0.9",
"@akkafinance/web3-react-bitkeep": "^1.0.0",
"@coinbase/wallet-sdk": "^3.7.2",
"@craco/craco": "^6.2.0",
Expand Down
71 changes: 43 additions & 28 deletions src/app/store.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import { configureStore, ThunkAction, Action } from "@reduxjs/toolkit";
import {
configureStore,
ThunkAction,
Action,
ThunkDispatch,
AnyAction,
Store,
combineReducers,
} from "@reduxjs/toolkit";

import {
balancesReducer,
Expand All @@ -18,31 +26,38 @@ import transactionsReducer from "../features/transactions/transactionsSlice";
import userSettingsReducer from "../features/userSettings/userSettingsSlice";
import web3Reducer from "../features/web3/web3Slice";

export const store = configureStore({
reducer: {
allowances: allowancesReducer,
transactions: transactionsReducer,
balances: balancesReducer,
metadata: metadataReducer,
tradeTerms: tradeTermsReducer,
indexer: indexerReducer,
orders: ordersReducer,
gasCost: gasCostReducer,
registry: registryReducer,
userSettings: userSettingsReducer,
makeOtc: makeOtcReducer,
myOrders: myOrdersReducer,
takeOtc: takeOtcReducer,
web3: web3Reducer,
quotes: quotesReducer,
},
});
const reducers = {
allowances: allowancesReducer,
transactions: transactionsReducer,
balances: balancesReducer,
metadata: metadataReducer,
tradeTerms: tradeTermsReducer,
indexer: indexerReducer,
orders: ordersReducer,
gasCost: gasCostReducer,
registry: registryReducer,
userSettings: userSettingsReducer,
makeOtc: makeOtcReducer,
myOrders: myOrdersReducer,
takeOtc: takeOtcReducer,
web3: web3Reducer,
quotes: quotesReducer,
};

const rootReducer = combineReducers(reducers);

// 1. Get the root state's type from reducers
export type RootState = ReturnType<typeof rootReducer>;

export type AppDispatch = typeof store.dispatch;
export type RootState = ReturnType<typeof store.getState>;
export type AppThunk<ReturnType = void> = ThunkAction<
ReturnType,
RootState,
unknown,
Action<string>
>;
// 2. Create a type for thunk dispatch
export type AppDispatch = ThunkDispatch<RootState, any, AnyAction>;

// 3. Create a type for store using RootState and Thunk enabled dispatch
export type AppStore = Omit<Store<RootState, AnyAction>, "dispatch"> & {
dispatch: AppDispatch;
};

//4. create the store with your custom AppStore
export const store: AppStore = configureStore({
reducer: rootReducer,
});
2 changes: 1 addition & 1 deletion src/components/@widgets/CancelWidget/CancelWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import useCancellationSuccess from "../../../hooks/useCancellationSuccess";
import { AppRoutes } from "../../../routes";
import { OrderStatus } from "../../../types/orderStatus";
import Icon from "../../Icon/Icon";
import SubmittedCancellationScreen from "../../SubmittedCancellationScreen";
import TransactionOverlay from "../../TransactionOverlay/TransactionOverlay";
import { Title } from "../../Typography/Typography";
import { InfoSubHeading } from "../../Typography/Typography";
Expand All @@ -27,7 +28,6 @@ import {
BackButton,
CancelButton,
} from "./CancelWidget.styles";
import SubmittedCancellationScreen from "./subcomponentss/SubmittedCancellationScreen/SubmittedCancellationScreen";

interface CancelWidgetProps {
library: Web3Provider;
Expand Down
33 changes: 32 additions & 1 deletion src/components/@widgets/MyOrdersWidget/MyOrdersWidget.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC, useContext, useMemo } from "react";
import React, { FC, useContext, useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
import { useHistory } from "react-router-dom";

Expand All @@ -17,8 +17,14 @@ import {
} from "../../../features/myOrders/myOrdersSlice";
import { getNonceUsed } from "../../../features/orders/ordersHelpers";
import { cancelOrder } from "../../../features/takeOtc/takeOtcActions";
import { selectTakeOtcStatus } from "../../../features/takeOtc/takeOtcSlice";
import { selectPendingCancellations } from "../../../features/transactions/transactionsSlice";
import switchToDefaultChain from "../../../helpers/switchToDefaultChain";
import useCancellationPending from "../../../hooks/useCancellationPending";
import { AppRoutes } from "../../../routes";
import SubmittedCancellationScreen from "../../SubmittedCancellationScreen";
import TransactionOverlay from "../../TransactionOverlay/TransactionOverlay";
import WalletSignScreen from "../../WalletSignScreen/WalletSignScreen";
import { Container, InfoSectionContainer } from "./MyOrdersWidget.styles";
import { getSortedOrders } from "./helpers";
import ActionButtons, {
Expand All @@ -40,6 +46,14 @@ const MyOrdersWidget: FC = () => {
selectMyOrdersReducer
);

const status = useAppSelector(selectTakeOtcStatus);
const [activeCancellationNonce, setActiveCancellationNonce] =
useState<string>();
const pendingCancelTranssaction = useCancellationPending(
activeCancellationNonce || null,
true
);

// Modal states
const { setShowWalletList } = useContext(InterfaceContext);

Expand All @@ -61,6 +75,7 @@ const MyOrdersWidget: FC = () => {
const nonceUsed = await getNonceUsed(order, library!);

if (!isExpired && !nonceUsed) {
setActiveCancellationNonce(order.nonce);
await dispatch(
cancelOrder({ order: order, chainId: chainId!, library: library! })
);
Expand Down Expand Up @@ -93,6 +108,22 @@ const MyOrdersWidget: FC = () => {
return (
<Container>
<MyOrdersWidgetHeader title={t("common.myOrders")} />

<TransactionOverlay isHidden={status !== "signing"}>
<WalletSignScreen type="signature" />
</TransactionOverlay>

<TransactionOverlay
isHidden={status === "signing" || !pendingCancelTranssaction}
>
{pendingCancelTranssaction && (
<SubmittedCancellationScreen
chainId={chainId}
transaction={pendingCancelTranssaction}
/>
)}
</TransactionOverlay>

{!!sortedUserOrders.length && (
<>
<MyOrdersList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ export const ActionButton = styled(IconButton)`
}
`;

export const StyledNavLink = styled(NavLink)<{ isHovered: boolean }>`
export const StyledNavLink = styled(NavLink)<{ $isHovered?: boolean }>`
position: absolute;
top: -1px;
left: 0;
border-radius: 0.5rem;
width: 100%;
height: calc(100% + 1px);
background: ${({ theme }) => theme.colors.darkBlue};
opacity: ${({ isHovered }) => (isHovered ? 1 : 0)};
opacity: ${({ $isHovered }) => ($isHovered ? 1 : 0)};
z-index: 1;
&:hover,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const Order: FC<PropsWithChildren<OrderProps>> = ({
{orderStatus === OrderStatus.open ? timeLeft : orderStatusTranslation}
</Text>
<StyledNavLink
isHovered={isHoveredActionButton}
$isHovered={isHoveredActionButton}
to={`/${AppRoutes.order}/${orderString}`}
/>

Expand Down
13 changes: 0 additions & 13 deletions src/components/@widgets/SwapWidget/SwapWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -645,19 +645,6 @@ const SwapWidget: FC = () => {
onCloseButtonClick={() => setProtocolFeeInfo(false)}
/>
</ModalOverlay>
{baseTokenInfo && quoteTokenInfo && (
<ModalOverlay
title={t("orders.availableOrders")}
isHidden={!showViewAllQuotes}
onClose={() => toggleShowViewAllQuotes()}
>
<AvailableOrdersWidget
senderToken={baseTokenInfo}
signerToken={quoteTokenInfo}
onSwapLinkClick={() => toggleShowViewAllQuotes()}
/>
</ModalOverlay>
)}

<TransactionOverlay isHidden={ordersStatus !== "signing"}>
<WalletSignScreen type="approve" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { FC, useState } from "react";
import { useTranslation } from "react-i18next";

import { SubmittedCancellation } from "../../../../../entities/SubmittedTransaction/SubmittedTransaction";
import useDebounce from "../../../../../hooks/useDebounce";
import { SubmittedCancellation } from "../entities/SubmittedTransaction/SubmittedTransaction";
import useDebounce from "../hooks/useDebounce";
import {
OverlayContainer,
OverlaySubHeading,
OverlayTitle,
OverlayTransactionLink,
} from "../../../../../styled-components/Overlay/Overlay";
import { TransactionStatusType } from "../../../../../types/transactionTypes";
import OverlayLoader from "../../../../OverlayLoader/OverlayLoader";
} from "../styled-components/Overlay/Overlay";
import { TransactionStatusType } from "../types/transactionTypes";
import OverlayLoader from "./OverlayLoader/OverlayLoader";

interface SubmittedCancellationScreenProps {
chainId?: number;
Expand Down
4 changes: 3 additions & 1 deletion src/components/Toasts/Toast.styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,7 @@ export const HiXContainer = styled.button`
`;

export const TextContainer = styled.div`
display: block;
display: flex;
flex-direction: column;
gap: 0.25rem;
`;
Loading

0 comments on commit e003031

Please sign in to comment.