Error: Expected a Resource or Concept

核能气质少年 提交于 2019-12-06 00:25:48

there are a number of issues with your code

  • the original issue of expected Resource or Concept was the latter - this wasn't being supplied correctly to the Event
  • you were using the wrong object when assigning to property so your assetRegistry update would not work
  • you need to define the Concept values when you assign to your event fields - see code
  • have left in console.logs so you can see the output
  • you need to provide more data (eg, Concept Address fields) to your transaction
  • there is a rentAmount assignment below - you need to remove - its there so you can see that the Property Asset has been updated as it should be by the transaction Agreement

/*
 * 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 transaction processor function.
 * @param {org.acme.payrent.Agreement} tntObj The sample transaction instance.
 * @transaction
 */

function Agreement(tntObj)
{

    var factory = getFactory();
    var Namespace = "org.acme.payrent";
    var property = tntObj.property;   // please note
    console.log('property is ' + property);
    var addTntEvent = factory.newEvent(Namespace, 'E1');
    addTntEvent.email = tntObj.email;

    addTntEvent.mobileNumber  = tntObj.mobileNumber ;
    addTntEvent.tntName = tntObj.tntName;

    var tntBankDetails = factory.newConcept(Namespace, 'TBankDetails');

    tntBankDetails.bankName = tntObj.bankName;
    tntBankDetails.ifscCode = tntObj.ifscCode;
    tntBankDetails.branchName = tntObj.branchName;

    addTntEvent.tntBankDetails = tntBankDetails;

    var conceptAddress = factory.newConcept(Namespace, 'Address');

    conceptAddress.houseNumber = '10';
    conceptAddress.street = '20';
    conceptAddress.city = 'Mainz';
    conceptAddress.country = 'DE';

    addTntEvent.propertyAddress = conceptAddress;

    emit(addTntEvent);



    //remove this! var a = getAssetRegistry('org.acme.payrent.Property');

    property.rentAmount =44.22 ; /// so you can see the value change on the asset in playground etc

    return getAssetRegistry('org.acme.payrent.Property')
                            .then(function(propertyRegistry) {
                                return propertyRegistry.update(property); 
    });
}

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!