dwp
dwp

Reputation: 958

Cannot deploy business network model in to composer-playground?

I am very new to Hyperledger Fabric works. I have built a business network and then I create the .bna file and tried to deploy it to the composer-playground. Then It shows me an error like this.

Cannot import an invalid Business Network Definition. Found SyntaxError: Unexpected token (27:6)

This is my Business network modal file.

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
}

And this is my logic.js file.

/*
 * 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);
}

I search but I was unable to find any suitable answer for my problem. Can someone help me to solve this problem?. Thank you.

Note: After I get the suggestion to change my code by adding transaction instance in the @Param line this is how it showing to me in the playground. Can someone give me more solutions to fix this problem? Thank you very much!! enter image description hereProblem:

Upvotes: 0

Views: 149

Answers (1)

Monarth Sarvaiya
Monarth Sarvaiya

Reputation: 1126

You forgot to write unlockLandTitle in logic.js file.

Just replace this line:

* @param {org.landreg.UnlockLandTitle} //transaction object define in the cto file

with

 * @param {org.landreg.UnlockLandTitle} unlockLandTitle //transaction object define in the cto file

Upvotes: 1

Related Questions