Fix linter errors

# Conflicts:
#	lib/contracts/contribution.js
#	lib/contracts/contributor.js
#	lib/contracts/proposal.js
#	lib/kredits.js
#	lib/utils/pagination.js
This commit is contained in:
2019-04-12 23:31:20 +02:00
parent e405644b1d
commit a9093c1c40
13 changed files with 77 additions and 78 deletions

View File

@@ -2,8 +2,7 @@ const ipfsClient = require('ipfs-http-client');
const multihashes = require('multihashes');
class IPFS {
constructor(config) {
constructor (config) {
if (!config) {
config = { host: 'localhost', port: '5001', protocol: 'http' };
}
@@ -11,7 +10,7 @@ class IPFS {
this._config = config;
}
catAndMerge(data, deserialize) {
catAndMerge (data, deserialize) {
// if no hash details are found simply return the data; nothing to merge
if (!data.hashSize || data.hashSize === 0) {
return data;
@@ -26,7 +25,7 @@ class IPFS {
});
}
add(data) {
add (data) {
return this._ipfsAPI
.add(ipfsClient.Buffer.from(data))
.then((res) => {
@@ -34,7 +33,7 @@ class IPFS {
});
}
cat(hashData) {
cat (hashData) {
let ipfsHash = hashData; // default - if it is a string
if (hashData.hasOwnProperty('hashSize')) {
ipfsHash = this.encodeHash(hashData);
@@ -42,21 +41,20 @@ class IPFS {
return this._ipfsAPI.cat(ipfsHash);
}
decodeHash(ipfsHash) {
decodeHash (ipfsHash) {
let multihash = multihashes.decode(multihashes.fromB58String(ipfsHash));
return {
hashDigest: '0x' + multihashes.toHexString(multihash.digest),
hashSize: multihash.length,
hashFunction: multihash.code,
ipfsHash: ipfsHash
ipfsHash: ipfsHash,
};
}
encodeHash(hashData) {
encodeHash (hashData) {
let digest = ipfsClient.Buffer.from(hashData.hashDigest.slice(2), 'hex');
return multihashes.encode(digest, hashData.hashFunction, hashData.hashSize);
}
}
module.exports = IPFS;