fixed assettransfer-ledgerqueries & private usage of commons util refactor

Signed-off-by: Sijo Cherian <sijo@ibm.com>
This commit is contained in:
Sijo Cherian 2020-08-12 23:21:44 -04:00
parent 7740ad6490
commit 207d3bf2ea
2 changed files with 15 additions and 13 deletions

View file

@ -10,10 +10,12 @@ const {Gateway, Wallets} = require('fabric-network');
const FabricCAServices = require('fabric-ca-client'); const FabricCAServices = require('fabric-ca-client');
const path = require('path'); const path = require('path');
const { buildCAClient, registerAndEnrollUser, enrollAdmin } = require('../../test-application/javascript/CAUtil.js'); const { buildCAClient, registerAndEnrollUser, enrollAdmin } = require('../../test-application/javascript/CAUtil.js');
const {buildCCP, buildWallet} = require('../../test-application/javascript/AppUtil.js'); const { buildCCPOrg1, buildWallet } = require('../../test-application/javascript/AppUtil.js');
const channelName = 'mychannel'; const channelName = 'mychannel';
const chaincodeName = 'ledger'; const chaincodeName = 'ledger';
const mspOrg1 = 'Org1MSP';
const walletPath = path.join(__dirname, 'wallet'); const walletPath = path.join(__dirname, 'wallet');
const userId = 'appUser'; const userId = 'appUser';
@ -78,21 +80,21 @@ async function main() {
try { try {
// build an in memory object with the network configuration (also known as a connection profile) // build an in memory object with the network configuration (also known as a connection profile)
const ccp = buildCCP(); const ccp = buildCCPOrg1();
// build an instance of the fabric ca services client based on // build an instance of the fabric ca services client based on
// the information in the network configuration // the information in the network configuration
const caClient = buildCAClient(FabricCAServices, ccp); const caClient = buildCAClient(FabricCAServices, ccp, 'ca.org1.example.com');
// setup the wallet to hold the credentials of the application user // setup the wallet to hold the credentials of the application user
const wallet = await buildWallet(Wallets, walletPath); const wallet = await buildWallet(Wallets, walletPath);
// in a real application this would be done on an administrative flow, and only once // in a real application this would be done on an administrative flow, and only once
await enrollAdmin(caClient, wallet); await enrollAdmin(caClient, wallet, mspOrg1);
// in a real application this would be done only when a new user was required to be added // in a real application this would be done only when a new user was required to be added
// and would be part of an administrative flow // and would be part of an administrative flow
await registerAndEnrollUser(caClient, wallet, userId, 'org1.department1'); await registerAndEnrollUser(caClient, wallet, mspOrg1, userId, 'org1.department1');
// Create a new gateway instance for interacting with the fabric network. // Create a new gateway instance for interacting with the fabric network.
// In a real application this would be done as the backend server session is setup for // In a real application this would be done as the backend server session is setup for

View file

@ -9,7 +9,7 @@
const { Gateway, Wallets } = require('fabric-network'); const { Gateway, Wallets } = require('fabric-network');
const FabricCAServices = require('fabric-ca-client'); const FabricCAServices = require('fabric-ca-client');
const path = require('path'); const path = require('path');
const { buildCAClient, registerUser, enrollAdmin } = require('../../test-application/javascript/CAUtil.js'); const { buildCAClient, registerAndEnrollUser, enrollAdmin } = require('../../test-application/javascript/CAUtil.js');
const { buildCCPOrg1, buildCCPOrg2, buildWallet } = require('../../test-application/javascript/AppUtil.js'); const { buildCCPOrg1, buildCCPOrg2, buildWallet } = require('../../test-application/javascript/AppUtil.js');
const myChannel = 'mychannel'; const myChannel = 'mychannel';
@ -52,7 +52,7 @@ async function initContractFromOrg1Identity() {
// and stores app user identity in local wallet // and stores app user identity in local wallet
// In a real application this would be done only when a new user was required to be added // In a real application this would be done only when a new user was required to be added
// and would be part of an administrative flow // and would be part of an administrative flow
await registerUser(caOrg1Client, walletOrg1, mspOrg1, Org1UserId, 'org1.department1'); await registerAndEnrollUser(caOrg1Client, walletOrg1, mspOrg1, Org1UserId, 'org1.department1');
try { try {
// Create a new gateway for connecting to Org's peer node. // Create a new gateway for connecting to Org's peer node.
@ -77,7 +77,7 @@ async function initContractFromOrg2Identity() {
const walletOrg2 = await buildWallet(Wallets, walletPathOrg2); const walletOrg2 = await buildWallet(Wallets, walletPathOrg2);
await enrollAdmin(caOrg2Client, walletOrg2, mspOrg2); await enrollAdmin(caOrg2Client, walletOrg2, mspOrg2);
await registerUser(caOrg2Client, walletOrg2, mspOrg2, Org2UserId, 'org2.department1'); await registerAndEnrollUser(caOrg2Client, walletOrg2, mspOrg2, Org2UserId, 'org2.department1');
try { try {
// Create a new gateway for connecting to Org's peer node. // Create a new gateway for connecting to Org's peer node.