Contributor app tests #143

Merged
haythem96 merged 26 commits from tests/contracts-contributor into master 2019-07-22 06:55:23 +00:00
5 changed files with 783 additions and 110 deletions
Showing only changes of commit d206d55b7d - Show all commits

View File

@ -14,6 +14,10 @@ class Contribution extends Record {
});
}
getData (id) {
return this.functions.getContribution(id);
}
getByContributorId (contributorId) {
return this.functions.getContributorAddressById(contributorId)
.then(address => this.getByContributorAddress(address));
@ -62,6 +66,7 @@ class Contribution extends Record {
deprecate('The function `addContribution()` is deprecated and will be removed in the next major version. Use `add()` instead');
return this.add(...arguments);
}
}
module.exports = Contribution;

View File

@ -15,6 +15,10 @@ class Contributor extends Record {
});
}
getData (id) {
return this.functions.getContributorById(id);
}
filterByAccount (search) {
return this._byAccount(search, 'filter');
}
@ -84,6 +88,7 @@ class Contributor extends Record {
});
});
}
}
module.exports = Contributor;

View File

@ -1,13 +1,14 @@
const ipfsClient = require('ipfs-http-client');
const multihashes = require('multihashes');
const fetch = require('node-fetch');
class IPFS {
constructor (config) {
if (!config) {
config = { host: 'localhost', port: '5001', protocol: 'http' };
}
this._ipfsAPI = ipfsClient(config);
this._config = config;
this._ipfsAPI = ipfsClient(config);
}
catAndMerge (data, deserialize) {
@ -38,7 +39,19 @@ class IPFS {
if (hashData.hasOwnProperty('hashSize')) {
ipfsHash = this.encodeHash(hashData);
}
return this._ipfsAPI.cat(ipfsHash);
if (this._config['gatewayUrl']) {
return fetch(`${this._config['gatewayUrl']}/${ipfsHash}`).then(r => r.text());
} else {
return this._ipfsAPI.cat(ipfsHash);
}
}
pin (hashData) {
let ipfsHash = hashData; // default - if it is a string
if (hashData.hasOwnProperty('hashSize')) {
ipfsHash = this.encodeHash(hashData);
}
return this._ipfsAPI.pin.add(multihashes.toB58String(ipfsHash));
}
decodeHash (ipfsHash) {

859
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "kredits-contracts",
"version": "5.3.0",
"version": "5.4.0",
"description": "Ethereum contracts and npm wrapper for Kredits",
"main": "./lib/kredits.js",
"directories": {
@ -12,7 +12,7 @@
"build-json": "npm run compile-contracts && node ./scripts/build-json.js",
"repl": "truffle exec scripts/repl.js",
"seeds": "truffle exec scripts/seeds.js",
"compile-contracts": "aragon contracts compile --all",
"compile-contracts": "truffle compile --all",
"bootstrap": "npm run reset:hard && npm run seeds",
"reset": "npm run deploy:kit && npm run deploy:dao",
"reset:hard": "npm run deploy:apps && npm run reset",
@ -59,8 +59,9 @@
},
"dependencies": {
"ethers": "^4.0.29",
"ipfs-http-client": "^32.0.1",
"ipfs-http-client": "^30.1.3",
"kosmos-schemas": "^2.1.0",
"node-fetch": "^2.6.0",
"tv4": "^1.3.0"
},
"keywords": [