6
6
} from "../interface" ;
7
7
import { AptosAccount , AptosClient } from "aptos" ;
8
8
import { DurationInSeconds } from "../utils" ;
9
- import { PriceServiceConnection } from "@pythnetwork/price-service -client" ;
9
+ import { HermesClient } from "@pythnetwork/hermes -client" ;
10
10
import { Logger } from "pino" ;
11
11
12
12
export class AptosPriceListener extends ChainPriceListener {
@@ -89,7 +89,7 @@ export class AptosPricePusher implements IPricePusher {
89
89
private sequenceNumberLocked : boolean ;
90
90
91
91
constructor (
92
- private priceServiceConnection : PriceServiceConnection ,
92
+ private hermesClient : HermesClient ,
93
93
private logger : Logger ,
94
94
private pythContractAddress : string ,
95
95
private endpoint : string ,
@@ -107,11 +107,12 @@ export class AptosPricePusher implements IPricePusher {
107
107
* @returns Array of price update data.
108
108
*/
109
109
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" ) )
113
115
) ;
114
- return latestVaas . map ( ( vaa ) => Array . from ( Buffer . from ( vaa , "base64" ) ) ) ;
115
116
}
116
117
117
118
async updatePriceFeed (
@@ -226,7 +227,7 @@ export class AptosPricePusher implements IPricePusher {
226
227
) ;
227
228
return this . lastSequenceNumber ;
228
229
} catch ( e : any ) {
229
- throw new Error ( "Failed to retrieve sequence number" ) ;
230
+ throw new Error ( "Failed to retrieve sequence number" + e ) ;
230
231
} finally {
231
232
this . sequenceNumberLocked = false ;
232
233
}
0 commit comments