我想从另一个交易中调用/触发交易。怎么可能。
async function updateOrder(uo) { // eslint-disable-line no-unused-vars
// Get the asset registry for the asset.
assetRegistry = await getAssetRegistry('org.example.basic.OrderList');
for(var i=0;i< uo.asset.orderDtls.length;i++)
{
if(uo.asset.orderDtls[i].orderID==uo.orderID){
uo.asset.orderDtls[i].orderStatus="Accepted";
}
}
await assetRegistry.update(uo.asset);
请提供任何示例代码/示例,以便在此事务发生时触发另一个事务。
答案 0 :(得分:0)
请在此处查看github问题:
https://github.com/hyperledger/composer/issues/4375
它应该回答您的问题。引用该问题的话:
/**
* TransactionOne
* @param {org.example.TransactionOne} The transaction one object
* @transaction
*/
async function transactionOne(tx) {
const factory = getFactory();
tx.subTransactions.forEach(async (subTransactionData, idx) => {
const subTx = factory.newResource(namespace, "TransactionTwo", tx.transactionId + ":" + idx);
subTx.subTransactionData= subTransactiondata;
await transactionTwo(subTx);
});
}