mirror of
https://github.com/0xbow-io/privacy-pools-core.git
synced 2026-01-09 01:17:58 -05:00
feat: QuoteError
This commit is contained in:
@@ -31,6 +31,9 @@ export enum ErrorCode {
|
||||
|
||||
// SDK error. Wrapper for sdk's native errors
|
||||
SDK_ERROR = "SDK_ERROR",
|
||||
|
||||
// Quote errors
|
||||
QUOTE_ERROR = "QUOTE_ERROR",
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -257,3 +260,16 @@ export class BlockchainError extends RelayerError {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export class QuoterError extends RelayerError {
|
||||
constructor(message: string, code: ErrorCode = ErrorCode.QUOTE_ERROR, details?: Record<string, unknown> | string) {
|
||||
super(message, code, details);
|
||||
this.name = this.constructor.name;
|
||||
}
|
||||
|
||||
public static assetNotSupported(
|
||||
details?: Record<string, unknown> | string) {
|
||||
return new QuoterError("Asset is not supported", ErrorCode.ASSET_NOT_SUPPORTED, details);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { NextFunction, Request, Response } from "express";
|
||||
import { getAddress } from "viem";
|
||||
import { getAssetConfig } from "../../config/index.js";
|
||||
import { RelayerError } from "../../exceptions/base.exception.js";
|
||||
import { QuoterError } from "../../exceptions/base.exception.js";
|
||||
import { web3Provider } from "../../providers/index.js";
|
||||
import { QuoteProvider } from "../../providers/quote.provider.js";
|
||||
import { QuoteMarshall } from "../../types.js";
|
||||
@@ -20,7 +20,7 @@ export async function relayQuoteHandler(
|
||||
|
||||
const config = getAssetConfig(chainId, tokenAddress);
|
||||
if (config === undefined)
|
||||
throw RelayerError.unknown(`Asset ${tokenAddress} for chain ${chainId} is not supported`)
|
||||
return next(QuoterError.assetNotSupported(`Asset ${tokenAddress} for chain ${chainId} is not supported`));
|
||||
|
||||
const quoteProvider = new QuoteProvider(config.fee_bps);
|
||||
const gasPrice = await web3Provider.getGasPrice(chainId);
|
||||
|
||||
Reference in New Issue
Block a user