Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: token owner to Executor [CHAIN-310] #18

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,11 @@ sequenceDiagram
deployer ->> Executor: grantRole(CANCELLER_ROLE, FluenceMultisig)
deployer ->> Executor: revokeRole(ADMIN_ROLE, deployer)
deployer ->>+ FluenceToken: transfer (balance) to Governor
FluenceToken ->>- Governor: transfer (balance)
FluenceToken ->>- Executor: transfer (balance)
FluenceToken ->> Executor: transferOwnership(Executor)

Note over Governor: Owner: Executor
Note over FluenceToken: Owner: Executor
Note over Executor: Admin Role: [0x0]
Note over Executor: Proposer Role: [Governor]
Note over Executor: Canceller Role: [Governor, FluenceMultisig]
Expand Down
30 changes: 21 additions & 9 deletions contracts/deploy/0007_Governor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const CANCELLER_ROLE = ethers.utils.keccak256(
ethers.utils.toUtf8Bytes("CANCELLER_ROLE")
);
const DEFAULT_ADMIN_ROLE = ethers.utils.hexZeroPad([0], 32);
const DEFAULT_WAIT_CONFIRMATIONS = 1;

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployer } = await hre.getNamedAccounts();
Expand Down Expand Up @@ -47,7 +48,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
},
log: true,
autoMine: true,
waitConfirmations: 1,
waitConfirmations: DEFAULT_WAIT_CONFIRMATIONS,
});

await hre.deployments.execute(
Expand All @@ -56,7 +57,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
from: deployer,
log: true,
autoMine: true,
waitConfirmations: 1,
waitConfirmations: DEFAULT_WAIT_CONFIRMATIONS,
},
"grantRole",
RPROPOSER_ROLE,
Expand All @@ -69,7 +70,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
from: deployer,
log: true,
autoMine: true,
waitConfirmations: 1,
waitConfirmations: DEFAULT_WAIT_CONFIRMATIONS,
},
"grantRole",
CANCELLER_ROLE,
Expand All @@ -83,7 +84,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
from: deployer,
log: true,
autoMine: true,
waitConfirmations: 1,
waitConfirmations: DEFAULT_WAIT_CONFIRMATIONS,
},
"grantRole",
CANCELLER_ROLE,
Expand All @@ -96,13 +97,14 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
from: deployer,
log: true,
autoMine: true,
waitConfirmations: 1,
waitConfirmations: DEFAULT_WAIT_CONFIRMATIONS,
},
"revokeRole",
DEFAULT_ADMIN_ROLE,
deployer
);

// Send all tokens to Executor and announce ownership to Executor.
const balance: BigNumber = await hre.deployments.read(
"FluenceToken",
{
Expand All @@ -119,15 +121,25 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
from: deployer,
log: true,
autoMine: true,
waitConfirmations: 1,
waitConfirmations: DEFAULT_WAIT_CONFIRMATIONS,
},
"transfer",
(
await hre.deployments.get("Executor")
).address,
executorAddress,
balance
);
}

await hre.deployments.execute(
"FluenceToken",
{
from: deployer,
log: true,
autoMine: true,
waitConfirmations: DEFAULT_WAIT_CONFIRMATIONS,
},
"transferOwnership",
executorAddress
);
};

export default func;
Expand Down
18 changes: 12 additions & 6 deletions contracts/test/Deploy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ describe("Deploy script", () => {
const setupTest = deployments.createFixture(
async (hre: HardhatRuntimeEnvironment) => {
const hardhatSigners = await hre.ethers.getSigners();
usdToken = await new DevERC20__factory(
hardhatSigners[0]
).deploy("USD", "USD", ethers.utils.parseEther(String(lbpUSDAmount)));
usdToken = await new DevERC20__factory(hardhatSigners[0]).deploy(
"USD",
"USD",
ethers.utils.parseEther(String(lbpUSDAmount))
);

fluenceMultisig = hardhatSigners[hardhatSigners.length - 1];

Expand Down Expand Up @@ -201,6 +203,8 @@ describe("Deploy script", () => {
expect(await token.totalSupply()).to.eq(
ethers.utils.parseEther(String(config.deployment!.token!.totalSupply))
);

expect(await token.owner()).to.eq(executor.address);
});

it("token balances are correct", async () => {
Expand Down Expand Up @@ -264,7 +268,7 @@ describe("Deploy script", () => {

expect(await token.balanceOf(governor.address)).to.eq(0);

//TODO: veify balancer
// TODO: veify balancer
});

it("executor roles are correct", async () => {
Expand Down Expand Up @@ -293,8 +297,10 @@ describe("Deploy script", () => {
"0x0000000000000000000000000000000000000000"
)
).to.eq(true);

expect(await executor.hasRole(CANCELLER_ROLE, fluenceMultisig.address)).to.eq(true);

expect(
await executor.hasRole(CANCELLER_ROLE, fluenceMultisig.address)
).to.eq(true);
});

it("DevRewardDistributor is correct", async () => {
Expand Down
Loading