1- import { HexString , PriceServiceConnection } from "@pythnetwork/pyth-common-js" ;
21import {
3- ChainPricePusher ,
2+ HexString ,
3+ PriceServiceConnection ,
4+ } from "@pythnetwork/price-service-client" ;
5+ import {
6+ IPricePusher ,
47 PriceInfo ,
58 ChainPriceListener ,
69 PriceItem ,
@@ -35,11 +38,10 @@ type UpdateFeeResponse = {
3538 amount : string ;
3639} ;
3740
38- // FIXME: CLEANUP contractAddr variable name consistency
3941// this use price without leading 0x
4042export class InjectivePriceListener extends ChainPriceListener {
4143 constructor (
42- private contractAddress : string ,
44+ private pythContractAddress : string ,
4345 private grpcEndpoint : string ,
4446 priceItems : PriceItem [ ] ,
4547 config : {
@@ -56,14 +58,14 @@ export class InjectivePriceListener extends ChainPriceListener {
5658 try {
5759 const api = new ChainGrpcWasmApi ( this . grpcEndpoint ) ;
5860 const { data } = await api . fetchSmartContractState (
59- this . contractAddress ,
61+ this . pythContractAddress ,
6062 Buffer . from ( `{"price_feed":{"id":"${ priceId } "}}` ) . toString ( "base64" )
6163 ) ;
6264
6365 const json = Buffer . from ( data as string , "base64" ) . toString ( ) ;
6466 priceQueryResponse = JSON . parse ( json ) ;
6567 } catch ( e ) {
66- console . error ( `Getting on-chain price for ${ priceId } failed. Error:` ) ;
68+ console . error ( `Polling on-chain price for ${ priceId } failed. Error:` ) ;
6769 console . error ( e ) ;
6870 return undefined ;
6971 }
@@ -82,11 +84,11 @@ export class InjectivePriceListener extends ChainPriceListener {
8284 }
8385}
8486
85- export class InjectivePricePusher implements ChainPricePusher {
87+ export class InjectivePricePusher implements IPricePusher {
8688 private wallet : PrivateKey ;
8789 constructor (
8890 private priceServiceConnection : PriceServiceConnection ,
89- private pythContract : string ,
91+ private pythContractAddress : string ,
9092 private grpcEndpoint : string ,
9193 mnemonic : string
9294 ) {
@@ -160,7 +162,7 @@ export class InjectivePricePusher implements ChainPricePusher {
160162 try {
161163 const api = new ChainGrpcWasmApi ( this . grpcEndpoint ) ;
162164 const { data } = await api . fetchSmartContractState (
163- this . pythContract ,
165+ this . pythContractAddress ,
164166 Buffer . from (
165167 JSON . stringify ( {
166168 get_update_fee : {
@@ -178,11 +180,10 @@ export class InjectivePricePusher implements ChainPricePusher {
178180 return ;
179181 }
180182
181- // TODO: add specific error messages
182183 try {
183184 const executeMsg = MsgExecuteContract . fromJSON ( {
184185 sender : this . injectiveAddress ( ) ,
185- contractAddress : this . pythContract ,
186+ contractAddress : this . pythContractAddress ,
186187 msg : priceFeedUpdateObject ,
187188 funds : [ updateFeeQueryResponse ] ,
188189 } ) ;
0 commit comments