mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-21 00:55:10 +00:00
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:
parent
6ebf692ab8
commit
9f07960dae
1 changed files with 1 additions and 3 deletions
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue