Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8539b56a48 | |||
| f59c37827a | |||
| 58db57ee45 | |||
| b64a7ca299 | |||
| 6f09ca8d13 | |||
| 6f53c8097e | |||
| 6b2ac15f56 | |||
| 359989f235 | |||
| 5894f6323b | |||
| 09b78e1e8f | |||
| 48c8f6b9b3 | |||
| 791190f5e7 | |||
| 375d8f3275 | |||
| 3cb94fb660 |
@@ -1,7 +1,36 @@
|
|||||||
const contractCalls = [
|
const contractCalls = [
|
||||||
['Contributor', 'add', [{ account: '0x7e8f313c56f809188313aa274fa67ee58c31515d', name: 'bumi', kind: 'person', url: '', github_username: 'bumi', github_uid: 318, wiki_username: 'Bumi' }, { gasLimit: 200000 }]],
|
['Contributor', 'add', [{
|
||||||
['Contributor', 'add', [{ account: '0x49575f3DD9a0d60aE661BC992f72D837A77f05Bc', name: 'raucao', kind: 'person', url: '', github_username: 'skddc', github_uid: 842, wiki_username: 'Basti' }, { gasLimit: 200000 }]],
|
account: '0x7e8f313c56f809188313aa274fa67ee58c31515d',
|
||||||
['Contributor', 'add', [{ account: '0xF722709ECC3B05c19d02E82a2a4A4021B8F48C62', name: 'Manuel', kind: 'person', url: '', github_username: 'fsmanuel', github_uid: 54812, wiki_username: 'Manuel' }, { gasLimit: 200000 }]],
|
name: 'bumi',
|
||||||
|
kind: 'person',
|
||||||
|
url: '',
|
||||||
|
github_username: 'bumi',
|
||||||
|
github_uid: 318,
|
||||||
|
gitea_username: 'bumi',
|
||||||
|
wiki_username: 'Bumi'
|
||||||
|
}, { gasLimit: 200000 }]],
|
||||||
|
|
||||||
|
['Contributor', 'add', [{
|
||||||
|
account: '0x49575f3DD9a0d60aE661BC992f72D837A77f05Bc',
|
||||||
|
name: 'raucao',
|
||||||
|
kind: 'person',
|
||||||
|
url: '',
|
||||||
|
github_username: 'skddc',
|
||||||
|
github_uid: 842,
|
||||||
|
gitea_username: 'raucao',
|
||||||
|
wiki_username: 'Basti'
|
||||||
|
}, { gasLimit: 200000 }]],
|
||||||
|
|
||||||
|
['Contributor', 'add', [{
|
||||||
|
account: '0xF722709ECC3B05c19d02E82a2a4A4021B8F48C62',
|
||||||
|
name: 'Manuel',
|
||||||
|
kind: 'person',
|
||||||
|
url: '',
|
||||||
|
github_username: 'fsmanuel',
|
||||||
|
github_uid: 54812,
|
||||||
|
wiki_username: 'Manuel'
|
||||||
|
}, { gasLimit: 200000 }]],
|
||||||
|
|
||||||
['Proposal', 'addProposal', [{ contributorId: 1, contributorIpfsHash: 'QmWKCYGr2rSf6abUPaTYqf98urvoZxGrb7dbspFZA6oyVF', date: '2019-04-09', amount: 500, kind: 'dev', description: '[67P/kredits-contracts] Ran the seeds', url: '' }, { gasLimit: 350000 }]],
|
['Proposal', 'addProposal', [{ contributorId: 1, contributorIpfsHash: 'QmWKCYGr2rSf6abUPaTYqf98urvoZxGrb7dbspFZA6oyVF', date: '2019-04-09', amount: 500, kind: 'dev', description: '[67P/kredits-contracts] Ran the seeds', url: '' }, { gasLimit: 350000 }]],
|
||||||
['Proposal', 'addProposal', [{ contributorId: 2, contributorIpfsHash: 'QmcHzEeAM26HV2zHTf5HnZrCtCtGdEccL5kUtDakAB7ozB', date: '2019-04-10', amount: 500, kind: 'dev', description: '[67P/kredits-contracts] Ran the seeds', url: '' }, { gasLimit: 350000 }]],
|
['Proposal', 'addProposal', [{ contributorId: 2, contributorIpfsHash: 'QmcHzEeAM26HV2zHTf5HnZrCtCtGdEccL5kUtDakAB7ozB', date: '2019-04-10', amount: 500, kind: 'dev', description: '[67P/kredits-contracts] Ran the seeds', url: '' }, { gasLimit: 350000 }]],
|
||||||
['Proposal', 'addProposal', [{ contributorId: 2, contributorIpfsHash: 'QmcHzEeAM26HV2zHTf5HnZrCtCtGdEccL5kUtDakAB7ozB', date: '2019-04-11', amount: 500, kind: 'dev', description: '[67P/kredits-contracts] Hacked on kredits', url: '' }, { gasLimit: 350000 }]],
|
['Proposal', 'addProposal', [{ contributorId: 2, contributorIpfsHash: 'QmcHzEeAM26HV2zHTf5HnZrCtCtGdEccL5kUtDakAB7ozB', date: '2019-04-11', amount: 500, kind: 'dev', description: '[67P/kredits-contracts] Hacked on kredits', url: '' }, { gasLimit: 350000 }]],
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
const Record = require('./record');
|
const Record = require('./record');
|
||||||
const ContributorSerializer = require('../serializers/contributor');
|
const ContributorSerializer = require('../serializers/contributor');
|
||||||
|
const formatKredits = require('../utils/format-kredits');
|
||||||
|
|
||||||
class Contributor extends Record {
|
class Contributor extends Record {
|
||||||
get count () {
|
get count () {
|
||||||
@@ -8,9 +9,10 @@ class Contributor extends Record {
|
|||||||
|
|
||||||
getById(id) {
|
getById(id) {
|
||||||
return this.functions.getContributorById(id)
|
return this.functions.getContributorById(id)
|
||||||
.then((data) => {
|
.then(data => {
|
||||||
|
data.balanceInt = formatKredits(data.balance);
|
||||||
return this.ipfs.catAndMerge(data, ContributorSerializer.deserialize);
|
return this.ipfs.catAndMerge(data, ContributorSerializer.deserialize);
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
filterByAccount(search) {
|
filterByAccount(search) {
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ class Contributor {
|
|||||||
url,
|
url,
|
||||||
github_uid,
|
github_uid,
|
||||||
github_username,
|
github_username,
|
||||||
|
gitea_username,
|
||||||
wiki_username,
|
wiki_username,
|
||||||
} = this;
|
} = this;
|
||||||
|
|
||||||
@@ -50,6 +51,14 @@ class Contributor {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gitea_username) {
|
||||||
|
data.accounts.push({
|
||||||
|
"site": "gitea.kosmos.org",
|
||||||
|
"username": gitea_username,
|
||||||
|
"url": `https://gitea.kosmos.org/${gitea_username}`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (wiki_username) {
|
if (wiki_username) {
|
||||||
data.accounts.push({
|
data.accounts.push({
|
||||||
"site": "wiki.kosmos.org",
|
"site": "wiki.kosmos.org",
|
||||||
@@ -87,13 +96,17 @@ class Contributor {
|
|||||||
accounts,
|
accounts,
|
||||||
} = JSON.parse(serialized.toString('utf8'));
|
} = JSON.parse(serialized.toString('utf8'));
|
||||||
|
|
||||||
let github_username, github_uid, wiki_username;
|
let github_username, github_uid, gitea_username, wiki_username;
|
||||||
let github = accounts.find((a) => a.site === 'github.com');
|
let github = accounts.find(a => a.site === 'github.com');
|
||||||
let wiki = accounts.find((a) => a.site === 'wiki.kosmos.org');
|
let gitea = accounts.find(a => a.site === 'gitea.kosmos.org');
|
||||||
|
let wiki = accounts.find(a => a.site === 'wiki.kosmos.org');
|
||||||
|
|
||||||
if (github) {
|
if (github) {
|
||||||
(({ username: github_username, uid: github_uid} = github));
|
(({ username: github_username, uid: github_uid} = github));
|
||||||
}
|
}
|
||||||
|
if (gitea) {
|
||||||
|
(({ username: gitea_username } = gitea));
|
||||||
|
}
|
||||||
if (wiki) {
|
if (wiki) {
|
||||||
(({ username: wiki_username } = wiki));
|
(({ username: wiki_username } = wiki));
|
||||||
}
|
}
|
||||||
@@ -105,6 +118,7 @@ class Contributor {
|
|||||||
accounts,
|
accounts,
|
||||||
github_uid,
|
github_uid,
|
||||||
github_username,
|
github_username,
|
||||||
|
gitea_username,
|
||||||
wiki_username,
|
wiki_username,
|
||||||
ipfsData: serialized,
|
ipfsData: serialized,
|
||||||
};
|
};
|
||||||
|
|||||||
10
lib/utils/format-kredits.js
Normal file
10
lib/utils/format-kredits.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
const ethersUtils = require('ethers').utils;
|
||||||
|
|
||||||
|
module.exports = function (value, options = {}) {
|
||||||
|
let etherValue = ethersUtils.formatEther(value);
|
||||||
|
if (options.asFloat) {
|
||||||
|
return parseFloat(etherValue);
|
||||||
|
} else {
|
||||||
|
return parseInt(etherValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "kredits-contracts",
|
"name": "kredits-contracts",
|
||||||
"version": "5.2.0",
|
"version": "5.3.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "kredits-contracts",
|
"name": "kredits-contracts",
|
||||||
"version": "5.2.0",
|
"version": "5.3.0",
|
||||||
"description": "Ethereum contracts and npm wrapper for Kredits",
|
"description": "Ethereum contracts and npm wrapper for Kredits",
|
||||||
"main": "./lib/kredits.js",
|
"main": "./lib/kredits.js",
|
||||||
"directories": {
|
"directories": {
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ module.exports = async function(callback) {
|
|||||||
|
|
||||||
console.log(table.toString());
|
console.log(table.toString());
|
||||||
|
|
||||||
let totalContributionBalances = await kredits.Contribution.functions.totalCount(true);
|
let totalKreditsEarned = await kredits.Contribution.functions.totalKreditsEarned(true);
|
||||||
console.log(`Total confirmed balance: ${totalContributionBalances}`);
|
console.log(`Total confirmed kredits: ${totalKreditsEarned}`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,10 +21,6 @@ module.exports = async function(callback) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const contributors = await kredits.Contributor.all()
|
const contributors = await kredits.Contributor.all()
|
||||||
} catch(e) {
|
|
||||||
callback(e);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
contributors.forEach((c) => {
|
contributors.forEach((c) => {
|
||||||
table.push([
|
table.push([
|
||||||
@@ -32,7 +28,7 @@ module.exports = async function(callback) {
|
|||||||
c.account,
|
c.account,
|
||||||
`${c.name}`,
|
`${c.name}`,
|
||||||
c.isCore,
|
c.isCore,
|
||||||
ethers.utils.formatEther(c.balance),
|
c.balanceInt.toString(),
|
||||||
c.totalKreditsEarned.toString(),
|
c.totalKreditsEarned.toString(),
|
||||||
c.contributionsCount.toString(),
|
c.contributionsCount.toString(),
|
||||||
c.ipfsHash
|
c.ipfsHash
|
||||||
@@ -40,7 +36,10 @@ module.exports = async function(callback) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
console.log(table.toString())
|
console.log(table.toString())
|
||||||
|
} catch(e) {
|
||||||
|
callback(e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
callback()
|
callback()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user