首页 > 解决方案 > 超级账本作曲家游乐场中的预期资源或概念

问题描述

我在操场超级账本作曲家中有一个错误说“预期的资源或概念” 两个参与者 1. 学校 2. 公司

两项资产 1. 成绩单 2. Transcript_status

一笔交易 updateStatus: • 将学生的成绩单状态从未读更新为不感兴趣或不感兴趣

参与者学校、学生、公司资产成绩单、成绩单_状态交易更新状态

  1. 学校创建参与学校
  2. 公司创建参与公司
  3. 学校创建资产成绩单
  4. 公司创建资产成绩单_状态

工作流程:创建学生资产(成绩单)后,学校可以将记录上传到其网站,企业可以查看第一个资产成绩单。之后,公司可以提交交易 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
}

标签: hyperledger-composer

解决方案


据我了解,我运行您的代码。我已经解决了一些问题。在您的代码中,您可以更新 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

希望它能解决你的问题:)


推荐阅读