Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function _evaluateTransaction(org, chaincode, network_config){
const ccp = network_config['common-connection-profile'];
const orgConfig = ccp.organizations[org];
const cert = common.readAllFiles(orgConfig.signedCertPEM)[0];
const key = common.readAllFiles(orgConfig.adminPrivateKeyPEM)[0];
const inMemoryWallet = new InMemoryWallet();
const gateway = new Gateway();
try {
await inMemoryWallet.import('admin', X509WalletMixin.createIdentity(orgConfig.mspid, cert, key));
const opts = {
wallet: inMemoryWallet,
identity: 'admin',
discovery: { enabled: false }
};
await gateway.connect(ccp, opts);
const network = await gateway.getNetwork(chaincode.channelId)
const contract = await network.getContract(chaincode.chaincodeId);
async function _submitTransaction(org, chaincode, network_config){
const ccp = network_config['common-connection-profile'];
const orgConfig = ccp.organizations[org];
const cert = common.readAllFiles(orgConfig.signedCertPEM)[0];
const key = common.readAllFiles(orgConfig.adminPrivateKeyPEM)[0];
const inMemoryWallet = new InMemoryWallet();
const gateway = new Gateway();
try {
await inMemoryWallet.import('admin', X509WalletMixin.createIdentity(orgConfig.mspid, cert, key));
const opts = {
wallet: inMemoryWallet,
identity: 'admin',
discovery: { enabled: false }
};
await gateway.connect(ccp, opts);
const network = await gateway.getNetwork(chaincode.channelId)
const contract = await network.getContract(chaincode.chaincodeId);
_prepareWallet() {
if (this.configUseGateway || this.fileWalletPath) {
if (this.fileWalletPath) {
logger.info(`Using defined file wallet path ${this.fileWalletPath}`);
this.wallet = new FabricNetworkAPI.FileSystemWallet(this.fileWalletPath);
} else {
logger.info('Creating new InMemoryWallet to persist user identities');
this.wallet = new FabricNetworkAPI.InMemoryWallet();
}
}
}