Skip to content

Commit 0f8a1f4

Browse files
committed
refactor: address comments
1 parent b3a66f1 commit 0f8a1f4

File tree

2 files changed

+14
-22
lines changed

2 files changed

+14
-22
lines changed

apps/price_pusher/src/evm/evm.ts

+6-18
Original file line numberDiff line numberDiff line change
@@ -296,31 +296,18 @@ export class EvmPricePusher implements IPricePusher {
296296
[priceFeedUpdateData, priceIdsWith0x, pubTimesToPushParam],
297297
{
298298
value: updateFee,
299-
gasPrice: BigInt(Math.round(gasPrice)),
299+
gasPrice: BigInt(Math.ceil(gasPrice)),
300300
nonce: txNonce,
301301
gas:
302302
this.gasLimit !== undefined
303-
? BigInt(Math.round(this.gasLimit))
303+
? BigInt(Math.ceil(this.gasLimit))
304304
: undefined,
305305
}
306306
);
307307

308308
this.logger.debug({ request }, "Simulated request successfully");
309309

310-
const hash = await this.pythContract.write.updatePriceFeedsIfNecessary(
311-
[priceFeedUpdateData, priceIdsWith0x, pubTimesToPushParam],
312-
{
313-
value: updateFee,
314-
gasPrice: BigInt(Math.round(gasPrice)),
315-
nonce: txNonce,
316-
gas:
317-
this.gasLimit !== undefined
318-
? BigInt(Math.round(this.gasLimit))
319-
: undefined,
320-
chain: this.client.chain,
321-
account: this.client.account!,
322-
}
323-
);
310+
const hash = await this.client.writeContract(request);
324311

325312
this.logger.info({ hash }, "Price update sent");
326313

@@ -345,10 +332,10 @@ export class EvmPricePusher implements IPricePusher {
345332
if (err.walk((e) => e instanceof InsufficientFundsError)) {
346333
this.logger.error(
347334
{ err },
348-
"Wallet doesn't have enough balance. In a rare case, there might be issues with gas price " +
335+
"Wallet doesn't have enough balance. In rare cases, there might be issues with gas price " +
349336
"calculation in the RPC."
350337
);
351-
throw new Error("Please top up the wallet");
338+
throw err;
352339
}
353340

354341
if (
@@ -457,6 +444,7 @@ export class EvmPricePusher implements IPricePusher {
457444

458445
switch (receipt.status) {
459446
case "success":
447+
this.logger.debug({ hash, receipt }, "Price update successful");
460448
this.logger.info({ hash }, "Price update successful");
461449
break;
462450
default:

apps/price_pusher/src/evm/pyth-abi.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const IPyth = [
1+
export const IPythAbi = [
22
{
33
anonymous: false,
44
inputs: [
@@ -546,7 +546,7 @@ const IPyth = [
546546
},
547547
] as const;
548548

549-
const IPythEvents = [
549+
export const IPythEventsAbi = [
550550
{
551551
anonymous: false,
552552
inputs: [
@@ -580,7 +580,7 @@ const IPythEvents = [
580580
},
581581
] as const;
582582

583-
const PythErrors = [
583+
export const PythErrorsAbi = [
584584
{
585585
inputs: [],
586586
name: "InsufficientFee",
@@ -653,4 +653,8 @@ const PythErrors = [
653653
},
654654
] as const;
655655

656-
export const PythAbi = [...IPyth, ...IPythEvents, ...PythErrors] as const;
656+
export const PythAbi = [
657+
...IPythAbi,
658+
...IPythEventsAbi,
659+
...PythErrorsAbi,
660+
] as const;

0 commit comments

Comments
 (0)