import { CallOptions, ChannelInterface, ClientDuplexStream, ClientReadableStream, ClientUnaryCall, ClientWritableStream, Deadline, Metadata, requestCallback } from '@grpc/grpc-js'; import { ChaincodeEventsRequest, Commit, Proposal, Transaction } from '.'; import { BlockAndPrivateDataEventsRequest, BlockEventsRequest, FilteredBlockEventsRequest } from './blockeventsrequest'; import { GatewayGrpcClient } from './client'; import { Hash } from './hash/hash'; import { Identity } from './identity/identity'; import { Signer } from './identity/signer'; import { Network } from './network'; /** * Interface describing the public API of the gRPC [Client](https://grpc.github.io/grpc/node/grpc.Client.html) class, * used to provide better version-to-version type compatibility between gRPC releases. Application code should use a * concrete gRPC [Client](https://grpc.github.io/grpc/node/grpc.Client.html) instance. */ export interface GrpcClient { /** @internal */ close(): void; /** @internal */ getChannel(): ChannelInterface; /** @internal */ waitForReady(deadline: Deadline, callback: (error?: Error) => void): void; /** @internal */ makeUnaryRequest(method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, argument: RequestType, metadata: Metadata, options: CallOptions, callback: requestCallback): ClientUnaryCall; /** @internal */ makeUnaryRequest(method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, argument: RequestType, metadata: CallOptions | Metadata, callback: requestCallback): ClientUnaryCall; /** @internal */ makeUnaryRequest(method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, argument: RequestType, callback: requestCallback): ClientUnaryCall; /** @internal */ makeClientStreamRequest(method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, metadata: Metadata, options: CallOptions, callback: requestCallback): ClientWritableStream; /** @internal */ makeClientStreamRequest(method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, metadata: CallOptions | Metadata, callback: requestCallback): ClientWritableStream; /** @internal */ makeClientStreamRequest(method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, callback: requestCallback): ClientWritableStream; /** @internal */ makeServerStreamRequest(method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, argument: RequestType, metadata: Metadata, options?: CallOptions): ClientReadableStream; /** @internal */ makeServerStreamRequest(method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, argument: RequestType, options?: CallOptions): ClientReadableStream; /** @internal */ makeBidiStreamRequest(method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, metadata: Metadata, options?: CallOptions): ClientDuplexStream; /** @internal */ makeBidiStreamRequest(method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, options?: CallOptions): ClientDuplexStream; } /** * Options used when connecting to a Fabric Gateway. * @example * ```typescript * function defaultTimeout(): grpc.CallOptions { * return { * deadline: Date.now() + 5000, // 5 second timeout * }; * }; * const options: ConnectOptions { * identity: { * mspId: 'myorg', * credentials, * }, * signer: signers.newPrivateKeySigner(privateKey), * client: new grpc.Client('gateway.example.org:1337', grpc.credentials.createInsecure()), * evaluateOptions: defaultTimeout, * endorseOptions: defaultTimeout, * submitOptions: defaultTimeout, * commitStatusOptions: defaultTimeout, * }; * ``` */ export interface ConnectOptions { /** * A gRPC [Client](https://grpc.github.io/grpc/node/grpc.Client.html) connection to a Fabric Gateway. This should be * shared by all gateway instances connecting to the same Fabric Gateway. The client connection will not be closed * when the gateway is closed. */ client: GrpcClient; /** * Client identity used by the gateway. */ identity: Identity; /** * Signing implementation used to sign messages sent by the gateway. */ signer?: Signer; /** * Hash implementation used by the gateway to generate digital signatures. If this option is not specified, SHA-256 * is used by default. */ hash?: Hash; /** * SHA-256 hash of the TLS client certificate. This option is required only if mutual TLS authentication is used * for the gRPC connection to the Gateway peer. */ tlsClientCertificateHash?: Uint8Array; /** * Supplier of default gRPC [CallOptions](https://grpc.github.io/grpc/node/grpc.Client.html#~CallOptions) for * endorsements. */ endorseOptions?: () => CallOptions; /** * Supplier of default gRPC [CallOptions](https://grpc.github.io/grpc/node/grpc.Client.html#~CallOptions) for * evaluating transactions. */ evaluateOptions?: () => CallOptions; /** * Supplier of default gRPC [CallOptions](https://grpc.github.io/grpc/node/grpc.Client.html#~CallOptions) for * submit of transactions to the orderer. */ submitOptions?: () => CallOptions; /** * Supplier of default gRPC [CallOptions](https://grpc.github.io/grpc/node/grpc.Client.html#~CallOptions) for * retrieving transaction commit status. */ commitStatusOptions?: () => CallOptions; /** * Supplier of default gRPC [CallOptions](https://grpc.github.io/grpc/node/grpc.Client.html#~CallOptions) for * chaincode events. */ chaincodeEventsOptions?: () => CallOptions; /** * Supplier of default gRPC [CallOptions](https://grpc.github.io/grpc/node/grpc.Client.html#~CallOptions) for * block events. */ blockEventsOptions?: () => CallOptions; /** * Supplier of default gRPC [CallOptions](https://grpc.github.io/grpc/node/grpc.Client.html#~CallOptions) for * filtered block events. */ filteredBlockEventsOptions?: () => CallOptions; /** * Supplier of default gRPC [CallOptions](https://grpc.github.io/grpc/node/grpc.Client.html#~CallOptions) for * block and private data events. */ blockAndPrivateDataEventsOptions?: () => CallOptions; } /** * Connect to a Fabric Gateway using a client identity, gRPC connection and signing implementation. * @param options - Connection options. * @returns A connected gateway. */ export declare function connect(options: Readonly): Gateway; export interface InternalConnectOptions extends Omit { client: GatewayGrpcClient; } export declare function internalConnect(options: Readonly): Gateway; /** * Gateway represents the connection of a specific client identity to a Fabric Gateway. A Gateway is obtained using the * {@link connect} function. * * This type implements the Disposable interface, allowing instances to be disposed of with ECMAScript explicit * resource management and the `using` keyword instead of calling {@link close} directly. * * @see [ECMAScript explicit resource management](https://github.com/tc39/proposal-explicit-resource-management) */ export interface Gateway extends Disposable { /** * Get the identity used by this gateway. */ getIdentity(): Identity; /** * Get a network representing the named Fabric channel. * @param channelName - Fabric channel name. */ getNetwork(channelName: string): Network; /** * Create a proposal with the specified digital signature. Supports off-line signing flow. * @param bytes - Serialized proposal. * @param signature - Digital signature. * @returns A signed proposal. */ newSignedProposal(bytes: Uint8Array, signature: Uint8Array): Proposal; /** * Recreate a proposal from serialized data. * @param bytes - Serialized proposal. * @returns A proposal. */ newProposal(bytes: Uint8Array): Proposal; /** * Create a transaction with the specified digital signature. Supports off-line signing flow. * @param bytes - Serialized proposal. * @param signature - Digital signature. * @returns A signed transaction. */ newSignedTransaction(bytes: Uint8Array, signature: Uint8Array): Transaction; /** * Recreate a transaction from serialized data. * @param bytes - Serialized proposal. * @returns A transaction. */ newTransaction(bytes: Uint8Array): Transaction; /** * Create a commit with the specified digital signature, which can be used to access information about a * transaction that is committed to the ledger. Supports off-line signing flow. * @param bytes - Serialized commit status request. * @param signature - Digital signature. * @returns A signed commit status request. */ newSignedCommit(bytes: Uint8Array, signature: Uint8Array): Commit; /** * Recreate a commit status request from serialized data. * @param bytes - Serialized commit status request. * @returns A commit status request. */ newCommit(bytes: Uint8Array): Commit; /** * Create a chaincode events request with the specified digital signature. Supports off-line signing flow. * @param bytes - Serialized chaincode events request. * @param signature - Digital signature. * @returns A signed chaincode events request. */ newSignedChaincodeEventsRequest(bytes: Uint8Array, signature: Uint8Array): ChaincodeEventsRequest; /** * Recreate a chaincode events request from serialized data. * @param bytes - Serialized chaincode events request. * @returns A chaincode events request. */ newChaincodeEventsRequest(bytes: Uint8Array): ChaincodeEventsRequest; /** * Create a block events request with the specified digital signature. Supports off-line signing flow. * @param bytes - Serialized block events request. * @param signature - Digital signature. * @returns A signed block events request. */ newSignedBlockEventsRequest(bytes: Uint8Array, signature: Uint8Array): BlockEventsRequest; /** * Recreate a block events request from serialized data. * @param bytes - Serialized block events request. * @returns A block events request. */ newBlockEventsRequest(bytes: Uint8Array): BlockEventsRequest; /** * Create a filtered block events request with the specified digital signature. Supports off-line signing flow. * @param bytes - Serialized filtered block events request. * @param signature - Digital signature. * @returns A signed filtered block events request. */ newSignedFilteredBlockEventsRequest(bytes: Uint8Array, signature: Uint8Array): FilteredBlockEventsRequest; /** * Recreate a filtered block events request from serialized data. * @param bytes - Serialized filtered block events request. * @returns A filtered block events request. */ newFilteredBlockEventsRequest(bytes: Uint8Array): FilteredBlockEventsRequest; /** * Create a block and private data events request with the specified digital signature. Supports off-line signing * flow. * @param bytes - Serialized block and private data events request. * @param signature - Digital signature. * @returns A signed block and private data events request. */ newSignedBlockAndPrivateDataEventsRequest(bytes: Uint8Array, signature: Uint8Array): BlockAndPrivateDataEventsRequest; /** * Recreate a block and private data events request from serialized data. * @param bytes - Serialized block and private data events request. * @returns A block and private data events request. */ newBlockAndPrivateDataEventsRequest(bytes: Uint8Array): BlockAndPrivateDataEventsRequest; /** * Close the gateway when it is no longer required. This releases all resources associated with networks and * contracts obtained using the Gateway, including removing event listeners. */ close(): void; } export declare function assertDefined(value: T | null | undefined, message: string): T; //# sourceMappingURL=gateway.d.ts.map