3

I am trying to change the value of the Participant using a transaction. It throws the error "Error: Object with ID 'Participant:com.test.participant' in collection with ID '$sysregistries' does not exist"

Please let me know what is the issue. Was there any change in the new version ??

Base cto :

namespace com.test.base

enum Gender {
 o MALE
 o FEMALE
 o OTHER
}

/**
 * A concept for a simple street address
 */
concept Address {
  o String address
  o Boolean isAddressValidated 
}

Participant CTO :

/**
 * New model file
 */

namespace com.test.participant
import com.test.base.*

abstract participant User{
  o  String lastname
 }

participant Customer identified by userId extends User {
  o String userId 
  o String fName
  o Address address
}

transaction ValidateAddress {
  o Boolean isAddressValidated
  --> Customer customer
}

Js file:

 /**
     * Sample transaction processor function.
     * @param {com.test.participant.ValidateAddress} tx The sample transaction instance.
     * @transaction
     */
    async function sampleTransaction(tx) { 
         tx.customer.address.isAddressValidated = tx.isAddressValidated;

        const participantRegistry = await getParticipantRegistry('com.test.participant','Costumer');
  await participantRegistry.update(tx.customer);

     }

Test values:

{
  "$class": "com.test.participant.Customer",
  "uId": "customer1",
  "fName": "Pradeep",
  "address": {
    "$class": "com.test.base.Address",
    "address": "",
    "isAddressValidated": false
  },
  "lastname": "P"
}

{
  "$class": "com.test.participant.ValidateAddress",
  "isAddressValidated": true,
  "customer": "resource:com.test.participant.Customer#customer1"
}

Download bna file as well in the link https://drive.google.com/file/d/1NQYELmLzMyuN2V4yvDhUoLWackjs18Fa/view?usp=sharing

  • think your problem is simple - your participant registry in your txn code is actually `const participantRegistry = await getParticipantRegistry('com.test.participant','Customer')` - that's why the registry error/complaint you posted appears – Paul O'Mahony Jun 07 '18 at 09:55

1 Answers1

2

I edited two things in you network definition, NOTE: I tested this on Hyperldger Playground and it worked

  1. Changed uId to userId in your test data
  2. Cleared Customer typos in your transactions code where you get your Participant registry.

So I came up with this code after all the changes

namespace com.test.base

enum Gender {
 o MALE
 o FEMALE
 o OTHER
}

/**
 * A concept for a simple street address
 */
concept Address {
  o String address
  o Boolean isAddressValidated  
}


/**
 * New model file
*/

namespace com.test.participant
import com.test.base.*

abstract participant User{
  o  String lastname
 }

participant Customer identified by userId extends User {
  o String userId 
  o String fName
  o Address address
}

transaction ValidateAddress {
  o Boolean isAddressValidated
  --> Customer customer
}

The test data looks as follows

{
  "$class": "com.test.participant.Customer",
  "userId": "customer1",
  "fName": "Pradeep",
  "address": {
    "$class": "com.test.base.Address",
    "address": "New York",
    "isAddressValidated": true
  },
  "lastname": "P"
}

For the transaction I did not change anything. I hope this helps

Mohale
  • 2,040
  • 3
  • 17
  • 18
  • Small spell mistake caused so much time :P. Can we have some plugin to catch hold this errors in future. Really helpful developers – Pradeep Padmarajaiah Jun 07 '18 at 10:29
  • you should use playground for testing, it helps avoid some error but not all. Also use Visual Studio Code Hyperledger Plugin – Mohale Jun 07 '18 at 10:31