Better ipfs handling and default configs
This commit is contained in:
parent
424a2c4d02
commit
a16cd862f6
@ -32,14 +32,13 @@ class Kredits {
|
||||
// Initialize our registry contract
|
||||
this.addresses = addresses;
|
||||
this.contracts = {};
|
||||
this.ipfs = new IPFS();
|
||||
}
|
||||
|
||||
static setup(provider, signer, ipfsConfig) {
|
||||
this.ipfsConfig = ipfsConfig;
|
||||
static setup(provider, signer, ipfsConfig = null) {
|
||||
let ipfsAPI = new IPFS(ipfsConfig);
|
||||
this.ipfs = ipfsAPI;
|
||||
|
||||
return this.ipfs._ipfsAPI.id().catch((error) => {
|
||||
return ipfsAPI._ipfsAPI.id().catch((error) => {
|
||||
throw new Error(`IPFS node not available; config: ${JSON.stringify(ipfsConfig)} - ${error.message}`);
|
||||
}).then(() => {
|
||||
|
||||
@ -83,13 +82,6 @@ class Kredits {
|
||||
return new ethers.Contract(address, abi, provider);
|
||||
}
|
||||
|
||||
get ipfs() {
|
||||
return this._ipfsAPI;
|
||||
}
|
||||
set ipfs(ipfs) {
|
||||
this._ipfsAPI = ipfs;
|
||||
}
|
||||
|
||||
get Contributor() {
|
||||
// TODO: rename to contributor
|
||||
return this.contractFor('contributors');
|
||||
|
@ -4,6 +4,9 @@ const multihashes = require('multihashes');
|
||||
class IPFS {
|
||||
|
||||
constructor(config) {
|
||||
if (!config) {
|
||||
config = {host: 'localhost', port: '5001', protocol: 'http'};
|
||||
}
|
||||
this._ipfsAPI = ipfsAPI(config);
|
||||
this._config = config;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user