1- import {
2- HexString ,
3- PriceServiceConnection ,
4- PriceServiceConnectionConfig ,
5- } from "@pythnetwork/pyth-common-js" ;
1+ import { HexString , PriceServiceConnection } from "@pythnetwork/pyth-common-js" ;
62import { ChainPricePusher , PriceInfo , PriceListener } from "./interface" ;
73import { DurationInSeconds } from "./utils" ;
84import { PriceConfig } from "./price-config" ;
@@ -124,7 +120,7 @@ export class InjectivePriceListener implements PriceListener {
124120export class InjectivePricePusher implements ChainPricePusher {
125121 private wallet : PrivateKey ;
126122 constructor (
127- private cwPriceServiceConnection : CwPriceServiceConnection ,
123+ private priceServiceConnection : PriceServiceConnection ,
128124 private pythContract : string ,
129125 private grpcEndpoint : string ,
130126 mnemonic : string
@@ -164,6 +160,16 @@ export class InjectivePricePusher implements ChainPricePusher {
164160 return txResponse ;
165161 }
166162
163+ async getPriceFeedUpdateObject ( priceIds : string [ ] ) : Promise < any > {
164+ const vaas = await this . priceServiceConnection . getLatestVaas ( priceIds ) ;
165+
166+ return {
167+ update_price_feeds : {
168+ data : vaas ,
169+ } ,
170+ } ;
171+ }
172+
167173 async updatePriceFeed (
168174 priceIds : string [ ] ,
169175 pubTimesToPush : number [ ]
@@ -178,8 +184,7 @@ export class InjectivePricePusher implements ChainPricePusher {
178184 let priceFeedUpdateObject ;
179185 try {
180186 // get the latest VAAs for updatePriceFeed and then push them
181- priceFeedUpdateObject =
182- await this . cwPriceServiceConnection . getPriceFeedUpdateObject ( priceIds ) ;
187+ priceFeedUpdateObject = await this . getPriceFeedUpdateObject ( priceIds ) ;
183188 } catch ( e ) {
184189 console . error ( "Error fetching the latest vaas to push" ) ;
185190 console . error ( e ) ;
@@ -228,20 +233,3 @@ export class InjectivePricePusher implements ChainPricePusher {
228233 }
229234 }
230235}
231-
232- // FIXME: a better place for it while refactoring
233- export class CwPriceServiceConnection extends PriceServiceConnection {
234- constructor ( endpoint : string , config ?: PriceServiceConnectionConfig ) {
235- super ( endpoint , config ) ;
236- }
237-
238- async getPriceFeedUpdateObject ( priceIds : string [ ] ) : Promise < any > {
239- const vaas = await this . getLatestVaas ( priceIds ) ;
240-
241- return {
242- update_price_feeds : {
243- data : vaas ,
244- } ,
245- } ;
246- }
247- }
0 commit comments