Skip to content

Commit

Permalink
[FAB-8878] update type definitions for fabric-client
Browse files Browse the repository at this point in the history
Change-Id: I51bb191f1f293e28c457cbddea263519d78cf8d5
Signed-off-by: zhaochy <zhaochy_2015@hotmail.com>
  • Loading branch information
zhaochy1990 committed Mar 15, 2018
1 parent 9ad4356 commit b98458d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
47 changes: 25 additions & 22 deletions fabric-client/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

import { FabricCAServices } from 'fabric-ca-client';

declare enum Status {
UNKNOWN = 0,
SUCCESS = 200,
Expand Down Expand Up @@ -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> | User;
setUserContext(user: User, skipPersistence?: boolean): Promise<User>;
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<BroadcastResponse>;
createUser(opts: UserOptions): Promise<User>;
signChannelConfig(config: Buffer): ConfigSignature;
getStateStore(): IKeyValueStore;
setStateStore(store: IKeyValueStore): void;
installChaincode(request: ChaincodeInstallRequest): Promise<ProposalResponseObject>;
queryInstalledChaincodes(target: Peer): Promise<ChaincodeQueryResponse>;
queryChannels(target: Peer): Promise<ChannelQueryResponse>;
createChannel(request: ChannelRequest): Promise<BroadcastResponse>;
updateChannel(request: ChannelRequest): Promise<BroadcastResponse>;
queryChannels(peer: Peer, useAdmin: boolean): Promise<ChannelQueryResponse>;
queryInstalledChaincodes(peer: Peer, useAdmin: boolean): Promise<ChaincodeQueryResponse>;
installChaincode(request: ChaincodeInstallRequest, timeout: number): Promise<ProposalResponseObject>;
initCredentialStores(): Promise<boolean>;
loadFromConfig(config: any): void;
loadUserFromStateStore(name: string): Promise<User>;
saveUserToStateStore(): Promise<any>;
setStateStore(store: IKeyValueStore): void;
setAdminSigningIdentity(private_key: string, certificate: string, mspid: string): void;
updateChannel(request: ChannelRequest): Promise<BroadcastResponse>;

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<User>;
setUserContext(user: User, skipPersistence?: boolean): Promise<User>;
getUserContext(name: string, checkPersistence?: boolean): Promise<User> | User;
loadUserFromStateStore(name: string): Promise<User>;
getStateStore(): IKeyValueStore;
createUser(opts: UserOptions): Promise<User>;
}

declare module 'fabric-client' {
Expand Down
6 changes: 3 additions & 3 deletions fabric-client/lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ var Client = class extends BaseClient {
if(this._network_config.hasClient()) {
this._setAdminFromConfig();
}

}

/**
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit b98458d

Please sign in to comment.