diff --git a/packages/contracts/allowlist.txt b/packages/contracts/allowlist.txt index df8dc4f7..ff81a079 100644 --- a/packages/contracts/allowlist.txt +++ b/packages/contracts/allowlist.txt @@ -1,4 +1,4 @@ -0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266,ID -0x70997970C51812dc3A010C7d01b50e0d17dc79C8,ID -0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC,ID -0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC,ID +0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 +0x70997970C51812dc3A010C7d01b50e0d17dc79C8 +0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC +0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC diff --git a/packages/contracts/contracts/discovery/Project.sol b/packages/contracts/contracts/discovery/Project.sol index 7c31a6a4..505c5f9c 100644 --- a/packages/contracts/contracts/discovery/Project.sol +++ b/packages/contracts/contracts/discovery/Project.sol @@ -113,10 +113,9 @@ contract Project is IProject, ERC165 { function invest( uint256 _peoplesAmount, uint256 _stakersAmount, - string calldata _id, bytes32[] calldata _merkleProof ) public override(IProject) { - bytes32 leaf = keccak256(abi.encodePacked(msg.sender, _id)); + bytes32 leaf = keccak256(abi.encodePacked(msg.sender)); bool isValidLeaf = MerkleProof.verify(_merkleProof, merkleRoot, leaf); if (!isValidLeaf) revert InvalidLeaf(); } diff --git a/packages/contracts/contracts/discovery/interfaces/IProject.sol b/packages/contracts/contracts/discovery/interfaces/IProject.sol index da4facb3..f2380cc8 100644 --- a/packages/contracts/contracts/discovery/interfaces/IProject.sol +++ b/packages/contracts/contracts/discovery/interfaces/IProject.sol @@ -28,7 +28,6 @@ interface IProject { function invest( uint256 _peoplesAmount, uint256 _stakersAmount, - string calldata _id, bytes32[] calldata _merkleProof ) external; diff --git a/packages/contracts/contracts/test/MockProject.sol b/packages/contracts/contracts/test/MockProject.sol index f4c5971d..1d044937 100644 --- a/packages/contracts/contracts/test/MockProject.sol +++ b/packages/contracts/contracts/test/MockProject.sol @@ -46,7 +46,6 @@ contract MockProject is IProject { function invest( uint256 _peoplesAmount, uint256 _stakersAmount, - string calldata _id, bytes32[] calldata _merkleProof ) external { if (stakersPool != address(0)) { diff --git a/packages/contracts/deploy/controller.ts b/packages/contracts/deploy/controller.ts index 4e81295d..8238d395 100644 --- a/packages/contracts/deploy/controller.ts +++ b/packages/contracts/deploy/controller.ts @@ -10,7 +10,7 @@ const func: DeployFunction = async function (hre) { const citizend = await get("Citizend"); const staking = await get("Staking"); const merkleRoot = - "0x8e7ccfa471d15a7917e49017f94715d09cb940a6d5f088f516e16b0da32ff610"; + "0xa5c09e2a9128afef7246a5900cfe02c4bd2cfcac8ac4286f0159a699c8455a49"; await acalaDeploy(hre, "Controller", { from: deployer, diff --git a/packages/contracts/script/DevDeploy.s.sol b/packages/contracts/script/DevDeploy.s.sol index 007d669a..06180d84 100644 --- a/packages/contracts/script/DevDeploy.s.sol +++ b/packages/contracts/script/DevDeploy.s.sol @@ -27,7 +27,7 @@ contract DevDeployScript is Script { Citizend citizend = new Citizend(alice); Staking staking = new Staking(address(citizend)); - bytes32 merkleRoot = 0x8e7ccfa471d15a7917e49017f94715d09cb940a6d5f088f516e16b0da32ff610; + bytes32 merkleRoot = 0xa5c09e2a9128afef7246a5900cfe02c4bd2cfcac8ac4286f0159a699c8455a49; Project project = new Project("token sale project", address(citizend), 1000, 1, address(0), merkleRoot); for (uint256 i; i < testAccounts.length; i++) { diff --git a/packages/contracts/script/generateMerkleTree.ts b/packages/contracts/script/generateMerkleTree.ts index 8b610528..f6b38c87 100644 --- a/packages/contracts/script/generateMerkleTree.ts +++ b/packages/contracts/script/generateMerkleTree.ts @@ -4,13 +4,13 @@ import fs from "fs"; import { keccak256, encodePacked } from "viem"; let test_addresses = [ - ["0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", "ID"], - ["0x70997970C51812dc3A010C7d01b50e0d17dc79C8", "ID"], - ["0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC", "ID"], - ["0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC", "ID"], + "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + "0x70997970C51812dc3A010C7d01b50e0d17dc79C8", + "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC", + "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC", ]; -async function main(address: string, credential: string) { +async function main(address: string) { let addresses: string[][]; if (process.env.TEST_MODE) { @@ -20,10 +20,7 @@ async function main(address: string, credential: string) { .readFileSync("allowlist.txt") .toString() .split("\n") - .filter((s: string) => s.length > 0) - .map((s: string) => { - return s.split(","); - }); + .filter((s: string) => s.length > 0); } console.log("Addresses: ", addresses); @@ -31,7 +28,7 @@ async function main(address: string, credential: string) { const data = addresses.map((addr: string) => { return { address: addr, - leaf: keccak256(encodePacked(["address", "string"], addr)), + leaf: keccak256(encodePacked(["address"], [addr])), }; }); @@ -40,14 +37,14 @@ async function main(address: string, credential: string) { console.log(`Merkle root: ${merkleTree.getHexRoot()}`); - const key = [address, credential]; + const key = [address]; console.log(`\n\nProof for ${key}:`); console.log( - merkleTree.getHexProof(keccak256(encodePacked(["address", "string"], key))) + merkleTree.getHexProof(keccak256(encodePacked(["address"], key))) ); } -main(process.argv[2], process.argv[3]) +main(process.argv[2]) .then(() => process.exit(0)) .catch((error) => { console.error(error); diff --git a/packages/contracts/test/contracts/discovery/Batch.ts b/packages/contracts/test/contracts/discovery/Batch.ts index 6205617b..f52f59b0 100644 --- a/packages/contracts/test/contracts/discovery/Batch.ts +++ b/packages/contracts/test/contracts/discovery/Batch.ts @@ -61,7 +61,7 @@ describe("Batch", () => { registry.address, staking.address, citizend.address, - "0x8e7ccfa471d15a7917e49017f94715d09cb940a6d5f088f516e16b0da32ff610" + "0xa5c09e2a9128afef7246a5900cfe02c4bd2cfcac8ac4286f0159a699c8455a49" ); aUSD = await new MockERC20__factory(owner).deploy("aUSD", "aUSD", 12); diff --git a/packages/contracts/test/contracts/discovery/Controller.ts b/packages/contracts/test/contracts/discovery/Controller.ts index 336a7210..fcf5f50e 100644 --- a/packages/contracts/test/contracts/discovery/Controller.ts +++ b/packages/contracts/test/contracts/discovery/Controller.ts @@ -54,7 +54,7 @@ describe("Controller", () => { registry.address, staking.address, citizend.address, - "0x8e7ccfa471d15a7917e49017f94715d09cb940a6d5f088f516e16b0da32ff610" + "0xa5c09e2a9128afef7246a5900cfe02c4bd2cfcac8ac4286f0159a699c8455a49" ); }); diff --git a/packages/contracts/test/contracts/discovery/Project.d.sol b/packages/contracts/test/contracts/discovery/Project.d.sol index dc460a5b..fd5f5885 100644 --- a/packages/contracts/test/contracts/discovery/Project.d.sol +++ b/packages/contracts/test/contracts/discovery/Project.d.sol @@ -22,10 +22,10 @@ contract ProjectTest is Test { function setUp() public { vm.startPrank(alice); - bytes32 merkleRoot = 0x8e7ccfa471d15a7917e49017f94715d09cb940a6d5f088f516e16b0da32ff610; + bytes32 merkleRoot = 0xa5c09e2a9128afef7246a5900cfe02c4bd2cfcac8ac4286f0159a699c8455a49; proofs[alice] = [ - bytes32(0xd3f793615f8d887594ece7ec035678d9b82bc492d243cdf3d4d54a007dfab520), - bytes32(0x6c31f90dc2f54aacc0a676de83d706f1e0fdd99e31867640d8c87a6af1a1dd86) + bytes32(0x00314e565e0574cb412563df634608d76f5c59d9f817e85966100ec1d48005c0), + bytes32(0x347dce04eb339ca70588960730ef0cada966bb1d5e10a9b9489a3e0ba47dc1b6) ]; citizend = new Citizend(alice); @@ -37,16 +37,16 @@ contract ProjectTest is Test { function testInvest() public { vm.startPrank(alice); - project.invest(1,1,"ID", proofs[alice]); + project.invest(1,1, proofs[alice]); vm.stopPrank(); } - function testInvestShouldRevertWithInvalidCrendetial() public { + function testInvestShouldRevertWithInvalidProof() public { vm.startPrank(alice); vm.expectRevert(); - project.invest(1,1,"NOID", proofs[alice]); + project.invest(1,1, proofs[bob]); vm.stopPrank(); } diff --git a/packages/contracts/test/contracts/discovery/ProjectVoting.ts b/packages/contracts/test/contracts/discovery/ProjectVoting.ts index 3e655f17..591ec07e 100644 --- a/packages/contracts/test/contracts/discovery/ProjectVoting.ts +++ b/packages/contracts/test/contracts/discovery/ProjectVoting.ts @@ -257,7 +257,7 @@ describe("ProjectVoting", () => { 1000, 10, aUSD.address, - "0x8e7ccfa471d15a7917e49017f94715d09cb940a6d5f088f516e16b0da32ff610" + "0xa5c09e2a9128afef7246a5900cfe02c4bd2cfcac8ac4286f0159a699c8455a49" ); } }); diff --git a/packages/contracts/test/contracts/discovery/pool/Pool.ts b/packages/contracts/test/contracts/discovery/pool/Pool.ts index 4e178790..5f7e40d7 100644 --- a/packages/contracts/test/contracts/discovery/pool/Pool.ts +++ b/packages/contracts/test/contracts/discovery/pool/Pool.ts @@ -25,16 +25,14 @@ describe("Pool", () => { let pool: TestPool; - let id: string; let merkleProof: BytesLike[]; beforeEach(async () => { [owner, alice, bob] = await ethers.getSigners(); - id = "ID"; merkleProof = [ - "0xd3f793615f8d887594ece7ec035678d9b82bc492d243cdf3d4d54a007dfab520", - "0x6c31f90dc2f54aacc0a676de83d706f1e0fdd99e31867640d8c87a6af1a1dd86", + "0x00314e565e0574cb412563df634608d76f5c59d9f817e85966100ec1d48005c0", + "0x347dce04eb339ca70588960730ef0cada966bb1d5e10a9b9489a3e0ba47dc1b6", ]; aUSD = await new MockERC20__factory(owner).deploy("aUSD", "aUSD", 12); @@ -64,7 +62,7 @@ describe("Pool", () => { describe("setIndividualCap", () => { it("allows me to set the cap after investment period is over", async () => { - await project.connect(alice).invest(0, 100, id, merkleProof); + await project.connect(alice).invest(0, 100, merkleProof); await pool.setIndividualCap(100, { gasLimit: 10000000 }); @@ -73,7 +71,7 @@ describe("Pool", () => { }); it("fails to validate the cap for the wrong value", async () => { - await project.connect(alice).invest(0, 100, id, merkleProof); + await project.connect(alice).invest(0, 100, merkleProof); await pool.setIndividualCap(50, { gasLimit: 10000000 }); @@ -84,7 +82,7 @@ describe("Pool", () => { describe("refund", () => { it("fails if individual cap is not yet set", async () => { - await project.connect(alice).invest(0, 100, id, merkleProof); + await project.connect(alice).invest(0, 100, merkleProof); await expect(pool.refund(alice.address)).to.be.revertedWith( "cap not yet set" @@ -94,7 +92,7 @@ describe("Pool", () => { it("refunds the correct amount once the cap is set", async () => { const cap = 1000; const amount = cap + 1000; - await project.connect(alice).invest(0, amount, id, merkleProof); + await project.connect(alice).invest(0, amount, merkleProof); await pool.setIndividualCap(cap, { gasLimit: 10000000 }); await expect(() => pool.refund(alice.address)).to.changeTokenBalance( @@ -107,7 +105,7 @@ describe("Pool", () => { it("emits an event", async () => { const cap = 1000; const amount = cap + 1000; - await project.connect(alice).invest(0, amount, id, merkleProof); + await project.connect(alice).invest(0, amount, merkleProof); await pool.setIndividualCap(cap, { gasLimit: 10000000 }); await expect(pool.refund(alice.address)) @@ -118,7 +116,7 @@ describe("Pool", () => { it("does not allow double refunds", async () => { const cap = 1000; const amount = cap + 1000; - await project.connect(alice).invest(0, amount, id, merkleProof); + await project.connect(alice).invest(0, amount, merkleProof); await pool.setIndividualCap(cap, { gasLimit: 10000000 }); await pool.refund(alice.address); @@ -139,8 +137,8 @@ describe("Pool", () => { }); it("is 0 if the individual cap is higher than the invested total", async () => { - await project.connect(alice).invest(0, 200, id, merkleProof); - await project.connect(bob).invest(0, 200, id, merkleProof); + await project.connect(alice).invest(0, 200, merkleProof); + await project.connect(bob).invest(0, 200, merkleProof); await pool.setIndividualCap(800, { gasLimit: 10000000 }); @@ -148,7 +146,7 @@ describe("Pool", () => { }); it("is the difference between the cap and the invested total", async () => { - await project.connect(alice).invest(0, 1001, id, merkleProof); + await project.connect(alice).invest(0, 1001, merkleProof); await pool.setIndividualCap(1000, { gasLimit: 10000000 }); @@ -158,7 +156,7 @@ describe("Pool", () => { describe("uncappedAllocation", () => { it("is the amount that was invested", async () => { - await project.connect(alice).invest(0, 100, id, merkleProof); + await project.connect(alice).invest(0, 100, merkleProof); expect(await pool.uncappedAllocation(alice.address)).to.equal(100); }); @@ -170,8 +168,8 @@ describe("Pool", () => { }); it("is the amount that was invested if below cap", async () => { - await project.connect(alice).invest(0, 50, id, merkleProof); - await project.connect(bob).invest(0, 1000, id, merkleProof); + await project.connect(alice).invest(0, 50, merkleProof); + await project.connect(bob).invest(0, 1000, merkleProof); await pool.setIndividualCap(950, { gasLimit: 10000000 }); @@ -179,7 +177,7 @@ describe("Pool", () => { }); it("is the amount that was invested if above cap", async () => { - await project.connect(alice).invest(0, 1001, id, merkleProof); + await project.connect(alice).invest(0, 1001, merkleProof); await pool.setIndividualCap(1000, { gasLimit: 10000000 });