From 68bc0a8a5869ec8bc7c33fc1ec1c19376044ec0b Mon Sep 17 00:00:00 2001 From: Brendan from DeFi Date: Tue, 4 Mar 2025 12:26:27 -0800 Subject: [PATCH] fix: getPriceQuote error message and types (#2073) --- src/api/getPriceQuote.test.ts | 2 +- src/api/getPriceQuote.ts | 4 ++-- src/api/types.ts | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/api/getPriceQuote.test.ts b/src/api/getPriceQuote.test.ts index 6df5ece562..f78157eee6 100644 --- a/src/api/getPriceQuote.test.ts +++ b/src/api/getPriceQuote.test.ts @@ -67,7 +67,7 @@ describe('getPriceQuote', () => { expect(result).toEqual({ code: 'INVALID_INPUT', error: 'Invalid input: tokens must be an array of at least one token', - message: '', + message: 'Tokens must be an array of at least one token', }); }); diff --git a/src/api/getPriceQuote.ts b/src/api/getPriceQuote.ts index 6f0ce02878..e22c26d3ac 100644 --- a/src/api/getPriceQuote.ts +++ b/src/api/getPriceQuote.ts @@ -29,7 +29,7 @@ export async function getPriceQuote( ); if (res.error) { return { - code: `${res.error.code}`, + code: String(res.error.code), error: 'Error fetching price quote', message: res.error.message, }; @@ -51,7 +51,7 @@ function validateGetPriceQuoteParams(params: GetPriceQuoteParams) { return { code: 'INVALID_INPUT', error: 'Invalid input: tokens must be an array of at least one token', - message: '', + message: 'Tokens must be an array of at least one token', }; } diff --git a/src/api/types.ts b/src/api/types.ts index 651b97b800..1d02129ce1 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -397,15 +397,15 @@ export type GetPriceQuoteParams = { type PriceQuote = { /** The name of the token */ - name: string | ''; + name: string; /** The symbol of the token */ - symbol: string | ''; + symbol: string; /** The contract address of the token */ contractAddress: Address | ''; /** The price of the token */ - price: string | ''; + price: string; /** The timestamp of the price quote */ - timestamp: number | 0; + timestamp: number; }; /**