How to use the fabric-contract-api.Contract.prototype function in fabric-contract-api

To help you get started, we’ve selected a few fabric-contract-api examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hyperledger / fabric-chaincode-node / libraries / fabric-shim / lib / contract-spi / chaincodefromcontract.js View on Github external
_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);