Skip to content

Commit c3ae2f6

Browse files
committed
refactor: address part of the comments
1 parent 9fcf830 commit c3ae2f6

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

Diff for: apps/price_pusher/src/evm/evm.ts

+10-12
Original file line numberDiff line numberDiff line change
@@ -435,18 +435,16 @@ export class EvmPricePusher implements IPricePusher {
435435
hash: hash,
436436
});
437437

438-
if (receipt.status === "success") {
439-
this.logger.info({ hash }, "Price update successful");
440-
} else if (receipt.status === "reverted") {
441-
this.logger.info(
442-
{ hash, receipt },
443-
"Price update reverted or its transaction did not land. " +
444-
"This is an expected behaviour in high frequency or multi-instance setup."
445-
);
446-
} else {
447-
throw new Error(
448-
"This codepath should be unreachable. Please file a bug report."
449-
);
438+
switch (receipt.status) {
439+
case "success":
440+
this.logger.info({ hash }, "Price update successful");
441+
break;
442+
default:
443+
this.logger.info(
444+
{ hash, receipt },
445+
"Price update did not succeed or its transaction did not land. " +
446+
"This is an expected behaviour in high frequency or multi-instance setup."
447+
);
450448
}
451449
} catch (err: any) {
452450
this.logger.warn({ err }, "Failed to get transaction receipt");

Diff for: apps/price_pusher/src/utils.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@ export function removeLeading0x(id: HexString): HexString {
1818
return id;
1919
}
2020

21-
export function addLeading0x(id: HexString): `0x${string}` {
22-
if (id.startsWith("0x")) {
23-
return id as `0x${string}`;
24-
}
25-
return ("0x" + id) as `0x${string}`;
26-
}
21+
export const addLeading0x = (id: HexString): `0x${string}` =>
22+
hasLeading0x(id) ? id : `0x${id}`;
23+
24+
const hasLeading0x = (input: string): input is `0x${string}` =>
25+
input.startsWith("0x");
2726

2827
export function isWsEndpoint(endpoint: string): boolean {
2928
const url = new URL(endpoint);

0 commit comments

Comments
 (0)