TypeError:factory.newTransaction不是函数:Composer Playground

时间:2019-07-11 21:36:30

标签: blockchain factory hyperledger-composer

我的资产不足:

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不是函数会引发错误。

0 个答案:

没有答案