11import { Contract , EventData } from "web3-eth-contract" ;
2- import { PriceConfig } from "./price-config" ;
3- import { ChainPricePusher , PriceInfo , ChainPriceListener } from "./interface" ;
2+ import {
3+ ChainPricePusher ,
4+ PriceInfo ,
5+ ChainPriceListener ,
6+ PriceItem ,
7+ } from "./interface" ;
48import { TransactionReceipt } from "ethereum-protocol" ;
59import { addLeading0x , DurationInSeconds , removeLeading0x } from "./utils" ;
610import AbstractPythAbi from "@pythnetwork/pyth-sdk-solidity/abis/AbstractPyth.json" ;
@@ -17,23 +21,15 @@ import {
1721export class EvmPriceListener extends ChainPriceListener {
1822 private pythContractFactory : PythContractFactory ;
1923 private pythContract : Contract ;
20- private priceIdToAlias : Map < HexString , string > ;
2124
2225 constructor (
2326 pythContractFactory : PythContractFactory ,
24- priceConfigs : PriceConfig [ ] ,
27+ priceItems : PriceItem [ ] ,
2528 config : {
2629 pollingFrequency : DurationInSeconds ;
2730 }
2831 ) {
29- super (
30- "Evm" ,
31- config . pollingFrequency ,
32- priceConfigs . map ( ( priceConfig ) => priceConfig . id )
33- ) ;
34- this . priceIdToAlias = new Map (
35- priceConfigs . map ( ( priceConfig ) => [ priceConfig . id , priceConfig . alias ] )
36- ) ;
32+ super ( "Evm" , config . pollingFrequency , priceItems ) ;
3733
3834 this . pythContractFactory = pythContractFactory ;
3935 this . pythContract = this . pythContractFactory . createPythContract ( ) ;
@@ -57,7 +53,7 @@ export class EvmPriceListener extends ChainPriceListener {
5753 }
5854
5955 private async startSubscription ( ) {
60- for ( const priceId of this . priceIds ) {
56+ for ( const { id : priceId } of this . priceItems ) {
6157 this . pythContract . events . PriceFeedUpdate (
6258 {
6359 filter : {
@@ -106,6 +102,12 @@ export class EvmPriceListener extends ChainPriceListener {
106102 return undefined ;
107103 }
108104
105+ console . log (
106+ `Polled an EVM on chain price for feed ${ this . priceIdToAlias . get (
107+ priceId
108+ ) } (${ priceId } ).`
109+ ) ;
110+
109111 return {
110112 conf : priceRaw . conf ,
111113 price : priceRaw . price ,
0 commit comments