Skip to content

Commit d0a9a80

Browse files
committed
refactor: adopt ERC-5313 by renaming governor to owner
1 parent 057957e commit d0a9a80

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+848
-709
lines changed

contracts/deploy/00-home-chain-arbitration-ruler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
2929
await deployUpgradable(deployments, "KlerosCoreRuler", {
3030
from: deployer,
3131
args: [
32-
deployer, // governor
32+
deployer, // owner
3333
pnk.target,
3434
[minStake, alpha, feeForJuror, jurorsForCourtJump],
3535
],

contracts/deploy/00-home-chain-arbitration-university.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
5050
const klerosCore = await deployUpgradable(deployments, "KlerosCoreUniversity", {
5151
from: deployer,
5252
args: [
53-
deployer, // governor
53+
deployer, // owner
5454
deployer, // instructor
5555
pnk.target,
5656
ZeroAddress, // KlerosCore is configured later

contracts/hardhat.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import "hardhat-contract-sizer";
1515
import "hardhat-tracer";
1616
require("./scripts/populatePolicyRegistry");
1717
require("./scripts/populateCourts");
18-
require("./scripts/changeGovernor");
18+
require("./scripts/changeOwner");
1919
require("./scripts/getDisputeTemplate");
2020
require("./scripts/compareStorageLayout");
2121
require("./scripts/storage-layout");

contracts/scripts/changeGovernor.ts

Lines changed: 0 additions & 77 deletions
This file was deleted.

contracts/scripts/changeOwner.ts

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import { task } from "hardhat/config";
2+
import { prompt, print } from "gluegun";
3+
import { Cores, getContracts } from "./utils/contracts";
4+
import { isAddress } from "viem";
5+
6+
const { bold } = print.colors;
7+
8+
task("change-owner", "Changes the owner for all the contracts")
9+
.addPositionalParam("newOwner", "The address of the new owner")
10+
.addOptionalParam("coreType", "The type of core to use between base, neo, university (default: base)", Cores.BASE)
11+
.setAction(async (taskArgs, hre) => {
12+
const newOwner = taskArgs.newOwner;
13+
if (!isAddress(newOwner)) {
14+
throw new Error("Invalid owner address provided");
15+
}
16+
print.highlight(`💣 Changing owner to ${bold(newOwner)}`);
17+
18+
const { confirm } = await prompt.ask({
19+
type: "confirm",
20+
name: "confirm",
21+
message: "Are you sure you want to proceed?",
22+
});
23+
if (!confirm) {
24+
console.log("Operation cancelled by user.");
25+
return;
26+
}
27+
28+
const coreType = Cores[taskArgs.coreType.toUpperCase() as keyof typeof Cores];
29+
if (coreType === undefined) {
30+
console.error("Invalid core type, must be one of base, neo, university");
31+
return;
32+
}
33+
console.log("Using core type %s", coreType);
34+
35+
const {
36+
core,
37+
disputeKitClassic,
38+
disputeResolver,
39+
disputeTemplateRegistry,
40+
policyRegistry,
41+
chainlinkRng,
42+
randomizerRng,
43+
snapshotProxy,
44+
sortition,
45+
evidence,
46+
} = await getContracts(hre, coreType);
47+
48+
const updateOwner = async (contractName: string, contractInstance: any) => {
49+
print.info(`Changing owner for ${contractName}`);
50+
51+
const spinner = print.spin(`Executing transaction for ${contractName}...`);
52+
try {
53+
const tx = await contractInstance.changeOwner(newOwner);
54+
await tx.wait();
55+
spinner.succeed(`Owner changed for ${contractName}, tx hash: ${tx.hash}`);
56+
} catch (error) {
57+
if (error instanceof Error) {
58+
spinner.fail(`Failed to change owner for ${contractName}: ${error.message}`);
59+
} else {
60+
spinner.fail(`Failed to change owner for ${contractName}: ${String(error)}`);
61+
}
62+
}
63+
};
64+
65+
await updateOwner("KlerosCore", core);
66+
await updateOwner("DisputeKitClassic", disputeKitClassic);
67+
await updateOwner("DisputeResolver", disputeResolver);
68+
await updateOwner("DisputeTemplateRegistry", disputeTemplateRegistry);
69+
await updateOwner("PolicyRegistry", policyRegistry);
70+
await updateOwner("KlerosCoreSnapshotProxy", snapshotProxy);
71+
await updateOwner("SortitionModule", sortition);
72+
await updateOwner("EvidenceModule", evidence);
73+
if (chainlinkRng) await updateOwner("ChainlinkRNG", chainlinkRng);
74+
if (randomizerRng) await updateOwner("RandomizerRNG", randomizerRng);
75+
76+
print.success("Owner changed successfully");
77+
});

contracts/scripts/utils/execution.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { type BuilderTransaction, template, transaction, transactionBuilderUrl }
55
const governableAbi = [
66
{
77
inputs: [],
8-
name: "governor",
8+
name: "owner",
99
outputs: [
1010
{
1111
internalType: "address",
@@ -25,8 +25,8 @@ export const execute = async (tx: ContractTransaction) => {
2525
const { ethers } = hre;
2626

2727
const contract = await ethers.getContractAt(governableAbi, tx.to);
28-
const governor = await contract.governor();
29-
const isContract = (await ethers.provider.getCode(governor)).length > 2;
28+
const owner = await contract.owner();
29+
const isContract = (await ethers.provider.getCode(owner)).length > 2;
3030
if (isContract) {
3131
// Don't execute, just log the tx. It must be submitted for execution separately.
3232
const { to, value, data } = tx;

contracts/scripts/utils/tx-builder.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { arbitrum } from "viem/chains";
22

3-
const governor = "0x66e8DE9B42308c6Ca913D1EE041d6F6fD037A57e";
3+
const owner = "0x66e8DE9B42308c6Ca913D1EE041d6F6fD037A57e";
44
const deployer = "0xf1C7c037891525E360C59f708739Ac09A7670c59";
55

66
// Transaction batch example: https://github.com/safe-global/safe-wallet-monorepo/blob/8bbf3b82edc347b70a038629cd9afd45eb1ed38a/apps/web/cypress/fixtures/test-working-batch.json
@@ -12,7 +12,7 @@ export const template = ({ name, transactions }: { name: string; transactions: B
1212
name,
1313
description: "", // Not used because the Safe app doesn't show it
1414
txBuilderVersion: "1.18.0",
15-
createdFromSafeAddress: governor,
15+
createdFromSafeAddress: owner,
1616
createdFromOwnerAddress: deployer,
1717
},
1818
transactions,
@@ -42,4 +42,4 @@ export interface BuilderTransaction {
4242
contractInputsValues: null;
4343
}
4444

45-
export const transactionBuilderUrl = `https://app.safe.global/apps/open?safe=arb1:${governor}&appUrl=https%3A%2F%2Fapps-portal.safe.global%2Ftx-builder`;
45+
export const transactionBuilderUrl = `https://app.safe.global/apps/open?safe=arb1:${owner}&appUrl=https%3A%2F%2Fapps-portal.safe.global%2Ftx-builder`;

contracts/scripts/viemTest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const main = async () => {
1515
client: client,
1616
});
1717

18-
await disputeKit.read.governor().then(console.log);
18+
await disputeKit.read.owner().then(console.log);
1919

2020
// --------------------------------------------------
2121

contracts/src/arbitration/DisputeTemplateRegistry.sol

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ contract DisputeTemplateRegistry is IDisputeTemplateRegistry, UUPSProxiable, Ini
1414
// * Storage * //
1515
// ************************************* //
1616

17-
/// @dev The governor of the contract.
18-
address public governor;
17+
/// @dev The owner of the contract.
18+
address public owner;
1919

2020
/// @dev The number of templates.
2121
uint256 public templates;
@@ -24,8 +24,8 @@ contract DisputeTemplateRegistry is IDisputeTemplateRegistry, UUPSProxiable, Ini
2424
// * Function Modifiers * //
2525
// ************************************* //
2626

27-
modifier onlyByGovernor() {
28-
if (governor != msg.sender) revert GovernorOnly();
27+
modifier onlyByOwner() {
28+
if (owner != msg.sender) revert OwnerOnly();
2929
_;
3030
}
3131

@@ -39,9 +39,9 @@ contract DisputeTemplateRegistry is IDisputeTemplateRegistry, UUPSProxiable, Ini
3939
}
4040

4141
/// @dev Initializer
42-
/// @param _governor Governor of the contract.
43-
function initialize(address _governor) external reinitializer(1) {
44-
governor = _governor;
42+
/// @param _owner Owner of the contract.
43+
function initialize(address _owner) external reinitializer(1) {
44+
owner = _owner;
4545
}
4646

4747
function initialize2() external reinitializer(2) {
@@ -53,15 +53,15 @@ contract DisputeTemplateRegistry is IDisputeTemplateRegistry, UUPSProxiable, Ini
5353
// ************************ //
5454

5555
/// @dev Access Control to perform implementation upgrades (UUPS Proxiable)
56-
/// Only the governor can perform upgrades (`onlyByGovernor`)
57-
function _authorizeUpgrade(address) internal view override onlyByGovernor {
56+
/// Only the owner can perform upgrades (`onlyByOwner`)
57+
function _authorizeUpgrade(address) internal view override onlyByOwner {
5858
// NOP
5959
}
6060

61-
/// @dev Changes the governor of the contract.
62-
/// @param _governor The new governor.
63-
function changeGovernor(address _governor) external onlyByGovernor {
64-
governor = _governor;
61+
/// @dev Changes the owner of the contract.
62+
/// @param _owner The new owner.
63+
function changeOwner(address _owner) external onlyByOwner {
64+
owner = _owner;
6565
}
6666

6767
// ************************************* //
@@ -85,5 +85,5 @@ contract DisputeTemplateRegistry is IDisputeTemplateRegistry, UUPSProxiable, Ini
8585
// * Errors * //
8686
// ************************************* //
8787

88-
error GovernorOnly();
88+
error OwnerOnly();
8989
}

contracts/src/arbitration/KlerosCore.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ contract KlerosCore is KlerosCoreBase {
2020
}
2121

2222
/// @dev Initializer (constructor equivalent for upgradable contracts).
23-
/// @param _governor The governor's address.
23+
/// @param _owner The owner's address.
2424
/// @param _guardian The guardian's address.
2525
/// @param _pinakion The address of the token contract.
2626
/// @param _jurorProsecutionModule The address of the juror prosecution module.
@@ -32,7 +32,7 @@ contract KlerosCore is KlerosCoreBase {
3232
/// @param _sortitionModuleAddress The sortition module responsible for sortition of the jurors.
3333
/// @param _wNative The wrapped native token address, typically wETH.
3434
function initialize(
35-
address _governor,
35+
address _owner,
3636
address _guardian,
3737
IERC20 _pinakion,
3838
address _jurorProsecutionModule,
@@ -45,7 +45,7 @@ contract KlerosCore is KlerosCoreBase {
4545
address _wNative
4646
) external reinitializer(1) {
4747
__KlerosCoreBase_initialize(
48-
_governor,
48+
_owner,
4949
_guardian,
5050
_pinakion,
5151
_jurorProsecutionModule,
@@ -68,8 +68,8 @@ contract KlerosCore is KlerosCoreBase {
6868
// ************************************* //
6969

7070
/// @dev Access Control to perform implementation upgrades (UUPS Proxiable)
71-
/// Only the governor can perform upgrades (`onlyByGovernor`)
72-
function _authorizeUpgrade(address) internal view override onlyByGovernor {
71+
/// Only the owner can perform upgrades (`onlyByOwner`)
72+
function _authorizeUpgrade(address) internal view override onlyByOwner {
7373
// NOP
7474
}
7575
}

0 commit comments

Comments
 (0)