Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_augmentMetadataFromCode(metadata) {
if (!metadata.$schema) {
metadata.$schema = 'https://fabric-shim.github.io/master/contract-schema.json';
}
if (!metadata.contracts || Object.keys(metadata.contracts).length === 0) {
logger.debug('_augmentMetadataFromCode - Contracts not supplied. Generating default');
const Contract = require('fabric-contract-api').Contract;
const skipNames = Object.getOwnPropertyNames(Contract.prototype);
metadata.contracts = JSON.parse(JSON.stringify(this.contractImplementations));
for (const contractKey in metadata.contracts) {
const contract = metadata.contracts[contractKey];
for (const instanceKey in contract.contractInstance) {
if (instanceKey.startsWith('_')) {
delete contract.contractInstance[instanceKey];
}
}
const impl = this.contractImplementations[contractKey].contractInstance;
contract.transactions = this._processContractTransactions(impl, skipNames);
contract.info = this._processContractInfo(impl);