Skip to content

Commit

Permalink
[FAB-5581] Misc corrrections and updates to the typings
Browse files Browse the repository at this point in the history
Change-Id: I30a6c8d549ba129936dd9f95fab82c43e77d0a6b
Signed-off-by: Kapil Sachdeva <[email protected]>
  • Loading branch information
ksachdeva committed Oct 10, 2017
1 parent 5d174cb commit c1db676
Showing 1 changed file with 46 additions and 23 deletions.
69 changes: 46 additions & 23 deletions fabric-client/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,6 @@ interface UserOptions {
cryptoContent: IdentityFiles | IdentityPEMs;
}

interface UserConfig {
enrollmentID: string;
name: string
roles?: string[];
affiliation?: string;
}

interface ICryptoSuite {
decrypt(key: ICryptoKey, cipherText: Buffer, opts: any): Buffer;
deriveKey(key: ICryptoKey): ICryptoKey;
Expand Down Expand Up @@ -172,10 +165,18 @@ interface ChaincodeInfo {
vscc: string;
}

interface ChannelInfo {
channel_id: string;
}

interface ChaincodeQueryResponse {
chaincodes: ChaincodeInfo[];
}

interface ChannelQueryResponse {
channels: ChannelInfo[];
}

interface OrdererRequest {
txId: TransactionId;
}
Expand Down Expand Up @@ -213,32 +214,23 @@ interface ProposalResponse {

type ProposalResponseObject = [Array<ProposalResponse>, Proposal, Header];

declare class User {
getName(): string;
getRoles(): string[];
setRoles(roles: string[]): void;
getAffiliation(): string;
setAffiliation(affiliation: string): void;
getIdentity(): IIdentity;
getSigningIdentity(): ISigningIdentity;
setCryptoSuite(suite: ICryptoSuite): void;
setEnrollment(privateKey: ICryptoKey, certificate: string, mspId: string): Promise<void>;
}

declare class Orderer {
}

declare class Peer {

setName(name: string): void;
getName(): string;
}

declare class EventHub {
connect(): void;
disconnect(): void;
getPeerAddr(): string;
setPeerAddr(url: string, opts: ConnectionOptions): void;
isConnected(): boolean;
isconnected(): boolean;
registerBlockEvent(onEvent: (b: any) => void, onError?: (err: Error) => void): number;
registerTxEvent(txId: string, onEvent: (txId: any, code: string) => void, onError?: (err: Error) => void): void;
unregisterTxEvent(txId: string): void;
}

declare class Channel {
Expand All @@ -252,9 +244,16 @@ declare class Channel {
sendTransactionProposal(request: ChaincodeInvokeRequest): Promise<ProposalResponseObject>;
sendTransaction(request: TransactionRequest): Promise<BroadcastResponse>;
queryByChaincode(request: ChaincodeQueryRequest): Promise<Buffer[]>;
queryBlock(blockNumber: number, target: Peer): Promise<any>;
queryTransaction(txId: string, target: Peer): Promise<any>;
queryInstantiatedChaincodes(target: Peer): Promise<ChaincodeQueryResponse>;
queryInfo(target: Peer): Promise<any>;
getOrderers(): Orderer[];
getPeers(): Peer[];
}

declare abstract class BaseClient {
static setLogger(logger: any): void;
static addConfigFile(path: string): void;
static getConfigSetting(name: string, default_value?: any): any;
static newCryptoSuite(): ICryptoSuite;
Expand All @@ -265,11 +264,33 @@ declare abstract class BaseClient {
}

declare class TransactionId {
getTransactionId(): string;
getTransactionID(): string;
}

interface UserConfig {
enrollmentID: string;
name: string
roles?: string[];
affiliation?: string;
}

declare class User {
isEnrolled(): boolean;
getName(): string;
getRoles(): string[];
setRoles(roles: string[]): void;
getAffiliation(): string;
setAffiliation(affiliation: string): void;
getIdentity(): IIdentity;
getSigningIdentity(): ISigningIdentity;
setCryptoSuite(suite: ICryptoSuite): void;
setEnrollment(privateKey: ICryptoKey, certificate: string, mspId: string): Promise<void>;
}

declare class Client extends BaseClient {
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;
Expand All @@ -281,7 +302,9 @@ declare class Client extends BaseClient {
createUser(opts: UserOptions): Promise<User>;
signChannelConfig(config: Buffer): ConfigSignature;
setStateStore(store: IKeyValueStore): void;
installChaincode(request: ChaincodeInstallRequest): Promise<ProposalResponse>;
installChaincode(request: ChaincodeInstallRequest): Promise<ProposalResponseObject>;
queryInstalledChaincodes(target: Peer): Promise<ChaincodeQueryResponse>;
queryChannels(target: Peer): Promise<ChannelQueryResponse>;
}

declare module 'fabric-client' {
Expand Down

0 comments on commit c1db676

Please sign in to comment.