Cleanup
This commit is contained in:
parent
ffff09ab23
commit
ccd52f6ee5
@ -5,17 +5,17 @@ const Addresses = require('./addresses/KreditsKit.json');
|
|||||||
|
|
||||||
class KreditsKit {
|
class KreditsKit {
|
||||||
|
|
||||||
constructor(provider, signer, options = {}) {
|
constructor (provider, signer, options = {}) {
|
||||||
let { address, abi, ipfsConfig } = options;
|
let { address, abi } = options;
|
||||||
|
|
||||||
this.provider = provider;
|
this.provider = provider;
|
||||||
this.signer = signer;
|
this.signer = signer;
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.address = address
|
this.address = address;
|
||||||
this.abi = abi || ABI;
|
this.abi = abi || ABI;
|
||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
init () {
|
||||||
return this.provider.getNetwork().then((network) => {
|
return this.provider.getNetwork().then((network) => {
|
||||||
this.address = this.address || Addresses[network.chainId.toString()];
|
this.address = this.address || Addresses[network.chainId.toString()];
|
||||||
this.contract = new ethers.Contract(
|
this.contract = new ethers.Contract(
|
||||||
@ -27,20 +27,20 @@ class KreditsKit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
appIdFor(contractName) {
|
appIdFor (contractName) {
|
||||||
// see appIds in KreditsKit.sol for more details
|
// see appIds in KreditsKit.sol for more details
|
||||||
const knownContracts = ['Contribution', 'Contributor', 'Proposal', 'Token'];
|
const knownContracts = ['Contribution', 'Contributor', 'Proposal', 'Token'];
|
||||||
return this.contract.functions.appIds(knownContracts.indexOf(contractName));
|
return this.contract.functions.appIds(knownContracts.indexOf(contractName));
|
||||||
}
|
}
|
||||||
|
|
||||||
newDAO(options = {}) {
|
newDAO (options = {}) {
|
||||||
return this.contract.functions.newInstance(options).then(transaction => {
|
return this.contract.functions.newInstance(options).then(transaction => {
|
||||||
return transaction.wait().then(result => {
|
return transaction.wait().then(result => {
|
||||||
const deployEvent = result.events.find(e => e.event === 'DeployInstance');
|
const deployEvent = result.events.find(e => e.event === 'DeployInstance');
|
||||||
return {
|
return {
|
||||||
daoAddress: deployEvent.args.dao,
|
daoAddress: deployEvent.args.dao,
|
||||||
transactionHash: transaction.hash
|
transactionHash: transaction.hash,
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user