import { ChainObject, ClassConstructor, DefaultError, Inferred, NotFoundError, RangedChainObject, ValidationFailedError } from "@gala-chain/api"; import { QueryResponseMetadata } from "fabric-shim"; import { GalaChainContext } from "../types"; export declare class ObjectNotFoundError extends NotFoundError { constructor(objectId: string); } export declare class NoObjectIdsError extends ValidationFailedError { constructor(); } export declare class InvalidResultsError extends DefaultError { constructor(messages: string[]); } /** * @description * * Validate the provided `ChainObject`, serialize it into an appropriate * format for on-chain storage, and queue a `putState` call in the `GalaChainStub`. * Will write the data to World State indexed by its composite key upon * successful transaction completeion. * * Throws `ObjectValidationFailedError` on validation failure. * * @remarks * See also `GalaChainStub` for details on caching and transactional writes * supported by this method. * * @param ctx * @param data * @returns */ export declare function putChainObject(ctx: GalaChainContext, data: ChainObject): Promise; /** * @description * * Validate the provided `RangedChainObject`, serialize it into an appropriate format * for on-chain storage, and queue a `putState` call in the `GalaChainStub`. * Will write the data to World State indexed by its simple key upon successful * transaction completion. * * @remarks * See also `GalaChainStub` for details on caching and transactional writes * supported by this method. * * @param ctx * @param data * @returns */ export declare function putRangedChainObject(ctx: GalaChainContext, data: RangedChainObject): Promise; /** * @description * * Queue a `deleteState` call in the `GalaChainStub` using the composite key * of the provided `ChainObject`. * * @remarks * See also `GalaChainStub` for details on caching and transactional writes * supported by this method. * * @param ctx * @param data * @returns */ export declare function deleteChainObject(ctx: GalaChainContext, data: ChainObject): Promise; /** * @description * * Query Chain Objects by Partial Composite Key. Refer to class definitions * for types that extend `ChainObject` to determine property names and order * of the `@ChainKey` composite parts. * * Non-paginated version. Use cases that expect large numbers of results * should use `getObjectsByPartialCompositeKeyWithPagination()` instead. * * @remarks * The `@ChainKeys` that make up the World State composite keys are ordered, * and cannot be skipped when making partial composite key queries. * Be advised that broad queries can lead * to performance issues for large result sets. * * @param ctx * @param objectType * @param attributes * @param constructor * @returns Array of Chain Objects deserialized using the provided constructor */ export declare function getObjectsByPartialCompositeKey(ctx: GalaChainContext, objectType: string, attributes: string[], constructor: ClassConstructor>): Promise>; /** * @description * * Query Chain Objects by Partial Composite Key. Refer to class definitions * for types that extend `ChainObject` to determine property names and order * of the `@ChainKey` composite parts. * * Paginated version. Use cases that expect large numbers of results * can use this method to page through results. Cannot be used in SUBMIT * transactions. * * @remarks * The `@ChainKeys` that make up the World State composite keys are ordered, * and cannot be skipped when making partial composite key queries. * Be advised that broad queries can lead * to performance issues for large result sets. Tune page size using the `limit` * property accordingly. * * @param ctx * @param objectType * @param attributes * @param constructor * @returns * Promise of an Object containing two properties: * results: Array of Chain Objects deserialized using the provided constructor, * metadata: QueryResponseMetadata */ export declare function getObjectsByPartialCompositeKeyWithPagination(ctx: GalaChainContext, objectType: string, attributes: string[], constructor: ClassConstructor>, bookmark: string | undefined, limit?: number): Promise<{ results: Array; metadata: QueryResponseMetadata; }>; /** * @description * * Fetch an object from on-chain World State by its key. * * The result will be deserialized and returned as an * instantiated class instance using the provided `constructor`. * * @remarks * * Reads from `GalaChainStub` if object has been read * previously during transaction execution. * * @param ctx * @param constructor * @param objectId */ export declare function getObjectByKey(ctx: GalaChainContext, constructor: ClassConstructor>, objectId: string): Promise; /** * @description * * Lookup a single ranged object by its key. `RangedChainObject` instances * use HyperLedger Fabric's simple key scheme and are indexed in World State * separately from the composite key namespace. * * The result will be deserialized and returned as an * instantiated class instance using the provided `constructor`. * * @remarks * Reads from `GalaChainStub` if object has been read * previously during transaction execution. * * @param ctx * @param constructor * @param objectId */ export declare function getRangedObjectByKey(ctx: GalaChainContext, constructor: ClassConstructor>, objectId: string): Promise; export declare function getPlainObjectByKey(ctx: GalaChainContext, objectId: string): Promise>; export declare function getObjectHistory(ctx: GalaChainContext, objectId: string): Promise<{ history: unknown[]; }>; /** * @description * * Gets objects by keys and returns them in the same order as in `projectIds` parameter. * If getting at least one object fails, throws an exception. */ export declare function getObjectsByKeys(ctx: GalaChainContext, constructor: ClassConstructor>, objectIds: Array): Promise>; /** * @description * * objectExists returns true when asset with given ID exists in world state. * Only use this function to check for existence. The stored data will not be * deserialized or returned. * * @param ctx * @param id * @returns `Promise` */ export declare function objectExists(ctx: GalaChainContext, id: string): Promise; //# sourceMappingURL=state.d.ts.map