diff --git a/apps/api/src/api/controllers/auth.controller.ts b/apps/api/src/api/controllers/auth.controller.ts index 14cdb6650..64e6f6c01 100644 --- a/apps/api/src/api/controllers/auth.controller.ts +++ b/apps/api/src/api/controllers/auth.controller.ts @@ -1,4 +1,5 @@ import { Request, Response } from "express"; +import logger from "../../config/logger"; import User from "../../models/user.model"; import { SupabaseAuthService } from "../services/auth"; @@ -24,7 +25,7 @@ export class AuthController { exists }); } catch (error) { - console.error("Error in checkEmail:", error); + logger.error("Error in checkEmail:", error); return res.status(500).json({ error: "Failed to check email" }); @@ -58,7 +59,7 @@ export class AuthController { success: true }); } catch (error) { - console.error("Error in requestOTP:", error); + logger.error("Error in requestOTP:", error); return res.status(500).json({ error: "Failed to send OTP" }); @@ -94,7 +95,7 @@ export class AuthController { user_id: result.user_id }); } catch (error) { - console.error("Error in verifyOTP:", error); + logger.error("Error in verifyOTP:", error); return res.status(400).json({ error: "Invalid OTP or OTP expired" }); @@ -123,7 +124,7 @@ export class AuthController { success: true }); } catch (error) { - console.error("Error in refreshToken:", error); + logger.error("Error in refreshToken:", error); return res.status(401).json({ error: "Invalid refresh token" }); @@ -158,7 +159,7 @@ export class AuthController { valid: true }); } catch (error) { - console.error("Error in verifyToken:", error); + logger.error("Error in verifyToken:", error); return res.status(401).json({ error: "Token verification failed", valid: false diff --git a/apps/api/src/api/controllers/brla.controller.ts b/apps/api/src/api/controllers/brla.controller.ts index 8b6cefe59..5639ca038 100644 --- a/apps/api/src/api/controllers/brla.controller.ts +++ b/apps/api/src/api/controllers/brla.controller.ts @@ -33,6 +33,7 @@ import { import { Request, Response } from "express"; import httpStatus from "http-status"; import { Op } from "sequelize"; +import logger from "../../config/logger"; import TaxId, { TaxIdInternalStatus } from "../../models/taxId.model"; import { APIError } from "../errors/api-error"; @@ -96,7 +97,7 @@ function mapKycFailureReason(webhookReason: string | undefined): KycFailureReaso // Helper function to use in the catch block of the controller functions. function handleApiError(error: unknown, res: Response, apiMethod: string): void { - console.error(`Error while performing ${apiMethod}: `, error); + logger.error(`Error while performing ${apiMethod}: `, error); if (error instanceof Error && error.message.includes("status '400'")) { const splitError = error.message.split("Error: ", 1); @@ -174,7 +175,7 @@ export const getAveniaUser = async ( }); return; } catch (error) { - console.log(error); + logger.info(error); if ( error instanceof Error && (error.message.includes("sub-account-id does not exist") || error.message.includes("sub-account-id is invalid")) @@ -335,7 +336,7 @@ export const createSubaccount = async ( res.status(httpStatus.OK).json({ subAccountId: id }); } catch (error) { - console.error("Error creating subaccount:", error); + logger.error("Error creating subaccount:", error); handleApiError(error, res, "createSubaccount"); } }; @@ -465,7 +466,7 @@ export const getSelfieLivenessUrl = async ( validateLivenessToken: selfieUrl.validateLivenessToken ?? "" }); } catch (error) { - console.error(error); + logger.error(error); handleApiError(error, res, "getSelfieLivenessUrl"); } }; @@ -536,7 +537,7 @@ export const getUploadUrls = async ( } }); } catch (error) { - console.error(error); + logger.error(error); handleApiError(error, res, "getUploadUrls"); } }; diff --git a/apps/api/src/api/controllers/googleSpreadSheet.controller.ts b/apps/api/src/api/controllers/googleSpreadSheet.controller.ts index ecb110faf..96d7a0ffd 100644 --- a/apps/api/src/api/controllers/googleSpreadSheet.controller.ts +++ b/apps/api/src/api/controllers/googleSpreadSheet.controller.ts @@ -1,6 +1,7 @@ import "dotenv/config"; import { Request, Response } from "express"; import httpStatus from "http-status"; +import logger from "../../config/logger"; import { config } from "../../config/vars"; import { APIError } from "../errors/api-error"; import { appendData, GoogleCredentials, getOrCreateSheet, initGoogleSpreadsheet } from "../services/spreadsheet.service"; @@ -44,7 +45,7 @@ export async function storeDataInGoogleSpreadsheet( await appendData(sheet, req.body); return res.status(httpStatus.OK).json({ message: "Data stored successfully" }); } catch (error) { - console.error("Error in storeData:", error); + logger.error("Error in storeData:", error); const errorMessage = error instanceof Error ? error.message : "Unknown error occurred"; return res.status(httpStatus.INTERNAL_SERVER_ERROR).json({ details: errorMessage, diff --git a/apps/api/src/api/controllers/monerium.controller.ts b/apps/api/src/api/controllers/monerium.controller.ts index ec9b37ded..ba8180c0a 100644 --- a/apps/api/src/api/controllers/monerium.controller.ts +++ b/apps/api/src/api/controllers/monerium.controller.ts @@ -1,6 +1,7 @@ import { Networks } from "@vortexfi/shared"; import { Request, Response } from "express"; import httpStatus from "http-status"; +import logger from "../../config/logger"; import { checkAddressExists } from "../services/monerium"; export const checkAddressExistsController = async (req: Request, res: Response): Promise => { @@ -24,7 +25,7 @@ export const checkAddressExistsController = async (req: Request, res: Response): res.status(httpStatus.NOT_FOUND).json({ error: "Address not found" }); } } catch (error) { - console.error("Error in checkAddressExistsController:", error); + logger.error("Error in checkAddressExistsController:", error); res.status(httpStatus.INTERNAL_SERVER_ERROR).json({ error: "Internal Server Error" }); } }; diff --git a/apps/api/src/api/controllers/moonbeam.controller.ts b/apps/api/src/api/controllers/moonbeam.controller.ts index e8d6ebaff..f69d37f04 100644 --- a/apps/api/src/api/controllers/moonbeam.controller.ts +++ b/apps/api/src/api/controllers/moonbeam.controller.ts @@ -10,6 +10,7 @@ import { Request, Response } from "express"; import httpStatus from "http-status"; import { Address, encodeFunctionData } from "viem"; import { privateKeyToAccount } from "viem/accounts"; +import logger from "../../config/logger"; import { MOONBEAM_EXECUTOR_PRIVATE_KEY, MOONBEAM_FUNDING_AMOUNT_UNITS, @@ -60,12 +61,12 @@ export const executeXcmController = async ( res.json({ hash }); return; } catch (error) { - console.error("Error executing XCM:", error); + logger.error("Error executing XCM:", error); res.status(httpStatus.BAD_REQUEST).json({ error: "Invalid transaction" }); return; } } catch (error) { - console.error("Error executing XCM:", error); + logger.error("Error executing XCM:", error); res.status(httpStatus.INTERNAL_SERVER_ERROR).json({ error: "Internal Server Error" }); } }; @@ -92,7 +93,7 @@ export const sendStatusWithPk = async (): Promise => { return { public: moonbeamExecutorAccount.address, status: true }; } catch (error) { - console.error("Error fetching Moonbeam executor balance:", error); + logger.error("Error fetching Moonbeam executor balance:", error); return { public: moonbeamExecutorAccount?.address, status: false }; } }; diff --git a/apps/api/src/api/controllers/pendulum.controller.ts b/apps/api/src/api/controllers/pendulum.controller.ts index 11c131923..61717da30 100644 --- a/apps/api/src/api/controllers/pendulum.controller.ts +++ b/apps/api/src/api/controllers/pendulum.controller.ts @@ -43,7 +43,7 @@ export const fundEphemeralAccountController = async ( res.status(httpStatus.INTERNAL_SERVER_ERROR).send({ error: "Funding error" }); return; } catch (error) { - console.error("Error funding ephemeral account:", error); + logger.error("Error funding ephemeral account:", error); res.status(httpStatus.INTERNAL_SERVER_ERROR).send({ error: "Internal Server Error" }); } }; diff --git a/apps/api/src/api/controllers/price.controller.ts b/apps/api/src/api/controllers/price.controller.ts index 952e12850..27c4768c6 100644 --- a/apps/api/src/api/controllers/price.controller.ts +++ b/apps/api/src/api/controllers/price.controller.ts @@ -11,7 +11,7 @@ import { } from "@vortexfi/shared"; import { RequestHandler } from "express"; import httpStatus from "http-status"; - +import logger from "../../config/logger"; import { InvalidAmountError, InvalidParameterError, @@ -110,10 +110,10 @@ export const getPriceForProvider: RequestHandler => { res.status(httpStatus.UNAUTHORIZED).json({ error: "Invalid authentication token." }); } } catch (error) { - console.error("Auth check error:", error); + logger.error("Auth check error:", error); res.status(httpStatus.INTERNAL_SERVER_ERROR).json({ error: "An error occurred during authentication check." }); } }; diff --git a/apps/api/src/api/controllers/stellar.controller.ts b/apps/api/src/api/controllers/stellar.controller.ts index 8c83f5486..5671a61c1 100644 --- a/apps/api/src/api/controllers/stellar.controller.ts +++ b/apps/api/src/api/controllers/stellar.controller.ts @@ -9,6 +9,7 @@ import { import { NextFunction, Request, Response } from "express"; import httpStatus from "http-status"; import { Keypair } from "stellar-sdk"; +import logger from "../../config/logger"; import { FUNDING_SECRET, SEP10_MASTER_SECRET, STELLAR_FUNDING_AMOUNT_UNITS } from "../../constants/constants"; import { signSep10Challenge } from "../services/sep10/sep10.service"; import { SlackNotifier } from "../services/slack.service"; @@ -35,7 +36,7 @@ export const createStellarTransactionHandler = async ( res.json({ public: FUNDING_PUBLIC_KEY, sequence, signature }); return; } catch (error) { - console.error("Error in createStellarTransaction:", error); + logger.error("Error in createStellarTransaction:", error); res.status(httpStatus.INTERNAL_SERVER_ERROR).json({ details: (error as Error).message, error: "Failed to create transaction" @@ -63,7 +64,7 @@ export const signSep10ChallengeHandler = async ( }); return; } catch (error) { - console.error("Error in signSep10Challenge:", error); + logger.error("Error in signSep10Challenge:", error); res.status(httpStatus.INTERNAL_SERVER_ERROR).json({ details: (error as Error).message, error: "Failed to sign challenge" @@ -84,7 +85,7 @@ export const getSep10MasterPKHandler = async ( res.json({ masterSep10Public }); return; } catch (error) { - console.error("Error in getSep10MasterPK:", error); + logger.error("Error in getSep10MasterPK:", error); res.status(httpStatus.INTERNAL_SERVER_ERROR).json({ details: (error as Error).message, error: "Failed to get master public key" @@ -117,7 +118,7 @@ export async function sendStatusWithPk(): Promise { return { public: FUNDING_PUBLIC_KEY, status: true }; } catch (error) { - console.error("Couldn't load Stellar account:", error); + logger.error("Couldn't load Stellar account:", error); return { public: FUNDING_PUBLIC_KEY, status: false }; } } diff --git a/apps/api/src/api/controllers/subsidize.controller.ts b/apps/api/src/api/controllers/subsidize.controller.ts index c542ef29a..6333b713b 100644 --- a/apps/api/src/api/controllers/subsidize.controller.ts +++ b/apps/api/src/api/controllers/subsidize.controller.ts @@ -67,7 +67,7 @@ export const subsidizePreSwap = async ( res.json({ message: "Subsidy transferred successfully" }); return; } catch (error) { - console.error("Error in subsidizePreSwap::", error); + logger.error("Error in subsidizePreSwap::", error); res.status(httpStatus.INTERNAL_SERVER_ERROR).json({ details: error instanceof Error ? error.message : "Unknown error", error: "Server error" @@ -97,7 +97,7 @@ export const subsidizePostSwap = async ( res.json({ message: "Subsidy transferred successfully" }); return; } catch (error) { - console.error("Error in subsidizePostSwap::", error); + logger.error("Error in subsidizePostSwap::", error); res.status(httpStatus.INTERNAL_SERVER_ERROR).json({ details: error instanceof Error ? error.message : "Unknown error", error: "Server error" diff --git a/apps/api/src/api/middlewares/auth.ts b/apps/api/src/api/middlewares/auth.ts index 8a4d85d07..0d9e5801a 100644 --- a/apps/api/src/api/middlewares/auth.ts +++ b/apps/api/src/api/middlewares/auth.ts @@ -1,5 +1,6 @@ import { NextFunction, Request, Response } from "express"; import httpStatus from "http-status"; +import logger from "../../config/logger"; import { validateSignatureAndGetMemo } from "../services/siwe.service"; declare global { @@ -60,7 +61,7 @@ async function getMemoFromCookiesMiddleware(req: Request, res: Response, next: N return; } - console.error(`Error in getMemoFromCookiesMiddleware: ${err.message}`); + logger.error(`Error in getMemoFromCookiesMiddleware: ${err.message}`); res.status(httpStatus.INTERNAL_SERVER_ERROR).json({ details: err.message, error: "Error while verifying signature" diff --git a/apps/api/src/api/middlewares/supabaseAuth.ts b/apps/api/src/api/middlewares/supabaseAuth.ts index eb2479211..f599aa586 100644 --- a/apps/api/src/api/middlewares/supabaseAuth.ts +++ b/apps/api/src/api/middlewares/supabaseAuth.ts @@ -35,7 +35,7 @@ export async function requireAuth(req: Request, res: Response, next: NextFunctio req.userId = result.user_id; next(); } catch (error) { - console.error("Auth middleware error:", error); + logger.error("Auth middleware error:", error); return res.status(401).json({ error: "Authentication failed" }); diff --git a/apps/api/src/api/middlewares/validators.ts b/apps/api/src/api/middlewares/validators.ts index cecf9178e..e7b184d9e 100644 --- a/apps/api/src/api/middlewares/validators.ts +++ b/apps/api/src/api/middlewares/validators.ts @@ -20,6 +20,7 @@ import { } from "@vortexfi/shared"; import { RequestHandler } from "express"; import httpStatus from "http-status"; +import logger from "../../config/logger"; import { CONTACT_SHEET_HEADER_VALUES } from "../controllers/contact.controller"; import { EMAIL_SHEET_HEADER_VALUES } from "../controllers/email.controller"; import { RATING_SHEET_HEADER_VALUES } from "../controllers/rating.controller"; @@ -253,7 +254,7 @@ const validateRequestBodyValues = if (!requiredRequestBodyKeys.every(key => data[key])) { const missingItems = requiredRequestBodyKeys.filter(key => !data[key]); const errorMessage = `Request body data does not match schema. Missing items: ${missingItems.join(", ")}`; - console.error(errorMessage); + logger.error(errorMessage); res.status(httpStatus.BAD_REQUEST).json({ error: errorMessage }); return; } diff --git a/apps/api/src/api/services/alchemypay/alchemypay.service.ts b/apps/api/src/api/services/alchemypay/alchemypay.service.ts index 47e26bf6b..ba100cff1 100644 --- a/apps/api/src/api/services/alchemypay/alchemypay.service.ts +++ b/apps/api/src/api/services/alchemypay/alchemypay.service.ts @@ -1,4 +1,5 @@ import { AlchemyPayPriceResponse, RampDirection } from "@vortexfi/shared"; +import logger from "../../../config/logger"; import { ProviderInternalError } from "../../errors/providerErrors"; import { createQuoteRequest } from "./request-creator"; import { AlchemyPayResponse, processAlchemyPayResponse } from "./response-handler"; @@ -21,7 +22,7 @@ async function fetchAlchemyPayData(url: string, request: RequestInit): Promise= 500) { throw new ProviderInternalError(`AlchemyPay server error: ${errorMessage}`); @@ -54,7 +55,7 @@ function handleHttpError(response: Response, body: AlchemyPayResponse): never { */ function handleLogicError(body: AlchemyPayResponse): never { const errorMessage = body.returnMsg || "AlchemyPay API returned success=false with no message"; - console.error(`AlchemyPay API Logic Error: ${errorMessage}`); + logger.error(`AlchemyPay API Logic Error: ${errorMessage}`); // Analyze returnMsg for specific errors const lowerErrorMessage = errorMessage.toLowerCase(); diff --git a/apps/api/src/api/services/moonpay/moonpay.service.ts b/apps/api/src/api/services/moonpay/moonpay.service.ts index 92e651e77..db1cfecea 100644 --- a/apps/api/src/api/services/moonpay/moonpay.service.ts +++ b/apps/api/src/api/services/moonpay/moonpay.service.ts @@ -1,5 +1,6 @@ import { MoonpayPriceResponse, RampDirection } from "@vortexfi/shared"; import { config } from "../../../config"; +import logger from "../../../config/logger"; import { ProviderInternalError } from "../../errors/providerErrors"; import { createQuoteRequest } from "./request-creator"; import { processMoonpayResponse } from "./response-handler"; @@ -41,7 +42,7 @@ async function fetchMoonpayData(url: string): Promise { type: error instanceof TypeError ? "NETWORK" : "PARSE" }; - console.error("Moonpay error:", moonpayError); + logger.error("Moonpay error:", moonpayError); throw new ProviderInternalError( moonpayError.type === "NETWORK" diff --git a/apps/api/src/api/services/moonpay/response-handler.ts b/apps/api/src/api/services/moonpay/response-handler.ts index a5b87b207..070466979 100644 --- a/apps/api/src/api/services/moonpay/response-handler.ts +++ b/apps/api/src/api/services/moonpay/response-handler.ts @@ -1,4 +1,5 @@ import { MoonpayPriceResponse, RampDirection } from "@vortexfi/shared"; +import logger from "../../../config/logger"; import { InvalidAmountError, InvalidParameterError, @@ -16,7 +17,7 @@ function handleMoonpayError(response: Response, body: MoonpayErrorResponse): nev const errorMessage = body?.message || `HTTP error ${response.status}: ${response.statusText}`; const errorType = body?.type; - console.error(`Moonpay API Error (${response.status}): Type: ${errorType}, Message: ${errorMessage}`); + logger.error(`Moonpay API Error (${response.status}): Type: ${errorType}, Message: ${errorMessage}`); if (errorType === "NotFoundError" || errorMessage.toLowerCase().includes("unsupported")) { throw new UnsupportedPairError(`Moonpay: ${errorMessage}`); @@ -62,7 +63,7 @@ function validateMoonpayResponse( } if (Number(requestedAmount) !== receivedBaseCurrencyAmount) { - console.warn( + logger.warn( `Moonpay Warning: Requested base amount ${requestedAmount} differs from received ${receivedBaseCurrencyAmount}` ); throw new ProviderInternalError( diff --git a/apps/api/src/api/services/pendulum/pendulum.service.ts b/apps/api/src/api/services/pendulum/pendulum.service.ts index c5136fe9b..de90bb1a6 100644 --- a/apps/api/src/api/services/pendulum/pendulum.service.ts +++ b/apps/api/src/api/services/pendulum/pendulum.service.ts @@ -2,6 +2,7 @@ import { Keyring } from "@polkadot/api"; import { KeyringPair } from "@polkadot/keyring/types"; import { ApiManager, SubstrateApiNetwork, TOKEN_CONFIG, waitUntilTrueWithTimeout } from "@vortexfi/shared"; import Big from "big.js"; +import logger from "../../../config/logger"; import { GLMR_FUNDING_AMOUNT_RAW, PENDULUM_EPHEMERAL_STARTING_BALANCE_UNITS } from "../../../constants/constants"; import { multiplyByPowerOfTen } from "./helpers"; @@ -64,7 +65,7 @@ export const fundEphemeralAccount = async ( return true; } catch (error) { - console.error("Error during funding:", error); + logger.error("Error during funding:", error); return false; } }; diff --git a/apps/api/src/api/services/phases/handlers/brla-payout-moonbeam-handler.ts b/apps/api/src/api/services/phases/handlers/brla-payout-moonbeam-handler.ts index 1284a2493..effedf8ad 100644 --- a/apps/api/src/api/services/phases/handlers/brla-payout-moonbeam-handler.ts +++ b/apps/api/src/api/services/phases/handlers/brla-payout-moonbeam-handler.ts @@ -128,7 +128,7 @@ export class BrlaPayoutOnMoonbeamPhaseHandler extends BasePhaseHandler { await this.checkTicketStatusPaid({ subAccountId: taxIdRecord.subAccountId, ticketId: payOutTicketId }); return this.transitionToNextPhase(state, "complete"); } catch (e) { - console.error("Error in brlaPayoutOnMoonbeam", e); + logger.error("Error in brlaPayoutOnMoonbeam", e); throw this.createUnrecoverableError("BrlaPayoutOnMoonbeamPhaseHandler: Failed to trigger BRLA offramp."); } } diff --git a/apps/api/src/api/services/phases/handlers/final-settlement-subsidy.ts b/apps/api/src/api/services/phases/handlers/final-settlement-subsidy.ts index 43d7b3a17..11dc9654b 100644 --- a/apps/api/src/api/services/phases/handlers/final-settlement-subsidy.ts +++ b/apps/api/src/api/services/phases/handlers/final-settlement-subsidy.ts @@ -134,7 +134,6 @@ export class FinalSettlementSubsidyHandler extends BasePhaseHandler { nativeToken.symbol as RampCurrency ); const oneUsdInNativeRaw = multiplyByPowerOfTen(oneUsdInNative, nativeToken.decimals).toFixed(0); - console.log("values; oneUsdInNativeRaw:", oneUsdInNativeRaw); const chainId = getNetworkId(destinationNetwork).toString(); const testRouteResult = await getRoute({ diff --git a/apps/api/src/api/services/phases/handlers/fund-ephemeral-handler.ts b/apps/api/src/api/services/phases/handlers/fund-ephemeral-handler.ts index 923388076..906967151 100644 --- a/apps/api/src/api/services/phases/handlers/fund-ephemeral-handler.ts +++ b/apps/api/src/api/services/phases/handlers/fund-ephemeral-handler.ts @@ -192,7 +192,7 @@ export class FundEphemeralPhaseHandler extends BasePhaseHandler { logger.info(`Destination EVM ephemeral address already funded on ${destinationNetwork}.`); } } catch (e) { - console.error("Error in FundEphemeralPhaseHandler:", e); + logger.error("Error in FundEphemeralPhaseHandler:", e); // Preserve UnrecoverablePhaseError if (e instanceof UnrecoverablePhaseError) { @@ -313,7 +313,7 @@ export class FundEphemeralPhaseHandler extends BasePhaseHandler { throw new Error(`FundEphemeralPhaseHandler: Transaction ${txHash} failed or was not found`); } } catch (error) { - console.error("FundEphemeralPhaseHandler: Error during funding Polygon ephemeral:", error); + logger.error("FundEphemeralPhaseHandler: Error during funding Polygon ephemeral:", error); throw new Error("FundEphemeralPhaseHandler: Error during funding Polygon ephemeral: " + error); } } @@ -348,7 +348,7 @@ export class FundEphemeralPhaseHandler extends BasePhaseHandler { throw new Error(`FundEphemeralPhaseHandler: Transaction ${txHash} failed or was not found on ${destinationNetwork}`); } } catch (error) { - console.error(`FundEphemeralPhaseHandler: Error during funding ${destinationNetwork} ephemeral:`, error); + logger.error(`FundEphemeralPhaseHandler: Error during funding ${destinationNetwork} ephemeral:`, error); throw new Error(`FundEphemeralPhaseHandler: Error during funding ${destinationNetwork} ephemeral: ` + error); } } diff --git a/apps/api/src/api/services/phases/handlers/hydration-swap-handler.ts b/apps/api/src/api/services/phases/handlers/hydration-swap-handler.ts index 3f1124856..168e5bced 100644 --- a/apps/api/src/api/services/phases/handlers/hydration-swap-handler.ts +++ b/apps/api/src/api/services/phases/handlers/hydration-swap-handler.ts @@ -1,4 +1,5 @@ import { ApiManager, decodeSubmittableExtrinsic, RampPhase, submitExtrinsic } from "@vortexfi/shared"; +import logger from "../../../../config/logger"; import RampState from "../../../../models/rampState.model"; import { BasePhaseHandler } from "../base-phase-handler"; import { StateMetadata } from "../meta-state-types"; @@ -33,7 +34,7 @@ export class HydrationSwapPhaseHandler extends BasePhaseHandler { return this.transitionToNextPhase(state, "hydrationToAssethubXcm"); } catch (e) { - console.error("Error in hydrationSwap phase:", e); + logger.error("Error in hydrationSwap phase:", e); throw e; } } diff --git a/apps/api/src/api/services/phases/handlers/hydration-to-assethub-xcm-phase-handler.ts b/apps/api/src/api/services/phases/handlers/hydration-to-assethub-xcm-phase-handler.ts index ca528dd3c..ba145c6ae 100644 --- a/apps/api/src/api/services/phases/handlers/hydration-to-assethub-xcm-phase-handler.ts +++ b/apps/api/src/api/services/phases/handlers/hydration-to-assethub-xcm-phase-handler.ts @@ -43,7 +43,7 @@ export class HydrationToAssethubXCMPhaseHandler extends BasePhaseHandler { return this.transitionToNextPhase(state, "complete"); } catch (e) { - console.error("Error in hydrationToAssethubXcm phase:", e); + logger.error("Error in hydrationToAssethubXcm phase:", e); throw e; } } diff --git a/apps/api/src/api/services/phases/handlers/moonbeam-to-pendulum-handler.ts b/apps/api/src/api/services/phases/handlers/moonbeam-to-pendulum-handler.ts index 0b1f97b6d..28e42ade0 100644 --- a/apps/api/src/api/services/phases/handlers/moonbeam-to-pendulum-handler.ts +++ b/apps/api/src/api/services/phases/handlers/moonbeam-to-pendulum-handler.ts @@ -78,7 +78,7 @@ export class MoonbeamToPendulumPhaseHandler extends BasePhaseHandler { try { if (!(await didInputTokenArriveOnPendulum())) { await waitUntilTrue(isHashRegisteredInSplitReceiver); - console.log(`Hash ${squidRouterReceiverHash} is registered in receiver contract`); + logger.info(`Hash ${squidRouterReceiverHash} is registered in receiver contract`); } } catch (e) { logger.error(e); @@ -98,6 +98,10 @@ export class MoonbeamToPendulumPhaseHandler extends BasePhaseHandler { functionName: "executeXCM" }); + logger.info( + `Sending transaction to Moonbeam split receiver contract at address ${MOONBEAM_RECEIVER_CONTRACT_ADDRESS} with data ${data}. Args: [${squidRouterReceiverId}, ${squidRouterPayload}]` + ); + const { maxFeePerGas, maxPriorityFeePerGas } = await publicClient.estimateFeesPerGas(); let receipt: TransactionReceipt | undefined = undefined; @@ -133,14 +137,14 @@ export class MoonbeamToPendulumPhaseHandler extends BasePhaseHandler { } } } catch (e) { - console.error("Error while executing moonbeam split contract transaction:", e); + logger.error("Error while executing moonbeam split contract transaction:", e); throw new RecoverablePhaseError("MoonbeamToPendulumPhaseHandler: Failed to send XCM transaction", 30); } try { await waitUntilTrue(didInputTokenArriveOnPendulum, 5000); } catch (e) { - console.error("Error while waiting for transaction receipt:", e); + logger.error("Error while waiting for transaction receipt:", e); throw new RecoverablePhaseError("MoonbeamToPendulumPhaseHandler: Failed to wait for tokens to arrive on Pendulum.", 30); } diff --git a/apps/api/src/api/services/phases/handlers/moonbeam-to-pendulum-xcm-handler.ts b/apps/api/src/api/services/phases/handlers/moonbeam-to-pendulum-xcm-handler.ts index 18f678bae..ce78d71ac 100644 --- a/apps/api/src/api/services/phases/handlers/moonbeam-to-pendulum-xcm-handler.ts +++ b/apps/api/src/api/services/phases/handlers/moonbeam-to-pendulum-xcm-handler.ts @@ -1,5 +1,6 @@ -import { ApiManager, decodeSubmittableExtrinsic, logger, RampPhase, submitMoonbeamXcm, waitUntilTrue } from "@vortexfi/shared"; +import { ApiManager, decodeSubmittableExtrinsic, RampPhase, submitMoonbeamXcm, waitUntilTrue } from "@vortexfi/shared"; import Big from "big.js"; +import logger from "../../../../config/logger"; import QuoteTicket from "../../../../models/quoteTicket.model"; import RampState from "../../../../models/rampState.model"; import { RecoverablePhaseError } from "../../../errors/phase-error"; @@ -74,7 +75,7 @@ export class MoonbeamToPendulumXcmPhaseHandler extends BasePhaseHandler { const txNonce = xcmTransaction.nonce.toNumber(); const accountNonce = await moonbeamNode.api.rpc.system.accountNextIndex(evmEphemeralAddress); if (txNonce !== accountNonce.toNumber()) { - logger.current.warn( + logger.warn( `Nonce mismatch for XCM transaction of account ${evmEphemeralAddress}: expected ${accountNonce.toNumber()}, got ${txNonce}` ); } @@ -90,15 +91,15 @@ export class MoonbeamToPendulumXcmPhaseHandler extends BasePhaseHandler { ); } } - console.error("Error while executing moonbeam-to-pendulum xcm:", error); + logger.error("Error while executing moonbeam-to-pendulum xcm:", error); throw new RecoverablePhaseError("MoonbeamToPendulumXcmPhaseHandler: Failed to send XCM transaction", 120); } try { - logger.current.info("waiting for token to arrive on pendulum..."); + logger.info("waiting for token to arrive on pendulum..."); await waitUntilTrue(didInputTokenArriveOnPendulum, 5000); } catch (e) { - console.error("Error while waiting for transaction receipt:", e); + logger.error("Error while waiting for transaction receipt:", e); throw new Error("MoonbeamToPendulumXcmPhaseHandler: Failed to wait for tokens to arrive on Pendulum."); } diff --git a/apps/api/src/api/services/phases/handlers/pendulum-to-assethub-phase-handler.ts b/apps/api/src/api/services/phases/handlers/pendulum-to-assethub-phase-handler.ts index 1ee1a6d95..788cea7a0 100644 --- a/apps/api/src/api/services/phases/handlers/pendulum-to-assethub-phase-handler.ts +++ b/apps/api/src/api/services/phases/handlers/pendulum-to-assethub-phase-handler.ts @@ -1,4 +1,5 @@ import { ApiManager, decodeSubmittableExtrinsic, getAddressForFormat, RampPhase, submitXTokens } from "@vortexfi/shared"; +import logger from "../../../../config/logger"; import RampState from "../../../../models/rampState.model"; import { BasePhaseHandler } from "../base-phase-handler"; import { StateMetadata } from "../meta-state-types"; @@ -36,7 +37,7 @@ export class PendulumToAssethubXCMPhaseHandler extends BasePhaseHandler { return this.transitionToNextPhase(state, "complete"); } catch (e) { - console.error("Error in PendulumToAssethubPhase:", e); + logger.error("Error in PendulumToAssethubPhase:", e); throw e; } } diff --git a/apps/api/src/api/services/phases/handlers/pendulum-to-hydration-xcm-phase-handler.ts b/apps/api/src/api/services/phases/handlers/pendulum-to-hydration-xcm-phase-handler.ts index 5e65065d6..0ee234faf 100644 --- a/apps/api/src/api/services/phases/handlers/pendulum-to-hydration-xcm-phase-handler.ts +++ b/apps/api/src/api/services/phases/handlers/pendulum-to-hydration-xcm-phase-handler.ts @@ -69,7 +69,7 @@ export class PendulumToHydrationXCMPhaseHandler extends BasePhaseHandler { return this.transitionToNextPhase(state, "hydrationSwap"); } catch (e) { - console.error("Error in pendulumToHydrationXcm phase:", e); + logger.error("Error in pendulumToHydrationXcm phase:", e); throw e; } } diff --git a/apps/api/src/api/services/phases/handlers/pendulum-to-moonbeam-xcm-handler.ts b/apps/api/src/api/services/phases/handlers/pendulum-to-moonbeam-xcm-handler.ts index 1d48c4b0f..ea8559c5c 100644 --- a/apps/api/src/api/services/phases/handlers/pendulum-to-moonbeam-xcm-handler.ts +++ b/apps/api/src/api/services/phases/handlers/pendulum-to-moonbeam-xcm-handler.ts @@ -172,7 +172,7 @@ export class PendulumToMoonbeamXCMPhaseHandler extends BasePhaseHandler { return this.transitionToNextPhase(state, this.nextPhaseSelector(state)); } catch (e) { - console.error("Error in PendulumToMoonbeamPhase:", e); + logger.error("Error in PendulumToMoonbeamPhase:", e); throw this.createRecoverableError("Error in PendulumToMoonbeamPhase"); } } diff --git a/apps/api/src/api/services/phases/handlers/stellar-payment-handler.ts b/apps/api/src/api/services/phases/handlers/stellar-payment-handler.ts index bacc9358d..fa933605f 100644 --- a/apps/api/src/api/services/phases/handlers/stellar-payment-handler.ts +++ b/apps/api/src/api/services/phases/handlers/stellar-payment-handler.ts @@ -58,10 +58,10 @@ export class StellarPaymentPhaseHandler extends BasePhaseHandler { } } - console.error(horizonError.response.data.extras); + logger.error(horizonError.response.data.extras); throw new Error("Could not submit the offramping transaction"); } else { - console.error("Error while submitting the offramp transaction", e); + logger.error("Error while submitting the offramp transaction", e); throw new Error("Could not submit the offramping transaction"); } } diff --git a/apps/api/src/api/services/phases/handlers/subsidize-pre-swap-handler.ts b/apps/api/src/api/services/phases/handlers/subsidize-pre-swap-handler.ts index 574e6a6b9..e7f71e0b1 100644 --- a/apps/api/src/api/services/phases/handlers/subsidize-pre-swap-handler.ts +++ b/apps/api/src/api/services/phases/handlers/subsidize-pre-swap-handler.ts @@ -88,7 +88,7 @@ export class SubsidizePreSwapPhaseHandler extends BasePhaseHandler { return this.transitionToNextPhase(state, "nablaApprove"); } catch (e) { - console.error("Error in subsidizePreSwap:", e); + logger.error("Error in subsidizePreSwap:", e); throw this.createRecoverableError("SubsidizePreSwapPhaseHandler: Failed to subsidize pre swap."); } } diff --git a/apps/api/src/api/services/ramp/ramp.service.ts b/apps/api/src/api/services/ramp/ramp.service.ts index 31ab66e93..28ff39e2b 100644 --- a/apps/api/src/api/services/ramp/ramp.service.ts +++ b/apps/api/src/api/services/ramp/ramp.service.ts @@ -360,7 +360,7 @@ export class RampService extends BaseRampService { }); } - console.log("Triggering TRANSACTION_CREATED webhook for ramp state:", rampState.id); + logger.log("Triggering TRANSACTION_CREATED webhook for ramp state:", rampState.id); webhookDeliveryService .triggerTransactionCreated( rampState.quoteId, diff --git a/apps/api/src/api/services/stellar/checkBalance.ts b/apps/api/src/api/services/stellar/checkBalance.ts index 888953315..2a7ac1a5c 100644 --- a/apps/api/src/api/services/stellar/checkBalance.ts +++ b/apps/api/src/api/services/stellar/checkBalance.ts @@ -26,7 +26,7 @@ export function checkBalancePeriodically( reject(new Error(`Balance did not meet the limit within the specified time (${timeoutMs} ms)`)); } } catch (error) { - console.error("Error checking balance:", error); + logger.error("Error checking balance:", error); // Don't clear the interval here, allow it to continue checking } }, intervalMs); diff --git a/apps/api/src/api/services/transactions/moonbeam/balance.ts b/apps/api/src/api/services/transactions/moonbeam/balance.ts index 9bc2236b5..7a51eeeb1 100644 --- a/apps/api/src/api/services/transactions/moonbeam/balance.ts +++ b/apps/api/src/api/services/transactions/moonbeam/balance.ts @@ -1,5 +1,6 @@ import { ApiManager, EvmAddress, EvmClientManager, multiplyByPowerOfTen, Networks } from "@vortexfi/shared"; import { privateKeyToAccount } from "viem/accounts"; +import logger from "../../../../config/logger"; import { MOONBEAM_EPHEMERAL_STARTING_BALANCE_UNITS, MOONBEAM_FUNDING_PRIVATE_KEY } from "../../../../constants/constants"; export const fundMoonbeamEphemeralAccount = async (ephemeralAddress: string) => { @@ -26,7 +27,7 @@ export const fundMoonbeamEphemeralAccount = async (ephemeralAddress: string) => throw new Error(`fundMoonbeamEphemeralAccount: Transaction ${txHash} failed or was not found`); } } catch (error) { - console.error("Error during funding Moonbeam ephemeral:", error); + logger.error("Error during funding Moonbeam ephemeral:", error); throw new Error("Error during funding Moonbeam ephemeral: " + error); } }; diff --git a/apps/api/src/api/services/transactions/stellar/offrampTransaction.ts b/apps/api/src/api/services/transactions/stellar/offrampTransaction.ts index eb6f4dea8..ed4e308ae 100644 --- a/apps/api/src/api/services/transactions/stellar/offrampTransaction.ts +++ b/apps/api/src/api/services/transactions/stellar/offrampTransaction.ts @@ -201,7 +201,7 @@ async function getFutureShiftedLedgerSequence( return shiftedSequence; } catch (error) { - console.error("Error fetching and calculating ledger sequence:", error); + logger.error("Error fetching and calculating ledger sequence:", error); throw error; } } diff --git a/apps/api/src/api/services/transactions/validation.ts b/apps/api/src/api/services/transactions/validation.ts index f2ef3fd54..72823f80c 100644 --- a/apps/api/src/api/services/transactions/validation.ts +++ b/apps/api/src/api/services/transactions/validation.ts @@ -4,7 +4,6 @@ import { ApiManager, CleanupPhase, EphemeralAccountType, - FiatToken, getNetworkId, PresignedTx, RampDirection, @@ -17,7 +16,6 @@ import httpStatus from "http-status"; import { Networks as StellarNetworks, Transaction as StellarTransaction, TransactionBuilder } from "stellar-sdk"; import logger from "../../../config/logger"; import { SANDBOX_ENABLED } from "../../../constants/constants"; -import QuoteTicket from "../../../models/quoteTicket.model"; import { APIError } from "../../errors/api-error"; /// Checks if all the transactions in 'subset' are contained in 'set' based on phase, network, nonce, and signer. @@ -226,7 +224,7 @@ async function validateStellarTransaction(tx: PresignedTx, expectedSigner: strin }); } - console.log("Parsed Stellar transaction source:", transaction.source); + logger.info("Parsed Stellar transaction source:", transaction.source); if (phase === "stellarCreateAccount") { if (transaction.operations.length !== 3) { diff --git a/apps/api/src/api/services/transak/response-handler.ts b/apps/api/src/api/services/transak/response-handler.ts index cdf51828d..8043f6c07 100644 --- a/apps/api/src/api/services/transak/response-handler.ts +++ b/apps/api/src/api/services/transak/response-handler.ts @@ -1,4 +1,5 @@ import { RampDirection, TransakPriceResponse } from "@vortexfi/shared"; +import logger from "../../../config/logger"; import { InvalidAmountError, InvalidParameterError, @@ -32,7 +33,7 @@ export interface TransakApiResponse { function handleTransakError(response: Response, body: TransakApiResponse): never { const errorMessage = body?.error?.message || `HTTP error ${response.status}: ${response.statusText}`; - console.error(`Transak API Error (${response.status}): ${errorMessage}`); + logger.error(`Transak API Error (${response.status}): ${errorMessage}`); const lowerErrorMessage = errorMessage.toLowerCase(); diff --git a/apps/api/src/api/services/transak/transak.service.ts b/apps/api/src/api/services/transak/transak.service.ts index edec02778..47ef7f059 100644 --- a/apps/api/src/api/services/transak/transak.service.ts +++ b/apps/api/src/api/services/transak/transak.service.ts @@ -1,4 +1,5 @@ import { Networks, RampDirection, TransakPriceResponse } from "@vortexfi/shared"; +import logger from "../../../config/logger"; import { config } from "../../../config/vars"; import { ProviderInternalError } from "../../errors/providerErrors"; import { createQuoteRequest } from "./request-creator"; @@ -26,7 +27,7 @@ async function fetchTransakData(url: string): Promise { const body = (await response.json()) as TransakApiResponse; return { body, response }; } catch (fetchError) { - console.error("Transak fetch error:", fetchError); + logger.error("Transak fetch error:", fetchError); throw new ProviderInternalError(`Network error fetching price from Transak: ${(fetchError as Error).message}`); } }