Hyperledger Composer Playground找不到我的交易功能

问题描述 投票:0回答:1

我在使我的交易在Hyperledger作曲家游乐场上工作时遇到问题。

我的script.js文件中有一个名为CastVote的函数,而模型文件中有一个名为CastVote的事务。每当我尝试提交事务时,似乎都无法在我的脚本文件中找到CastVote函数。我收到以下错误:

enter image description here

下面是我的代码:

模型文件:

namespace org.example.tasweetx

asset Vote identified by voteID {
  o String voteID
  o String voterID
  o String candidateID

}


participant Voter identified by voterID {

  o String voterID
  o String voterFirstName
  o String voterLastName
  o String voterEmail
  o String voterEmiratesID

}

participant Candidate identified by candidateID {

  o String candidateID
  o String candidateFirstName
  o String candidateLastName
  o Integer voteCount

}

transaction CastVote {

  --> Voter voter
  --> Candidate candidate
}

脚本文件:

/**
 * 
 * @param {org.example.tasweetx.CastVote} transacation Function to handle vote casting and incrementing candidate vote count
 * @transacation
 */
function CastVote(transacation) {

  if(voter.voted == false) {
        voter.voted == true;
        IncrementVoteCount(transacation)

        return getAssetRegistry('org.example.tasweetx.Candidate')
            .then(function (assetRegistry){

                return assetRegistry.update(voteCount);
            })
    } else {
        throw new Error('You have already voted!');
    }
 }

 function IncrementVoteCount(transacation) {

     candidate.voteCount += 1;

     return getAssetRegistry('org.example.tasweetx.Candidate')
        .then(function (assetRegistry) {
            return assetRegistry.update(voteCount);
        })

 }
hyperledger-composer
1个回答
0
投票

您输入的transaction拼写有误

 * @transacation

应该的时候

 * @transaction
© www.soinside.com 2019 - 2024. All rights reserved.