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:
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));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user