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:
fsmanuel 2019-04-12 23:31:20 +02:00
parent e405644b1d
commit a9093c1c40
13 changed files with 77 additions and 78 deletions

View File

@ -2,11 +2,15 @@ const Base = require('./base');
const EthersUtils = require('ethers').utils; const EthersUtils = require('ethers').utils;
class Acl extends Base { class Acl extends Base {
hasPermission (fromAddress, contractAddress, roleID, params = null) { hasPermission (fromAddress, contractAddress, roleID, params = null) {
let roleHash = EthersUtils.keccak256(EthersUtils.toUtf8Bytes(roleID)); let roleHash = EthersUtils.keccak256(EthersUtils.toUtf8Bytes(roleID));
console.log(roleHash)
return this.functions.hasPermission(fromAddress, contractAddress, roleHash, params); return this.functions.hasPermission(
fromAddress,
contractAddress,
roleHash,
params
);
} }
} }

View File

@ -1,5 +1,3 @@
const ethers = require('ethers');
const ContributionSerializer = require('../serializers/contribution'); const ContributionSerializer = require('../serializers/contribution');
const Base = require('./base'); const Base = require('./base');
@ -10,7 +8,7 @@ class Contribution extends Base {
let contributions = []; let contributions = [];
for (let id = 1; id <= count; id++) { for (let id = 1; id <= count; id++) {
const contribution = await this.getById(id) const contribution = await this.getById(id);
contributions.push(contribution); contributions.push(contribution);
} }
@ -23,7 +21,6 @@ class Contribution extends Base {
.then(data => { .then(data => {
return this.ipfs.catAndMerge(data, ContributionSerializer.deserialize); return this.ipfs.catAndMerge(data, ContributionSerializer.deserialize);
}); });
} }
getByContributorId (contributorId) { getByContributorId (contributorId) {

View File

@ -4,5 +4,5 @@ module.exports = {
Proposal: require('./proposal'), Proposal: require('./proposal'),
Token: require('./token'), Token: require('./token'),
Kernel: require('./kernel'), Kernel: require('./kernel'),
Acl: require('./acl') Acl: require('./acl'),
}; };

View File

@ -48,4 +48,4 @@ class Proposal extends Base {
} }
} }
module.exports = Proposal module.exports = Proposal;

View File

@ -9,19 +9,19 @@ const ABIS = {
Token: require('./abis/Token.json'), Token: require('./abis/Token.json'),
Proposal: require('./abis/Proposal.json'), Proposal: require('./abis/Proposal.json'),
Kernel: require('./abis/Kernel.json'), Kernel: require('./abis/Kernel.json'),
Acl: require('./abis/ACL.json') Acl: require('./abis/ACL.json'),
}; };
const APP_CONTRACTS = [ const APP_CONTRACTS = [
'Contributor', 'Contributor',
'Contribution', 'Contribution',
'Token', 'Token',
'Proposal', 'Proposal',
'Acl' 'Acl',
]; ];
const DaoAddresses = require('./addresses/dao.json'); const DaoAddresses = require('./addresses/dao.json');
const Contracts = require('./contracts'); const Contracts = require('./contracts');
const IPFS = require('./utils/ipfs') const IPFS = require('./utils/ipfs');
// Helpers // Helpers
function capitalize (word) { function capitalize (word) {
@ -57,7 +57,7 @@ class Kredits {
); );
}); });
}); });
return RSVP.all(addressPromises).then(() => { return this }); return RSVP.all(addressPromises).then(() => { return this; });
}); });
} }

View File

@ -26,24 +26,24 @@ class Contribution {
kind, kind,
description, description,
url, url,
details details,
} = this; } = this;
let data = { let data = {
"@context": "https://schema.kosmos.org", '@context': 'https://schema.kosmos.org',
"@type": "Contribution", '@type': 'Contribution',
"contributor": { 'contributor': {
"ipfs": contributorIpfsHash 'ipfs': contributorIpfsHash,
}, },
date, date,
time, time,
kind, kind,
description, description,
"details": details || {} 'details': details || {},
}; };
if (url) { if (url) {
data["url"] = url; data['url'] = url;
} }
// Write it pretty to ipfs // Write it pretty to ipfs

View File

@ -64,7 +64,7 @@ class Contributor {
"@type": "Contributor", "@type": "Contributor",
kind, kind,
name, name,
"accounts": [] "accounts": [],
}; };
if (url) { if (url) {
@ -76,7 +76,7 @@ class Contributor {
"site": "github.com", "site": "github.com",
"uid": github_uid, "uid": github_uid,
"username": github_username, "username": github_username,
"url": `https://github.com/${github_username}` "url": `https://github.com/${github_username}`,
}); });
} }
@ -84,7 +84,7 @@ class Contributor {
data.accounts.push({ data.accounts.push({
"site": "wiki.kosmos.org", "site": "wiki.kosmos.org",
"username": wiki_username, "username": wiki_username,
"url": `https://wiki.kosmos.org/User:${wiki_username}` "url": `https://wiki.kosmos.org/User:${wiki_username}`,
}); });
} }

View File

@ -2,7 +2,6 @@ const ipfsClient = require('ipfs-http-client');
const multihashes = require('multihashes'); const multihashes = require('multihashes');
class IPFS { class IPFS {
constructor (config) { constructor (config) {
if (!config) { if (!config) {
config = { host: 'localhost', port: '5001', protocol: 'http' }; config = { host: 'localhost', port: '5001', protocol: 'http' };
@ -48,7 +47,7 @@ class IPFS {
hashDigest: '0x' + multihashes.toHexString(multihash.digest), hashDigest: '0x' + multihashes.toHexString(multihash.digest),
hashSize: multihash.length, hashSize: multihash.length,
hashFunction: multihash.code, hashFunction: multihash.code,
ipfsHash: ipfsHash ipfsHash: ipfsHash,
}; };
} }
@ -56,7 +55,6 @@ class IPFS {
let digest = ipfsClient.Buffer.from(hashData.hashDigest.slice(2), 'hex'); let digest = ipfsClient.Buffer.from(hashData.hashDigest.slice(2), 'hex');
return multihashes.encode(digest, hashData.hashFunction, hashData.hashSize); return multihashes.encode(digest, hashData.hashFunction, hashData.hashSize);
} }
} }
module.exports = IPFS; module.exports = IPFS;

View File

@ -4,12 +4,12 @@ const validator = tv4.freshApi();
validator.addFormat({ validator.addFormat({
'date': function(value) { 'date': function(value) {
const dateRegexp = /^[0-9]{4,}-[0-9]{2}-[0-9]{2}$/; const dateRegexp = /^[0-9]{4,}-[0-9]{2}-[0-9]{2}$/;
return dateRegexp.test(value) ? null : "A valid ISO 8601 full-date string is expected"; return dateRegexp.test(value) ? null : 'A valid ISO 8601 full-date string is expected';
}, },
'time': function(value) { 'time': function(value) {
const timeRegexp = /^([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\.[0-9]+)?(([Zz])|([\+|\-]([01][0-9]|2[0-3]):[0-5][0-9]))$/; const timeRegexp = /^([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\.[0-9]+)?(([Zz])|([\+|\-]([01][0-9]|2[0-3]):[0-5][0-9]))$/;
return timeRegexp.test(value) ? null : "A valid ISO 8601 full-time string is expected"; return timeRegexp.test(value) ? null : 'A valid ISO 8601 full-time string is expected';
} },
}) });
module.exports = validator; module.exports = validator;