/** * Blockchain interface wrapper for Sui network operations using the SuiGraphQLClient. * * All operations go through GraphQL, including transaction simulation via * `gqlClient.core.simulateTransaction`, which builds the transaction, resolves * gas, and simulates server-side. No JSON-RPC or gRPC client is used. */ import { SuiGraphQLClient } from "@mysten/sui/graphql"; import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions"; import { Network } from "../constants/index.js"; import { Constants } from "../constants/types.js"; import { MarketType, PositionType, PositionCapType } from "../utils/parsedTypes.js"; import { MarketGqlFields } from "../utils/queryTypes.js"; export interface GqlObject { address: string; contents?: T; } export interface EarliestTxInfo { digest: string; timestampMs: number; } export declare class Blockchain { network: Network; gqlClient: SuiGraphQLClient; constants: Constants; private initialSharedVersionCache; constructor(network: Network, graphqlUrl?: string); /** * Get an object's flattened `contents.json` (Move struct fields) by ID. * * Returns the address at the top level alongside `contents` so callers can * correlate the response with the queried id (mirrors `getOwnedObjectsOfType` * and dynamic-field helpers). */ getObject>(objectId: string): Promise | undefined>; /** * Get an object's raw owner metadata (currently only used for reading * `Shared.initialSharedVersion` for shared objects). */ private getObjectOwner; /** Batch get object contents by IDs. */ multiGetObjects>(objectIds: string[]): Promise>; /** * Paginated fetch of objects of `type` owned by `owner`. Returns * `{ address, contents }` tuples so callers can access both the object id * and its fields. */ getOwnedObjectsOfType>(owner: string, type: string): Promise[]>; /** * Source an exact-`amount` coin of `coinType` for spending, drawing from BOTH * the user's address balance (the accumulator) AND their `Coin` objects. */ getCoinObject(tx: Transaction, coinType: string, address: string, amount: bigint): import("@mysten/sui/transactions").TransactionResult; /** * Credit a `Coin` to `address`'s address balance (the accumulator) */ sendCoinToAddressBalance(tx: Transaction, coinType: string, address: string, coin: TransactionObjectArgument | string): void; /** * Fetch a single dynamic field under `parentId`. The name is BCS-encoded * and base64'd by callers of the convenience helpers below * (`getMarketQuery`, `getMarket`, `getPosition`). * * `address` is always the `Field` wrapper object's own address * (equivalent to the JSON-RPC `objectId` of the dynamic field). For * dynamic *object* fields (stored via `dynamic_object_field` / * `ObjectTable`) the child object's own address is exposed * separately as `childObjectAddress`; `valueJson` still carries the * unwrapped struct fields in both cases. */ private getDynamicField; /** * Paginated fetch of every dynamic field under `parentId`. Each entry * returns the `Field` wrapper object's own `address`, the decoded * `name` (with its Move type), and the unwrapped `valueJson`. For dynamic * *object* fields the child object's own address is exposed separately * as `childObjectAddress`; `valueJson` continues to carry the unwrapped * struct fields. * * `first` is intentionally omitted from the query so the service-side * default maximum page size is used on every page. Pagination continues * via `pageInfo.endCursor` until there are no more pages. */ getAllDynamicFields, K = unknown>(parentId: string): Promise<{ address: string; name: { type: string; json: K; }; valueJson: V | undefined; childObjectAddress?: string; }[]>; /** * Find the earliest (creation) transaction that affected `objectId` and * return its digest plus timestamp in ms since epoch. Used to order * position caps by creation time (replaces JSON-RPC's * `queryTransactionBlocks({ ChangedObject, order: "ascending" })`). */ getEarliestTxForObject(objectId: string): Promise; /** * Simulate a transaction via the GraphQL client's core API, which builds the * transaction, resolves gas, and simulates server-side. Returns the parsed * transaction effects (or undefined if effects are unavailable). */ simulateTransaction(tx: Transaction, sender: string): Promise; /** Estimate gas budget by simulating the transaction. */ getEstimatedGasBudget(tx: Transaction, sender: string): Promise; /** * Get the initial shared version of a shared object. Result is cached per * `objectId` since `initial_shared_version` never changes for a given * shared object. */ getInitialSharedVersion(objectId: string): Promise; /** Returns the raw (GraphQL-flattened) market fields for a given market id. */ getMarketQuery(marketId: number): Promise; getMarket(marketId: number): Promise; getAllMarkets(): Promise; /** * Get position by position ID (the object ID of the position itself, used * as the key inside the positions table). */ getPosition(positionId: string): Promise; /** Get all positions for a user by first reading position caps. */ getPositionsForUser(userAddress: string): Promise; getPositionFromPositionCapId(positionCapId: string): Promise; getPositionCapsForUser(userAddress: string): Promise; } //# sourceMappingURL=blockchain.d.ts.map