Contributor app tests #143
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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
859
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -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": [
|
||||
|
Loading…
x
Reference in New Issue
Block a user