hyperledger-composer - 超级账本作曲家游乐场中的预期资源或概念
问题描述
我在操场超级账本作曲家中有一个错误说“预期的资源或概念” 两个参与者 1. 学校 2. 公司
两项资产 1. 成绩单 2. Transcript_status
一笔交易 updateStatus: • 将学生的成绩单状态从未读更新为不感兴趣或不感兴趣
参与者学校、学生、公司资产成绩单、成绩单_状态交易更新状态
- 学校创建参与学校
- 公司创建参与公司
- 学校创建资产成绩单
- 公司创建资产成绩单_状态
工作流程:创建学生资产(成绩单)后,学校可以将记录上传到其网站,企业可以查看第一个资产成绩单。之后,公司可以提交交易 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
}
解决方案
据我了解,我运行您的代码。我已经解决了一些问题。在您的代码中,您可以更新 areadStatus
下的 a transcript
asset
。如果您更新s资产下的单个值,则需要将该资产的对象放入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);
}
运行此事务后,它将更新 a 下的 readStatus(由true更新false值 )。Transcript
asset
希望它能解决你的问题:)
推荐阅读
- java - Spring核心具有多个上下文的同一类
- typescript - 根据另一个字符串属性的值解析一个属性的动态类型
- python-3.x - python3中的END参数是什么
- docker - Docker 在 Windows 上启动 Microsoft nanoserver 容器
- sql - 在 SQL 中显示以“Jan/10/2015”格式存储的日期的字符串表示形式的完整月份名称
- python - 如何删除电报聊天中的所有消息?(蟒蛇,电报.ext)
- sails.js - 在开发模式下连接 Sails 应用程序中的 postgres 时出现超时错误?
- java - Java Collection 框架,Arraylist 处理对象
- python - 如何在python中使用具有相同ID的新记录更新csv
- python-3.x - “未定义”类型的对象不是 Airflow 的 JSON 可序列化错误