Skip to content

Commit ef22f62

Browse files
committed
fix: added helper to change owner and guardian for ccc
1 parent 66fbf4a commit ef22f62

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,3 +288,6 @@ deploy-celo-path-payload:
288288

289289
update-owners-and-guardians:
290290
$(call deploy_fn,helpers/Update_Ownership,zksync)
291+
292+
update-celo-permissions:
293+
$(call deploy_fn,helpers/UpdateCCCPermissions,celo)
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// SPDX-License-Identifier: BUSL-1.1
2+
pragma solidity ^0.8.0;
3+
4+
import 'forge-std/Script.sol';
5+
import {OwnableWithGuardian, IWithGuardian} from 'solidity-utils/contracts/access-control/OwnableWithGuardian.sol';
6+
7+
abstract contract UpdateCCCPermissions {
8+
function targetOwner() public pure virtual returns (address);
9+
10+
function targetADIGuardian() public pure virtual returns (address);
11+
12+
function aDIContractsToUpdate() public pure virtual returns (address[] memory);
13+
14+
function _changeOwnerAndGuardian(
15+
address owner,
16+
address guardian,
17+
address[] memory contracts
18+
) internal {
19+
require(owner != address(0), 'NEW_OWNER_CANT_BE_0');
20+
require(guardian != address(0), 'NEW_GUARDIAN_CANT_BE_0');
21+
22+
for (uint256 i = 0; i < contracts.length; i++) {
23+
OwnableWithGuardian contractWithAC = OwnableWithGuardian(contracts[i]);
24+
try contractWithAC.guardian() returns (address currentGuardian) {
25+
if (currentGuardian != guardian) {
26+
IWithGuardian(contracts[i]).updateGuardian(guardian);
27+
}
28+
} catch {}
29+
if (contractWithAC.owner() != owner) {
30+
contractWithAC.transferOwnership(owner);
31+
}
32+
}
33+
}
34+
35+
function _changeOwnerAndGuardian() internal {
36+
_changeOwnerAndGuardian(targetOwner(), targetADIGuardian(), aDIContractsToUpdate());
37+
}
38+
}
39+
40+
41+
42+
contract UpdateCCCPermissionsCelo is UpdateCCCPermissions {
43+
function targetOwner() public pure override returns (address) {
44+
return 0x1dF462e2712496373A347f8ad10802a5E95f053D;
45+
}
46+
47+
function targetADIGuardian() public pure override returns (address) {
48+
return 0xbE815420A63A413BB8D508d8022C0FF150Ea7C39; // Granular Guardian
49+
}
50+
51+
52+
function aDIContractsToUpdate() public pure override returns (address[] memory) {
53+
address[] memory contracts = new address[](1);
54+
contracts[0] = 0x50F4dAA86F3c747ce15C3C38bD0383200B61d6Dd;
55+
return contracts;
56+
}
57+
}
58+
59+
contract Celo is Script, UpdateCCCPermissionsCelo {
60+
function run() external {
61+
vm.startBroadcast();
62+
63+
_changeOwnerAndGuardian();
64+
65+
vm.stopBroadcast();
66+
}
67+
}

0 commit comments

Comments
 (0)