Parcourir la source

fix(price-pusher): fixed build

benduran il y a 4 semaines
Parent
commit
47c372385f

+ 170 - 37
apps/price_pusher/package.json

@@ -3,8 +3,8 @@
   "version": "10.2.0",
   "description": "Pyth Price Pusher",
   "homepage": "https://pyth.network",
-  "main": "./dist/cjs/index.js",
-  "types": "./dist/esm/index.d.mts",
+  "main": "./cjs/index.js",
+  "types": "./cjs/index.d.ts",
   "files": [
     "lib/**/*",
     "dist/**/*"
@@ -26,7 +26,7 @@
     "fix:lint": "eslint src/ --fix --max-warnings 0",
     "test:format": "prettier --check \"src/**/*.ts\"",
     "test:lint": "eslint src/ --max-warnings 0",
-    "start": "node lib/index.js",
+    "start": "node dist/esm/index.js",
     "dev": "tsx src/index.ts",
     "prepublishOnly": "pnpm run build && pnpm run test:lint",
     "preversion": "pnpm run test:lint",
@@ -45,6 +45,7 @@
   ],
   "license": "Apache-2.0",
   "devDependencies": {
+    "@cprussin/tsconfig": "catalog:",
     "@types/ethereum-protocol": "^1.0.2",
     "@types/express": "^4.17.21",
     "@types/jest": "^27.4.1",
@@ -96,41 +97,173 @@
     "pnpm": ">=10.19.0"
   },
   "packageManager": "pnpm@10.19.0",
-  "module": "./dist/esm/index.mjs",
+  "module": "./esm/index.js",
   "exports": {
-    ".": "./src/index.ts",
-    "./aptos/aptos": "./src/aptos/aptos.ts",
-    "./aptos/balance-tracker": "./src/aptos/balance-tracker.ts",
-    "./aptos/command": "./src/aptos/command.ts",
-    "./common": "./src/common.ts",
-    "./controller": "./src/controller.ts",
-    "./evm/balance-tracker": "./src/evm/balance-tracker.ts",
-    "./evm/command": "./src/evm/command.ts",
-    "./evm/custom-gas-station": "./src/evm/custom-gas-station.ts",
-    "./evm/evm": "./src/evm/evm.ts",
-    "./evm/pyth-abi": "./src/evm/pyth-abi.ts",
-    "./evm/pyth-contract": "./src/evm/pyth-contract.ts",
-    "./evm/super-wallet": "./src/evm/super-wallet.ts",
-    "./fuel/command": "./src/fuel/command.ts",
-    "./fuel/fuel": "./src/fuel/fuel.ts",
-    "./injective/command": "./src/injective/command.ts",
-    "./injective/injective": "./src/injective/injective.ts",
-    "./interface": "./src/interface.ts",
-    "./metrics": "./src/metrics.ts",
-    "./near/command": "./src/near/command.ts",
-    "./near/near": "./src/near/near.ts",
-    "./options": "./src/options.ts",
-    "./price-config": "./src/price-config.ts",
-    "./pyth-price-listener": "./src/pyth-price-listener.ts",
-    "./solana/balance-tracker": "./src/solana/balance-tracker.ts",
-    "./solana/command": "./src/solana/command.ts",
-    "./solana/solana": "./src/solana/solana.ts",
-    "./sui/balance-tracker": "./src/sui/balance-tracker.ts",
-    "./sui/command": "./src/sui/command.ts",
-    "./sui/sui": "./src/sui/sui.ts",
-    "./ton/command": "./src/ton/command.ts",
-    "./ton/ton": "./src/ton/ton.ts",
-    "./utils": "./src/utils.ts",
+    "./aptos/aptos": {
+      "import": "./dist/esm/aptos/aptos.js",
+      "types": "./dist/esm/aptos/aptos.d.ts",
+      "require": "./dist/cjs/aptos/aptos.js"
+    },
+    "./aptos/balance-tracker": {
+      "import": "./dist/esm/aptos/balance-tracker.js",
+      "types": "./dist/esm/aptos/balance-tracker.d.ts",
+      "require": "./dist/cjs/aptos/balance-tracker.js"
+    },
+    "./aptos/command": {
+      "import": "./dist/esm/aptos/command.js",
+      "types": "./dist/esm/aptos/command.d.ts",
+      "require": "./dist/cjs/aptos/command.js"
+    },
+    "./common": {
+      "import": "./dist/esm/common.js",
+      "types": "./dist/esm/common.d.ts",
+      "require": "./dist/cjs/common.js"
+    },
+    "./controller": {
+      "import": "./dist/esm/controller.js",
+      "types": "./dist/esm/controller.d.ts",
+      "require": "./dist/cjs/controller.js"
+    },
+    "./evm/balance-tracker": {
+      "import": "./dist/esm/evm/balance-tracker.js",
+      "types": "./dist/esm/evm/balance-tracker.d.ts",
+      "require": "./dist/cjs/evm/balance-tracker.js"
+    },
+    "./evm/command": {
+      "import": "./dist/esm/evm/command.js",
+      "types": "./dist/esm/evm/command.d.ts",
+      "require": "./dist/cjs/evm/command.js"
+    },
+    "./evm/custom-gas-station": {
+      "import": "./dist/esm/evm/custom-gas-station.js",
+      "types": "./dist/esm/evm/custom-gas-station.d.ts",
+      "require": "./dist/cjs/evm/custom-gas-station.js"
+    },
+    "./evm/evm": {
+      "import": "./dist/esm/evm/evm.js",
+      "types": "./dist/esm/evm/evm.d.ts",
+      "require": "./dist/cjs/evm/evm.js"
+    },
+    "./evm/pyth-abi": {
+      "import": "./dist/esm/evm/pyth-abi.js",
+      "types": "./dist/esm/evm/pyth-abi.d.ts",
+      "require": "./dist/cjs/evm/pyth-abi.js"
+    },
+    "./evm/pyth-contract": {
+      "import": "./dist/esm/evm/pyth-contract.js",
+      "types": "./dist/esm/evm/pyth-contract.d.ts",
+      "require": "./dist/cjs/evm/pyth-contract.js"
+    },
+    "./evm/super-wallet": {
+      "import": "./dist/esm/evm/super-wallet.js",
+      "types": "./dist/esm/evm/super-wallet.d.ts",
+      "require": "./dist/cjs/evm/super-wallet.js"
+    },
+    "./fuel/command": {
+      "import": "./dist/esm/fuel/command.js",
+      "types": "./dist/esm/fuel/command.d.ts",
+      "require": "./dist/cjs/fuel/command.js"
+    },
+    "./fuel/fuel": {
+      "import": "./dist/esm/fuel/fuel.js",
+      "types": "./dist/esm/fuel/fuel.d.ts",
+      "require": "./dist/cjs/fuel/fuel.js"
+    },
+    ".": {
+      "import": "./dist/esm/index.js",
+      "types": "./dist/esm/index.d.ts",
+      "require": "./dist/cjs/index.js"
+    },
+    "./injective/command": {
+      "import": "./dist/esm/injective/command.js",
+      "types": "./dist/esm/injective/command.d.ts",
+      "require": "./dist/cjs/injective/command.js"
+    },
+    "./injective/injective": {
+      "import": "./dist/esm/injective/injective.js",
+      "types": "./dist/esm/injective/injective.d.ts",
+      "require": "./dist/cjs/injective/injective.js"
+    },
+    "./interface": {
+      "import": "./dist/esm/interface.js",
+      "types": "./dist/esm/interface.d.ts",
+      "require": "./dist/cjs/interface.js"
+    },
+    "./metrics": {
+      "import": "./dist/esm/metrics.js",
+      "types": "./dist/esm/metrics.d.ts",
+      "require": "./dist/cjs/metrics.js"
+    },
+    "./near/command": {
+      "import": "./dist/esm/near/command.js",
+      "types": "./dist/esm/near/command.d.ts",
+      "require": "./dist/cjs/near/command.js"
+    },
+    "./near/near": {
+      "import": "./dist/esm/near/near.js",
+      "types": "./dist/esm/near/near.d.ts",
+      "require": "./dist/cjs/near/near.js"
+    },
+    "./options": {
+      "import": "./dist/esm/options.js",
+      "types": "./dist/esm/options.d.ts",
+      "require": "./dist/cjs/options.js"
+    },
+    "./price-config": {
+      "import": "./dist/esm/price-config.js",
+      "types": "./dist/esm/price-config.d.ts",
+      "require": "./dist/cjs/price-config.js"
+    },
+    "./pyth-price-listener": {
+      "import": "./dist/esm/pyth-price-listener.js",
+      "types": "./dist/esm/pyth-price-listener.d.ts",
+      "require": "./dist/cjs/pyth-price-listener.js"
+    },
+    "./solana/balance-tracker": {
+      "import": "./dist/esm/solana/balance-tracker.js",
+      "types": "./dist/esm/solana/balance-tracker.d.ts",
+      "require": "./dist/cjs/solana/balance-tracker.js"
+    },
+    "./solana/command": {
+      "import": "./dist/esm/solana/command.js",
+      "types": "./dist/esm/solana/command.d.ts",
+      "require": "./dist/cjs/solana/command.js"
+    },
+    "./solana/solana": {
+      "import": "./dist/esm/solana/solana.js",
+      "types": "./dist/esm/solana/solana.d.ts",
+      "require": "./dist/cjs/solana/solana.js"
+    },
+    "./sui/balance-tracker": {
+      "import": "./dist/esm/sui/balance-tracker.js",
+      "types": "./dist/esm/sui/balance-tracker.d.ts",
+      "require": "./dist/cjs/sui/balance-tracker.js"
+    },
+    "./sui/command": {
+      "import": "./dist/esm/sui/command.js",
+      "types": "./dist/esm/sui/command.d.ts",
+      "require": "./dist/cjs/sui/command.js"
+    },
+    "./sui/sui": {
+      "import": "./dist/esm/sui/sui.js",
+      "types": "./dist/esm/sui/sui.d.ts",
+      "require": "./dist/cjs/sui/sui.js"
+    },
+    "./ton/command": {
+      "import": "./dist/esm/ton/command.js",
+      "types": "./dist/esm/ton/command.d.ts",
+      "require": "./dist/cjs/ton/command.js"
+    },
+    "./ton/ton": {
+      "import": "./dist/esm/ton/ton.js",
+      "types": "./dist/esm/ton/ton.d.ts",
+      "require": "./dist/cjs/ton/ton.js"
+    },
+    "./utils": {
+      "import": "./dist/esm/utils.js",
+      "types": "./dist/esm/utils.d.ts",
+      "require": "./dist/cjs/utils.js"
+    },
     "./package.json": "./package.json"
   }
 }

+ 1 - 0
apps/price_pusher/src/aptos/aptos.ts

@@ -96,6 +96,7 @@ export class AptosPricePusher implements IPricePusher {
     private mnemonic: string,
     private overrideGasPriceMultiplier: number,
   ) {
+    this.overrideGasPriceMultiplier;
     this.sequenceNumberLocked = false;
   }
 

+ 5 - 5
apps/price_pusher/src/aptos/balance-tracker.ts

@@ -1,12 +1,12 @@
 import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
 import {
   BaseBalanceTracker,
-  BaseBalanceTrackerConfig,
-  IBalanceTracker,
+  type BaseBalanceTrackerConfig,
+  type IBalanceTracker,
 } from "../interface";
-import { DurationInSeconds } from "../utils";
+import type { DurationInSeconds } from "../utils";
 import { PricePusherMetrics } from "../metrics";
-import { Logger } from "pino";
+import type { Logger } from "pino";
 
 /**
  * Aptos-specific configuration for balance tracker
@@ -103,6 +103,6 @@ export function createAptosBalanceTracker(
     updateInterval: params.updateInterval,
     metrics: params.metrics,
     logger: params.logger,
-    decimals: params.decimals,
+    decimals: params.decimals ?? 0,
   });
 }

+ 2 - 1
apps/price_pusher/src/aptos/command.ts

@@ -4,7 +4,7 @@ import { readPriceConfigFile } from "../price-config";
 import fs from "fs";
 import { PythPriceListener } from "../pyth-price-listener";
 import { Controller } from "../controller";
-import { Options } from "yargs";
+import type { Options } from "yargs";
 import {
   AptosPriceListener,
   AptosPricePusher,
@@ -128,6 +128,7 @@ export default {
       aptosListener,
       aptosPusher,
       logger.child({ module: "Controller" }, { level: controllerLogLevel }),
+      // @ts-expect-error - allegedly, this is safe to do here, despite having nullish typings
       {
         pushingFrequency,
         metrics,

+ 8 - 6
apps/price_pusher/src/controller.ts

@@ -1,8 +1,8 @@
-import { UnixTimestamp } from "@pythnetwork/hermes-client";
-import { DurationInSeconds, sleep } from "./utils";
-import { IPriceListener, IPricePusher } from "./interface";
-import { PriceConfig, shouldUpdate, UpdateCondition } from "./price-config";
-import { Logger } from "pino";
+import type { UnixTimestamp } from "@pythnetwork/hermes-client";
+import { type DurationInSeconds, sleep } from "./utils";
+import type { IPriceListener, IPricePusher } from "./interface";
+import { type PriceConfig, shouldUpdate, UpdateCondition } from "./price-config";
+import type { Logger } from "pino";
 import { PricePusherMetrics } from "./metrics";
 
 export class Controller {
@@ -21,7 +21,9 @@ export class Controller {
     },
   ) {
     this.pushingFrequency = config.pushingFrequency;
-    this.metrics = config.metrics;
+    if (config.metrics) {
+      this.metrics = config.metrics;
+    }
 
     // Set the number of price feeds if metrics are enabled
     this.metrics?.setPriceFeedsTotal(this.priceConfigs.length);

+ 2 - 1
apps/price_pusher/src/evm/command.ts

@@ -1,6 +1,6 @@
 import { HermesClient } from "@pythnetwork/hermes-client";
 import fs from "fs";
-import { Options } from "yargs";
+import type { Options } from "yargs";
 import * as options from "../options";
 import { readPriceConfigFile } from "../price-config";
 import { PythPriceListener } from "../pyth-price-listener";
@@ -196,6 +196,7 @@ export default {
       evmListener,
       evmPusher,
       logger.child({ module: "Controller" }, { level: controllerLogLevel }),
+      // @ts-expect-error - types aren't narrowed but this is, allegedly, safe
       {
         pushingFrequency,
         metrics,

+ 4 - 3
apps/price_pusher/src/evm/custom-gas-station.ts

@@ -1,11 +1,11 @@
 import {
-  CustomGasChainId,
-  TxSpeed,
+  type CustomGasChainId,
+  type TxSpeed,
   verifyValidOption,
   txSpeeds,
   customGasChainIds,
 } from "../utils";
-import { Logger } from "pino";
+import type { Logger } from "pino";
 import { parseGwei } from "viem";
 
 type chainMethods = Record<CustomGasChainId, () => Promise<bigint | undefined>>;
@@ -51,4 +51,5 @@ export function getCustomGasStation(
   if (customGasStation && txSpeed) {
     return new CustomGasStation(logger, customGasStation, txSpeed);
   }
+  return;
 }

+ 12 - 12
apps/price_pusher/src/evm/evm.ts

@@ -1,26 +1,26 @@
 import {
-  IPricePusher,
-  PriceInfo,
+  type IPricePusher,
+  type PriceInfo,
   ChainPriceListener,
-  PriceItem,
+  type PriceItem,
 } from "../interface";
 import {
   addLeading0x,
   assertDefined,
-  DurationInSeconds,
+  type DurationInSeconds,
   removeLeading0x,
 } from "../utils";
 import { PythAbi } from "./pyth-abi";
-import { Logger } from "pino";
+import type { Logger } from "pino";
 import {
   HermesClient,
-  HexString,
-  UnixTimestamp,
+  type HexString,
+  type UnixTimestamp,
 } from "@pythnetwork/hermes-client";
 import { CustomGasStation } from "./custom-gas-station";
-import { PushAttempt } from "../common";
+import type { PushAttempt } from "../common";
 import {
-  WatchContractEventOnLogsParameter,
+  type WatchContractEventOnLogsParameter,
   TransactionExecutionError,
   BaseError,
   ContractFunctionRevertedError,
@@ -30,8 +30,8 @@ import {
   ContractFunctionExecutionError,
 } from "viem";
 
-import { PythContract } from "./pyth-contract";
-import { SuperWalletClient } from "./super-wallet";
+import type { PythContract } from "./pyth-contract";
+import type { SuperWalletClient } from "./super-wallet";
 
 export class EvmPriceListener extends ChainPriceListener {
   constructor(
@@ -51,7 +51,7 @@ export class EvmPriceListener extends ChainPriceListener {
 
   // This method should be awaited on and once it finishes it has the latest value
   // for the given price feeds (if they exist).
-  async start() {
+  override async start() {
     if (this.watchEvents) {
       this.logger.info("Watching target network pyth contract events...");
       this.startWatching();

+ 21 - 9
apps/price_pusher/src/fuel/fuel.ts

@@ -1,12 +1,12 @@
 import { HermesClient } from "@pythnetwork/hermes-client";
 import {
   ChainPriceListener,
-  IPricePusher,
-  PriceInfo,
-  PriceItem,
+  type IPricePusher,
+  type PriceInfo,
+  type PriceItem,
 } from "../interface";
-import { addLeading0x, DurationInSeconds } from "../utils";
-import { Logger } from "pino";
+import { addLeading0x, type DurationInSeconds } from "../utils";
+import type { Logger } from "pino";
 import { Provider, Contract, hexlify, arrayify, Wallet, BN } from "fuels";
 import {
   PYTH_CONTRACT_ABI,
@@ -45,9 +45,13 @@ export class FuelPriceListener extends ChainPriceListener {
     try {
       const formattedPriceId = addLeading0x(priceId);
       const priceInfo = await this.contract.functions
-        .price_unsafe(formattedPriceId)
+        .price_unsafe?.(formattedPriceId)
         .get();
 
+      if (!priceInfo) {
+        throw new Error('priceInfo was not found');
+      }
+
       console.log({
         conf: priceInfo.value.confidence.toString(),
         price: priceInfo.value.price.toString(),
@@ -91,7 +95,7 @@ export class FuelPricePusher implements IPricePusher {
   async updatePriceFeed(
     priceIds: string[],
     // eslint-disable-next-line @typescript-eslint/no-unused-vars
-    pubTimesToPush: number[],
+    _: number[],
   ): Promise<void> {
     if (priceIds.length === 0) {
       return;
@@ -113,16 +117,24 @@ export class FuelPricePusher implements IPricePusher {
 
     try {
       const updateFee = await this.contract.functions
-        .update_fee(updateData)
+        .update_fee?.(updateData)
         .get();
 
+        if (!updateFee) {
+          throw new Error('updateFee is nullish');
+        }
+
       const result = await this.contract.functions
-        .update_price_feeds(updateData)
+        .update_price_feeds?.(updateData)
         .callParams({
           forward: [updateFee.value, hexlify(FUEL_ETH_ASSET_ID)],
         })
         .call();
 
+      if (!result) {
+        throw new Error('result is nullish');
+      }
+
       this.logger.info(
         { transactionId: result.transactionId },
         "updatePriceFeed successful",

+ 1 - 1
apps/price_pusher/src/interface.ts

@@ -152,7 +152,7 @@ export abstract class BaseBalanceTracker implements IBalanceTracker {
 
   private async startUpdateLoop(): Promise<void> {
     // We're using dynamic import to avoid circular dependencies
-    const { sleep } = await import("./utils");
+    const { sleep } = await import("./utils.js");
 
     // Run in a loop to regularly update the balance
     for (;;) {

+ 2 - 2
apps/price_pusher/src/metrics.ts

@@ -1,6 +1,6 @@
 import { Registry, Counter, Gauge } from "prom-client";
 import express from "express";
-import { Logger } from "pino";
+import type { Logger } from "pino";
 import { UpdateCondition } from "./price-config";
 
 // Define the metrics we want to track
@@ -86,7 +86,7 @@ export class PricePusherMetrics {
     });
 
     // Setup the metrics endpoint
-    this.server.get("/metrics", async (req, res) => {
+    this.server.get("/metrics", async (_, res) => {
       res.set("Content-Type", this.registry.contentType);
       res.end(await this.registry.metrics());
     });

+ 4 - 3
apps/price_pusher/src/solana/command.ts

@@ -1,4 +1,4 @@
-import { Options } from "yargs";
+import type { Options } from "yargs";
 import * as options from "../options";
 import { readPriceConfigFile } from "../price-config";
 import { PythPriceListener } from "../pyth-price-listener";
@@ -18,12 +18,12 @@ import {
   searcherClient,
 } from "jito-ts/dist/sdk/block-engine/searcher";
 import pino from "pino";
-import { Logger } from "pino";
+import type { Logger } from "pino";
 import { HermesClient } from "@pythnetwork/hermes-client";
 import { filterInvalidPriceItems } from "../utils";
 import { PricePusherMetrics } from "../metrics";
 import { createSolanaBalanceTracker } from "./balance-tracker";
-import { IBalanceTracker } from "../interface";
+import type { IBalanceTracker } from "../interface";
 
 export default {
   command: "solana",
@@ -263,6 +263,7 @@ export default {
       solanaPriceListener,
       solanaPricePusher,
       logger.child({ module: "Controller" }, { level: controllerLogLevel }),
+      // @ts-expect-error - types aren't narrowed but should be safe
       {
         pushingFrequency,
         metrics,

+ 6 - 6
apps/price_pusher/src/solana/solana.ts

@@ -1,11 +1,11 @@
 import { PythSolanaReceiver } from "@pythnetwork/pyth-solana-receiver";
 import {
   ChainPriceListener,
-  IPricePusher,
-  PriceInfo,
-  PriceItem,
+  type IPricePusher,
+  type PriceInfo,
+  type PriceItem,
 } from "../interface";
-import { DurationInSeconds } from "../utils";
+import type { DurationInSeconds } from "../utils";
 import { HermesClient } from "@pythnetwork/hermes-client";
 import {
   sendTransactions,
@@ -13,7 +13,7 @@ import {
 } from "@pythnetwork/solana-utils";
 import { SearcherClient } from "jito-ts/dist/sdk/block-engine/searcher";
 import { sliceAccumulatorUpdateData } from "@pythnetwork/price-service-sdk";
-import { Logger } from "pino";
+import type { Logger } from "pino";
 import { AddressLookupTableAccount, LAMPORTS_PER_SOL } from "@solana/web3.js";
 
 const HEALTH_CHECK_TIMEOUT_SECONDS = 60;
@@ -55,7 +55,7 @@ export class SolanaPriceListener extends ChainPriceListener {
     }
   }
 
-  async start() {
+  override async start() {
     // Frequently check the RPC connection to ensure it is healthy
     setInterval(this.checkHealth.bind(this), 5000);
 

+ 2 - 1
apps/price_pusher/src/sui/command.ts

@@ -4,7 +4,7 @@ import { readPriceConfigFile } from "../price-config";
 import fs from "fs";
 import { PythPriceListener } from "../pyth-price-listener";
 import { Controller } from "../controller";
-import { Options } from "yargs";
+import { type Options } from "yargs";
 import { SuiPriceListener, SuiPricePusher } from "./sui";
 import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";
 import pino from "pino";
@@ -170,6 +170,7 @@ export default {
       suiListener,
       suiPusher,
       logger.child({ module: "Controller" }, { level: controllerLogLevel }),
+      // @ts-expect-error - metrics is not narrowed to be truthy but should be safe to use
       {
         pushingFrequency,
         metrics,

+ 11 - 10
apps/price_pusher/src/sui/sui.ts

@@ -1,15 +1,15 @@
 import {
   ChainPriceListener,
-  IPricePusher,
-  PriceInfo,
-  PriceItem,
+  type IPricePusher,
+  type PriceInfo,
+  type PriceItem,
 } from "../interface";
-import { DurationInSeconds } from "../utils";
+import type { DurationInSeconds } from "../utils";
 import { SuiPythClient } from "@pythnetwork/pyth-sui-js";
 import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";
 import { Transaction } from "@mysten/sui/transactions";
-import { SuiClient, SuiObjectRef, PaginatedCoins } from "@mysten/sui/client";
-import { Logger } from "pino";
+import { SuiClient, type SuiObjectRef, type PaginatedCoins } from "@mysten/sui/client";
+import type { Logger } from "pino";
 import { HermesClient } from "@pythnetwork/hermes-client";
 const GAS_FEE_FOR_SPLIT = 2_000_000_000;
 // TODO: read this from on chain config
@@ -237,7 +237,7 @@ export class SuiPricePusher implements IPricePusher {
         const tx = new Transaction();
         await this.pythClient.updatePriceFeeds(
           tx,
-          [Buffer.from(vaa, "base64")],
+          [Buffer.from(vaa ?? '', "base64")],
           priceIdChunk,
         );
         txBlocks.push(tx);
@@ -428,8 +428,9 @@ export class SuiPricePusher implements IPricePusher {
       Array.from({ length: numGasObjects }, () => tx.pure.u64(splitAmount)),
     );
 
+    
     tx.transferObjects(
-      Array.from({ length: numGasObjects }, (_, i) => coins[i]),
+      Array.from({ length: numGasObjects }, (_, i) => coins[i]).filter((c): c is typeof coins[0] => c !== undefined),
       tx.pure.address(signerAddress),
     );
     tx.setGasPayment([gasCoin]);
@@ -463,7 +464,7 @@ export class SuiPricePusher implements IPricePusher {
     const gasCoins = await SuiPricePusher.getAllGasCoins(provider, owner);
     // skip merging if there is only one coin
     if (gasCoins.length === 1) {
-      return gasCoins[0];
+      return gasCoins[0]!;
     }
 
     const gasCoinsChunks = chunkArray<SuiObjectRef>(
@@ -475,7 +476,7 @@ export class SuiPricePusher implements IPricePusher {
     initialLockedAddresses.forEach((value) => lockedAddresses.add(value));
     for (let i = 0; i < gasCoinsChunks.length; i++) {
       const mergeTx = new Transaction();
-      let coins = gasCoinsChunks[i];
+      let coins = gasCoinsChunks[i] ?? [];
       coins = coins.filter((coin) => !lockedAddresses.has(coin.objectId));
       if (finalCoin) {
         coins = [finalCoin, ...coins];

+ 9 - 9
apps/price_pusher/src/ton/ton.ts

@@ -1,17 +1,17 @@
 import { HermesClient } from "@pythnetwork/hermes-client";
 import {
   ChainPriceListener,
-  IPricePusher,
-  PriceInfo,
-  PriceItem,
+  type IPricePusher,
+  type PriceInfo,
+  type PriceItem,
 } from "../interface";
-import { addLeading0x, DurationInSeconds } from "../utils";
-import { Logger } from "pino";
+import { addLeading0x, type DurationInSeconds } from "../utils";
+import { type Logger } from "pino";
 import {
   Address,
-  ContractProvider,
-  OpenedContract,
-  Sender,
+  type ContractProvider,
+  type OpenedContract,
+  type Sender,
   TonClient,
   WalletContractV4,
 } from "@ton/ton";
@@ -88,7 +88,7 @@ export class TonPricePusher implements IPricePusher {
   async updatePriceFeed(
     priceIds: string[],
     // eslint-disable-next-line @typescript-eslint/no-unused-vars
-    pubTimesToPush: number[],
+    _: number[],
   ): Promise<void> {
     if (priceIds.length === 0) {
       return;

+ 10 - 0
apps/price_pusher/tsconfig.build.json

@@ -0,0 +1,10 @@
+{
+  "extends": "./tsconfig.json",
+  "compilerOptions": {
+    "declaration": true,
+    "incremental": false,
+    "noEmit": false,
+    "verbatimModuleSyntax": false,
+  },
+  "exclude": ["dist", "node_modules"]
+}

+ 2 - 12
apps/price_pusher/tsconfig.json

@@ -1,15 +1,5 @@
 {
-  "extends": "../../tsconfig.base.json",
-  "compilerOptions": {
-    "target": "esnext",
-    "module": "commonjs",
-    "declaration": true,
-    "rootDir": "src/",
-    "outDir": "./lib",
-    "strict": true,
-    "esModuleInterop": true,
-    "resolveJsonModule": true
-  },
+  "extends": "@cprussin/tsconfig/nextjs.json",
   "include": ["src"],
-  "exclude": ["node_modules", "**/__tests__/*"]
+  "exclude": ["dist", "node_modules"]
 }

+ 3 - 0
pnpm-lock.yaml

@@ -1233,6 +1233,9 @@ importers:
         specifier: ^17.5.1
         version: 17.7.2
     devDependencies:
+      '@cprussin/tsconfig':
+        specifier: 'catalog:'
+        version: 3.1.2(typescript@5.9.3)
       '@types/ethereum-protocol':
         specifier: ^1.0.2
         version: 1.0.5

+ 33 - 8
target_chains/fuel/sdk/js/package.json

@@ -6,8 +6,8 @@
   "author": {
     "name": "Pyth Data Association"
   },
-  "main": "./dist/cjs/index.js",
-  "types": "./dist/esm/index.d.mts",
+  "main": "./cjs/index.js",
+  "types": "./cjs/index.d.ts",
   "files": [
     "lib/**/*",
     "dist/**/*"
@@ -58,13 +58,38 @@
     "pnpm": ">=10.19.0"
   },
   "packageManager": "pnpm@10.19.0",
-  "module": "./dist/esm/index.mjs",
+  "module": "./esm/index.js",
   "exports": {
-    ".": "./src/index.ts",
-    "./abi/pyth-contract-abi": "./src/abi/pyth-contract-abi.ts",
-    "./types": "./src/types/index.ts",
-    "./types/PythContract": "./src/types/PythContract.ts",
-    "./types/PythContractFactory": "./src/types/PythContractFactory.ts",
+    "./abi/pyth-contract-abi": {
+      "import": "./dist/esm/abi/pyth-contract-abi.js",
+      "types": "./dist/esm/abi/pyth-contract-abi.d.ts",
+      "require": "./dist/cjs/abi/pyth-contract-abi.js"
+    },
+    "./examples/usage": {
+      "import": "./dist/esm/examples/usage.js",
+      "types": "./dist/esm/examples/usage.d.ts",
+      "require": "./dist/cjs/examples/usage.js"
+    },
+    ".": {
+      "import": "./dist/esm/index.js",
+      "types": "./dist/esm/index.d.ts",
+      "require": "./dist/cjs/index.js"
+    },
+    "./types/PythContract": {
+      "import": "./dist/esm/types/PythContract.js",
+      "types": "./dist/esm/types/PythContract.d.ts",
+      "require": "./dist/cjs/types/PythContract.js"
+    },
+    "./types/PythContractFactory": {
+      "import": "./dist/esm/types/PythContractFactory.js",
+      "types": "./dist/esm/types/PythContractFactory.d.ts",
+      "require": "./dist/cjs/types/PythContractFactory.js"
+    },
+    "./types": {
+      "import": "./dist/esm/types/index.js",
+      "types": "./dist/esm/types/index.d.ts",
+      "require": "./dist/cjs/types/index.js"
+    },
     "./package.json": "./package.json"
   }
 }