无法将业务网络模型部署到 composer-playground?
Cannot deploy business network model in to composer-playground?
我对 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
行中添加事务实例来更改我的代码的建议后,这就是它在操场上向我显示的方式。有人可以给我更多的解决方案来解决这个问题吗?非常感谢你!!
问题:
您忘记在 logic.js
文件中写入 unlockLandTitle
。
只需替换这一行:
* @param {org.landreg.UnlockLandTitle} //transaction object define in the cto file
与
* @param {org.landreg.UnlockLandTitle} unlockLandTitle //transaction object define in the cto file
我对 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
行中添加事务实例来更改我的代码的建议后,这就是它在操场上向我显示的方式。有人可以给我更多的解决方案来解决这个问题吗?非常感谢你!!
您忘记在 logic.js
文件中写入 unlockLandTitle
。
只需替换这一行:
* @param {org.landreg.UnlockLandTitle} //transaction object define in the cto file
与
* @param {org.landreg.UnlockLandTitle} unlockLandTitle //transaction object define in the cto file