import { Buffer } from "node:buffer"; import type { ClientWithCoreApi } from "@mysten/sui/client"; import type { Transaction } from "@mysten/sui/transactions"; import type { HexString } from "@pythnetwork/hermes-client"; type NestedTransactionResult = { $kind: "NestedResult"; NestedResult: [number, number]; }; export type ObjectId = string; /** * Any `@mysten/sui` v2 client exposes the unified `.core` API — this includes * both `SuiJsonRpcClient` (`@mysten/sui/jsonRpc`) and the experimental * `SuiGrpcClient` (`@mysten/sui/grpc`). `SuiPythClient` reads exclusively through * `.core` so it works transport-agnostically with either one. */ export type SuiPythClientProvider = ClientWithCoreApi; /** * The `.core` JSON view represents a nested Move struct as `{ type, fields }` * over JSON-RPC but flattens it to a plain field map over gRPC. Return the inner * field map for either shape so callers can read fields transport-agnostically. */ export declare function getStructFields(value: unknown): Record; export declare class SuiPythClient { provider: SuiPythClientProvider; pythStateId: ObjectId; wormholeStateId: ObjectId; private pythPackageId; private wormholePackageId; private priceTableInfo; private priceFeedObjectIdCache; private baseUpdateFee; constructor(provider: SuiPythClientProvider, pythStateId: ObjectId, wormholeStateId: ObjectId); getBaseUpdateFee(): Promise; /** * getPackageId returns the latest package id that the object belongs to. Use this to * fetch the latest package id for a given object id and handle package upgrades automatically. * @param objectId - the object id * @returns package id */ getPackageId(objectId: ObjectId): Promise; /** * Adds the commands for calling wormhole and verifying the vaas and returns the verified vaas. * @param vaas - array of vaas to verify * @param tx - transaction block to add commands to */ verifyVaas(vaas: Buffer[], tx: Transaction): Promise<({ NestedResult: [number, number]; $kind: "NestedResult"; } | undefined)[]>; verifyVaasAndGetHotPotato(tx: Transaction, updates: Buffer[], packageId: string): Promise; executePriceFeedUpdates(tx: Transaction, packageId: string, feedIds: HexString[], priceUpdatesHotPotato: any, coins: NestedTransactionResult[]): Promise; /** * Adds the necessary commands for updating the pyth price feeds to the transaction block. * @param tx - transaction block to add commands to * @param updates - array of price feed updates received from the price service * @param feedIds - array of feed ids to update (in hex format) */ updatePriceFeeds(tx: Transaction, updates: Buffer[], feedIds: HexString[]): Promise; /** * Updates price feeds using the coin input for payment. Coins can be generated by calling splitCoin on tx.gas. * @param tx - transaction block to add commands to * @param updates - array of price feed updates received from the price service * @param feedIds - array of feed ids to update (in hex format) * @param coins - array of Coins for payment of update operations */ updatePriceFeedsWithCoins(tx: Transaction, updates: Buffer[], feedIds: HexString[], coins: NestedTransactionResult[]): Promise; createPriceFeed(tx: Transaction, updates: Buffer[]): Promise; /** * Get the packageId for the wormhole package if not already cached */ getWormholePackageId(): Promise; /** * Get the packageId for the pyth package if not already cached */ getPythPackageId(): Promise; /** * Get the priceFeedObjectId for a given feedId if not already cached * @param feedId - the feed id */ getPriceFeedObjectId(feedId: HexString): Promise; /** * Fetches the price table object id for the current state id if not cached * @returns price table object id */ getPriceTableInfo(): Promise<{ id: ObjectId; fieldType: ObjectId; }>; /** * Obtains the vaa bytes embedded in an accumulator message. * @param accumulatorMessage - the accumulator price update message * @returns vaa bytes as a uint8 array */ extractVaaBytesFromAccumulatorMessage(accumulatorMessage: Buffer): Buffer; } export {};