Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_resolveContractImplementations(contractClasses) {
logger.debug('Supplied contract classes', contractClasses);
this.defaultContractName = Reflect.getMetadata('fabric:default', global);
const Contract = require('fabric-contract-api').Contract;
const implementations = {};
for (const contractClass of contractClasses) {
const contract = new (contractClass);
if (!(Contract._isContract(contract))) {
throw new Error(`invalid contract instance ${JSON.stringify(contract)}`);
}
const name = contract.getName();
if (!this.defaultContractName) {
this.defaultContractName = name;
contract.default = true;
} else if (this.defaultContractName === contract.getName()) {
contract.default = true;
}
implementations[name] = {name, contractInstance: contract};
}
return implementations;
}