Correct Javascript Chaincode

- 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 <d_kelsey@uk.ibm.com>
This commit is contained in:
D 2021-05-11 09:40:42 +01:00
parent 6ebf692ab8
commit 80ecc98739

View file

@ -72,7 +72,7 @@ class AssetTransfer extends Contract {
Owner: owner, Owner: owner,
AppraisedValue: appraisedValue, 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); return JSON.stringify(asset);
} }
@ -146,8 +146,6 @@ class AssetTransfer extends Contract {
} }
return JSON.stringify(allResults); return JSON.stringify(allResults);
} }
} }
module.exports = AssetTransfer; module.exports = AssetTransfer;