Add ACL contract wrapper
this mainly allows us to check if an account has a certain role and thus if the account can call specific contract functions. At some point we might want to extend that to support the check if an account can call the function. For that we would need to have a mapping between function names and roles, which we have not right now.
This commit is contained in:
parent
4f5ae01c5a
commit
94832d4d07
1
lib/abis/ACL.json
Normal file
1
lib/abis/ACL.json
Normal file
File diff suppressed because one or more lines are too long
13
lib/contracts/acl.js
Normal file
13
lib/contracts/acl.js
Normal file
@ -0,0 +1,13 @@
|
||||
const Base = require('./base');
|
||||
const EthersUtils = require('ethers').utils;
|
||||
|
||||
class Acl extends Base {
|
||||
|
||||
hasPermission(fromAddress, contractAddress, roleID, params = null) {
|
||||
let roleHash = EthersUtils.keccak256(EthersUtils.toUtf8Bytes(roleID));
|
||||
console.log(roleHash)
|
||||
return this.functions.hasPermission(fromAddress, contractAddress, roleHash, params);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Acl;
|
@ -3,5 +3,6 @@ module.exports = {
|
||||
Contribution: require('./contribution'),
|
||||
Proposal: require('./proposal'),
|
||||
Token: require('./token'),
|
||||
Kernel: require('./kernel')
|
||||
Kernel: require('./kernel'),
|
||||
Acl: require('./acl')
|
||||
};
|
||||
|
@ -5,6 +5,9 @@ KERNEL_APP_ADDR_NAMESPACE = '0xd6f028ca0e8edb4a8c9757ca4fdccab25fa1e0317da118810
|
||||
class Kernel extends Base {
|
||||
|
||||
getApp(appName) {
|
||||
if (appName === 'Acl') {
|
||||
return this.functions.acl();
|
||||
}
|
||||
return this.functions.getApp(KERNEL_APP_ADDR_NAMESPACE, this.appNamehash(appName));
|
||||
}
|
||||
|
||||
|
@ -8,13 +8,15 @@ const ABIS = {
|
||||
Contribution: require('./abis/Contribution.json'),
|
||||
Token: require('./abis/Token.json'),
|
||||
Proposal: require('./abis/Proposal.json'),
|
||||
Kernel: require('./abis/Kernel.json')
|
||||
Kernel: require('./abis/Kernel.json'),
|
||||
Acl: require('./abis/ACL.json')
|
||||
};
|
||||
const APP_CONTRACTS = [
|
||||
'Contributor',
|
||||
'Contribution',
|
||||
'Token',
|
||||
'Proposal'
|
||||
'Proposal',
|
||||
'Acl'
|
||||
];
|
||||
const DaoAddresses = require('./addresses/dao.json');
|
||||
|
||||
@ -86,6 +88,10 @@ class Kredits {
|
||||
return this.contractFor('Contribution');
|
||||
}
|
||||
|
||||
get Acl() {
|
||||
return this.contractFor('Acl');
|
||||
}
|
||||
|
||||
// Should be private
|
||||
contractFor(name) {
|
||||
if (this.contracts[name]) {
|
||||
|
@ -10,7 +10,8 @@ const files = [
|
||||
'Contribution',
|
||||
'Kernel',
|
||||
'Proposal',
|
||||
'Token'
|
||||
'Token',
|
||||
'ACL'
|
||||
];
|
||||
|
||||
files.forEach((fileName) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user