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 <d_kelsey@uk.ibm.com>

Co-authored-by: D <d_kelsey@uk.ibm.com>
This commit is contained in:
Dave Kelsey 2021-05-11 10:22:25 +01:00 committed by GitHub
parent 6ebf692ab8
commit 9f07960dae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;