Skip to content

Commit

Permalink
refactor: Add totalSupply in constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
PacificYield committed Nov 12, 2024
1 parent 01a8bef commit ff67828
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
16 changes: 9 additions & 7 deletions contracts/governance/Comp.sol
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,21 @@ abstract contract Comp is IComp, EncryptedERC20, EIP712, Ownable2Step {
euint64 private _EUINT64_ZERO;

/**
* @param owner_ Owner address.
* @param name_ Token name.
* @param symbol_ Token symbol.
* @param version_ Version (e.g. "0.1", "1.0").
* @param owner_ Owner address.
* @param name_ Token name.
* @param symbol_ Token symbol.
* @param version_ Version (e.g. "0.1", "1.0").
* @param totalSupply_ Total supply to mint.
*/
constructor(
address owner_,
string memory name_,
string memory symbol_,
string memory version_
string memory version_,
uint64 totalSupply_
) EncryptedERC20(name_, symbol_) EIP712(name_, version_) Ownable(owner_) {
_unsafeMint(owner_, TFHE.asEuint64(10000000e6)); /// 10 million Comp
_totalSupply = 10000000e6;
_unsafeMint(owner_, TFHE.asEuint64(totalSupply_));
_totalSupply = totalSupply_;

/// @dev Define the constant in the storage.
_EUINT64_ZERO = TFHE.asEuint64(0);
Expand Down
5 changes: 3 additions & 2 deletions contracts/test/governance/TestComp.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ contract TestComp is DefaultFHEVMConfig, Comp {
address owner_,
string memory name_,
string memory symbol_,
string memory version_
) Comp(owner_, name_, symbol_, version_) {
string memory version_,
uint64 totalSupply_
) Comp(owner_, name_, symbol_, version_, totalSupply_) {
//
}
}
3 changes: 2 additions & 1 deletion test/governance/Comp.fixture.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { parseUnits } from "ethers";
import { ethers } from "hardhat";

import type { TestComp } from "../../types";
Expand All @@ -9,7 +10,7 @@ export async function deployCompFixture(signers: Signers): Promise<TestComp> {
const contractFactory = await ethers.getContractFactory("TestComp");
const contract = await contractFactory
.connect(signers.alice)
.deploy(signers.alice.address, "CompoundZama", "COMP", "1.0");
.deploy(signers.alice.address, "CompoundZama", "COMP", "1.0", parseUnits("10000000", 6));
await contract.waitForDeployment();
return contract;
}
Expand Down

0 comments on commit ff67828

Please sign in to comment.