Skip to content

Commit 08e06e2

Browse files
committed
More improvements to util functions
1 parent 8a83108 commit 08e06e2

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

js/utils.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,12 @@ async function makeAllViewsPublic(acMgr, contract) {
283283
* @param {methods} list of methods to enable for this role
284284
*/
285285
async function setupAMRole(acMgr, contract, roles, role, methods) {
286-
await acMgr.labelRole(roles[role], role);
286+
const roleId = roles === undefined ? getAccessManagerRole(role) : roles[role];
287+
await acMgr.labelRole(roleId, role);
287288
const selectors = methods.map((method) =>
288289
method.startsWith("0x") ? method : contract.interface.getFunction(method).selector
289290
);
290-
await acMgr.setTargetFunctionRole(contract, selectors, roles[role]);
291+
await acMgr.setTargetFunctionRole(contract, selectors, roleId);
291292
}
292293

293294
/**
@@ -300,7 +301,11 @@ async function setupAMRole(acMgr, contract, roles, role, methods) {
300301
* @return The id of the created role (roleId)
301302
*/
302303
async function setupAMSuperAdminRole(acMgr, contract, roleId = 1111, roleName = "SUPERADMIN") {
303-
await acMgr.labelRole(roleId, roleName);
304+
roleId = roleId === undefined ? getAccessManagerRole(roleName) : roleId;
305+
if (AM_ROLES[roleName] === undefined) {
306+
// Don't label PUBLIC_ROLE or ADMIN_ROLE
307+
await acMgr.labelRole(roleId, roleName);
308+
}
304309
const selectors = contract.interface.fragments
305310
.filter(
306311
(fragment) =>
@@ -375,4 +380,5 @@ module.exports = {
375380
setupAMSuperAdminRole,
376381
captureAny,
377382
newCaptureAny,
383+
AM_ROLES,
378384
};

js/verifiableBinaries.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,13 @@ function addTasks() {
368368
.addParam("contractType", "The contract type to verify")
369369
.addParam("address", "The contract address to verify")
370370
.addOptionalVariadicPositionalParam("constructorArguments", "The constructor arguments", [])
371-
.setAction(async function ({ contractType, constructorArguments, address }, hre) {
371+
.addOptionalParam("libraries", "Libraries", "", types.str)
372+
.setAction(async function ({ contractType, constructorArguments, address, libraries }, hre) {
373+
const librariesDict =
374+
libraries !== "" ? Object.fromEntries(libraries.split(",").map((keyAddress) => keyAddress.split(":"))) : {};
372375
const contract = await hre.ethers.getContractAt(contractType, address);
373376

374-
await verifyBinaryContract(hre, contract, false, constructorArguments);
377+
await verifyBinaryContract(hre, contract, false, constructorArguments, librariesDict);
375378
});
376379
task("vb:findArtifact", "Finds the artifact for a contract")
377380
.addPositionalParam("contract", "The contract type to find")

0 commit comments

Comments
 (0)