Constructor confugration options
This changes the function signature of the constructor but allows us to pass any options. Mainly this is now used for the ipfs configs.
This commit is contained in:
@@ -22,16 +22,16 @@ function capitalize(word) {
|
|||||||
|
|
||||||
class Kredits {
|
class Kredits {
|
||||||
|
|
||||||
constructor(provider, signer, addresses) {
|
constructor(provider, signer, options = {}) {
|
||||||
this.provider = provider;
|
this.provider = provider;
|
||||||
this.signer = signer;
|
this.signer = signer;
|
||||||
|
|
||||||
// by default we only need the registry address.
|
// by default we only need the registry address.
|
||||||
// the rest is loaded from there in the init() function
|
// the rest is loaded from there in the init() function
|
||||||
this.addresses = addresses || {Registry: RegistryAddress[this.provider.chainId.toString()]}; // chaiID must be a string
|
this.addresses = options['addresses'] || { Registry: RegistryAddress[this.provider.chainId.toString()] }; // chaiID must be a string
|
||||||
this.abis = ABIS;
|
this.abis = options['abis'] || ABIS;
|
||||||
|
this.ipfs = new IPFS(options['ipfsConfig']);
|
||||||
this.contracts = {};
|
this.contracts = {};
|
||||||
this.ipfs = new IPFS();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init(names) {
|
init(names) {
|
||||||
@@ -50,11 +50,7 @@ class Kredits {
|
|||||||
|
|
||||||
static setup(provider, signer, ipfsConfig = null) {
|
static setup(provider, signer, ipfsConfig = null) {
|
||||||
console.log('Kredits.setup() is deprecated use new Kredits().init() instead');
|
console.log('Kredits.setup() is deprecated use new Kredits().init() instead');
|
||||||
let ipfs = new IPFS(ipfsConfig);
|
return new Kredits(provider, signer, { ipfsConfig: ipfsConfig }).init();
|
||||||
return new Kredits(provider, signer).init().then((kredits) => {
|
|
||||||
kredits.ipfs = ipfs;
|
|
||||||
return kredits;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get Registry() {
|
get Registry() {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ class IPFS {
|
|||||||
|
|
||||||
constructor(config) {
|
constructor(config) {
|
||||||
if (!config) {
|
if (!config) {
|
||||||
config = {host: 'localhost', port: '5001', protocol: 'http'};
|
config = { host: 'localhost', port: '5001', protocol: 'http' };
|
||||||
}
|
}
|
||||||
this._ipfsAPI = ipfsAPI(config);
|
this._ipfsAPI = ipfsAPI(config);
|
||||||
this._config = config;
|
this._config = config;
|
||||||
|
|||||||
Reference in New Issue
Block a user