当我调用名为IntentForSale的事务时,我得到“错误:名称空间org.example.property中Type PropertyListing的标识符无效或丢失”
我试图更改let propertyListing = factory.newResource(propertynamespace,'Property',tx.PID); 让propertyListing = factory.newResource(propertynamespace,'PropertyListing',tx.PID);并检查了我的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);
}
当我通过这些
{
"$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 它应该使交易成功