Skip to content

Commit

Permalink
fix lint and prettier errors and warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Jim Ulle <jrulle@gmail.com>
  • Loading branch information
jimulle authored and petermetz committed Nov 19, 2019
1 parent 9add091 commit 48915f1
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 67 deletions.
24 changes: 15 additions & 9 deletions examples/simple-asset-transfer/fabric/connector.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const rp = require(`request-promise-native`);
const { Connector } = require(`@hyperledger-labs/blockchain-integration-framework`);

class MyFabricConnector extends Connector.FABRIC {

static snakeToCamel(str) {
return str.replace(/(_\w)/g, m => m[1].toUpperCase());
}
Expand All @@ -14,15 +13,18 @@ class MyFabricConnector extends Connector.FABRIC {
const isArray = Array.isArray(value);
acc[newKey] = isArray ? value.map(item => MyFabricConnector.objectKeysSnakeToCamel(item)) : value;
return acc;
}, {})
}, {});
}

static omitDeep(obj, omitKey) {
return Object.keys(obj).reduce((acc, key) => {
if (key === omitKey) return acc;
acc[key] = obj[key];
return acc;
}, { ...obj[omitKey] })
return Object.keys(obj).reduce(
(acc, key) => {
if (key === omitKey) return acc;
acc[key] = obj[key];
return acc;
},
{ ...obj[omitKey] }
);
}

static renameKeysByMap(obj, map) {
Expand All @@ -32,13 +34,17 @@ class MyFabricConnector extends Connector.FABRIC {
const isArray = Array.isArray(value);
acc[newKey] = isArray ? value.map(item => MyFabricConnector.renameKeysByMap(item, map)) : value;
return acc;
}, {})
}, {});
}

static standardizeAssetOutput(asset) {
const camelAsset = MyFabricConnector.objectKeysSnakeToCamel(asset);
const deepOmitedAsset = MyFabricConnector.omitDeep(camelAsset, 'properties');
return MyFabricConnector.renameKeysByMap(deepOmitedAsset, { dltId: 'dltID', originDltId: 'originDLTId', receiverPk: 'receiverPK' });
return MyFabricConnector.renameKeysByMap(deepOmitedAsset, {
dltId: 'dltID',
originDltId: 'originDLTId',
receiverPk: 'receiverPK',
});
}

/**
Expand Down
2 changes: 1 addition & 1 deletion examples/simple-asset-transfer/quorum/connector.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class MyQuorumConnector extends Connector.QUORUM {
return {
asset_id: asset.assetId,
dltId: asset.dltID,
origin: asset.origin.map(item => ({
origin: asset.origin.map(() => ({
origin_dlt_id: `DLT100`,
origin_asset_id: `Asset_DLT100_1`,
})),
Expand Down
Loading

0 comments on commit 48915f1

Please sign in to comment.