Skip to content

Commit b5412b2

Browse files
UdhayakumariArchanaArige
authored andcommitted
Display correct chaincode metadata fix in the backend
Signed-off-by: Udhayakumari <[email protected]>
1 parent 35cc1c5 commit b5412b2

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

app/platform/fabric/Proxy.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -603,13 +603,13 @@ export class Proxy {
603603
* @returns
604604
* @memberof Proxy
605605
*/
606-
async getContractMetadata(network_id, contract_name) {
606+
async getContractMetadata(network_id, contract_name, channel_genesis_hash) {
607607
const client = this.platform.getClient(network_id);
608-
const channel_name = Object.keys(client.fabricGateway.config.channels)[0];
608+
const channel_name = client.getChannelNameByHash(channel_genesis_hash);
609609
let metadata;
610610
try {
611-
metadata = await client.fabricGateway.queryContractMetadata(channel_name, contract_name);
612-
} catch (e) {
611+
metadata = await client.fabricGateway.queryContractMetadata(channel_name, contract_name, channel_genesis_hash);
612+
} catch (e) {
613613
logger.debug('getContractMetadata >> ', e);
614614
} if (metadata) {
615615
return metadata;

app/rest/platformroutes.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,11 @@ export async function platformroutes(
260260
* GET /metadata
261261
* curl -i 'http://<host>:<port>/metadata/<chaincode>'
262262
*/
263-
router.get('/metadata/:chaincode', (req, res) => {
263+
router.get('/metadata/:channel_genesis_hash/:chaincode', (req, res) => {
264264
const chaincode = req.params.chaincode;
265-
if (chaincode) {
266-
proxy.getContractMetadata(req.network, chaincode).then((data: any) => {
265+
const channel_genesis_hash = req.params.channel_genesis_hash;
266+
if (chaincode && channel_genesis_hash) {
267+
proxy.getContractMetadata(req.network, chaincode, channel_genesis_hash).then((data: any) => {
267268
res.send({ status: 200, data: data });
268269
});
269270
} else {

0 commit comments

Comments
 (0)