Skip to content

Commit

Permalink
FABN-1053: Rename contract namespace to name
Browse files Browse the repository at this point in the history
Change to parameter, JSDoc and TypeScript definitions for Network.getContract().

Change-Id: Ib9130d5b715660d48cba71345c65f642e3abdcd2
Signed-off-by: Mark S. Lewis <[email protected]>
  • Loading branch information
bestbeforetoday committed Dec 6, 2018
1 parent 18ba6d6 commit 55c8f55
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions fabric-network/lib/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,23 +152,23 @@ class Network {
/**
* Get an instance of a contract (chaincode) on the current network.
* @param {string} chaincodeId the chaincode identifier.
* @param {string} [namespace] optional namespace for the contract.
* @param {string} [name] name of the contract.
* @returns {module:fabric-network.Contract} the contract.
*/
getContract(chaincodeId, namespace = '') {
getContract(chaincodeId, name = '') {
logger.debug('in getContract');
if (!this.initialized) {
throw new Error('Unable to get contract as network has failed to initialize');
}
const key = `${chaincodeId}:${namespace}`;
const key = `${chaincodeId}:${name}`;
let contract = this.contracts.get(key);
if (!contract) {
contract = new Contract(
this,
chaincodeId,
this.gateway,
this.queryHandler,
namespace
name
);
this.contracts.set(key, contract);
}
Expand Down
2 changes: 1 addition & 1 deletion fabric-network/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class Gateway {

export class Network {
public getChannel(): Channel;
public getContract(chaincodeId: string, namespace?: string): Contract;
public getContract(chaincodeId: string, name?: string): Contract;
}

export class Contract {
Expand Down

0 comments on commit 55c8f55

Please sign in to comment.