@pythnetwork/pyth-sui-js
Version:
Pyth Network Sui Utilities
84 lines • 3.71 kB
TypeScript
import { SuiClient } from "@mysten/sui/client";
import { Transaction } from "@mysten/sui/transactions";
import { HexString } from "@pythnetwork/price-service-client";
import { Buffer } from "buffer";
type NestedTransactionResult = {
$kind: "NestedResult";
NestedResult: [number, number];
};
export type ObjectId = string;
export declare class SuiPythClient {
provider: SuiClient;
pythStateId: ObjectId;
wormholeStateId: ObjectId;
private pythPackageId;
private wormholePackageId;
private priceTableInfo;
private priceFeedObjectIdCache;
private baseUpdateFee;
constructor(provider: SuiClient, pythStateId: ObjectId, wormholeStateId: ObjectId);
getBaseUpdateFee(): Promise<number>;
/**
* 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
* @returns package id
*/
getPackageId(objectId: ObjectId): Promise<ObjectId>;
/**
* 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<{
$kind: "NestedResult";
NestedResult: [number, number];
}[]>;
verifyVaasAndGetHotPotato(tx: Transaction, updates: Buffer[], packageId: string): Promise<NestedTransactionResult>;
executePriceFeedUpdates(tx: Transaction, packageId: string, feedIds: HexString[], priceUpdatesHotPotato: any, coins: NestedTransactionResult[]): Promise<string[]>;
/**
* 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<ObjectId[]>;
/**
* 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<ObjectId[]>;
createPriceFeed(tx: Transaction, updates: Buffer[]): Promise<void>;
/**
* Get the packageId for the wormhole package if not already cached
*/
getWormholePackageId(): Promise<string>;
/**
* Get the packageId for the pyth package if not already cached
*/
getPythPackageId(): Promise<string>;
/**
* Get the priceFeedObjectId for a given feedId if not already cached
* @param feedId
*/
getPriceFeedObjectId(feedId: HexString): Promise<ObjectId | undefined>;
/**
* 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 {};
//# sourceMappingURL=client.d.ts.map