How to use composer-common - 10 common examples

To help you get started, we’ve selected a few composer-common 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 rddill-IBM / ZeroToBlockchain / Chapter06 / controller / restapi / features / composer / autoLoad.js View on Github external
.then((result) => {
                                    console.log('_arr[_idx].id: '+_arr[_idx].id);
                                    console.log('result.userID: '+result.userID);
                                    let _mem = _arr[_idx];
                                    _mem.secret = result.userSecret;
                                    _mem.userID = result.userID;
                                    memberTable.push(_mem);
                                    // svc.saveMemberTable(memberTable);
                                    let _meta = {};
                                    for (each in config.composer.metaData)
                                    {(function(_idx, _obj) {_meta[_idx] = _obj[_idx]; })(each, config.composer.metaData); }
                                    _meta.businessNetwork = config.composer.network;
                                    _meta.userName = result.userID;
                                    _meta.enrollmentSecret = result.userSecret;
                                    config.connectionProfile.keyValStore = _home+config.connectionProfile.keyValStore;
                                    let tempCard = new hlc_idCard(_meta, config.connectionProfile);
                                    return adminConnection.importCard(result.userID, tempCard)
                                    .then ((_res) => {
                                        if (_res) {console.log('card updated');} else {console.log('card imported');}
                                    })
                                    .catch((error) => {
                                            console.error('adminConnection.importCard failed. ',error.message);
                                        });
                                })
                                .catch((error) => {
github rddill-IBM / ZeroToBlockchain / Chapter12 / controller / restapi / features / composer / autoLoad.js View on Github external
.then((result) => {
                                    console.log('_arr[_idx].id: '+_arr[_idx].id);
                                    console.log('result.userID: '+result.userID);
                                    let _mem = _arr[_idx];
                                    _mem.secret = result.userSecret;
                                    _mem.userID = result.userID;
                                    memberTable.push(_mem);
                                    // svc.saveMemberTable(memberTable);
                                    let _meta = {};
                                    for (each in config.composer.metaData)
                                    {(function(_idx, _obj) {_meta[_idx] = _obj[_idx]; })(each, config.composer.metaData); }
                                    _meta.businessNetwork = config.composer.network;
                                    _meta.userName = result.userID;
                                    _meta.enrollmentSecret = result.userSecret;
                                    config.connectionProfile.keyValStore = _home+config.connectionProfile.keyValStore;
                                    let tempCard = new hlc_idCard(_meta, config.connectionProfile);
                                    return adminConnection.importCard(result.userID, tempCard)
                                        .then ((_res) => {
                                            if (_res) {console.log('card updated');} else {console.log('card imported');}
                                        })
                                        .catch((error) => {
                                            console.error('adminConnection.importCard failed. ',error.message);
                                        });
                                })
                                .catch((error) => {
github accordproject / concerto / packages / composer-runtime / lib / registrymanager.js View on Github external
* distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

'use strict';

const AssetDeclaration = require('composer-common').AssetDeclaration;
const EventEmitter = require('events');
const Logger = require('composer-common').Logger;
const ParticipantDeclaration = require('composer-common').ParticipantDeclaration;
const TransactionDeclaration = require('composer-common').TransactionDeclaration;
const Registry = require('./registry');

const LOG = Logger.getLog('RegistryManager');

// Do not add additional types to these constants. All system types are assets.
const TYPE_MAP = {
    Asset : 'AssetRegistry',
    Participant : 'ParticipantRegistry',
    Transaction : 'TransactionRegistry',
    Network : 'Network'
};

// This is a list of non-abstract system types that we do not want registries created for.
const VIRTUAL_TYPES = [
    'Network'
];

/**
 * A class for managing and persisting registries.
github accordproject / concerto / packages / composer-connector-proxy / lib / proxybusinessnetworkcardstore.js View on Github external
Object.keys(result).forEach((key) => {
                            let cardProperties = result[key];
                            let idCard = new IdCard(cardProperties.metadata, cardProperties.connectionProfile);
                            idCard.setCredentials(cardProperties.credentials);
                            resultMap.set(key, idCard);
                        });
                        LOG.exit(method, resultMap);
github accordproject / concerto / packages / composer-connector-server / lib / connectorserver.js View on Github external
businessNetworkCardStorePut (cardName, cardProperties, callback) {
        const method = 'businessNetworkCardStorePut';
        LOG.entry(method, cardName, cardProperties);
        let card = new IdCard(cardProperties.metadata, cardProperties.connectionProfile);
        card.setCredentials(cardProperties.credentials);
        return this.businessNetworkCardStore.put(cardName, card)
            .then((result) => {
                callback(null, result);
                LOG.exit(method, result);
            })
            .catch((error) => {
                LOG.error(method, error);
                callback(ConnectorServer.serializerr(error));
                LOG.exit(method, null);
            });
    }
github accordproject / concerto / packages / composer-connector-proxy / lib / proxybusinessnetworkcardstore.js View on Github external
this.socket.emit('/api/businessNetworkCardStoreGet', cardName, (error, result) => {
                        if (error) {
                            return reject(ProxyUtil.inflaterr(error));
                        }

                        let cardProperties = result;
                        let idCard = new IdCard(cardProperties.metadata, cardProperties.connectionProfile);
                        idCard.setCredentials(cardProperties.credentials);

                        LOG.exit(method, idCard);
                        resolve(idCard);
                    });
                });
github accordproject / concerto / packages / composer-playground / src / app / common / identity-card / identity-card.component.spec.ts View on Github external
it('should get one initial', () => {
            component['identity'] = new IdCard({
                userName: 'admin',
                businessNetwork: 'conga-network'
            }, {'name': 'dialup-modem', 'x-type': 'hlfv1'});

            fixture.detectChanges();

            let initialsElement = identityCardElement.query(By.css('.initials'));

            initialsElement.nativeElement.textContent.should.equal('a');
        });
github rddill-IBM / ZeroToBlockchain / Chapter05 / Documentation / answers / composer / hlcAdmin_complete.js View on Github external
exports.createCard = function(req, res, next) {
    let adminConnection = new AdminConnection();
    let _meta = {};
    for (let each in config.composer.metaData)
    {(function(_idx, _obj) {_meta[_idx] = _obj[_idx]; })(each, config.composer.metaData); }
    _meta.businessNetwork = config.composer.network;
    _meta.userName = req.body.id;
    _meta.enrollmentSecret = req.body.secret;
    config.connectionProfile.keyValStore = _home+config.connectionProfile.keyValStore;
    let tempCard = new hlc_idCard(_meta, config.connectionProfile);
    adminConnection.connect(config.composer.adminCard)
    .then(() => {
        return adminConnection.importCard(req.body.id, tempCard)
        .then ((_res) => { let _msg = ((_res) ? 'card updated' : 'card imported');
            console.log('create Card succeeded:'+_msg);
            res.send({'result': 'success', 'card': _msg});
        })
        .catch((error) => {
            console.error('adminConnection.importCard failed. ',error.message);
            res.send({'result': 'failed', 'error': error.message});
        });
    })
    .catch((error) => {
        console.error('adminConnection.connect failed. ',error.message);
        res.send({'result': 'failed', 'error': error.message});
    });
github rddill-IBM / ZeroToBlockchain / Chapter13 / controller / restapi / features / composer / autoLoad.js View on Github external
.then((_res) => {
                                    console.log(methodName+' svc.getThisMember('+_arr[_idx].id+') _res: ', _res);
                                    let member = JSON.parse(_res);
                                    let options = {};
                                    options.registry = member.type;
                                    let _meta = {};
                                    for (each in config.composer.metaData)
                                    {(function(_idx, _obj) {_meta[_idx] = _obj[_idx]; })(each, config.composer.metaData); }
                                    _meta.businessNetwork = config.composer.network;
                                    _meta.userName = member.id;
                                    _meta.enrollmentSecret = member.secret;
                                    console.log(methodName+' svc.getThisMember('+_arr[_idx].id+') _meta: ', _meta);
                                    let tempCard = new hlc_idCard(_meta, admin_connection);
                                    return adminConnection.importCard(member.id, tempCard)
                                    .then(() => {
                                        let currentMemberPath = path.join(basePath,member.id);
                                        fs.mkdirSync(currentMemberPath);
                                        for (let i=0; i<3; i++)
                                        {(function(_idx)
                                            {console.log(methodName+' looping on ['+_idx+'] is: '+member[CLIENT_DATA+_idx].name);
                                            let _path = path.join(basePath,member.id,member[CLIENT_DATA+_idx].name);
                                            fs.writeFileSync(_path, member[CLIENT_DATA+_idx].file);
                                            })(i)
                                        }
                                    })
                                    .catch((error) => {console.log(methodName+' adminConnection.importCard for '+member.id+' failed with error: ', error);})
                                })
                                .catch((_error) => {
github rddill-IBM / ZeroToBlockchain / Chapter13 / controller / restapi / features / composer / hlcAdmin.js View on Github external
exports.createCard = function(req, res, next) {
    let methodName = 'createCard';
    console.log(methodName+' entered for: ', req.body.id);
    let adminConnection = new AdminConnection();
    let _meta = {};
    for (let each in config.composer.metaData)
    {(function(_idx, _obj) {_meta[_idx] = _obj[_idx]; })(each, config.composer.metaData); }
    _meta.businessNetwork = config.composer.network;
    _meta.userName = req.body.id;
    _meta.enrollmentSecret = req.body.secret;
    let tempCard = new hlc_idCard(_meta, admin_connection);
    adminConnection.connect(config.composer.adminCard)
    .then(() => {
        return adminConnection.importCard(req.body.id, tempCard)
        .then ((_res) => { let _msg = ((_res) ? 'card updated' : 'card imported');
            console.log('create Card succeeded:'+_msg);
            let businessNetworkConnection = new BusinessNetworkConnection();
            return businessNetworkConnection.connect(req.body.id)
            .then(() => {
                return businessNetworkConnection.ping()
                .then((_msg) => { businessNetworkConnection.disconnect(); res.send({'result': 'success', 'card': _msg}); })
                .catch((error) => { console.log(methodName+' businessNetworkConnection.ping() failed. error: ',error); businessNetworkConnection.disconnect(); res.send({'result': 'failed', 'card': error});});
            })
            .catch((error) =>{ console.log(methodName+' businessNetworkConnection.connect('+req.body.id+') failed. error: ',error); res.send({'result': 'failed', 'card': error});});
        })
        .catch((error) => {
            console.error('adminConnection.importCard failed. ',error.message);

composer-common

Hyperledger Composer Common, code that is common across client, admin and runtime.

Apache-2.0
Latest version published 5 years ago

Package Health Score

45 / 100
Full package analysis

Popular composer-common functions