无法在作曲家游乐场提交交易?

时间:2018-11-02 06:36:24

标签: hyperledger hyperledger-composer

问题:

我已经在https://composer-playground.mybluemix.net中创建并部署了一个业务网络。在这里我可以按预期创建参与者和资产。但是“提交交易”按钮被禁用。

这是我的.cto文件。我在其中编写业务网络模型。

    namespace org.landreg

    abstract concept Address {
      o String addressLine
      o String locality
    }

    concept DutchAddress {
      o String postalCode regex=/\d{4}[ ]??[A-Z]{2}/
    }

    enum Gender {
      o FEMALE
      o MALE
    }

    participant Individual identified by passportNumber{
      o String passportNumber
      o DutchAddress address
      o Gender gender
    }

    asset  LandTitle identified by id {
      o String id
      o DutchAddress address
      o Integer area range=[1000,]
      o Boolean forSale default=false
      o Double price optional
      --> Individual owner
      --> Individual[] previousOwners
    }

    abstract transaction UnlockLandTitle {
      -->LandTitle landTitle
    } 

这是我的logic.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.
     */

    "use strict";
    /**
     * Write your transction processor functions here
     */

    const NS = "org.landreg";

    /**
     * Sample transaction
     * @param {org.landreg.UnlockLandTitle} tx //transaction object define in the cto file
     * @transaction
     */
    async function UnlockLandTitle(tx) {
      //Get asset registery for landTitles
      const landTitleRegistry = await getAssetRegistry(NS + ".LandTitle");

      if (tx.landTitle.forSale) {
        throw new Error(
          `Land Title with id ${tx.landTitle.getIdentifier()} is already unlocked for sale`
        );
      }

      // Unlock asset to be for sale
      tx.landTitle.forSale = true;

      await landTitleRegistry.update(tx.landTitle);
    }

有人可以帮我解决这个问题吗?因为没有解决这个问题,我无法前进。我搜索并尝试解决此问题。但是我找不到任何解决该问题的方法。谢谢!

1 个答案:

答案 0 :(得分:1)

问题出在您的 Model(.cto) 文件中。

您不能在交易中使用抽象,只需删除抽象关键字即可。

transaction UnlockLandTitle {
   --> LandTitle landTitle
}