@pythnetwork/price-pusher 8.3.2 → 8.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/aptos/command.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;;;;;;;;;;;;;;;;;oBAsCL,GAAG;;AA7B9B,wBAqGE"}
1
+ {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/aptos/command.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;;;;;;;;;;;;;;kBAoBvB,OAAO;yCAOP,OAAO;;oBAWW,GAAG;;AA7B9B,wBAqGE"}
@@ -1 +1 @@
1
- {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/evm/command.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;;oBAgFC,GAAG;;AApEpC,wBAkKE"}
1
+ {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/evm/command.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;;;;;;;;;;;;;;kBAyBvB,OAAO;8BAMP,OAAO;oBAMP,OAAO;yCAUP,OAAO;6CAQP,OAAO;qBAKP,OAAO;iCASP,OAAO;;oBAWiB,GAAG;;AApEpC,wBAkKE"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCustomGasStation = exports.CustomGasStation = void 0;
3
+ exports.CustomGasStation = void 0;
4
+ exports.getCustomGasStation = getCustomGasStation;
4
5
  const utils_1 = require("../utils");
5
6
  const viem_1 = require("viem");
6
7
  class CustomGasStation {
@@ -37,4 +38,3 @@ function getCustomGasStation(logger, customGasStation, txSpeed) {
37
38
  return new CustomGasStation(logger, customGasStation, txSpeed);
38
39
  }
39
40
  }
40
- exports.getCustomGasStation = getCustomGasStation;
@@ -1 +1 @@
1
- {"version":3,"file":"evm.d.ts","sourceRoot":"","sources":["../../src/evm/evm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,SAAS,EACT,kBAAkB,EAClB,SAAS,EACV,MAAM,cAAc,CAAC;AACtB,OAAO,EAGL,iBAAiB,EAElB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EACL,sBAAsB,EACtB,SAAS,EACT,aAAa,EACd,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAaxD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,qBAAa,gBAAiB,SAAQ,kBAAkB;IAEpD,OAAO,CAAC,YAAY;IAEpB,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,MAAM;gBAHN,YAAY,EAAE,YAAY,EAClC,UAAU,EAAE,SAAS,EAAE,EACf,WAAW,EAAE,OAAO,EACpB,MAAM,EAAE,MAAM,EACtB,MAAM,EAAE;QACN,gBAAgB,EAAE,iBAAiB,CAAC;KACrC;IAUG,KAAK;YAeG,aAAa;IAO3B,OAAO,CAAC,iBAAiB;IAuBnB,mBAAmB,CACvB,OAAO,EAAE,SAAS,GACjB,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;CAuBlC;AAED,qBAAa,cAAe,YAAW,YAAY;IAK/C,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,0BAA0B;IAClC,OAAO,CAAC,6BAA6B;IACrC,OAAO,CAAC,mBAAmB;IAC3B,OAAO,CAAC,QAAQ,CA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AE,OAAO,CAAC,GAAG,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CACzE,CAAC;AAcF,eAAO,MAAM,YAAY,aACb,MAAM,YACN,MAAM,KACf,QAAQ,iBAAiB,CAY3B,CAAC"}
1
+ {"version":3,"file":"super-wallet.d.ts","sourceRoot":"","sources":["../../src/evm/super-wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,OAAO,EACP,KAAK,EAEL,MAAM,EACN,SAAS,EACT,aAAa,EACb,aAAa,EAGb,SAAS,EACV,MAAM,MAAM,CAAC;AAmBd,MAAM,MAAM,iBAAiB,GAAG,MAAM,CACpC,SAAS,EACT,KAAK,EACL,OAAO,EACP,SAAS,EACT,aAAa,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CACzE,CAAC;AAcF,eAAO,MAAM,YAAY,aACb,MAAM,YACN,MAAM,KACf,OAAO,CAAC,iBAAiB,CAY3B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/fuel/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;;;;;;;;;;;;;;;;oBAsCC,GAAG;;AA3BpC,wBA6FE"}
1
+ {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/fuel/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;;;;;;;;;;;;kBAmBvB,OAAO;4BAKP,OAAO;iCAKP,OAAO;;oBASiB,GAAG;;AA3BpC,wBA6FE"}
@@ -1 +1 @@
1
- {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/injective/command.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;;;;;;;;;;;;;;;;;;;oBAuCL,GAAG;;AAnC9B,wBAgHE"}
1
+ {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/injective/command.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;;;;;;;;;;;;;;yBAevB,OAAO;iBAKP,OAAO;qBAIP,OAAO;0BAIP,OAAO;;oBAWW,GAAG;;AAnC9B,wBAgHE"}
@@ -1 +1 @@
1
- {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/near/command.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;;;;;;;;;;;;;;;;;;oBAsCL,GAAG;;AAlC9B,wBA0GE"}
1
+ {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/near/command.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;;;;;;;;;;;;;oBAavB,OAAO;iBAKP,OAAO;sBAKP,OAAO;4BAKP,OAAO;;oBAUW,GAAG;;AAlC9B,wBA0GE"}
@@ -1 +1 @@
1
- {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,eAAO,MAAM,oBAAoB;;CAOhC,CAAC;AAEF,eAAO,MAAM,mBAAmB;;CAQ/B,CAAC;AAEF,eAAO,MAAM,eAAe;;CAM3B,CAAC;AAEF,eAAO,MAAM,gBAAgB;;CAQ5B,CAAC;AAEF,eAAO,MAAM,gBAAgB;;CAU5B,CAAC;AAEF,eAAO,MAAM,YAAY;;CAMxB,CAAC;AAEF,eAAO,MAAM,QAAQ;;CAQpB,CAAC;AAEF,eAAO,MAAM,8BAA8B;;CAQ1C,CAAC;AAEF,eAAO,MAAM,kBAAkB;;CAQ9B,CAAC"}
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,eAAO,MAAM,oBAAoB;8BAM1B,OAAO;CACb,CAAC;AAEF,eAAO,MAAM,mBAAmB;6BAOzB,OAAO;CACb,CAAC;AAEF,eAAO,MAAM,eAAe;yBAKrB,OAAO;CACb,CAAC;AAEF,eAAO,MAAM,gBAAgB;yBAOtB,OAAO;CACb,CAAC;AAEF,eAAO,MAAM,gBAAgB;yBAStB,OAAO;CACb,CAAC;AAEF,eAAO,MAAM,YAAY;qBAKlB,OAAO;CACb,CAAC;AAEF,eAAO,MAAM,QAAQ;iBAOd,OAAO;CACb,CAAC;AAEF,eAAO,MAAM,8BAA8B;0CAOpC,OAAO;CACb,CAAC;AAEF,eAAO,MAAM,kBAAkB;4BAOxB,OAAO;CACb,CAAC"}
@@ -3,7 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.shouldUpdate = exports.UpdateCondition = exports.readPriceConfigFile = void 0;
6
+ exports.UpdateCondition = void 0;
7
+ exports.readPriceConfigFile = readPriceConfigFile;
8
+ exports.shouldUpdate = shouldUpdate;
7
9
  const joi_1 = __importDefault(require("joi"));
8
10
  const yaml_1 = __importDefault(require("yaml"));
9
11
  const fs_1 = __importDefault(require("fs"));
@@ -47,7 +49,6 @@ function readPriceConfigFile(path) {
47
49
  return priceConfig;
48
50
  });
49
51
  }
50
- exports.readPriceConfigFile = readPriceConfigFile;
51
52
  var UpdateCondition;
52
53
  (function (UpdateCondition) {
53
54
  // This price feed must be updated
@@ -106,4 +107,3 @@ function shouldUpdate(priceConfig, sourceLatestPrice, targetLatestPrice, logger)
106
107
  return UpdateCondition.NO;
107
108
  }
108
109
  }
109
- exports.shouldUpdate = shouldUpdate;
@@ -8,9 +8,11 @@ export declare class PythPriceListener implements IPriceListener {
8
8
  private latestPriceInfo;
9
9
  private logger;
10
10
  private lastUpdated;
11
+ private healthCheckInterval?;
11
12
  constructor(connection: PriceServiceConnection, priceItems: PriceItem[], logger: Logger);
12
13
  start(): Promise<void>;
13
14
  private onNewPriceFeed;
14
15
  getLatestPriceInfo(priceId: string): PriceInfo | undefined;
16
+ cleanup(): void;
15
17
  }
16
18
  //# sourceMappingURL=pyth-price-listener.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pyth-price-listener.d.ts","sourceRoot":"","sources":["../src/pyth-price-listener.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,sBAAsB,EACvB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAI9B,qBAAa,iBAAkB,YAAW,cAAc;IACtD,OAAO,CAAC,UAAU,CAAyB;IAC3C,OAAO,CAAC,QAAQ,CAAc;IAC9B,OAAO,CAAC,cAAc,CAAyB;IAC/C,OAAO,CAAC,eAAe,CAA4B;IACnD,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,WAAW,CAA4B;gBAG7C,UAAU,EAAE,sBAAsB,EAClC,UAAU,EAAE,SAAS,EAAE,EACvB,MAAM,EAAE,MAAM;IAaV,KAAK;IA8BX,OAAO,CAAC,cAAc;IAuBtB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;CAG3D"}
1
+ {"version":3,"file":"pyth-price-listener.d.ts","sourceRoot":"","sources":["../src/pyth-price-listener.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,sBAAsB,EACvB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAI9B,qBAAa,iBAAkB,YAAW,cAAc;IACtD,OAAO,CAAC,UAAU,CAAyB;IAC3C,OAAO,CAAC,QAAQ,CAAc;IAC9B,OAAO,CAAC,cAAc,CAAyB;IAC/C,OAAO,CAAC,eAAe,CAA4B;IACnD,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,WAAW,CAA4B;IAC/C,OAAO,CAAC,mBAAmB,CAAC,CAAiB;gBAG3C,UAAU,EAAE,sBAAsB,EAClC,UAAU,EAAE,SAAS,EAAE,EACvB,MAAM,EAAE,MAAM;IAaV,KAAK;IAmHX,OAAO,CAAC,cAAc;IAuBtB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;IAI1D,OAAO;CAKR"}
@@ -8,6 +8,7 @@ class PythPriceListener {
8
8
  latestPriceInfo;
9
9
  logger;
10
10
  lastUpdated;
11
+ healthCheckInterval;
11
12
  constructor(connection, priceItems, logger) {
12
13
  this.connection = connection;
13
14
  this.priceIds = priceItems.map((priceItem) => priceItem.id);
@@ -18,21 +19,77 @@ class PythPriceListener {
18
19
  // This method should be awaited on and once it finishes it has the latest value
19
20
  // for the given price feeds (if they exist).
20
21
  async start() {
22
+ // Set custom error handler for websocket errors
23
+ this.connection.onWsError = (error) => {
24
+ if (error.message.includes("not found")) {
25
+ // Extract invalid feed IDs from error message
26
+ const match = error.message.match(/\[(.*?)\]/);
27
+ if (match) {
28
+ const invalidFeedIds = match[1].split(",").map((id) => {
29
+ // Remove '0x' prefix if present to match our stored IDs
30
+ return id.trim().replace(/^0x/, "");
31
+ });
32
+ // Log invalid feeds with their aliases
33
+ invalidFeedIds.forEach((id) => {
34
+ this.logger.error(`Price feed ${id} (${this.priceIdToAlias.get(id)}) not found for subscribePriceFeedUpdates`);
35
+ });
36
+ // Filter out invalid feeds and resubscribe with valid ones
37
+ const validFeeds = this.priceIds.filter((id) => !invalidFeedIds.includes(id));
38
+ this.priceIds = validFeeds;
39
+ if (validFeeds.length > 0) {
40
+ this.logger.info("Resubscribing with valid feeds only");
41
+ this.connection.subscribePriceFeedUpdates(validFeeds, this.onNewPriceFeed.bind(this));
42
+ }
43
+ }
44
+ }
45
+ else {
46
+ this.logger.error("Websocket error occurred:", error);
47
+ }
48
+ };
21
49
  this.connection.subscribePriceFeedUpdates(this.priceIds, this.onNewPriceFeed.bind(this));
22
- const priceFeeds = await this.connection.getLatestPriceFeeds(this.priceIds);
23
- priceFeeds?.forEach((priceFeed) => {
24
- // Getting unchecked because although it might be old
25
- // but might not be there on the target chain.
26
- const latestAvailablePrice = priceFeed.getPriceUnchecked();
27
- this.latestPriceInfo.set(priceFeed.id, {
28
- price: latestAvailablePrice.price,
29
- conf: latestAvailablePrice.conf,
30
- publishTime: latestAvailablePrice.publishTime,
50
+ try {
51
+ const priceFeeds = await this.connection.getLatestPriceFeeds(this.priceIds);
52
+ priceFeeds?.forEach((priceFeed) => {
53
+ const latestAvailablePrice = priceFeed.getPriceUnchecked();
54
+ this.latestPriceInfo.set(priceFeed.id, {
55
+ price: latestAvailablePrice.price,
56
+ conf: latestAvailablePrice.conf,
57
+ publishTime: latestAvailablePrice.publishTime,
58
+ });
31
59
  });
32
- });
33
- // Check health of the price feeds 5 second. If the price feeds are not updating
34
- // for more than 30s, throw an error.
35
- setInterval(() => {
60
+ }
61
+ catch (error) {
62
+ // Always log the HTTP error first
63
+ this.logger.error("Failed to get latest price feeds:", error);
64
+ if (error.response.data.includes("Price ids not found:")) {
65
+ // Extract invalid feed IDs from error message
66
+ const invalidFeedIds = error.response.data
67
+ .split("Price ids not found:")[1]
68
+ .split(",")
69
+ .map((id) => id.trim().replace(/^0x/, ""));
70
+ // Log invalid feeds with their aliases
71
+ invalidFeedIds.forEach((id) => {
72
+ this.logger.error(`Price feed ${id} (${this.priceIdToAlias.get(id)}) not found for getLatestPriceFeeds`);
73
+ });
74
+ // Filter out invalid feeds and retry
75
+ const validFeeds = this.priceIds.filter((id) => !invalidFeedIds.includes(id));
76
+ this.priceIds = validFeeds;
77
+ if (validFeeds.length > 0) {
78
+ this.logger.info("Retrying getLatestPriceFeeds with valid feeds only");
79
+ const validPriceFeeds = await this.connection.getLatestPriceFeeds(validFeeds);
80
+ validPriceFeeds?.forEach((priceFeed) => {
81
+ const latestAvailablePrice = priceFeed.getPriceUnchecked();
82
+ this.latestPriceInfo.set(priceFeed.id, {
83
+ price: latestAvailablePrice.price,
84
+ conf: latestAvailablePrice.conf,
85
+ publishTime: latestAvailablePrice.publishTime,
86
+ });
87
+ });
88
+ }
89
+ }
90
+ }
91
+ // Store health check interval reference
92
+ this.healthCheckInterval = setInterval(() => {
36
93
  if (this.lastUpdated === undefined ||
37
94
  this.lastUpdated < Date.now() - 30 * 1000) {
38
95
  throw new Error("Hermes Price feeds are not updating.");
@@ -57,5 +114,10 @@ class PythPriceListener {
57
114
  getLatestPriceInfo(priceId) {
58
115
  return this.latestPriceInfo.get(priceId);
59
116
  }
117
+ cleanup() {
118
+ if (this.healthCheckInterval) {
119
+ clearInterval(this.healthCheckInterval);
120
+ }
121
+ }
60
122
  }
61
123
  exports.PythPriceListener = PythPriceListener;
@@ -1 +1 @@
1
- {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/solana/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAgBhC,OAAO,EACL,cAAc,EAEf,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;oBAuEH,GAAG;;AArE9B,wBAgLE;AAEF,eAAO,MAAM,cAAc,MAAO,cAAc,UAAU,MAAM,SAO/D,CAAC"}
1
+ {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/solana/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAgBhC,OAAO,EACL,cAAc,EAEf,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;;;;;;;;;;;;;kBAUrB,OAAO;wBAKP,OAAO;oBAKP,OAAO;6CAKP,OAAO;yBAKP,OAAO;6BAMP,OAAO;6BAKP,OAAO;6BAKP,OAAO;iCAKP,OAAO;4BAKP,OAAO;mCAKP,OAAO;;oBAUW,GAAG;;AArE9B,wBAgLE;AAEF,eAAO,MAAM,cAAc,MAAO,cAAc,UAAU,MAAM,SAO/D,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/sui/command.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;oBAqEC,GAAG;;AAhEpC,wBAoJE"}
1
+ {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/sui/command.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;;;;;;;;;;;;;kBAoBvB,OAAO;yBAOP,OAAO;6BAOP,OAAO;2BAMP,OAAO;8BAOP,OAAO;sBAMP,OAAO;yBAMP,OAAO;;oBAUiB,GAAG;;AAhEpC,wBAoJE"}
@@ -1 +1 @@
1
- {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/ton/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;;;;;;;;;;;;;;;;oBAsCC,GAAG;;AA3BpC,wBA+FE"}
1
+ {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/ton/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;;;;;;;;;;;;kBAmBvB,OAAO;4BAKP,OAAO;iCAKP,OAAO;;oBASiB,GAAG;;AA3BpC,wBA+FE"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAE9D,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAC/B,MAAM,MAAM,iBAAiB,GAAG,MAAM,CA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AAO,CAAC,IAAI,CAAC,CAErD;AAED,wBAAgB,eAAe,CAAC,EAAE,EAAE,SAAS,GAAG,SAAS,CAKxD;AAED,eAAO,MAAM,YAAY,OAAQ,SAAS,KAAG,KAAK,MAAM,EACrB,CAAC;AAKpC,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAStD;AAED,wBAAgB,iBAAiB,CAC/B,OAAO,SAAS,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EACpC,WAAW,SAAS,OAAO,CAAC,MAAM,CAAC,EACnC,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,GAEf,WAAW,CAK/B;AAED,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,CAAC,GAAG,SAAS,KAAG,CAMvD,CAAC"}
package/lib/utils.js CHANGED
@@ -1,19 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.assertDefined = exports.verifyValidOption = exports.isWsEndpoint = exports.addLeading0x = exports.removeLeading0x = exports.sleep = exports.customGasChainIds = exports.txSpeeds = void 0;
3
+ exports.assertDefined = exports.addLeading0x = exports.customGasChainIds = exports.txSpeeds = void 0;
4
+ exports.sleep = sleep;
5
+ exports.removeLeading0x = removeLeading0x;
6
+ exports.isWsEndpoint = isWsEndpoint;
7
+ exports.verifyValidOption = verifyValidOption;
4
8
  exports.txSpeeds = ["slow", "standard", "fast"];
5
9
  exports.customGasChainIds = [137];
6
10
  async function sleep(ms) {
7
11
  return new Promise((resolve) => setTimeout(resolve, ms));
8
12
  }
9
- exports.sleep = sleep;
10
13
  function removeLeading0x(id) {
11
14
  if (id.startsWith("0x")) {
12
15
  return id.substring(2);
13
16
  }
14
17
  return id;
15
18
  }
16
- exports.removeLeading0x = removeLeading0x;
17
19
  const addLeading0x = (id) => hasLeading0x(id) ? id : `0x${id}`;
18
20
  exports.addLeading0x = addLeading0x;
19
21
  const hasLeading0x = (input) => input.startsWith("0x");
@@ -25,7 +27,6 @@ function isWsEndpoint(endpoint) {
25
27
  }
26
28
  return false;
27
29
  }
28
- exports.isWsEndpoint = isWsEndpoint;
29
30
  function verifyValidOption(option, validOptions) {
30
31
  if (validOptions.includes(option)) {
31
32
  return option;
@@ -33,7 +34,6 @@ function verifyValidOption(option, validOptions) {
33
34
  const errorString = option + " is not a valid option. Please choose between " + validOptions;
34
35
  throw new Error(errorString);
35
36
  }
36
- exports.verifyValidOption = verifyValidOption;
37
37
  const assertDefined = (value) => {
38
38
  if (value === undefined) {
39
39
  throw new Error("Assertion failed: value was undefined");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pythnetwork/price-pusher",
3
- "version": "8.3.2",
3
+ "version": "8.3.3",
4
4
  "description": "Pyth Price Pusher",
5
5
  "homepage": "https://pyth.network",
6
6
  "main": "lib/index.js",
@@ -24,6 +24,7 @@
24
24
  "format": "prettier --write \"src/**/*.ts\"",
25
25
  "test:lint": "eslint src/",
26
26
  "start": "node lib/index.js",
27
+ "test": "jest",
27
28
  "dev": "ts-node src/index.ts",
28
29
  "prepublishOnly": "pnpm run build && pnpm run test:lint",
29
30
  "preversion": "pnpm run test:lint",
@@ -82,5 +83,5 @@
82
83
  "yaml": "^2.1.1",
83
84
  "yargs": "^17.5.1"
84
85
  },
85
- "gitHead": "cdaf99e8629cd6af655a5f1c2c5750de9bc485dd"
86
+ "gitHead": "707437af791b9b111f976eb45b958639f90a2e20"
86
87
  }