When I call a transaction named IntentForSale I get the 'Error: Invalid or missing identifier for Type PropertyListing in namespace org.example.property'
I have tried to change let propertyListing = factory.newResource(propertynamespace, 'Property', tx.PID); to let propertyListing = factory.newResource(propertynamespace, 'PropertyListing', tx.PID); and checked my model.cto.
Model.cto
/* This namespace helps in idetifying the entities for the network. */
namespace org.example.property
/* Asset Property identified by a striing PID
This is used to maintain the properties which are registered in the system.
*/
asset Property identified by PID {
o String PID
o String owner
o Integer mktprice
o String RegistrationDate
o String PropertyType
o String Location
o String Status default = "Registered"
o Boolean Public
o Boolean Private
o Boolean IntentOfSale
}
/* Asset PropertyListing identified by a striing PLID
This is used to maintain the properties which are listed for sale in the system.
*/
asset PropertyListing identified by PLID {
o String PLID
o String owner
o Integer mktprice
o String RegistrationDate
o String PropertyType
o String Location
o String Status default = "Intent Of Sale"
}
/* Participant Buyer identified by a striing Bname
This is used to maintain the buyers who are part of the system.
*/
participant Buyer identified by Bname {
o String Bname
o String Bemail
o Integer IdentityNo //Passport, SSN, Aadhar etc.
o String Bnkname
o String Bnkaddress
o Integer AccNo
o String IFSC
o Integer Balance
}
/* Participant Seller identified by a striing Sname
This is used to maintain the sellers who are part of the system.
*/
participant Seller identified by Sname {
o String Sname
o String Semail
o Integer IdentityNo
o String Bnkname
o String Bnkaddress
o Integer AccNo
o String IFSC
o Integer Balance
o String SaleDeedDocs
}
/* Participant Registrar identified by a striing Rname
This is used to maintain the registrar who are part of the system.
*/
participant Registrar identified by Rname {
o String Rname
o String Remail
}
/* Transaction Created
This is used to add new properties in the system.
*/
transaction Created {
o String PID
--> Property cproperty
}
transaction Registered {
o String PID
--> PropertyListing rpropertylisting
--> Buyer rbuyer
}
transaction IntentForSale {
--> Property iproperty
--> PropertyListing ipropertylisting
--> Seller iseller
}
Script.js
/**
* Transaction Created to put the property for sale in the system
* @param {org.example.property.IntentForSale} tx
* @transaction
*/
async function IntentForSale(tx){
console.log('Property IntentForSale Transaction');
//Getting the namespace and factory
const propertynamespace = 'org.example.property';
const factory = getFactory();
//Putting the property for sale
let propertyListing = factory.newResource(propertynamespace, 'PropertyListing', tx.PLID);
propertyListing.owner = tx.iseller.Sname;
propertyListing.mktprice = tx.iproperty.mktprice;
propertyListing.RegistrationDate = tx.iproperty.RegistrationDate;
propertyListing.PropertyType = tx.iproperty.PropertyType;
propertyListing.Location = tx.iproperty.Location;
propertyListing.Status = tx.iproperty.Status;
//Get the asset registry
let registry = await getAssetRegistry('org.example.property.PropertyListing');
// save the property
await registry.add(propertyListing);
}
when I pass these
{
"$class": "org.example.property.IntentForSale",
"iproperty": "resource:org.example.property.Property#101",
"ipropertylisting": "resource:org.example.property.PropertyListing#102",
"iseller": "resource:org.example.property.Seller#shantanu"
}
click to see error screenshot it should give transaction successful
Look, in IntentForSale transcation model you don't have atributte PLID and you are passing this trough in transaction logic. I think that what you want to do create a new resource, you need to give some id to it. So is something like:
//Putting the property for sale
let propertyListing = factory.newResource(propertynamespace, 'PropertyListing', tx.transactionId);