Refactor kredits address initialization #35

Merged
bumi merged 2 commits from refactor/kredits-init into master 2018-04-21 08:32:58 +00:00
bumi commented 2018-04-20 01:12:01 +00:00 (Migrated from github.com)

This moves the Kredits initialization to the instance which allows us to be more flexible with handling contract addresses.

Example:

var k = new Kredits(provider, signer, {Registry: '0xabc'});
k.init().then((kredits) { ...});

var k = new Kredits(provider, signer, {Contributors: '0xabc'})
k.Contributor.add(...);

instead of calling setup:

Kredits.setup(provider, signer, ipfsConfig).then((kredits) => { ...});

setup is still available but deprecated.

Please note: if a custom IPFS config is needed this needs to be set on the kredits instance to overwrite the default:

var k = await new Kredits(provider, signer).init();
k.ipfs = new IPFS(...);
This moves the Kredits initialization to the instance which allows us to be more flexible with handling contract addresses. Example: ```js var k = new Kredits(provider, signer, {Registry: '0xabc'}); k.init().then((kredits) { ...}); var k = new Kredits(provider, signer, {Contributors: '0xabc'}) k.Contributor.add(...); ``` instead of calling `setup`: ```js Kredits.setup(provider, signer, ipfsConfig).then((kredits) => { ...}); ``` `setup` is still available but deprecated. Please note: if a custom IPFS config is needed this needs to be set on the `kredits` instance to overwrite the default: ```js var k = await new Kredits(provider, signer).init(); k.ipfs = new IPFS(...); ```
fsmanuel (Migrated from github.com) reviewed 2018-04-20 10:22:06 +00:00
@ -21,65 +19,50 @@ function capitalize(word) {
}
fsmanuel (Migrated from github.com) commented 2018-04-20 10:22:06 +00:00

We can use Object.keys(ABIS) and remove static get contractNames().

We can use `Object.keys(ABIS)` and remove `static get contractNames()`.
fsmanuel (Migrated from github.com) approved these changes 2018-04-20 10:22:54 +00:00
fsmanuel (Migrated from github.com) left a comment

Nice! Just a suggestion.

Nice! Just a suggestion.
Sign in to join this conversation.
No description provided.