"Error: Could not find any functions to execute for transaction"

"Error: Could not find any functions to execute for transaction"

我正在构建一个网络,允许 "Hospitals" 使用他们的 public 键和数据哈希将自己添加到 "patient" 资产中的数组,但是当我测试它时它给了我

Error: Could not find any functions to execute for transaction

我正在使用在线作曲家游乐场,这是我第一次建立网络。我认为在这个网络中,我需要参与者、资产和交易,我将患者设置为具有一系列医院的资产,PatientHospital 是具有数据哈希和 public 密钥的参与者,一个交易,和这个交易调用的一个函数,我不知道哪里错了,但是当我测试时,它返回了以下错误:

"TypeError: Cannot read property 'state' of undefined"

"Error: Could not find any functions to execute for transaction >org.acme.patientchain.AddHospitalToPatient#bdd6ca0b-d0d9-4003-b6c3-05b818b3fc96"

我也尝试将 PatientHospital 设置为资产而不是参与者,但仍然出现同样的错误。

如何解决这个问题?

我的 model.cto 文件:

namespace org.acme.patientchain
 asset Patient identified by pubKeyPatient {
  o String pubKeyPatient
  o PatientHospital[] hospitals
}

participant PatientHospital identified by pubKeyHospital {
  o String pubKeyHospital
  o String dataHash
 // --> Hospital hospital
}

transaction AddHospitalToPatient {
  --> Patient patient
  o PatientHospital newHospital

 }

我的js文件中的函数:

function addHospitalToPatient(AddHospitalToPatient){
 AddHospitalToPatient.patient.hospitals.push(AddHospitalToPatient.newHospital);
  return getAssetRegistry('org.acme.patientchain.Patient')
  .then(function (assetRegistry) {
    return assetRegistry.update(patient.hospitals);
  });

}

根据我的理解,您需要更新一个Patientasset新值PatientHospital 参与者

logic.js 变化:

async function addHospitalToPatient(AddHospitalToPatient){
 AddHospitalToPatient.patient.hospitals.push(AddHospitalToPatient.newHospital);
  return getAssetRegistry('org.acme.patientchain.Patient')
  .then(function (assetRegistry) {
    return assetRegistry.update(AddHospitalToPatient.patient);
  });
}