Hyperledger Composer Playground 找不到我的交易功能
Hyperledger Composer Playground can not find my transaction function
我在尝试让我的交易在 Hyperledger composer playground 上运行时遇到问题。
我的 script.js 文件中有一个名为 CastVote 的函数,在我的模型文件中有一个名为 CastVote 的事务。每当我尝试提交交易时,似乎都无法在我的脚本文件中找到 CastVote 函数。我收到以下错误:
下面是我的代码:
模型文件:
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);
})
}
你拼错了transaction
,你输入了
* @transacation
什么时候应该
* @transaction
我在尝试让我的交易在 Hyperledger composer playground 上运行时遇到问题。
我的 script.js 文件中有一个名为 CastVote 的函数,在我的模型文件中有一个名为 CastVote 的事务。每当我尝试提交交易时,似乎都无法在我的脚本文件中找到 CastVote 函数。我收到以下错误:
下面是我的代码:
模型文件:
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);
})
}
你拼错了transaction
,你输入了
* @transacation
什么时候应该
* @transaction