diff --git a/src/components/dex/UserOrders/columns/index.tsx b/src/components/dex/UserOrders/columns/index.tsx
index 57c230a..b94104c 100644
--- a/src/components/dex/UserOrders/columns/index.tsx
+++ b/src/components/dex/UserOrders/columns/index.tsx
@@ -289,10 +289,7 @@ export function buildMyRequestsColumns({
width: '80px',
align: 'left',
cell: (row) => (
-
+
),
},
];
diff --git a/src/components/dex/UserOrders/components/CancelActionCell/index.tsx b/src/components/dex/UserOrders/components/CancelActionCell/index.tsx
index 13373d3..f6b5ceb 100644
--- a/src/components/dex/UserOrders/components/CancelActionCell/index.tsx
+++ b/src/components/dex/UserOrders/components/CancelActionCell/index.tsx
@@ -1,6 +1,6 @@
import { useState } from 'react';
import { useAlert } from '@/hook/useAlert';
-import { cancelOrder } from '@/utils/methods';
+import { cancelOrder, cancelTransaction } from '@/utils/methods';
import ActionBtn from '@/components/UI/ActionBtn';
import { CancelActionCellProps } from './types';
@@ -13,7 +13,7 @@ export default function CancelActionCell({ type = 'cancel', id, onAfter }: Cance
try {
setLoading(true);
- const result = await cancelOrder(id);
+ const result = type === 'cancel' ? await cancelOrder(id) : await cancelTransaction(id);
if (!result.success) {
setAlertState('error');
setAlertSubtitle('Error while cancelling order');
@@ -35,7 +35,7 @@ export default function CancelActionCell({ type = 'cancel', id, onAfter }: Cance
disabled={loading}
onClick={() => onClick()}
>
- {type === 'cancel' ? 'Cancel' : 'Reject'}
+ {type === 'cancel' || type === 'cancel_tx' ? 'Cancel' : 'Reject'}
);
}
diff --git a/src/components/dex/UserOrders/components/CancelActionCell/types.ts b/src/components/dex/UserOrders/components/CancelActionCell/types.ts
index bad984a..3d15917 100644
--- a/src/components/dex/UserOrders/components/CancelActionCell/types.ts
+++ b/src/components/dex/UserOrders/components/CancelActionCell/types.ts
@@ -1,5 +1,5 @@
export interface CancelActionCellProps {
- type?: 'cancel' | 'reject';
+ type?: 'cancel' | 'reject' | 'cancel_tx';
id: string;
onAfter: () => Promise;
}
diff --git a/src/pages/dex/orders/index.tsx b/src/pages/dex/orders/index.tsx
index 915842a..0e24402 100644
--- a/src/pages/dex/orders/index.tsx
+++ b/src/pages/dex/orders/index.tsx
@@ -165,13 +165,21 @@ function Orders() {
setAlertState('loading');
setAlertSubtitle('Canceling all orders...');
- const results = await Promise.allSettled(
- activeOrders.map(async (e) => {
- await cancelOrder(e.id);
- }),
- );
+ // const results = await Promise.allSettled(
+ // activeOrders.map(async (e) => {
+ // await cancelOrder(e.id);
+ // }),
+ // );
- if (results.some((e) => e.status === 'rejected')) {
+ const results = await (async () => {
+ const res = [];
+ for (const order of activeOrders) {
+ res.push(await cancelOrder(order.id).catch(() => null));
+ }
+ return res;
+ })();
+
+ if (results.some((e) => e === null)) {
setAlertState('error');
setAlertSubtitle('Some of the orders were not canceled');
} else {
diff --git a/src/pages/dex/trading/[id].tsx b/src/pages/dex/trading/[id].tsx
index 117c1e5..f1238d7 100644
--- a/src/pages/dex/trading/[id].tsx
+++ b/src/pages/dex/trading/[id].tsx
@@ -116,7 +116,10 @@ function Trading() {
setMyOrdersLoading(true);
try {
- await Promise.all(userOrders.map((order) => cancelOrder(order.id)));
+ for (const order of userOrders) {
+ await cancelOrder(order.id);
+ }
+
await updateUserOrders();
} catch (err) {
console.error(err);
diff --git a/src/utils/methods.ts b/src/utils/methods.ts
index 476bec0..89d6a41 100644
--- a/src/utils/methods.ts
+++ b/src/utils/methods.ts
@@ -259,6 +259,15 @@ export async function cancelOrder(id: string): Promise res.data);
}
+export async function cancelTransaction(id: string): Promise {
+ return axios
+ .post('/api/transactions/cancel', {
+ token: sessionStorage.getItem('token'),
+ transactionId: id,
+ })
+ .then((res) => res.data);
+}
+
export async function getCandles(
pairId: string,
period: Period,