hyperledger-composer playground中的预期资源或概念

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

我有一个错误说“预期资源或概念”在操场上hyperledger-composer两个参与者1.学校2.公司

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

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

参与者学校,学生,公司Assets Transcript,Transcript_status Transaction updateStatus

  1. 学校创建了一所参与学校
  2. 公司创建参与公司
  3. 学校创建资产记录
  4. 公司创建资产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
}
hyperledger-composer
1个回答
0
投票

根据我的理解,我运行你的代码。我解决了一些问题。在您的代码中,您可以在readStatus 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);
}

运行此事务后,它将在Transcript asset下更新readStatus(false值更新为true)。

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

© www.soinside.com 2019 - 2024. All rights reserved.