错误:需要资源或概念。在Hyperledger作曲家中尝试创建交易时

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

我不知道为什么我的代码无法正常工作。这是:

milk.cto

 * 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.
 */

/**
 * Sour milk business network definition.
 */
namespace org.example.milk

concept Address {
  o String street
  o String city default ="Gabrovo"
  o String country default = "Bulgaria"
}

asset SourMilk identified by batchId {
  o Integer quantity
  o String batchId
  --> Producer producer
  --> Owner owner
  o Address origin
  o String description
  o Double fats default=4.0
  o Double saturatedFats default=4.0
  o Double kilocalories default=66.0
  o Double lactose default=4.6
  o Double protein default=3.2
  o Double sodium default=0.1
  o Boolean checked default=false
  o Boolean confirmed default=false
  --> Inspector checkingInspector
}

participant Producer identified by producerId {
  o String producerId
  o String firstName
  o String lastName
  o Address address
}

participant Owner identified by ownerId {
  o String ownerId
  o String firmName
  o String firstNameOfCEO
  o String lastNameOfCEO
  o Address address
  o String description
}

participant Inspector identified by inspectorId {
  o String inspectorId
  o String firstName
  o String lastName
  o Address address
  o String institution default="HEI"
}
transaction QualityCheck {
  --> SourMilk batch
  --> Inspector inspector
  o Boolean approval
}

lib / sample.js

/*
 * 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 */

/**
 * Confirmation
 * @param {org.example.milk.QualityCheck} batch, inspector, approval
 * @transaction
 */
async function QualityCheck(batch, inspector, approval) 
{  
    batch.checked=true
    batch.confirmed=approval

    // Get the asset registry for the asset.
    const assetRegistry = await getAssetRegistry('org.example.milk.SourMilk');
    // Update the asset in the asset registry.
    await assetRegistry.update(batch.checked);
}

permissions.acl

/*
 * 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 ProducersCanReadEverything {
    description: "Allow producers read access to all resources"
    participant: "org.example.milk.Producer"
    operation: READ
    resource: "org.example.milk.*"
    action: ALLOW
}

rule OwnersCanReadEverything {
    description: "Allow owners read access to all resources"
    participant: "org.example.milk.Owner"
    operation: READ
    resource: "org.example.milk.*"
    action: ALLOW
}

rule InspectorCanReadEverything {
    description: "Allow inspectors read access to all resources"
    participant: "org.example.milk.Inspector"
    operation: READ
    resource: "org.example.milk.*"
    action: ALLOW
}

rule InspectorCanCheckQuality {
    description: "Allow inspectors to check quality"
    participant: "org.example.milk.Inspector"
    operation: CREATE
    resource: "org.example.milk.QualityCheck"
    action: ALLOW
}

rule ProducerHasFullAccessToTheirAssets {
    description: "Allow all participants full access to their assets"
    participant(p): "org.example.milk.Producer"
    operation: ALL
    resource(r): "org.example.milk.SourMilk"
    condition: ((r.producer.getIdentifier() === p.getIdentifier()) && !r.checked && !r.confirmed)
    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
}

为什么在尝试创建事务时为什么会出现此错误:错误:需要资源或概念我相信我输入的值是正确的。'''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''' ''''''''

javascript hyperledger-composer
1个回答
0
投票
尝试一下

await assetRegistry.update(batch);

在QualityCheck功能中]
© www.soinside.com 2019 - 2024. All rights reserved.