我的资产不足:
asset Shipment identified by ShipmentID {
o String ShipmentID
o AssetType assettyp
o ShipmentStatus ShipmntStatus
o Long unitCount
o TempReading[] temperature optional
o AccReading[] acceleration optional
o GPSReading[] gps optional
--> Contract contract
}
where,
transaction TempReading {
o Double celsius
o String latitude
o String longitude
o String readingTime
--> Shipment shipment
}
TemReading是一项事务,其数组存储在Asset:Shipment
中我正在尝试访问
的最后一个数组索引的celcius值TempReading []温度为:
/**
* function to notify shipment received.
* @param {org.test.network.ShipmentReceived} tx
* @transaction
*/
async function ShipmentReceived(tx) {
var factory = getFactory();
var tempLen = tx.shipment.temperature.length;
const t1 = factory.newTransaction('org.test.network', 'TempReading');
t1= tx.shipment.temperature[tempLen-1];
if(t1.celcius<tx.shipment.contract.MinTemp){...}
但是,Factory.newTransaction不是函数会引发错误。