mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-23 01:55:10 +00:00
eslint change
Signed-off-by: abdou.chakhkhar <abdelmoula.chakhkhar@uit.ac.ma>
This commit is contained in:
parent
b31f8db6ea
commit
0aa7b52666
2 changed files with 20 additions and 11 deletions
|
|
@ -12,22 +12,16 @@ module.exports = {
|
|||
ecmaVersion: 8,
|
||||
sourceType: 'script'
|
||||
},
|
||||
extends: "eslint:recommended",
|
||||
rules: {
|
||||
indent: ['error', 4],
|
||||
'linebreak-style': ['error', 'unix'],
|
||||
quotes: ['error', 'single'],
|
||||
semi: ['error', 'always'],
|
||||
'no-unused-vars': ['error', { args: 'none' }],
|
||||
'no-console': 'off',
|
||||
curly: 'error',
|
||||
eqeqeq: 'error',
|
||||
'no-throw-literal': 'error',
|
||||
strict: 'error',
|
||||
'no-var': 'error',
|
||||
'dot-notation': 'error',
|
||||
'no-tabs': 'error',
|
||||
'no-trailing-spaces': 'error',
|
||||
'no-use-before-define': 'error',
|
||||
'no-useless-call': 'error',
|
||||
'no-with': 'error',
|
||||
|
|
|
|||
|
|
@ -102,11 +102,26 @@ class PrivateAssetTransfer extends Contract {
|
|||
const promiseOfIterator = response.iterator.response.results;
|
||||
|
||||
const allResults = [];
|
||||
for await (const res of promiseOfIterator) {
|
||||
allResults.push(res.resultBytes.toString());
|
||||
let result = await promiseOfIterator.next();
|
||||
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
|
||||
|
|
@ -223,7 +238,7 @@ class PrivateAssetTransfer extends Contract {
|
|||
let valueJSON = JSON.parse(transientAssetJSON);
|
||||
|
||||
// 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`);
|
||||
}
|
||||
|
||||
|
|
@ -412,7 +427,7 @@ class PrivateAssetTransfer extends Contract {
|
|||
|
||||
// Get hash of owners agreed to value
|
||||
const ownerAppraisedValueHash = await ctx.stub.getPrivateDataHash(collectionOwner, assetID);
|
||||
|
||||
|
||||
if (!ownerAppraisedValueHash) {
|
||||
throw Error(`Hash of appraised value for ${assetID} does not exist in collection ${collectionOwner}.`)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue