Skip to content

Commit bb8cab7

Browse files
author
0xfirefist
committed
remove cwPriceServiceConnection
1 parent 931af06 commit bb8cab7

File tree

4 files changed

+31
-49
lines changed

4 files changed

+31
-49
lines changed

price_pusher/package-lock.json

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

price_pusher/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
},
4545
"dependencies": {
4646
"@injectivelabs/sdk-ts": "^1.0.457",
47-
"@pythnetwork/pyth-common-js": "^1.2.0",
47+
"@pythnetwork/pyth-common-js": "^1.4.0",
4848
"@pythnetwork/pyth-evm-js": "^1.1.0",
4949
"@pythnetwork/pyth-sdk-solidity": "^2.2.0",
5050
"@truffle/hdwallet-provider": "^2.1.3",

price_pusher/src/index.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ import { PythPriceListener } from "./pyth-price-listener";
1414
import fs from "fs";
1515
import { readPriceConfigFile } from "./price-config";
1616
import { PriceServiceConnection } from "@pythnetwork/pyth-common-js";
17-
import {
18-
CwPriceServiceConnection,
19-
InjectivePriceListener,
20-
InjectivePricePusher,
21-
} from "./injective";
17+
import { InjectivePriceListener, InjectivePricePusher } from "./injective";
2218

2319
const argv = yargs(hideBin(process.argv))
2420
.option("network", {
@@ -108,9 +104,7 @@ async function injectiveRun() {
108104
);
109105

110106
const injectivePricePusher = new InjectivePricePusher(
111-
new CwPriceServiceConnection(argv.priceEndpoint, {
112-
logger: console,
113-
}),
107+
connection,
114108
argv.pythContract,
115109
argv.endpoint,
116110
fs.readFileSync(argv.mnemonicFile, "utf-8").trim()

price_pusher/src/injective.ts

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import {
2-
HexString,
3-
PriceServiceConnection,
4-
PriceServiceConnectionConfig,
5-
} from "@pythnetwork/pyth-common-js";
1+
import { HexString, PriceServiceConnection } from "@pythnetwork/pyth-common-js";
62
import { ChainPricePusher, PriceInfo, PriceListener } from "./interface";
73
import { DurationInSeconds } from "./utils";
84
import { PriceConfig } from "./price-config";
@@ -124,7 +120,7 @@ export class InjectivePriceListener implements PriceListener {
124120
export 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

Comments
 (0)