我正在尝试测试一笔交易,但是作曲家不断抛出以下我不太了解的错误:
TypeError: Cannot read property 'parameters' of undefined
这似乎与建模文件中的Parameters concept
有关。我只是想将原始资产中的参数概念更新为交易定义的新概念:
transactionProcessing:
/**
* Create paramter transaction
* @param {org.spear.gtm.homenode.parameterUpdate} homeNodeTransaction
* @transaction
*/
async function parameterProcessor(homeNodeTransaction){
const oldParameters = homeNodeTransaction.asset.parameters;
const newParameters = homeNodeTransaction.newParameters;
homeNodeTransaction.asset.parameters = homeNodeTransaction.newParameters;
await getAssetRegistry('org.spear.gtm.homenode').then(registryResults.update(homeNodeTransaction.asset));
let event = getFactory().newEvent('org.spear.gtm.homenode', 'parameterUpdated');
event.updatedParameters = newParameters;
event.oldParameters = oldParameters;
emit(event);
}
参与者
/*
* 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.
*/
/**
* The home node is acting as a participant
*/
namespace org.spear.gtm.homenode
import org.spear.gtm.devicenode.IoTDevice
/**
* Defining participants on the home network
*/
participant HomeNode identified by participantKey {
//Home node key
o String participantKey regex = /[A-Fa-f0-9]{64}/
//parameter concept acts as a parameter dictionary //'old value in transaction Processor'
o Parameters parameters
//reputation paramter
o Double reputation
//An array of devices belong to this home node
--> Devices[] devices
}
concept Parameters {
//Arbitary string representing JSON parameters
o String parameters default = 'off'
/**
More parameters to be added
o Double..
o Double..
o Integer..
*/
}
transaction parameterUpdate {
o Parameters newParameters //'new value in transaction processor'
}
transaction addDevice {
--> IoTDevice device
}
event parameterUpdated {
o Parameters oldParameters
o Parameters updatedParameters
}
event deviceAdded{
o String homeID
o String deviceID
}