refactor contrats with aragonos
This commit is contained in:
@@ -4,13 +4,19 @@ const RSVP = require('rsvp');
|
||||
const Preflight = require('./utils/preflight');
|
||||
|
||||
const ABIS = {
|
||||
Contributors: require('./abis/Contributors.json'),
|
||||
Contributor: require('./abis/Contributor.json'),
|
||||
Contribution: require('./abis/Contribution.json'),
|
||||
Operator: require('./abis/Operator.json'),
|
||||
Registry: require('./abis/Registry.json'),
|
||||
Token: require('./abis/Token.json')
|
||||
Token: require('./abis/Token.json'),
|
||||
Proposal: require('./abis/Proposal.json'),
|
||||
Kernel: require('./abis/Kernel.json')
|
||||
};
|
||||
const RegistryAddress = require('./addresses/Registry.json');
|
||||
const APP_CONTRACTS = [
|
||||
'Contributor',
|
||||
'Contribution',
|
||||
'Token',
|
||||
'Proposal'
|
||||
];
|
||||
const DaoAddresses = require('./addresses/dao.json');
|
||||
|
||||
const Contracts = require('./contracts');
|
||||
const IPFS = require('./utils/ipfs')
|
||||
@@ -28,18 +34,18 @@ class Kredits {
|
||||
|
||||
this.provider = provider;
|
||||
this.signer = signer;
|
||||
// by default we only need the registry address.
|
||||
// by default we only need the DAO/Kernel address.
|
||||
// the rest is loaded from there in the init() function
|
||||
this.addresses = addresses || { Registry: RegistryAddress[this.provider.chainId.toString()] }; // chainID must be a string
|
||||
this.addresses = addresses || { Kernel: DaoAddresses[this.provider.chainId.toString()] }; // chainID must be a string
|
||||
this.abis = abis || ABIS;
|
||||
this.ipfs = new IPFS(ipfsConfig);
|
||||
this.contracts = {};
|
||||
}
|
||||
|
||||
init(names) {
|
||||
let contractsToLoad = names || Object.keys(ABIS);
|
||||
let contractsToLoad = names || APP_CONTRACTS;
|
||||
let addressPromises = contractsToLoad.map((contractName) => {
|
||||
return this.Registry.functions.getProxyFor(contractName).then((address) => {
|
||||
return this.Kernel.getApp(contractName).then((address) => {
|
||||
this.addresses[contractName] = address;
|
||||
}).catch((error) => {
|
||||
throw new Error(`Failed to get address for ${contractName} from registry at ${this.Registry.contract.address}
|
||||
@@ -55,13 +61,13 @@ class Kredits {
|
||||
return new Kredits(provider, signer, { ipfsConfig: ipfsConfig }).init();
|
||||
}
|
||||
|
||||
get Registry() {
|
||||
return this.contractFor('registry');
|
||||
get Kernel() {
|
||||
return this.contractFor('Kernel');
|
||||
}
|
||||
|
||||
get Contributor() {
|
||||
// TODO: rename to contributor
|
||||
return this.contractFor('contributors');
|
||||
return this.contractFor('Contributor');
|
||||
}
|
||||
|
||||
get Contributors() {
|
||||
@@ -69,16 +75,16 @@ class Kredits {
|
||||
return this.Contributor;
|
||||
}
|
||||
|
||||
get Operator() {
|
||||
return this.contractFor('operator');
|
||||
get Proposal() {
|
||||
return this.contractFor('Proposal');
|
||||
}
|
||||
|
||||
get Token() {
|
||||
return this.contractFor('token');
|
||||
return this.contractFor('Token');
|
||||
}
|
||||
|
||||
get Contribution() {
|
||||
return this.contractFor('contribution');
|
||||
return this.contractFor('Contribution');
|
||||
}
|
||||
|
||||
// Should be private
|
||||
|
||||
Reference in New Issue
Block a user