66} from "../interface" ;
77import { AptosAccount , AptosClient } from "aptos" ;
88import { DurationInSeconds } from "../utils" ;
9- import { PriceServiceConnection } from "@pythnetwork/price-service -client" ;
9+ import { HermesClient } from "@pythnetwork/hermes -client" ;
1010import { Logger } from "pino" ;
1111
1212export class AptosPriceListener extends ChainPriceListener {
@@ -89,7 +89,7 @@ export class AptosPricePusher implements IPricePusher {
8989 private sequenceNumberLocked : boolean ;
9090
9191 constructor (
92- private priceServiceConnection : PriceServiceConnection ,
92+ private hermesClient : HermesClient ,
9393 private logger : Logger ,
9494 private pythContractAddress : string ,
9595 private endpoint : string ,
@@ -107,11 +107,12 @@ export class AptosPricePusher implements IPricePusher {
107107 * @returns Array of price update data.
108108 */
109109 async getPriceFeedsUpdateData ( priceIds : string [ ] ) : Promise < number [ ] [ ] > {
110- // Fetch the latest price feed update VAAs from the price service
111- const latestVaas = await this . priceServiceConnection . getLatestVaas (
112- priceIds
110+ const response = await this . hermesClient . getLatestPriceUpdates ( priceIds , {
111+ encoding : "base64" ,
112+ } ) ;
113+ return response . binary . data . map ( ( data ) =>
114+ Array . from ( Buffer . from ( data , "base64" ) )
113115 ) ;
114- return latestVaas . map ( ( vaa ) => Array . from ( Buffer . from ( vaa , "base64" ) ) ) ;
115116 }
116117
117118 async updatePriceFeed (
@@ -226,7 +227,7 @@ export class AptosPricePusher implements IPricePusher {
226227 ) ;
227228 return this . lastSequenceNumber ;
228229 } catch ( e : any ) {
229- throw new Error ( "Failed to retrieve sequence number" ) ;
230+ throw new Error ( "Failed to retrieve sequence number" + e ) ;
230231 } finally {
231232 this . sequenceNumberLocked = false ;
232233 }
0 commit comments