From b98458d373f56a5e914eafbbd754b9f0b43ac4a1 Mon Sep 17 00:00:00 2001 From: zhaochy Date: Thu, 15 Mar 2018 16:23:45 +0800 Subject: [PATCH] [FAB-8878] update type definitions for fabric-client Change-Id: I51bb191f1f293e28c457cbddea263519d78cf8d5 Signed-off-by: zhaochy --- fabric-client/index.d.ts | 47 ++++++++++++++++++++----------------- fabric-client/lib/Client.js | 6 ++--- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/fabric-client/index.d.ts b/fabric-client/index.d.ts index 73f9463161..b1484cbfba 100644 --- a/fabric-client/index.d.ts +++ b/fabric-client/index.d.ts @@ -14,6 +14,8 @@ * limitations under the License. */ +import { FabricCAServices } from 'fabric-ca-client'; + declare enum Status { UNKNOWN = 0, SUCCESS = 200, @@ -420,38 +422,39 @@ declare abstract class BaseClient { declare class Client extends BaseClient { constructor(); static loadFromConfig(config: any): Client; + loadFromConfig(config: any): void; + setTlsClientCertAndKey(clientCert: string, clientKey: Buffer): void; + addTlsClientCertAndKey(opts: any): void; isDevMode(): boolean; - getUserContext(name: string, checkPersistence: boolean): Promise | User; - setUserContext(user: User, skipPersistence?: boolean): Promise; setDevMode(mode: boolean): void; - newOrderer(url: string, opts: ConnectionOptions): Orderer; newChannel(name: string): Channel; + getChannel(name?: string, throwError?: boolean): Channel; newPeer(url: string, opts: ConnectionOptions): Peer; newEventHub(): EventHub; + getEventHub(peer_name: string): EventHub; + getEventHubsForOrg(org_name: string): EventHub[]; + getPeersForOrg(org_name: string): Peer[]; + newOrderer(url: string, opts: ConnectionOptions): Orderer; + getCertificateAuthority(): FabricCAServices; + getClientConfig(): any; + getMspid(): string; newTransactionID(admin?: boolean): TransactionId; extractChannelConfig(envelope: Buffer): Buffer; - createChannel(request: ChannelRequest): Promise; - createUser(opts: UserOptions): Promise; signChannelConfig(config: Buffer): ConfigSignature; - getStateStore(): IKeyValueStore; - setStateStore(store: IKeyValueStore): void; - installChaincode(request: ChaincodeInstallRequest): Promise; - queryInstalledChaincodes(target: Peer): Promise; - queryChannels(target: Peer): Promise; + createChannel(request: ChannelRequest): Promise; + updateChannel(request: ChannelRequest): Promise; + queryChannels(peer: Peer, useAdmin: boolean): Promise; + queryInstalledChaincodes(peer: Peer, useAdmin: boolean): Promise; + installChaincode(request: ChaincodeInstallRequest, timeout: number): Promise; initCredentialStores(): Promise; - loadFromConfig(config: any): void; - loadUserFromStateStore(name: string): Promise; - saveUserToStateStore(): Promise; + setStateStore(store: IKeyValueStore): void; setAdminSigningIdentity(private_key: string, certificate: string, mspid: string): void; - updateChannel(request: ChannelRequest): Promise; - - getCertificateAuthority(): any; - getChannel(name?: string, throwError?: boolean): Channel; - getClientConfig(): any; - getEventHub(peer_name: string): EventHub; - getEventHubsForOrg(org_name: string): EventHub[]; - getMspid(): string; - getPeersForOrg(org_name: string): Peer[]; + saveUserToStateStore(): Promise; + setUserContext(user: User, skipPersistence?: boolean): Promise; + getUserContext(name: string, checkPersistence?: boolean): Promise | User; + loadUserFromStateStore(name: string): Promise; + getStateStore(): IKeyValueStore; + createUser(opts: UserOptions): Promise; } declare module 'fabric-client' { diff --git a/fabric-client/lib/Client.js b/fabric-client/lib/Client.js index 65227a5ecf..6ef3fe76d2 100644 --- a/fabric-client/lib/Client.js +++ b/fabric-client/lib/Client.js @@ -139,7 +139,6 @@ var Client = class extends BaseClient { if(this._network_config.hasClient()) { this._setAdminFromConfig(); } - } /** @@ -189,6 +188,7 @@ var Client = class extends BaseClient { /** * Set dev mode to true or false to reflect the mode of the fabric backend. See {@link Client#isDevMode} for details. + * @param {boolean} devMode */ setDevMode(devMode) { this._devMode = devMode; @@ -470,7 +470,7 @@ var Client = class extends BaseClient { /** * Returns the "client" section of the network configuration. * - * @returns {object} The cleint section from the configuration + * @returns {object} The client section from the configuration */ getClientConfig() { let result = null; @@ -1460,7 +1460,7 @@ var Client = class extends BaseClient { * attempt to check the state store for the requested user by the "name". If not * specified or falsey, the method is synchronous and returns the requested user from memory * @returns {Promise | User} Promise for the user object corresponding to the name, or null if the user does not exist or if the - * state store has not been set. If "checkPersistence" is not specified or falsey, then the user object + * state store has not been set. If "checkPersistence" is not specified or false, then the user object * is returned synchronously. */ getUserContext(name, checkPersistence) {