File tree Expand file tree Collapse file tree 4 files changed +25
-6
lines changed
src/core/services/mirrornode Expand file tree Collapse file tree 4 files changed +25
-6
lines changed Original file line number Diff line number Diff line change @@ -205,15 +205,15 @@ export const createMockExchangeRateResponse = (
205205) : ExchangeRateResponse => ( {
206206 current_rate : {
207207 cent_equivalent : 12 ,
208- expiration_time : '2024-01-01T12:00:00.000Z' ,
208+ expiration_time : 1774962000 ,
209209 hbar_equivalent : 1 ,
210210 } ,
211211 next_rate : {
212212 cent_equivalent : 12 ,
213- expiration_time : '2024-01-01T12:00:00.000Z' ,
213+ expiration_time : 1774965600 ,
214214 hbar_equivalent : 1 ,
215215 } ,
216- timestamp : '2024-01-01T12:00:00.000Z ' ,
216+ timestamp : '1774958462.794936000 ' ,
217217 ...overrides ,
218218} ) ;
219219
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ import { handleMirrorNodeErrorResponse } from '@/core/utils/handle-mirror-node-e
3737import {
3838 AccountAPIResponseSchema ,
3939 ContractInfoSchema ,
40+ ExchangeRateResponseSchema ,
4041 GetAccountsAPIResponseSchema ,
4142 NftInfoSchema ,
4243 TokenAirdropsResponseSchema ,
@@ -567,7 +568,11 @@ export class HederaMirrornodeServiceDefaultImpl implements HederaMirrornodeServi
567568 ) ;
568569 }
569570
570- return ( await response . json ( ) ) as ExchangeRateResponse ;
571+ return parseWithSchema (
572+ ExchangeRateResponseSchema ,
573+ await response . json ( ) ,
574+ 'Mirror Node GET /network/exchangerate' ,
575+ ) ;
571576 } catch ( error ) {
572577 if ( error instanceof CliError ) throw error ;
573578 throw new NetworkError ( 'Failed to fetch exchange rate' , {
Original file line number Diff line number Diff line change 88 type AccountListItemBalance ,
99 type AccountListItemTokenBalance ,
1010 type ContractInfo ,
11+ type ExchangeRateResponse ,
1112 type GetAccountsAPIResponse ,
1213 MirrorNodeKeyType ,
1314 type NftInfo ,
@@ -231,6 +232,19 @@ export const ContractInfoSchema: z.ZodType<ContractInfo> = z.object({
231232 stake_period_start : nullableStringKey ,
232233} ) ;
233234
235+ const exchangeRateBandSchema = z . object ( {
236+ cent_equivalent : z . number ( ) ,
237+ expiration_time : z . number ( ) ,
238+ hbar_equivalent : z . number ( ) ,
239+ } ) ;
240+
241+ export const ExchangeRateResponseSchema : z . ZodType < ExchangeRateResponse > =
242+ z . object ( {
243+ current_rate : exchangeRateBandSchema ,
244+ next_rate : exchangeRateBandSchema ,
245+ timestamp : z . string ( ) ,
246+ } ) ;
247+
234248const transactionTransferItemSchema : z . ZodType < TransactionTransferItem > =
235249 z . object ( {
236250 account : z . string ( ) ,
Original file line number Diff line number Diff line change @@ -244,12 +244,12 @@ export interface TokenAirdropsResponse {
244244export interface ExchangeRateResponse {
245245 current_rate : {
246246 cent_equivalent : number ;
247- expiration_time : string ;
247+ expiration_time : number ;
248248 hbar_equivalent : number ;
249249 } ;
250250 next_rate : {
251251 cent_equivalent : number ;
252- expiration_time : string ;
252+ expiration_time : number ;
253253 hbar_equivalent : number ;
254254 } ;
255255 timestamp : string ;
You can’t perform that action at this time.
0 commit comments