简体   繁体   中英

Hyperledger Composer - can't find transaction error

I am making a blockchain application using hyperledger composer and have written my cto, with on transaction, and the script file with no visible errors. However, when i try submit a transaction it returns this error: Error: Could not find any transactions to execute for org.evidence.net.evidenceDeposit.

Here is my CTO file:

namespace org.evidence.net

enum type {
  o storage
  o device
  o physical
  
}

enum status {
 o collected
 o stored
 o withdrawn
}

asset EvidenceItem identified by evidenceItemId {
  o String evidenceItemId
  o String caseNo
  o type Type
  o status Status
  o String optionalHash optional
  --> person Holder
}

abstract participant person identified by id {
  o String id
  o String firstName
  o String lastName
}

participant Investigator extends person {
  
}

participant EvidenceManager extends person {
  
}

participant FRT extends person {
  
}

transaction evidenceDeposit {
  --> EvidenceItem EvidenceItem
  --> EvidenceManager EvidenceManager
}

event FirstDeposit {
  o String evidenceItemId
  o String  id
}

And here is my script file:

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


/**
* Transfer evidence from FRT to Evidence Manager
* @param (org.evidence.net.evidenceDeposit} tx - the evidenceDeposit transaction
* @transaction
*/

const NS = 'org.evidence.net';


async function evidenceDeposit(tx) {
    // get asset registry for evidenceItem
  const evidenceItemRegistry = await getAssetRegistry(NS + '.evidenceItem');
  
  //Get participant registry for Evidence Manager
  const EvidenceManagerRegistry = await getParticipantRegistry(NS + '.EvidenceManager');
  
  const evidenceItem = await evidenceItemRegistry.get(tx.evidenceItem.getIdentifier());
    //Make sure that the evidenceItem exists
  
  if (!evidenceItem) {
    throw new Error(' Evidence with id ${tx.evidenceItem.getIdentifier()} does not exist');
    exit();
  }
  
  if (evidenceItem.status !== 'collected') {
    throw new Error('Evidence with id ${tx.evidenceItem.getIdentifier()} is not in collected status');
  }
  
  // Get Evidence Manager ID
  const EvidenceManagerID = tx.EvidenceManager.getIdentifier();
  
 //Make sure Evidence Manager exists
  const EvidenceManager = await EvidenceManagerRegistry.get(EvidenceManagerID);
  if(!EvidenceManager) {
    throw new Error('Evidence Manager with id ${EvidenceManagerID} does not exist');
  }
  
  //Update evidenceItem with new owner
  tx.evidenceItem.holder = tx.EvidenceManager;
  tx.evidenceItem.status = 'stored';
  
  //Update the asset in the asset registry
  await evidenceItemRegistry.update(tx.evidenceItem);
  
  //Create deposit event
  let FirstDepositEvent = getFactory().newEvent(NS, 'FirstDeposit');
  FirstDepositEvent.evidenceItemId = tx.evidenceItem.evidenceItemId;
  FirstDepositEvent.id = tx.EvidenceManager.id;
  
  // Emit the Event
  emit(FirstDepositEvent);
}

I have looked around and can't seem to find the problem. Any help is appreciated.

Please see the readme below as Hyperledger Composer has been deprecated for over a year. https://github.com/hyperledger/composer/blob/master/README.md

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM