From 9f07960daebe96d12ce0138f2d1879d150daa94f Mon Sep 17 00:00:00 2001 From: Dave Kelsey Date: Tue, 11 May 2021 10:22:25 +0100 Subject: [PATCH] Correct Javascript Chaincode (#445) - In CreateAsset, await was never called on putState causing issues especially with tools such as caliper and is not correct practice. Unfortunately all the other examples use `return` which works but is actually not the idiomatic way of handling promises, so here await is chosen rather than return Signed-off-by: D Co-authored-by: D --- .../chaincode-javascript/lib/assetTransfer.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/asset-transfer-basic/chaincode-javascript/lib/assetTransfer.js b/asset-transfer-basic/chaincode-javascript/lib/assetTransfer.js index d3a4fc47..821e413a 100644 --- a/asset-transfer-basic/chaincode-javascript/lib/assetTransfer.js +++ b/asset-transfer-basic/chaincode-javascript/lib/assetTransfer.js @@ -72,7 +72,7 @@ class AssetTransfer extends Contract { Owner: owner, AppraisedValue: appraisedValue, }; - ctx.stub.putState(id, Buffer.from(JSON.stringify(asset))); + await ctx.stub.putState(id, Buffer.from(JSON.stringify(asset))); return JSON.stringify(asset); } @@ -146,8 +146,6 @@ class AssetTransfer extends Contract { } return JSON.stringify(allResults); } - - } module.exports = AssetTransfer;