hyperledger-composer 游乐场中的预期资源或概念
Expected Resource or Concept in hyperledger-composer playground
我在 playground hyperledger-composer 中说 "Expected Resource or Concept" 错误
两名参与者
1.学校
2. 公司
两项资产
1.成绩单
2. Transcript_status
一笔交易更新状态:
• 将学生的成绩单状态从未读更新为不感兴趣或感兴趣
参加学校、学生、公司
资产记录,Transcript_status
事务更新状态
- 学校创建参与学校
- 公司创建一个参与公司
- 学校创建资产成绩单
- 公司创建资产transcript_status
工作流程:创建学生资产(成绩单)后,学校可以将记录上传到其网站,公司可以查看第一份资产成绩单。之后,公司可以提交交易 Transcript_status 并标记为已读。然后资产 Transcript_status 将从未读更新为已读。
/*
* 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.
*/
/**
* Definition of a Bond, based on the FpML schema:
* http://www.fpml.org/spec/fpml-5-3-2-wd-2/html/reporting/schemaDocumentation/schemas/fpml-asset-5-3_xsd/elements/bond.html
*
*/
namespace org.school.education
participant School identified by Schoolid {
o String Schoolid
o String name
}
participant Company identified by Companytid {
o String Companytid
o String name
}
participant Student identified by Studentid {
o String Studentid
o String studentName
o String ClassofYear
}
asset Transcript identified by tId{
o String tId
o String name
o String ClassofYear
o String gpa
o String major
o String jobexp optional
o String nationality
o Boolean readStatus default=false
--> School school
}
asset TranscriptStatus identified by tsId{
o String tsId
o String name
o String status
o String ReviewedCompany
--> Company company
}
transaction UpdateTranscript_status {
o String studentName
o Boolean readStatus default=false
--> School school
}
/*
* 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.
*/
/* global getAssetRegistry */
'use strict';
/**
* Process a property that is held for sale
* @param {org.school.education.UpdateTranscript_status} updateTranscript the transcript to be updated
* @transaction
*/
async function transcriptForUpdated(TforUpdated) { // eslint-disable-line no-unused-vars
console.log('### transcriptForUpdated ' + TforUpdated.toString());
TforUpdated.readStatus = true;
const registry = await getAssetRegistry('org.school.education.Transcript');
await registry.update(TforUpdated.readStatus);
}
/*
* 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.
*/
/**
* Sample access control list.
*/
rule EverybodyCanReadEverything {
description: "Allow all participants read access to all resources"
participant: "org.school.education.School"
operation: READ
resource: "org.school.education.*"
action: ALLOW
}
rule EverybodyCanSubmitTransactions {
description: "Allow all participants to submit transactions"
participant: "org.school.education.School"
operation: CREATE
resource: "org.schoo;.education.UpdateTranscript_status"
action: ALLOW
}
rule OwnerHasFullAccessToTheirAssets {
description: "Allow all participants full access to their assets"
participant(p): "org.school.education.School"
operation: ALL
resource(r): "org.school.education.Transcript"
condition: (r.owner.getIdentifier() === p.getIdentifier())
action: ALLOW
}
rule SystemACL {
description: "System ACL to permit all access"
participant: "org.hyperledger.composer.system.Participant"
operation: ALL
resource: "org.hyperledger.composer.system.**"
action: ALLOW
}
rule NetworkAdminUser {
description: "Grant business network administrators full access to user resources"
participant: "org.hyperledger.composer.system.NetworkAdmin"
operation: ALL
resource: "**"
action: ALLOW
}
rule NetworkAdminSystem {
description: "Grant business network administrators full access to system resources"
participant: "org.hyperledger.composer.system.NetworkAdmin"
operation: ALL
resource: "org.hyperledger.composer.system.**"
action: ALLOW
}
根据我的理解,我 运行 你的代码。我已经解决了一些问题。在您的代码中,您可以在 transcript
asset
下更新 readStatus
。如果您 更新 s asset 下的单个值,那么您需要将该资产的对象放入 Update函数。
1.模型文件更改:
transaction UpdateTranscript_status {
o Boolean readStatus default=false
--> Transcript transcript
}
2。 logic.js 改动:
async function transcriptForUpdated(TforUpdated) {
// eslint-disable-line no-unused-vars
TforUpdated.readStatus = true;
TforUpdated.transcript.readStatus = TforUpdated.readStatus;
const registry = await getAssetRegistry('org.school.education.Transcript');
await registry.update(TforUpdated.transcript);
}
在运行这个事务之后它会在Transcript
asset
.
希望它能解决您的问题:)
我在 playground hyperledger-composer 中说 "Expected Resource or Concept" 错误 两名参与者 1.学校 2. 公司
两项资产 1.成绩单 2. Transcript_status
一笔交易更新状态: • 将学生的成绩单状态从未读更新为不感兴趣或感兴趣
参加学校、学生、公司 资产记录,Transcript_status 事务更新状态
- 学校创建参与学校
- 公司创建一个参与公司
- 学校创建资产成绩单
- 公司创建资产transcript_status
工作流程:创建学生资产(成绩单)后,学校可以将记录上传到其网站,公司可以查看第一份资产成绩单。之后,公司可以提交交易 Transcript_status 并标记为已读。然后资产 Transcript_status 将从未读更新为已读。
/*
* 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.
*/
/**
* Definition of a Bond, based on the FpML schema:
* http://www.fpml.org/spec/fpml-5-3-2-wd-2/html/reporting/schemaDocumentation/schemas/fpml-asset-5-3_xsd/elements/bond.html
*
*/
namespace org.school.education
participant School identified by Schoolid {
o String Schoolid
o String name
}
participant Company identified by Companytid {
o String Companytid
o String name
}
participant Student identified by Studentid {
o String Studentid
o String studentName
o String ClassofYear
}
asset Transcript identified by tId{
o String tId
o String name
o String ClassofYear
o String gpa
o String major
o String jobexp optional
o String nationality
o Boolean readStatus default=false
--> School school
}
asset TranscriptStatus identified by tsId{
o String tsId
o String name
o String status
o String ReviewedCompany
--> Company company
}
transaction UpdateTranscript_status {
o String studentName
o Boolean readStatus default=false
--> School school
}
/*
* 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.
*/
/* global getAssetRegistry */
'use strict';
/**
* Process a property that is held for sale
* @param {org.school.education.UpdateTranscript_status} updateTranscript the transcript to be updated
* @transaction
*/
async function transcriptForUpdated(TforUpdated) { // eslint-disable-line no-unused-vars
console.log('### transcriptForUpdated ' + TforUpdated.toString());
TforUpdated.readStatus = true;
const registry = await getAssetRegistry('org.school.education.Transcript');
await registry.update(TforUpdated.readStatus);
}
/*
* 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.
*/
/**
* Sample access control list.
*/
rule EverybodyCanReadEverything {
description: "Allow all participants read access to all resources"
participant: "org.school.education.School"
operation: READ
resource: "org.school.education.*"
action: ALLOW
}
rule EverybodyCanSubmitTransactions {
description: "Allow all participants to submit transactions"
participant: "org.school.education.School"
operation: CREATE
resource: "org.schoo;.education.UpdateTranscript_status"
action: ALLOW
}
rule OwnerHasFullAccessToTheirAssets {
description: "Allow all participants full access to their assets"
participant(p): "org.school.education.School"
operation: ALL
resource(r): "org.school.education.Transcript"
condition: (r.owner.getIdentifier() === p.getIdentifier())
action: ALLOW
}
rule SystemACL {
description: "System ACL to permit all access"
participant: "org.hyperledger.composer.system.Participant"
operation: ALL
resource: "org.hyperledger.composer.system.**"
action: ALLOW
}
rule NetworkAdminUser {
description: "Grant business network administrators full access to user resources"
participant: "org.hyperledger.composer.system.NetworkAdmin"
operation: ALL
resource: "**"
action: ALLOW
}
rule NetworkAdminSystem {
description: "Grant business network administrators full access to system resources"
participant: "org.hyperledger.composer.system.NetworkAdmin"
operation: ALL
resource: "org.hyperledger.composer.system.**"
action: ALLOW
}
根据我的理解,我 运行 你的代码。我已经解决了一些问题。在您的代码中,您可以在 transcript
asset
下更新 readStatus
。如果您 更新 s asset 下的单个值,那么您需要将该资产的对象放入 Update函数。
1.模型文件更改:
transaction UpdateTranscript_status {
o Boolean readStatus default=false
--> Transcript transcript
}
2。 logic.js 改动:
async function transcriptForUpdated(TforUpdated) {
// eslint-disable-line no-unused-vars
TforUpdated.readStatus = true;
TforUpdated.transcript.readStatus = TforUpdated.readStatus;
const registry = await getAssetRegistry('org.school.education.Transcript');
await registry.update(TforUpdated.transcript);
}
在运行这个事务之后它会在Transcript
asset
.
希望它能解决您的问题:)