eslint change

Signed-off-by: abdou.chakhkhar <abdelmoula.chakhkhar@uit.ac.ma>
This commit is contained in:
abdou.chakhkhar 2022-08-26 21:27:35 +01:00
parent b31f8db6ea
commit 0aa7b52666
2 changed files with 20 additions and 11 deletions

View file

@ -12,22 +12,16 @@ module.exports = {
ecmaVersion: 8, ecmaVersion: 8,
sourceType: 'script' sourceType: 'script'
}, },
extends: "eslint:recommended",
rules: { rules: {
indent: ['error', 4], indent: ['error', 4],
'linebreak-style': ['error', 'unix'], 'linebreak-style': ['error', 'unix'],
quotes: ['error', 'single'],
semi: ['error', 'always'],
'no-unused-vars': ['error', { args: 'none' }], 'no-unused-vars': ['error', { args: 'none' }],
'no-console': 'off', 'no-console': 'off',
curly: 'error', curly: 'error',
eqeqeq: 'error',
'no-throw-literal': 'error', 'no-throw-literal': 'error',
strict: 'error', strict: 'error',
'no-var': 'error', 'no-var': 'error',
'dot-notation': 'error', 'dot-notation': 'error',
'no-tabs': 'error',
'no-trailing-spaces': 'error',
'no-use-before-define': 'error', 'no-use-before-define': 'error',
'no-useless-call': 'error', 'no-useless-call': 'error',
'no-with': 'error', 'no-with': 'error',

View file

@ -102,11 +102,26 @@ class PrivateAssetTransfer extends Contract {
const promiseOfIterator = response.iterator.response.results; const promiseOfIterator = response.iterator.response.results;
const allResults = []; const allResults = [];
for await (const res of promiseOfIterator) { let result = await promiseOfIterator.next();
allResults.push(res.resultBytes.toString()); while (!result.done) {
const strValue = Buffer.from(result.value.value.toString()).toString('utf8');
let record;
try {
record = JSON.parse(strValue);
} catch (err) {
console.log(err);
record = strValue;
}
allResults.push(record);
result = await promiseOfIterator.next();
} }
return allResults; // for await(const res of promiseOfIterator) {
// allResults.push(res.resultBytes.toString());
// }
return JSON.stringify(allResults);
} }
// ReadAssetPrivateDetails reads the asset private details in organization specific collection // ReadAssetPrivateDetails reads the asset private details in organization specific collection
@ -223,7 +238,7 @@ class PrivateAssetTransfer extends Contract {
let valueJSON = JSON.parse(transientAssetJSON); let valueJSON = JSON.parse(transientAssetJSON);
// Do some error checking since we get the chance // Do some error checking since we get the chance
if (!valueJSON.assetID && valueJSON.assetID === "") { if (!valueJSON.assetID && valueJSON.assetID === '') {
throw new Error(`assetID field must be a non-empty string`); throw new Error(`assetID field must be a non-empty string`);
} }
@ -412,7 +427,7 @@ class PrivateAssetTransfer extends Contract {
// Get hash of owners agreed to value // Get hash of owners agreed to value
const ownerAppraisedValueHash = await ctx.stub.getPrivateDataHash(collectionOwner, assetID); const ownerAppraisedValueHash = await ctx.stub.getPrivateDataHash(collectionOwner, assetID);
if (!ownerAppraisedValueHash) { if (!ownerAppraisedValueHash) {
throw Error(`Hash of appraised value for ${assetID} does not exist in collection ${collectionOwner}.`) throw Error(`Hash of appraised value for ${assetID} does not exist in collection ${collectionOwner}.`)
} }