Guest User

Untitled

a guest
Apr 17th, 2018
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. async function teste() {
  2. var namespace = 'br.com.synapsetec';
  3. var producerType = 'Producer';
  4. var producerNS = namespace + '.' + producerType;
  5. const AdminConnection = require('composer-admin').AdminConnection;
  6. const BusinessNetworkConnection = require('composer-client').BusinessNetworkConnection;
  7. const cardStore = require('composer-common').NetworkCardStoreManager.getCardStore();
  8. const { IdCard } = require('composer-common');
  9.  
  10. businessNetworkConnection = new BusinessNetworkConnection({ cardStore: cardStore });
  11.  
  12. await businessNetworkConnection.connect('admin@my-network');
  13.  
  14. factory = businessNetworkConnection.getBusinessNetwork().getFactory();
  15.  
  16. const producerRegistry = await businessNetworkConnection.getParticipantRegistry(producerNS);
  17.  
  18. const alice = factory.newResource(namespace, producerType, 'alice3@email.com');
  19.  
  20. await producerRegistry.add(alice);
  21.  
  22. let identity = await businessNetworkConnection.issueIdentity(producerNS + '#alice3@email.com', 'alice3');
  23.  
  24. const connectionProfile = {
  25. "name": "my-network",
  26. "x-type": "hlfv1"
  27. };
  28.  
  29. adminConnection = new AdminConnection({ cardStore: cardStore });
  30.  
  31. const metadata = {
  32. userName: identity.userID,
  33. version: 1,
  34. enrollmentSecret: identity.userSecret,
  35. businessNetwork: 'my-network'
  36. };
  37. const card = new IdCard(metadata, connectionProfile);
  38. await adminConnection.importCard('alice@my-network', card);
  39. console.log('ok');
  40. }
  41.  
  42. teste();
Add Comment
Please, Sign In to add comment