我对Hyperledger Fabric作品很陌生。我已经建立了一个业务网络,然后创建了.bna
文件,并尝试将其部署到composer-playground。然后它向我显示了这样的错误。
Cannot import an invalid Business Network Definition. Found SyntaxError: Unexpected token (27:6)
这是我的商业网络模式文件。
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} //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);
}
我进行了搜索,但是找不到适合我问题的答案。有人可以帮我解决这个问题吗?谢谢。
注意:
当我得到建议通过在@Param
行中添加事务实例来更改代码后,这就是在操场上向我展示的方式。有人可以给我更多解决方案来解决此问题吗?非常感谢你!!
问题:
答案 0 :(得分:1)
您忘记在unlockLandTitle
文件中写入 logic.js
。
只需替换此行:
* @param {org.landreg.UnlockLandTitle} //transaction object define in the cto file
使用
* @param {org.landreg.UnlockLandTitle} unlockLandTitle //transaction object define in the cto file