diff --git a/asset-transfer-ledger-queries/chaincode-javascript/index.js b/asset-transfer-ledger-queries/chaincode-javascript/index.js index c4c35ee9..5c7b6e0d 100644 --- a/asset-transfer-ledger-queries/chaincode-javascript/index.js +++ b/asset-transfer-ledger-queries/chaincode-javascript/index.js @@ -10,4 +10,4 @@ const CC = require('./lib/asset_transfer_ledger_chaincode.js'); module.exports.CC = CC; -module.exports.contracts = [ CC ]; \ No newline at end of file +module.exports.contracts = [ CC ]; diff --git a/asset-transfer-ledger-queries/chaincode-javascript/lib/asset_transfer_ledger_chaincode.js b/asset-transfer-ledger-queries/chaincode-javascript/lib/asset_transfer_ledger_chaincode.js index 7b1b6b20..df458738 100644 --- a/asset-transfer-ledger-queries/chaincode-javascript/lib/asset_transfer_ledger_chaincode.js +++ b/asset-transfer-ledger-queries/chaincode-javascript/lib/asset_transfer_ledger_chaincode.js @@ -75,7 +75,7 @@ class Chaincode extends Contract{ async createAsset(ctx, assetID, color, owner, size, appraisedValue) { const exists = await this.assetExists(ctx, assetID) if (exists) { - throw new Error('asset exists') + throw new Error(`The asset ${assetID} already exists`) } // ==== Create asset object and marshal to JSON ==== @@ -101,7 +101,7 @@ class Chaincode extends Contract{ async readAsset(ctx, id) { const assetJSON = await ctx.stub.getState(id); // get the asset from chaincode state if (!assetJSON || assetJSON.length === 0) { - throw new Error(`The asset ${id} does not exist`); + throw new Error(`Asset ${id} does not exist`); } return assetJSON.toString(); @@ -110,19 +110,19 @@ class Chaincode extends Contract{ // delete - remove a asset key/value pair from state async deleteAsset(ctx, id) { if (!id) { - throw new Error('asset name must not be empty'); + throw new Error('Asset name must not be empty'); } var exists = await this.assetExists(ctx, id) if (!exists) { - throw new Error('') + throw new Error(`Asset ${id} does not exist`) } // to maintain the color~name index, we need to read the asset first and get its color let valAsbytes = await ctx.stub.getState(id); // get the asset from chaincode state let jsonResp = {}; if (!valAsbytes) { - jsonResp.error = 'asset does not exist: ' + name; + jsonResp.error = 'Asset does not exist: ' + name; throw new Error(jsonResp); } let assetJSON = {}; @@ -150,7 +150,7 @@ class Chaincode extends Contract{ let assetAsBytes = await ctx.stub.getState(assetName); if (!assetAsBytes || !assetAsBytes.toString()) { - throw new Error('asset does not exist'); + throw new Error(`Asset ${assetName} does not exist`); } let assetToTransfer = {}; try { @@ -422,4 +422,4 @@ class Chaincode extends Contract{ } } -module.exports = Chaincode; \ No newline at end of file +module.exports = Chaincode; diff --git a/asset-transfer-ledger-queries/chaincode-javascript/package.json b/asset-transfer-ledger-queries/chaincode-javascript/package.json index 24991cd0..0427b5c8 100644 --- a/asset-transfer-ledger-queries/chaincode-javascript/package.json +++ b/asset-transfer-ledger-queries/chaincode-javascript/package.json @@ -4,7 +4,7 @@ "description": "asset chaincode implemented in node.js", "main": "index.js", "engines": { - "node": ">=8.4.0", + "node": ">=12", "npm": ">=5.3.0" }, "scripts": {