Skip to content

Commit 99e6d26

Browse files
committed
Fix type issues
1 parent cab7e49 commit 99e6d26

File tree

6 files changed

+26
-25
lines changed

6 files changed

+26
-25
lines changed

apps/api/src/api/services/ramp/ramp.service.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,13 @@ export class RampService extends BaseRampService {
547547
rampStates.map(async ramp => {
548548
const quote = quoteMap.get(ramp.quoteId);
549549

550+
if (!quote) {
551+
throw new APIError({
552+
message: `Associated quote not found for ramp ${ramp.id}`,
553+
status: httpStatus.NOT_FOUND
554+
});
555+
}
556+
550557
// Get or compute final transaction hash and explorer link (similar to getRampStatus)
551558
let transactionHash = ramp.state.finalTransactionHash;
552559
let transactionExplorerLink = ramp.state.finalTransactionExplorerLink;
@@ -555,8 +562,7 @@ export class RampService extends BaseRampService {
555562
if (
556563
ramp.type === RampDirection.BUY &&
557564
ramp.currentPhase === "complete" &&
558-
(!transactionHash || !transactionExplorerLink) &&
559-
quote
565+
(!transactionHash || !transactionExplorerLink)
560566
) {
561567
const result = await getFinalTransactionHashForRamp(ramp, quote);
562568
transactionHash = result.transactionHash;
@@ -578,14 +584,14 @@ export class RampService extends BaseRampService {
578584
date: ramp.createdAt.toISOString(),
579585
externalTxExplorerLink: transactionExplorerLink,
580586
externalTxHash: transactionHash,
581-
fromAmount: quote?.inputAmount || "",
582-
fromCurrency: quote?.inputCurrency || "",
583-
fromNetwork: ramp.from,
587+
from: ramp.from,
588+
fromAmount: quote.inputAmount,
589+
fromCurrency: quote.inputCurrency,
584590
id: ramp.id,
585591
status: this.mapPhaseToStatus(ramp.currentPhase),
586-
toAmount: quote?.outputAmount || "",
587-
toCurrency: quote?.outputCurrency || "",
588-
toNetwork: ramp.to,
592+
to: ramp.to,
593+
toAmount: quote.outputAmount,
594+
toCurrency: quote.outputCurrency,
589595
type: ramp.type
590596
};
591597
})

apps/frontend/src/components/StatusBadge/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { ArrowTopRightOnSquareIcon } from "@heroicons/react/20/solid";
2-
import { AnimatePresence, LayoutGroup, motion } from "framer-motion";
2+
import { TransactionStatus } from "@vortexfi/shared";
3+
import { AnimatePresence, motion } from "framer-motion";
34
import { FC } from "react";
45
import { useTranslation } from "react-i18next";
56
import { cn } from "../../helpers/cn";
6-
import { TransactionStatus } from "../menus/HistoryMenu/types";
77

88
interface StatusBadgeProps {
99
status: TransactionStatus;

apps/frontend/src/components/menus/HistoryMenu/TransactionItem/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const formatTooltipDate = (date: Date) =>
2727
year: "numeric"
2828
});
2929

30-
const getNetworkName = (network: Transaction["fromNetwork"] | Transaction["toNetwork"]) => {
30+
const getNetworkName = (network: Transaction["from"] | Transaction["to"]) => {
3131
if (typeof network === "string" && ["pix", "sepa", "cbu"].includes(network)) {
3232
return network.toUpperCase();
3333
}
@@ -54,9 +54,9 @@ export const TransactionItem: FC<TransactionItemProps> = ({ transaction }) => {
5454
</div>
5555
<div>
5656
<div className="flex items-center">
57-
<span className="text-gray-500">{getNetworkName(transaction.fromNetwork)}</span>
57+
<span className="text-gray-500">{getNetworkName(transaction.from)}</span>
5858
<ChevronRightIcon className="h-4 w-4 text-gray-400" />
59-
<span className="text-gray-500">{getNetworkName(transaction.toNetwork)}</span>
59+
<span className="text-gray-500">{getNetworkName(transaction.to)}</span>
6060
</div>
6161
<div className="flex items-center">
6262
<span className="font-medium">{roundDownToSignificantDecimals(Big(transaction.fromAmount), 2).toString()}</span>

apps/frontend/src/components/menus/HistoryMenu/types.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
import { Networks, PaymentMethod } from "@vortexfi/shared";
2-
3-
export type TransactionStatus = "pending" | "failed" | "complete";
1+
import { Networks, PaymentMethod, TransactionStatus } from "@vortexfi/shared";
42

53
export type TransactionDestination = Networks | PaymentMethod;
64

75
export interface Transaction {
86
id: string;
9-
fromNetwork: TransactionDestination;
10-
toNetwork: TransactionDestination;
7+
from: TransactionDestination;
8+
to: TransactionDestination;
119
fromAmount: string;
1210
toAmount: string;
1311
status: TransactionStatus;

apps/frontend/src/hooks/useRampHistory.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,14 @@ import { useQuery } from "@tanstack/react-query";
22
import { GetRampHistoryTransaction } from "@vortexfi/shared";
33
import { useAccount } from "wagmi";
44

5-
import { Transaction, TransactionDestination, TransactionStatus } from "../components/menus/HistoryMenu/types";
5+
import { Transaction } from "../components/menus/HistoryMenu/types";
66
import { usePolkadotWalletState } from "../contexts/polkadotWallet";
77
import { RampService } from "../services/api/ramp.service";
88

99
function formatTransaction(tx: GetRampHistoryTransaction): Transaction {
1010
return {
1111
...tx,
12-
date: new Date(tx.date),
13-
fromNetwork: tx.fromNetwork as TransactionDestination,
14-
status: tx.status as TransactionStatus,
15-
toNetwork: tx.toNetwork as TransactionDestination
12+
date: new Date(tx.date)
1613
};
1714
}
1815

packages/shared/src/endpoints/ramp.endpoints.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ export interface GetRampHistoryRequest {
195195
export interface GetRampHistoryTransaction {
196196
id: string;
197197
type: RampDirection;
198-
fromNetwork: Networks;
199-
toNetwork: Networks;
198+
from: Networks | PaymentMethod;
199+
to: Networks | PaymentMethod;
200200
fromAmount: string;
201201
toAmount: string;
202202
fromCurrency: RampCurrency;

0 commit comments

Comments
 (0)