import { ValidationError } from "class-validator"; import { UserAlias } from "./UserAlias"; import { UserRef } from "./UserRef"; import { GalaChainResponse } from "./contract"; type Base = T extends BaseT ? T : never; export type Inferred = T extends (infer U)[] ? Base : Base; export interface ClassConstructor { new (...args: unknown[]): T; } export declare const validateDTO: (dto: T) => Promise; /** * Parses JSON string and creates a Promise with valid DTO. Throws exception in case of validation errors. */ export declare const parseValidDTO: (constructor: ClassConstructor>, jsonStringOrObj: string | Record) => Promise; type NonFunctionPropertyNames = { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]; export type NonFunctionProperties = Pick>; export type SignablePromise = Promise & { signed(privateKey: string): SignablePromise; }; /** * Creates valid DTO object from provided plain object. * Throws exception in case of validation errors. */ export declare function createValidDTO(constructor: ClassConstructor, plain: NonFunctionProperties): SignablePromise; /** * Creates valid submit DTO object from provided plain object. * Throws exception in case of validation errors. * If the uniqueKey is not provided, it generates a random one: 32 random bytes in base64. */ export declare function createValidSubmitDTO(constructor: ClassConstructor, plain: Omit, "uniqueKey"> & { uniqueKey?: string; }): SignablePromise; /** * @description * * The base DTO (Data Transfer Object) class. Provides common properties and * methods for signing, uniqueness, validation, and serialization. All other DTOs in the * SDK extend from this base class. To implement custom a custom DTO, create a new class that * extends `ChainCallDTO`, and use the `class-validator` npm package to decorate * the properties of the new class. * * @remarks * * Additional details for specific properties of this class * are generated via the `class-validator-jsonschema` npm module and can either * be viewed in the source code * or in the OpenAPI documentation served alongside GalaChain's API endpoints. */ export declare class ChainCallDTO { uniqueKey?: string; prefix?: string; signerAddress?: UserRef; signerPublicKey?: string; signature?: string; multisig?: string[]; dtoOperation?: string; dtoExpiresAt?: number; validate(): Promise; validateOrReject(): Promise; /** * @description * * Serialze this object to string in a determinsitic fashion. * See Hyperledger Fabric's documentation on * [JSON Determinism](https://hyperledger-fabric.readthedocs.io/en/release-2.5/chaincode4ade.html#json-determinism) * for more details. * * @returns string */ serialize(): string; /** * @description * * Instantiate a class instance from a serialized object using the provided `ClassConstructor`. * * @param constructor * * `ClassConstructor` that extends `ChainCallDTO` * * @param object * * serialized string or plain object to be instantiated via the provided `ClassConstructor` * * @returns * * An instantiated class created with the provided `ClassConstructor` */ static deserialize(constructor: ClassConstructor>, object: string | Record | Record[]): T; getAllSignatures(): string[]; sign(privateKey: string, useDer?: boolean): void; /** * Creates a signed copy of current object. */ signed(privateKey: string, useDer?: boolean): this; expiresInMs(ms: number): this; withOperation(operation: string): this; withSigner(ref: UserRef): this; isSignatureValid(publicKey: string): boolean; } export declare class SubmitCallDTO extends ChainCallDTO { uniqueKey: string; } export declare class BatchOperationDto extends ChainCallDTO { method: string; dto: ChainCallDTO; } export declare class BatchDto extends ChainCallDTO { static readonly BATCH_SIZE_LIMIT: number; static readonly WRITES_DEFAULT_LIMIT: number; static readonly WRITES_HARD_LIMIT: number; writesLimit?: number; noPartialSuccess?: boolean; operations: BatchOperationDto[]; } export declare class ApplyRequestsDto extends SubmitCallDTO { maxRequests?: number; minDelayMs?: number; } export declare class HasPendingApplyRequestsDto extends ChainCallDTO { minDelayMs?: number; } /** * @description * * Input for the `GetObjectByKey` chaincode method defined on the GalaContract class. */ export declare class GetObjectDto extends ChainCallDTO { readonly objectId: string; } /** * @description * * Input for the `GetObjectByHistory` chaincode method defined on the GalaContract class. */ export declare class GetObjectHistoryDto extends ChainCallDTO { readonly objectId: string; } /** * @description * * Input for the `DryRun` chaincode method defined on the GalaContract class. * Use a `DryRunDto` and the `DryRun` chaincode method to simulate the * execution of a chaincode contract method. The results of the `DryRun` * will not be written chain. Instead, the Read/Write set that would have resulted from * the transaction will be returned to the consuming client for analysis. * * @remarks * * Authorization is not checked for `DryRun` execution. This allows application, * administrative, game server identities etc. to simulate a transaction result * without prompting the end user to sign the input first. This helps avoid * replay attacks (as the unique id would not be written to chain in a DryRun) * and also allows applications to present certain outcomes to the end user * before they decide to sign and authorize the transaction. * * Example use case: Executing a `DryRun` on a given method, and then processing * the results for `FeeChannelPaymentReceipt` or `FeeUserPaymentReceipt` objects * can yield the exepcted/estimated fee prior to executing a transaction. The * estimated fee can then be presented to an end user for them to decide whether * or not they want to authorize the transaction. */ export declare class DryRunDto extends ChainCallDTO { /** * @description * * The contract method intended for `DryRun` execution. * * @example * * "TransferToken" */ readonly method: string; /** * @description * * The identity used for the transaction simulation. */ readonly callerPublicKey?: string; /** * @description * * A input to be used for the `DryRun` execution. For example, if the * method to be `DryRun` is `TransferToken`, then a `TransferTokenDto` should * be provided here. */ dto?: ChainCallDTO; } /** * @description * * Data Transfer Object (DTO) representing the results of a successful `DryRun` execution, * to be sent back to the consuming client. */ export declare class DryRunResultDto extends ChainCallDTO { /** * @description * * The `GalaChainResponse` that would have occurred if the provided inputs had been * sent to the provided method, with a valid signature. */ response: GalaChainResponse; /** * @description * * The `writes` from the Hyperledger Fabric Read/Write set that would have been * written to chain, if the provided inputs had been sent to the provided method * with a valid signature. See the Hyperledger Fabric documentation on * [Valid Transactions](https://hyperledger-fabric.readthedocs.io/en/release-2.5/smartcontract/smartcontract.html#valid-transactions) * for more details on the importantce of Read/Write sets. */ writes: Record; /** * @description * * The `reads` from the Hyperledger Fabric Read/Write set that would have been * read from world state, if the provided inputs had been sent to the provided method * with a valid signature. See the Hyperledger Fabric documentation on * [Valid Transactions](https://hyperledger-fabric.readthedocs.io/en/release-2.5/smartcontract/smartcontract.html#valid-transactions) * for more details on the importantce of Read/Write sets. */ reads: Record; /** * @description * * The `deletes` from the Read/Write set that would have been deleted from * world state, if the provided inputs had been sent to the provided method with a * valid signature. See the Hyperledger Fabric documentation on * [Valid Transactions](https://hyperledger-fabric.readthedocs.io/en/release-2.5/smartcontract/smartcontract.html#valid-transactions) * for more details on the importantce of Read/Write sets. */ deletes: Record; } /** * @description * * Dto for secure method to save public keys for legacy users. * Method is called and signed by Curators */ export declare class RegisterUserDto extends SubmitCallDTO { /** * @description * * Id of user to save public key for. * Must be a valid user alias. See also @IsUserAlias(). */ user: UserAlias; publicKey?: string; publicKeySignature?: string; signers?: UserRef[]; signatureQuorum?: number; withPublicKeySignedBy(privateKey: string): this; } export declare class UpdatePublicKeyDto extends SubmitCallDTO { publicKey: string; publicKeySignature?: string; withPublicKeySignedBy(privateKey: string): this; } export declare class AddSignerDto extends SubmitCallDTO { signer: UserRef; } export declare class RemoveSignerDto extends SubmitCallDTO { signer: UserRef; } export declare class UpdateSignersDto extends SubmitCallDTO { toAdd?: UserRef[]; toRemove?: UserRef[]; } export declare class UpdateQuorumDto extends SubmitCallDTO { quorum: number; } export declare class UpdateUserRolesDto extends SubmitCallDTO { user: UserRef; roles: string[]; } export declare class GetPublicKeyDto extends ChainCallDTO { user?: UserRef; } export declare class GetMyProfileDto extends ChainCallDTO { signature: string; } export {}; //# sourceMappingURL=dtos.d.ts.map