Constructor configuration options #40
@ -22,16 +22,17 @@ function capitalize(word) {
|
||||
|
||||
class Kredits {
|
||||
|
||||
constructor(provider, signer, addresses) {
|
||||
constructor(provider, signer, options = {}) {
|
||||
let { addresses, abis, ipfsConfig } = options;
|
||||
|
||||
this.provider = provider;
|
||||
this.signer = signer;
|
||||
|
||||
// by default we only need the registry address.
|
||||
// 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.abis = ABIS;
|
||||
this.abis = abis || ABIS;
|
||||
this.ipfs = new IPFS(ipfsConfig);
|
||||
this.contracts = {};
|
||||
this.ipfs = new IPFS();
|
||||
}
|
||||
|
||||
init(names) {
|
||||
@ -50,11 +51,7 @@ class Kredits {
|
||||
|
||||
static setup(provider, signer, ipfsConfig = null) {
|
||||
console.log('Kredits.setup() is deprecated use new Kredits().init() instead');
|
||||
let ipfs = new IPFS(ipfsConfig);
|
||||
return new Kredits(provider, signer).init().then((kredits) => {
|
||||
kredits.ipfs = ipfs;
|
||||
return kredits;
|
||||
});
|
||||
return new Kredits(provider, signer, { ipfsConfig: ipfsConfig }).init();
|
||||
}
|
||||
|
||||
get Registry() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user