diff --git a/contracts/.openzeppelin/unknown-200.json b/contracts/.openzeppelin/unknown-200.json index 505f57b..fc38061 100644 --- a/contracts/.openzeppelin/unknown-200.json +++ b/contracts/.openzeppelin/unknown-200.json @@ -545,6 +545,36 @@ "txHash": "0xbaa0ffd2451137067aac3c232c94955842c9354b2eebf096fbca63c81fd95c82", "kind": "transparent" }, + { + "address": "0x6FD2E1C79ea43674AfaeE33006aDAE10e73c5703", + "txHash": "0x5493b85947f59ec616743d7733338368b7e3d611c5e4b1a6df5dc51629c0fd3f", + "kind": "transparent" + }, + { + "address": "0x8dafDB925f9465e81319A7FFa426B2db9895fFAA", + "txHash": "0xea8fa58978db6e11ea2aad4081bb6394ab1338775da85c16d50f8fff5f62066c", + "kind": "transparent" + }, + { + "address": "0x6bDA8D37D6F3ceC2eE0311A1E8DF71066785b0E5", + "txHash": "0xb86a19de3cc79d9682967c83e335ac6679f7abe11483d67f9c13229ccc810d0b", + "kind": "transparent" + }, + { + "address": "0xfAe3759AE4b14eCE78b61Dc20E6168dB02359437", + "txHash": "0xe75e6e217b517bddcf82e49320f73af362c704dcef38c7e694ce88828f722fd9", + "kind": "transparent" + }, + { + "address": "0xdCdc3faA387348AAB014CA1C367C537E886Fa6f3", + "txHash": "0xc62b5b2d523554b095a0f4921af26b6dda6df969bf4238230053b341c9953a55", + "kind": "transparent" + }, + { + "address": "0x482Eb47651084A137Db4d51996f8080C10200Ff1", + "txHash": "0x63f0f059ae33c8f5dc1bf750a0385f097fe88d11066b17ac2cb463eecd5a9174", + "kind": "transparent" + }, { "address": "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0", "txHash": "0x1d1956d4755c87951967682c732c65393635732738ea33738e89a4adb4e4ceb5", @@ -562,7 +592,7 @@ }, { "address": "0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6", - "txHash": "0x3760aa8fd584ec3fb85ba2c50a292048387ebf9fc5b0ffdfae8629457fe86814", + "txHash": "0xb33b4cdafad2af1a4ac86c1e20fc8cc7c4f35cefd1d82bcefd6eb9ff87b91df3", "kind": "transparent" } ], @@ -5250,9 +5280,9 @@ } } }, - "da6392f0cc476b3602421d3b0fe2acfc747f9cc353e2fff495fa0a9c4782c899": { - "address": "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9", - "txHash": "0x39d682e5ebb8167ba1cae807612ed2415a15405f14fed9da668e6688f107602d", + "f5a97feac430611f1bbc04c460fe3e24a8b15e2e07384b8c7d71efbd920f5c65": { + "address": "0x97a2403471c2cec531249CFb45dfb7983b41d7d8", + "txHash": "0xf4b458f4e61fde45dd34d55c731cea79d175cafe2fa23206fbafe67b6bb3b247", "layout": { "solcVersion": "0.8.12", "storage": [ @@ -5282,84 +5312,108 @@ "src": "@openzeppelin\\contracts-upgradeable\\utils\\ContextUpgradeable.sol:36" }, { - "label": "_balances", + "label": "_owner", "offset": 0, "slot": "51", - "type": "t_mapping(t_address,t_uint256)", - "contract": "ERC20Upgradeable", - "src": "@openzeppelin\\contracts-upgradeable\\token\\ERC20\\ERC20Upgradeable.sol:37" + "type": "t_address", + "contract": "OwnableUpgradeable", + "src": "@openzeppelin\\contracts-upgradeable\\access\\OwnableUpgradeable.sol:22" }, { - "label": "_allowances", + "label": "__gap", "offset": 0, "slot": "52", - "type": "t_mapping(t_address,t_mapping(t_address,t_uint256))", - "contract": "ERC20Upgradeable", - "src": "@openzeppelin\\contracts-upgradeable\\token\\ERC20\\ERC20Upgradeable.sol:39" + "type": "t_array(t_uint256)49_storage", + "contract": "OwnableUpgradeable", + "src": "@openzeppelin\\contracts-upgradeable\\access\\OwnableUpgradeable.sol:94" }, { - "label": "_totalSupply", + "label": "ACCEPTED", "offset": 0, - "slot": "53", - "type": "t_uint256", - "contract": "ERC20Upgradeable", - "src": "@openzeppelin\\contracts-upgradeable\\token\\ERC20\\ERC20Upgradeable.sol:41" + "slot": "101", + "type": "t_string_storage", + "contract": "ReportDomain", + "src": "contracts\\ReportDomain.sol:9" }, { - "label": "_name", + "label": "REJECTED", "offset": 0, - "slot": "54", + "slot": "102", "type": "t_string_storage", - "contract": "ERC20Upgradeable", - "src": "@openzeppelin\\contracts-upgradeable\\token\\ERC20\\ERC20Upgradeable.sol:43" + "contract": "ReportDomain", + "src": "contracts\\ReportDomain.sol:10" }, { - "label": "_symbol", + "label": "governanceBadgeNFT", "offset": 0, - "slot": "55", - "type": "t_string_storage", - "contract": "ERC20Upgradeable", - "src": "@openzeppelin\\contracts-upgradeable\\token\\ERC20\\ERC20Upgradeable.sol:44" + "slot": "103", + "type": "t_address", + "contract": "ReportDomain", + "src": "contracts\\ReportDomain.sol:12" }, { - "label": "__gap", + "label": "treasuryContract", "offset": 0, - "slot": "56", - "type": "t_array(t_uint256)45_storage", - "contract": "ERC20Upgradeable", - "src": "@openzeppelin\\contracts-upgradeable\\token\\ERC20\\ERC20Upgradeable.sol:400" + "slot": "104", + "type": "t_address", + "contract": "ReportDomain", + "src": "contracts\\ReportDomain.sol:13" }, { - "label": "_owner", + "label": "stakingAmount", "offset": 0, - "slot": "101", - "type": "t_address", - "contract": "OwnableUpgradeable", - "src": "@openzeppelin\\contracts-upgradeable\\access\\OwnableUpgradeable.sol:22" + "slot": "105", + "type": "t_uint256", + "contract": "ReportDomain", + "src": "contracts\\ReportDomain.sol:15" }, { - "label": "__gap", + "label": "reward", "offset": 0, - "slot": "102", - "type": "t_array(t_uint256)49_storage", - "contract": "OwnableUpgradeable", - "src": "@openzeppelin\\contracts-upgradeable\\access\\OwnableUpgradeable.sol:94" + "slot": "106", + "type": "t_uint256", + "contract": "ReportDomain", + "src": "contracts\\ReportDomain.sol:16" }, { - "label": "minted_reward_tokens", + "label": "lockedAmount", "offset": 0, - "slot": "151", + "slot": "107", "type": "t_uint256", - "contract": "Token", - "src": "contracts\\Token.sol:11" + "contract": "ReportDomain", + "src": "contracts\\ReportDomain.sol:17" }, { - "label": "minted_grant_tokens", + "label": "reportID", "offset": 0, - "slot": "152", + "slot": "108", "type": "t_uint256", - "contract": "Token", - "src": "contracts\\Token.sol:12" + "contract": "ReportDomain", + "src": "contracts\\ReportDomain.sol:18" + }, + { + "label": "reportsByDomain", + "offset": 0, + "slot": "109", + "type": "t_mapping(t_string_memory_ptr,t_struct(DomainClaim)3792_storage)", + "contract": "ReportDomain", + "src": "contracts\\ReportDomain.sol:46" + }, + { + "label": "reportsByID", + "offset": 0, + "slot": "110", + "type": "t_mapping(t_uint256,t_struct(ReportInfo)3821_storage)", + "contract": "ReportDomain", + "src": "contracts\\ReportDomain.sol:47" + }, + { + "label": "points", + "offset": 0, + "slot": "111", + "type": "t_mapping(t_address,t_uint256)", + "contract": "ReportDomain", + "src": "contracts\\ReportDomain.sol:48" } ], "types": { @@ -5367,10 +5421,6 @@ "label": "address", "numberOfBytes": "20" }, - "t_array(t_uint256)45_storage": { - "label": "uint256[45]", - "numberOfBytes": "1440" - }, "t_array(t_uint256)49_storage": { "label": "uint256[49]", "numberOfBytes": "1568" @@ -5383,18 +5433,158 @@ "label": "bool", "numberOfBytes": "1" }, - "t_mapping(t_address,t_mapping(t_address,t_uint256))": { - "label": "mapping(address => mapping(address => uint256))", - "numberOfBytes": "32" - }, "t_mapping(t_address,t_uint256)": { "label": "mapping(address => uint256)", "numberOfBytes": "32" }, + "t_mapping(t_string_memory_ptr,t_struct(DomainClaim)3792_storage)": { + "label": "mapping(string => struct ReportDomain.DomainClaim)", + "numberOfBytes": "32" + }, + "t_mapping(t_uint256,t_struct(ReportInfo)3821_storage)": { + "label": "mapping(uint256 => struct ReportDomain.ReportInfo)", + "numberOfBytes": "32" + }, + "t_string_memory_ptr": { + "label": "string", + "numberOfBytes": "32" + }, "t_string_storage": { "label": "string", "numberOfBytes": "32" }, + "t_struct(DomainClaim)3792_storage": { + "label": "struct ReportDomain.DomainClaim", + "members": [ + { + "label": "isScamClaim", + "type": "t_bool", + "offset": 0, + "slot": "0" + }, + { + "label": "isLegitClaim", + "type": "t_bool", + "offset": 1, + "slot": "0" + }, + { + "label": "scamReporter", + "type": "t_address", + "offset": 2, + "slot": "0" + }, + { + "label": "legitReporter", + "type": "t_address", + "offset": 0, + "slot": "1" + }, + { + "label": "reportIDforScam", + "type": "t_uint256", + "offset": 0, + "slot": "2" + }, + { + "label": "reportIDforLegit", + "type": "t_uint256", + "offset": 0, + "slot": "3" + } + ], + "numberOfBytes": "128" + }, + "t_struct(ReportInfo)3821_storage": { + "label": "struct ReportDomain.ReportInfo", + "members": [ + { + "label": "id", + "type": "t_uint256", + "offset": 0, + "slot": "0" + }, + { + "label": "stake", + "type": "t_uint256", + "offset": 0, + "slot": "1" + }, + { + "label": "createdon", + "type": "t_uint256", + "offset": 0, + "slot": "2" + }, + { + "label": "updatedon", + "type": "t_uint256", + "offset": 0, + "slot": "3" + }, + { + "label": "exists", + "type": "t_bool", + "offset": 0, + "slot": "4" + }, + { + "label": "isOpen", + "type": "t_bool", + "offset": 1, + "slot": "4" + }, + { + "label": "isScam", + "type": "t_bool", + "offset": 2, + "slot": "4" + }, + { + "label": "domain", + "type": "t_string_storage", + "offset": 0, + "slot": "5" + }, + { + "label": "evidences", + "type": "t_string_storage", + "offset": 0, + "slot": "6" + }, + { + "label": "comments", + "type": "t_string_storage", + "offset": 0, + "slot": "7" + }, + { + "label": "status", + "type": "t_string_storage", + "offset": 0, + "slot": "8" + }, + { + "label": "validatorComments", + "type": "t_string_storage", + "offset": 0, + "slot": "9" + }, + { + "label": "reporter", + "type": "t_address", + "offset": 0, + "slot": "10" + }, + { + "label": "validator", + "type": "t_address", + "offset": 0, + "slot": "11" + } + ], + "numberOfBytes": "384" + }, "t_uint256": { "label": "uint256", "numberOfBytes": "32" @@ -5406,9 +5596,9 @@ } } }, - "f5a97feac430611f1bbc04c460fe3e24a8b15e2e07384b8c7d71efbd920f5c65": { - "address": "0x97a2403471c2cec531249CFb45dfb7983b41d7d8", - "txHash": "0xf4b458f4e61fde45dd34d55c731cea79d175cafe2fa23206fbafe67b6bb3b247", + "9e3610f24aedf9f3426c187414a0f47ca54016a30ba511cad18b492fa001ca1a": { + "address": "0x910dfe7f5153650c88164b6FD508a558C3716d79", + "txHash": "0x01ff000f548e6969842e59b87602f07d117ff6523a01cd6b126adf773ad4af01", "layout": { "solcVersion": "0.8.12", "storage": [ @@ -5459,7 +5649,7 @@ "slot": "101", "type": "t_string_storage", "contract": "ReportDomain", - "src": "contracts\\ReportDomain.sol:9" + "src": "contracts\\ReportDomain.sol:10" }, { "label": "REJECTED", @@ -5467,7 +5657,7 @@ "slot": "102", "type": "t_string_storage", "contract": "ReportDomain", - "src": "contracts\\ReportDomain.sol:10" + "src": "contracts\\ReportDomain.sol:11" }, { "label": "governanceBadgeNFT", @@ -5475,7 +5665,7 @@ "slot": "103", "type": "t_address", "contract": "ReportDomain", - "src": "contracts\\ReportDomain.sol:12" + "src": "contracts\\ReportDomain.sol:13" }, { "label": "treasuryContract", @@ -5483,7 +5673,7 @@ "slot": "104", "type": "t_address", "contract": "ReportDomain", - "src": "contracts\\ReportDomain.sol:13" + "src": "contracts\\ReportDomain.sol:14" }, { "label": "stakingAmount", @@ -5491,7 +5681,7 @@ "slot": "105", "type": "t_uint256", "contract": "ReportDomain", - "src": "contracts\\ReportDomain.sol:15" + "src": "contracts\\ReportDomain.sol:16" }, { "label": "reward", @@ -5499,7 +5689,7 @@ "slot": "106", "type": "t_uint256", "contract": "ReportDomain", - "src": "contracts\\ReportDomain.sol:16" + "src": "contracts\\ReportDomain.sol:17" }, { "label": "lockedAmount", @@ -5507,7 +5697,7 @@ "slot": "107", "type": "t_uint256", "contract": "ReportDomain", - "src": "contracts\\ReportDomain.sol:17" + "src": "contracts\\ReportDomain.sol:18" }, { "label": "reportID", @@ -5515,7 +5705,7 @@ "slot": "108", "type": "t_uint256", "contract": "ReportDomain", - "src": "contracts\\ReportDomain.sol:18" + "src": "contracts\\ReportDomain.sol:19" }, { "label": "reportsByDomain", @@ -5523,7 +5713,7 @@ "slot": "109", "type": "t_mapping(t_string_memory_ptr,t_struct(DomainClaim)3792_storage)", "contract": "ReportDomain", - "src": "contracts\\ReportDomain.sol:46" + "src": "contracts\\ReportDomain.sol:47" }, { "label": "reportsByID", @@ -5531,7 +5721,7 @@ "slot": "110", "type": "t_mapping(t_uint256,t_struct(ReportInfo)3821_storage)", "contract": "ReportDomain", - "src": "contracts\\ReportDomain.sol:47" + "src": "contracts\\ReportDomain.sol:48" }, { "label": "points", @@ -5539,7 +5729,7 @@ "slot": "111", "type": "t_mapping(t_address,t_uint256)", "contract": "ReportDomain", - "src": "contracts\\ReportDomain.sol:48" + "src": "contracts\\ReportDomain.sol:49" } ], "types": { @@ -5722,9 +5912,165 @@ } } }, - "04db4bb5d6af4a1092cdcc049313198927e1d9c459974117036ab50fde9039ec": { + "da6392f0cc476b3602421d3b0fe2acfc747f9cc353e2fff495fa0a9c4782c899": { + "address": "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9", + "txHash": "0x39d682e5ebb8167ba1cae807612ed2415a15405f14fed9da668e6688f107602d", + "layout": { + "solcVersion": "0.8.12", + "storage": [ + { + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8", + "contract": "Initializable", + "src": "@openzeppelin\\contracts-upgradeable\\proxy\\utils\\Initializable.sol:62", + "retypedFrom": "bool" + }, + { + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool", + "contract": "Initializable", + "src": "@openzeppelin\\contracts-upgradeable\\proxy\\utils\\Initializable.sol:67" + }, + { + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage", + "contract": "ContextUpgradeable", + "src": "@openzeppelin\\contracts-upgradeable\\utils\\ContextUpgradeable.sol:36" + }, + { + "label": "_balances", + "offset": 0, + "slot": "51", + "type": "t_mapping(t_address,t_uint256)", + "contract": "ERC20Upgradeable", + "src": "@openzeppelin\\contracts-upgradeable\\token\\ERC20\\ERC20Upgradeable.sol:37" + }, + { + "label": "_allowances", + "offset": 0, + "slot": "52", + "type": "t_mapping(t_address,t_mapping(t_address,t_uint256))", + "contract": "ERC20Upgradeable", + "src": "@openzeppelin\\contracts-upgradeable\\token\\ERC20\\ERC20Upgradeable.sol:39" + }, + { + "label": "_totalSupply", + "offset": 0, + "slot": "53", + "type": "t_uint256", + "contract": "ERC20Upgradeable", + "src": "@openzeppelin\\contracts-upgradeable\\token\\ERC20\\ERC20Upgradeable.sol:41" + }, + { + "label": "_name", + "offset": 0, + "slot": "54", + "type": "t_string_storage", + "contract": "ERC20Upgradeable", + "src": "@openzeppelin\\contracts-upgradeable\\token\\ERC20\\ERC20Upgradeable.sol:43" + }, + { + "label": "_symbol", + "offset": 0, + "slot": "55", + "type": "t_string_storage", + "contract": "ERC20Upgradeable", + "src": "@openzeppelin\\contracts-upgradeable\\token\\ERC20\\ERC20Upgradeable.sol:44" + }, + { + "label": "__gap", + "offset": 0, + "slot": "56", + "type": "t_array(t_uint256)45_storage", + "contract": "ERC20Upgradeable", + "src": "@openzeppelin\\contracts-upgradeable\\token\\ERC20\\ERC20Upgradeable.sol:400" + }, + { + "label": "_owner", + "offset": 0, + "slot": "101", + "type": "t_address", + "contract": "OwnableUpgradeable", + "src": "@openzeppelin\\contracts-upgradeable\\access\\OwnableUpgradeable.sol:22" + }, + { + "label": "__gap", + "offset": 0, + "slot": "102", + "type": "t_array(t_uint256)49_storage", + "contract": "OwnableUpgradeable", + "src": "@openzeppelin\\contracts-upgradeable\\access\\OwnableUpgradeable.sol:94" + }, + { + "label": "minted_reward_tokens", + "offset": 0, + "slot": "151", + "type": "t_uint256", + "contract": "Token", + "src": "contracts\\Token.sol:11" + }, + { + "label": "minted_grant_tokens", + "offset": 0, + "slot": "152", + "type": "t_uint256", + "contract": "Token", + "src": "contracts\\Token.sol:12" + } + ], + "types": { + "t_address": { + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_uint256)45_storage": { + "label": "uint256[45]", + "numberOfBytes": "1440" + }, + "t_array(t_uint256)49_storage": { + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_bool": { + "label": "bool", + "numberOfBytes": "1" + }, + "t_mapping(t_address,t_mapping(t_address,t_uint256))": { + "label": "mapping(address => mapping(address => uint256))", + "numberOfBytes": "32" + }, + "t_mapping(t_address,t_uint256)": { + "label": "mapping(address => uint256)", + "numberOfBytes": "32" + }, + "t_string_storage": { + "label": "string", + "numberOfBytes": "32" + }, + "t_uint256": { + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "label": "uint8", + "numberOfBytes": "1" + } + } + } + }, + "bd3e46c0e67a4f60ef3410d3a93dd29ba60a098a3c4cab3c2d7bf3913cd5f2cf": { "address": "0xa513E6E4b8f2a923D98304ec87F64353C4D5C853", - "txHash": "0x39b18492a0fb06c0a32fffff9895810e733c68b002276b0cdd47ca3906b7a6d1", + "txHash": "0x4f6240ff6d0ce09b65c9032c5aea3b8bfb3fd73db1a205026a305fbcfd0e4dfe", "layout": { "solcVersion": "0.8.12", "storage": [ diff --git a/contracts/c4udit-report.md b/contracts/c4udit-report.md new file mode 100644 index 0000000..6da07de --- /dev/null +++ b/contracts/c4udit-report.md @@ -0,0 +1,116 @@ +# c4udit Report + +## Files analyzed +- contracts\GovernanceBadgeNFT.sol +- contracts\ReportDomain.sol +- contracts\Token.sol +- contracts\Treasury.sol + +## Issues found + +### Don't Initialize Variables with Default Value + +#### Impact +Issue Information: [G001](https://github.com/byterocket/c4-common-issues/blob/main/0-Gas-Optimizations.md#g001---dont-initialize-variables-with-default-value) + +#### Findings: +``` +contracts\ReportDomain.sol::104 => for(uint i=0; i uint nEvidences = evidenceHashes.length; +``` +#### Tools used +[c4udit](https://github.com/byterocket/c4udit) + +### Use != 0 instead of > 0 for Unsigned Integer Comparison + +#### Impact +Issue Information: [G003](https://github.com/byterocket/c4-common-issues/blob/main/0-Gas-Optimizations.md#g003---use--0-instead-of--0-for-unsigned-integer-comparison) + +#### Findings: +``` +contracts\GovernanceBadgeNFT.sol::55 => require(validationRequests[msg.sender] > 0, "no request present"); +contracts\GovernanceBadgeNFT.sol::77 => // require(balanceOf(validator,VALIDATOR_NFT) > 0,"No use of Revoking"); +contracts\GovernanceBadgeNFT.sol::102 => require(balanceOf(msg.sender,GOVERNANCE_NFT) > 0,"You are not governor to vote"); +contracts\ReportDomain.sol::102 => require(nEvidences > 0, "Require atleast one evidence"); +contracts\ReportDomain.sol::162 => require(bal > 0, "Only selected validators can validate"); +contracts\ReportDomain.sol::170 => if(reportsByID[_reportId].isScam && reportsByDomain[reportsByID[_reportId].domain].reportIDforLegit > 0) { +contracts\ReportDomain.sol::173 => else if(!reportsByID[_reportId].isScam && reportsByDomain[reportsByID[_reportId].domain].reportIDforScam > 0){ +``` +#### Tools used +[c4udit](https://github.com/byterocket/c4udit) + +### Use immutable for OpenZeppelin AccessControl's Roles Declarations + +#### Impact +Issue Information: [G006](https://github.com/byterocket/c4-common-issues/blob/main/0-Gas-Optimizations.md#g006---use-immutable-for-openzeppelin-accesscontrols-roles-declarations) + +#### Findings: +``` +contracts\ReportDomain.sol::210 => return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b)))); +``` +#### Tools used +[c4udit](https://github.com/byterocket/c4udit) + +### Long Revert Strings + +#### Impact +Issue Information: [G007](https://github.com/byterocket/c4-common-issues/blob/main/0-Gas-Optimizations.md#g007---long-revert-strings) + +#### Findings: +``` +contracts\GovernanceBadgeNFT.sol::4 => import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; +contracts\GovernanceBadgeNFT.sol::5 => import "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol"; +contracts\GovernanceBadgeNFT.sol::6 => import "@openzeppelin/contracts-upgradeable/token/ERC1155/utils/ERC1155HolderUpgradeable.sol"; +contracts\ReportDomain.sol::4 => import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; +contracts\ReportDomain.sol::5 => import "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol"; +contracts\ReportDomain.sol::162 => require(bal > 0, "Only selected validators can validate"); +contracts\ReportDomain.sol::166 => require(reportsByDomain[reportsByID[_reportId].domain].scamReporter != msg.sender, "You cannot validate your own report"); +contracts\ReportDomain.sol::168 => require(reportsByDomain[reportsByID[_reportId].domain].legitReporter != msg.sender, "You cannot validate your own report"); +contracts\ReportDomain.sol::222 => emit defaultValidated(domain, false, msg.sender,"Auto-verified: top 10k domain by traffic"); +contracts\Token.sol::3 => import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; +contracts\Token.sol::4 => import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; +contracts\Treasury.sol::3 => import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; +contracts\Treasury.sol::4 => import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; +``` +#### Tools used +[c4udit](https://github.com/byterocket/c4udit) + +### Unsafe ERC20 Operation(s) + +#### Impact +Issue Information: [L001](https://github.com/byterocket/c4-common-issues/blob/main/2-Low-Risk.md#l001---unsafe-erc20-operations) + +#### Findings: +``` +contracts\GovernanceBadgeNFT.sol::58 => payable(msg.sender).transfer(toTransfer); +contracts\ReportDomain.sol::187 => payable(reportsByID[_reportId].reporter).transfer(reportsByID[_reportId].stake); +contracts\Treasury.sol::12 => payable(to).transfer(amount); +contracts\Treasury.sol::16 => IERC20Upgradeable(token).transfer(to,amount); +``` +#### Tools used +[c4udit](https://github.com/byterocket/c4udit) + +### Unspecific Compiler Version Pragma + +#### Impact +Issue Information: [L003](https://github.com/byterocket/c4-common-issues/blob/main/2-Low-Risk.md#l003---unspecific-compiler-version-pragma) + +#### Findings: +``` +contracts\GovernanceBadgeNFT.sol::2 => pragma solidity ^0.8.12; +contracts\ReportDomain.sol::2 => pragma solidity ^0.8.12; +``` +#### Tools used +[c4udit](https://github.com/byterocket/c4udit) + diff --git a/contracts/contracts/ReportDomain.sol b/contracts/contracts/ReportDomain.sol index 850a1d6..7588bff 100644 --- a/contracts/contracts/ReportDomain.sol +++ b/contracts/contracts/ReportDomain.sol @@ -13,25 +13,25 @@ contract ReportDomain is OwnableUpgradeable { address governanceBadgeNFT; address treasuryContract; - uint public stakingAmount; - uint public reward; - uint public lockedAmount; - uint public reportID; + uint256 public stakingAmount; + uint256 public reward; + uint256 public lockedAmount; + uint256 public reportID; struct DomainClaim { bool isScamClaim; bool isLegitClaim; address scamReporter; address legitReporter; - uint reportIDforScam; - uint reportIDforLegit; + uint256 reportIDforScam; + uint256 reportIDforLegit; } struct ReportInfo { - uint id; - uint stake; - uint createdon; - uint updatedon; + uint256 id; + uint256 stake; + uint256 createdon; + uint256 updatedon; bool exists; bool isOpen; bool isScam; @@ -45,16 +45,41 @@ contract ReportDomain is OwnableUpgradeable { } mapping(string => DomainClaim) reportsByDomain; - mapping(uint => ReportInfo) reportsByID; - mapping (address => uint) public points; - - - event Reported(uint indexed id, string domain,bool isScam,address indexed reporter, uint createdOn,string evidences,string comments,uint stakeAmount); - event Validated(uint indexed id, string domain,bool isScam,address reporter,address indexed validator, uint updatedon,string validatorComments,string status,uint rewardAmount); - event defaultValidated(string domain,bool isScam,address reporter,string validatorComments); - - - function initialize(address _governanceBadgeNFT,address _treasuryContract) initializer public { + mapping(uint256 => ReportInfo) reportsByID; + mapping(address => uint256) public points; + + event Reported( + uint256 indexed id, + string domain, + bool isScam, + address indexed reporter, + uint256 createdOn, + string evidences, + string comments, + uint256 stakeAmount + ); + event Validated( + uint256 indexed id, + string domain, + bool isScam, + address reporter, + address indexed validator, + uint256 updatedon, + string validatorComments, + string status, + uint256 rewardAmount + ); + event defaultValidated( + string domain, + bool isScam, + address reporter, + string validatorComments + ); + + function initialize(address _governanceBadgeNFT, address _treasuryContract) + public + initializer + { __Ownable_init(); governanceBadgeNFT = _governanceBadgeNFT; treasuryContract = _treasuryContract; @@ -66,12 +91,16 @@ contract ReportDomain is OwnableUpgradeable { REJECTED = "REJECTED"; } - function setreward(uint _reward) public onlyOwner { + function setreward(uint256 _reward) public onlyOwner { reward = _reward; } - function isReported(string calldata domain, bool isScam) public view returns(bool) { - if(isScam) { + function isReported(string calldata domain, bool isScam) + public + view + returns (bool) + { + if (isScam) { return reportsByDomain[domain].isScamClaim; } else { return reportsByDomain[domain].isLegitClaim; @@ -79,45 +108,60 @@ contract ReportDomain is OwnableUpgradeable { } /* - * Report a domain - * params: domain, isScam, evidences, comments - * checks if a report already exists - */ - function report(string calldata domain, bool isScam, string[] calldata evidenceHashes, string calldata comments) public payable returns(uint) { - if(isScam){ - require(!reportsByDomain[domain].isScamClaim, "Is Scam report already filed"); - require(reportsByDomain[domain].legitReporter != msg.sender, "You already reported it as legit"); - } - else{ - require(!reportsByDomain[domain].isLegitClaim, "Is Legit report already filed"); - require(reportsByDomain[domain].scamReporter != msg.sender, "You already reported it as scam"); + * Report a domain + * params: domain, isScam, evidences, comments + * checks if a report already exists + */ + function report( + string calldata domain, + bool isScam, + string[] calldata evidenceHashes, + string calldata comments + ) public payable returns (uint256) { + if (isScam) { + require( + !reportsByDomain[domain].isScamClaim, + "Is Scam report already filed" + ); + require( + reportsByDomain[domain].legitReporter != msg.sender, + "You already reported it as legit" + ); + } else { + require( + !reportsByDomain[domain].isLegitClaim, + "Is Legit report already filed" + ); + require( + reportsByDomain[domain].scamReporter != msg.sender, + "You already reported it as scam" + ); } - require(msg.value == stakingAmount, "Incorrect stake amount sent"); lockedAmount += stakingAmount; string memory evidenceHashesSerialised = ""; - uint nEvidences = evidenceHashes.length; + uint256 nEvidences = evidenceHashes.length; require(nEvidences > 0, "Require atleast one evidence"); - for(uint i=0; i 0, "Only selected validators can validate"); require(reportsByID[_reportId].exists, "Case doesnt exist"); require(reportsByID[_reportId].isOpen, "Case already validated"); - if(reportsByID[_reportId].isScam) { - require(reportsByDomain[reportsByID[_reportId].domain].scamReporter != msg.sender, "You cannot validate your own report"); + if (reportsByID[_reportId].isScam) { + require( + reportsByDomain[reportsByID[_reportId].domain].scamReporter != + msg.sender, + "You cannot validate your own report" + ); } else { - require(reportsByDomain[reportsByID[_reportId].domain].legitReporter != msg.sender, "You cannot validate your own report"); + require( + reportsByDomain[reportsByID[_reportId].domain].legitReporter != + msg.sender, + "You cannot validate your own report" + ); } - if(reportsByID[_reportId].isScam && reportsByDomain[reportsByID[_reportId].domain].reportIDforLegit > 0) { - require(_reportId < reportsByDomain[reportsByID[_reportId].domain].reportIDforLegit, "First close the legit file"); - } - else if(!reportsByID[_reportId].isScam && reportsByDomain[reportsByID[_reportId].domain].reportIDforScam > 0){ - require(_reportId < reportsByDomain[reportsByID[_reportId].domain].reportIDforScam, "First close the scam file"); + if ( + reportsByID[_reportId].isScam && + reportsByDomain[reportsByID[_reportId].domain].reportIDforLegit > 0 + ) { + require( + _reportId < + reportsByDomain[reportsByID[_reportId].domain] + .reportIDforLegit, + "First close the legit file" + ); + } else if ( + !reportsByID[_reportId].isScam && + reportsByDomain[reportsByID[_reportId].domain].reportIDforScam > 0 + ) { + require( + _reportId < + reportsByDomain[reportsByID[_reportId].domain] + .reportIDforScam, + "First close the scam file" + ); } string memory status = ACCEPTED; - if(!isAccepted) - status = REJECTED; + if (!isAccepted) status = REJECTED; - uint timestamp = block.timestamp; + uint256 timestamp = block.timestamp; reportsByID[_reportId].status = status; reportsByID[_reportId].validatorComments = comments; reportsByID[_reportId].validator = msg.sender; reportsByID[_reportId].updatedon = timestamp; reportsByID[_reportId].isOpen = false; - if(compareStrings(status, ACCEPTED)) { - payable(reportsByID[_reportId].reporter).transfer(reportsByID[_reportId].stake); + if (compareStrings(status, ACCEPTED)) { + payable(reportsByID[_reportId].reporter).transfer( + reportsByID[_reportId].stake + ); points[reportsByID[_reportId].reporter] += reward; - emit Validated(_reportId, reportsByID[_reportId].domain, reportsByID[_reportId].isScam, reportsByID[_reportId].reporter,msg.sender, timestamp, comments,status,reward); - } - else{ - (bool sent,) = payable(treasuryContract).call{value:reportsByID[_reportId].stake}(""); + emit Validated( + _reportId, + reportsByID[_reportId].domain, + reportsByID[_reportId].isScam, + reportsByID[_reportId].reporter, + msg.sender, + timestamp, + comments, + status, + reward + ); + } else { + (bool sent, ) = payable(treasuryContract).call{ + value: reportsByID[_reportId].stake + }(""); require(sent, "Failed to send Ether"); - emit Validated(_reportId, reportsByID[_reportId].domain, reportsByID[_reportId].isScam, reportsByID[_reportId].reporter,msg.sender, timestamp, comments,status,0); + emit Validated( + _reportId, + reportsByID[_reportId].domain, + reportsByID[_reportId].isScam, + reportsByID[_reportId].reporter, + msg.sender, + timestamp, + comments, + status, + 0 + ); + reportsByDomain[reportsByID[_reportId].domain].isScamClaim = false; + reportsByDomain[reportsByID[_reportId].domain].isLegitClaim = false; + reportsByDomain[reportsByID[_reportId].domain] + .scamReporter = address(0); + reportsByDomain[reportsByID[_reportId].domain] + .legitReporter = address(0); + reportsByDomain[reportsByID[_reportId].domain].reportIDforScam = 0; + reportsByDomain[reportsByID[_reportId].domain].reportIDforLegit = 0; } lockedAmount -= reportsByID[_reportId].stake; - reportsByDomain[reportsByID[_reportId].domain].isScamClaim = false; - reportsByDomain[reportsByID[_reportId].domain].isLegitClaim = false; - reportsByDomain[reportsByID[_reportId].domain].scamReporter = address(0); - reportsByDomain[reportsByID[_reportId].domain].legitReporter = address(0); - reportsByDomain[reportsByID[_reportId].domain].reportIDforScam = 0; - reportsByDomain[reportsByID[_reportId].domain].reportIDforLegit = 0; } - - - - function compareStrings(string memory a, string memory b) internal view returns (bool) { - return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b)))); + function compareStrings(string memory a, string memory b) + internal + view + returns (bool) + { + return (keccak256(abi.encodePacked((a))) == + keccak256(abi.encodePacked((b)))); } - function setStakingAmount(uint _stakingAmount) public onlyOwner { + function setStakingAmount(uint256 _stakingAmount) public onlyOwner { stakingAmount = _stakingAmount; } @@ -218,8 +323,17 @@ contract ReportDomain is OwnableUpgradeable { return address(this).balance; } - function defaultDomain(string memory domain) public onlyOwner { - emit defaultValidated(domain, false, msg.sender,"Auto-verified: top 10k domain by traffic"); + function defaultDomain(string[] memory domain) public onlyOwner { + for (uint256 i = 0; i < domain.length; i++) { + reportsByDomain[domain[i]].isLegitClaim = true; + reportsByDomain[domain[i]].legitReporter = msg.sender; + emit defaultValidated( + domain[i], + true, + msg.sender, + "Auto-verified: top 10k domain by traffic" + ); + } } // function payDividends(uint amount) // todo diff --git a/contracts/hardhat.config.ts b/contracts/hardhat.config.ts index dda161a..281bd12 100644 --- a/contracts/hardhat.config.ts +++ b/contracts/hardhat.config.ts @@ -1,7 +1,7 @@ -require('dotenv').config() +require("dotenv").config(); import { HardhatUserConfig } from "hardhat/config"; import "@nomicfoundation/hardhat-toolbox"; -import '@openzeppelin/hardhat-upgrades'; +import "@openzeppelin/hardhat-upgrades"; const config: HardhatUserConfig = { solidity: { @@ -9,10 +9,10 @@ const config: HardhatUserConfig = { settings: { optimizer: { enabled: true, - runs: 200 - } - } - }, + runs: 200, + }, + }, + }, networks: { polygon: { url: process.env.POLYGON_URL || "", @@ -22,18 +22,23 @@ const config: HardhatUserConfig = { mumbai: { url: process.env.POLYGON_MUMBAI_RPC || "", accounts: - process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY, "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"] : [], + process.env.PRIVATE_KEY !== undefined + ? [ + process.env.PRIVATE_KEY, + "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d", + ] + : [], }, hardhat: { mining: { auto: false, - interval: 500 + interval: 500, }, - chainId: 200 - } + chainId: 200, + }, }, mocha: { - timeout: 480000 + timeout: 480000, }, etherscan: { apiKey: { diff --git a/contracts/scripts/deploy.ts b/contracts/scripts/deploy.ts index eb5be26..792a6f8 100644 --- a/contracts/scripts/deploy.ts +++ b/contracts/scripts/deploy.ts @@ -1,7 +1,7 @@ import { ethers, upgrades } from "hardhat"; const { getTopDomains } = require("./domains/helper.js"); async function main() { - const domains = (await getTopDomains()).slice(0, 10000); + const domains = (await getTopDomains()).slice(0, 1000); const governanceBadgeNFT = await ethers.getContractFactory( "GovernanceBadgeNFT" ); @@ -42,9 +42,15 @@ async function main() { const tx = await token.transferOwnership(reportDomain.address); await tx.wait(); - console.log(domains.length); - const validate = await reportDomain.defaultDomain(domains[0]); - await validate.wait(); + let slice; + let validate; + for (let i = 0; i < domains.length; ) { + slice = domains.slice(i, i + 100); + validate = await reportDomain.defaultDomain(slice); + await validate.wait(); + i += 100; + console.log("validated", i); + } console.log("validated"); } diff --git a/contracts/scripts/domains/helper.js b/contracts/scripts/domains/helper.js index 7e8e894..f0e523c 100644 --- a/contracts/scripts/domains/helper.js +++ b/contracts/scripts/domains/helper.js @@ -13,7 +13,7 @@ async function getTopDomains() { data.push(parsed.sld); } counter++; - if (data.length === 10000) { + if (data.length === 1000) { csvStream.end(); } }); diff --git a/contracts/test/ReportDomain.test.ts b/contracts/test/ReportDomain.test.ts index 4f60db4..87e5704 100644 --- a/contracts/test/ReportDomain.test.ts +++ b/contracts/test/ReportDomain.test.ts @@ -3,6 +3,7 @@ import { expect } from "chai"; import { Contract } from "ethers"; import { ethers, upgrades } from "hardhat"; import "./fetch-polyfills"; +const { getTopDomains } = require("../scripts/domains/helper.js"); describe("ReportDomain", function () { let governanceBadgeNFT: Contract; @@ -10,8 +11,11 @@ describe("ReportDomain", function () { let superAdmin: SignerWithAddress; let secondAdmin: SignerWithAddress; let reportImplementationAddress: string; + let domains: string[]; before(async () => { + domains = (await getTopDomains()).slice(0, 1000); + console.log(domains.length); let result = await ethers.getSigners(); superAdmin = result[0]; secondAdmin = result[1]; @@ -43,211 +47,229 @@ describe("ReportDomain", function () { console.log("reportDomain address: ", reportDomain.address); }); - it("validate with no ID", async () => { - try { - let tx = await reportDomain.validate(100, true, ""); - await tx.wait(); - } catch (err: any) { - return expect(err.message.includes("Case doesnt exist")); - } - throw new Error("Validation should have failed"); + it("validate 100 domains", async () => { + let validate = await reportDomain.defaultDomain(domains.slice(0, 100)); + await validate.wait(); + console.log("validated 100"); }); - it("report (ACCEPT)", async () => { - let domain = "google.com"; - let isScam = true; - let evidences = ["scd", "sdvsdv"]; - let comments = "sdasbvf"; - let stakingAmount = await reportDomain.callStatic.stakingAmount(); - console.log("stakingAmount: ", stakingAmount.toString()); - let reportID = await reportDomain.callStatic.report( - domain, - isScam, - evidences, - comments, - { value: stakingAmount.toString() } - ); - let tx = await reportDomain - .connect(secondAdmin) - .report(domain, isScam, evidences, comments, { - value: stakingAmount.toString(), - }); - await tx.wait(); - - let isReported = await reportDomain.callStatic.isReported(domain, isScam); - expect(isReported, "is reported scam should be true").to.eq(true); - - let isReported2 = await reportDomain.callStatic.isReported(domain, !isScam); - expect(isReported2, "is reported legit should be false").to.eq(false); - - let lockedAmount = await reportDomain.lockedAmount(); - expect(lockedAmount.toString(), "incorrect lockek amount").to.eq( - stakingAmount.toString() - ); - - let initialBal = await secondAdmin.provider?.getBalance( - secondAdmin.address - ); - console.log("secondAdmin before", { - initialBal: ethers.utils - .formatEther(initialBal?.toString() || "0") - .toString(), - }); - - let balance = await reportDomain.getBalance(); - expect(balance.toString(), "Balance should be 5ETH").to.eq( - stakingAmount.toString() - ); - console.log({ balance }); - - tx = await reportDomain.validate(reportID, true, "my comments"); - await tx.wait(); - console.log("validated"); - lockedAmount = await reportDomain.lockedAmount(); - expect(lockedAmount.toString(), "incorrect locked amount").to.eq("0"); - console.log("locked amount is 0"); - balance = await reportDomain.getBalance(); - expect(balance?.toString(), "Balance should be 0").to.eq("0"); - console.log("balance is 0"); - let afterBal = await secondAdmin.provider?.getBalance(secondAdmin.address); - console.log("secondAdmin after", { - afterBal: ethers.utils - .formatEther(afterBal?.toString() || "0") - .toString(), - }); - expect(afterBal?.toString(), "second admin should have +5").to.eq( - initialBal?.add(stakingAmount).toString() - ); + it("validate 150 domains", async () => { + let validate = await reportDomain.defaultDomain(domains.slice(0, 200)); + await validate.wait(); + console.log("validated 150"); + }); - let points = await reportDomain.points(secondAdmin.address); - expect(points.toString(), "points should be 10").to.eq("10"); + it("validate 200 domains", async () => { + let validate = await reportDomain.defaultDomain(domains.slice(0, 200)); + await validate.wait(); + console.log("validated 200"); }); - it("report (REJECT)", async () => { - let domain = "google.com"; - let isScam = false; - let evidences = ["scd", "sdvsdv"]; - let comments = "sdasbvf"; - let stakingAmount = await reportDomain.callStatic.stakingAmount(); - let reportID = await reportDomain.callStatic.report( - domain, - isScam, - evidences, - comments, - { value: stakingAmount.toString() } - ); - let tx = await reportDomain - .connect(secondAdmin) - .report(domain, isScam, evidences, comments, { - value: stakingAmount.toString(), - }); - await tx.wait(); - - let isReported = await reportDomain.callStatic.isReported(domain, isScam); - expect(isReported, "is reported legit should be true").to.eq(true); - - let isReported2 = await reportDomain.callStatic.isReported(domain, !isScam); - expect(isReported2, "is reported scam should be false").to.eq(false); - - let lockedAmount = await reportDomain.lockedAmount(); - expect(lockedAmount.toString(), "incorrect lockek amount").to.eq( - stakingAmount.toString() - ); + // it("validate with no ID", async () => { + // try { + // let tx = await reportDomain.validate(100, true, ""); + // await tx.wait(); + // } catch (err: any) { + // return expect(err.message.includes("Case doesnt exist")); + // } + // throw new Error("Validation should have failed"); + // }); - let initialBal = await secondAdmin.provider?.getBalance( - secondAdmin.address - ); - console.log("secondAdmin before", { - initialBal: ethers.utils - .formatEther(initialBal?.toString() || "0") - .toString(), - }); - - let balance = await reportDomain.getBalance(); - console.log({ balance }); - expect(balance.toString(), "Balance should be 5ETH").to.eq( - stakingAmount.toString() - ); + // it("report (ACCEPT)", async () => { + // let domain = "google.com"; + // let isScam = true; + // let evidences = ["scd", "sdvsdv"]; + // let comments = "sdasbvf"; + // let stakingAmount = await reportDomain.callStatic.stakingAmount(); + // console.log("stakingAmount: ", stakingAmount.toString()); + // let reportID = await reportDomain.callStatic.report( + // domain, + // isScam, + // evidences, + // comments, + // { value: stakingAmount.toString() } + // ); + // let tx = await reportDomain + // .connect(secondAdmin) + // .report(domain, isScam, evidences, comments, { + // value: stakingAmount.toString(), + // }); + // await tx.wait(); - tx = await reportDomain.validate(reportID, false, "my comments"); - await tx.wait(); + // let isReported = await reportDomain.callStatic.isReported(domain, isScam); + // expect(isReported, "is reported scam should be true").to.eq(true); - lockedAmount = await reportDomain.lockedAmount(); - expect(lockedAmount.toString(), "incorrect lockek amount").to.eq("0"); // lock released + // let isReported2 = await reportDomain.callStatic.isReported(domain, !isScam); + // expect(isReported2, "is reported legit should be false").to.eq(false); - balance = await reportDomain.getBalance(); - expect(balance?.toString(), "Balance should be 0").to.eq("0"); + // let lockedAmount = await reportDomain.lockedAmount(); + // expect(lockedAmount.toString(), "incorrect lockek amount").to.eq( + // stakingAmount.toString() + // ); - let afterBal = await secondAdmin.provider?.getBalance(secondAdmin.address); - console.log("secondAdmin after", { - afterBal: ethers.utils - .formatEther(afterBal?.toString() || "0") - .toString(), - }); - expect(afterBal?.toString(), "second admin should have +5").to.eq( - initialBal?.toString() - ); - }); + // let initialBal = await secondAdmin.provider?.getBalance( + // secondAdmin.address + // ); + // console.log("secondAdmin before", { + // initialBal: ethers.utils + // .formatEther(initialBal?.toString() || "0") + // .toString(), + // }); - it("report on same domain", async () => { - let domain = "google.com"; - let isScam = false; - let evidences = ["scd", "sdvsdv"]; - let comments = "sdasbvf"; - let stakingAmount = await reportDomain.callStatic.stakingAmount(); - let tx = await reportDomain - .connect(secondAdmin) - .report(domain, isScam, evidences, comments, { - value: stakingAmount.toString(), - }); - await tx.wait(); - - let isReported = await reportDomain.callStatic.isReported(domain, isScam); - expect(isReported, "is reported legit should be true").to.eq(true); - - let isReported2 = await reportDomain.callStatic.isReported(domain, !isScam); - expect(isReported2, "is reported scam should be false").to.eq(false); - - await expect( - reportDomain - .connect(secondAdmin) - .callStatic.report(domain, isScam, evidences, comments, { - value: stakingAmount.toString(), - }) - ).to.be.rejectedWith("Is Legit report already filed"); - await expect( - reportDomain - .connect(secondAdmin) - .callStatic.report(domain, !isScam, evidences, comments, { - value: stakingAmount.toString(), - }) - ).to.be.rejectedWith("You already reported it as legit"); - tx = await reportDomain.report(domain, !isScam, evidences, comments, { - value: stakingAmount.toString(), - }); - await tx.wait(); - console.log("reported again"); - await expect( - reportDomain.callStatic.report(domain, !isScam, evidences, comments, { - value: stakingAmount.toString(), - }) - ).to.be.rejectedWith("Is Scam report already filed"); - await expect( - reportDomain.callStatic.report(domain, isScam, evidences, comments, { - value: stakingAmount.toString(), - }) - ).to.be.rejectedWith("Is Legit report already filed"); - }); + // let balance = await reportDomain.getBalance(); + // expect(balance.toString(), "Balance should be 5ETH").to.eq( + // stakingAmount.toString() + // ); + // console.log({ balance }); - it("change Reward", async () => { - let reward = await reportDomain.reward(); - console.log({ reward }); - let tx = await reportDomain.setreward(reward.add(1)); - await tx.wait(); - let newReward = await reportDomain.reward(); - console.log({ newReward }); - expect(newReward.toString(), "reward should be +1").to.eq( - reward.add(1).toString() - ); - }); + // tx = await reportDomain.validate(reportID, true, "my comments"); + // await tx.wait(); + // console.log("validated"); + // lockedAmount = await reportDomain.lockedAmount(); + // expect(lockedAmount.toString(), "incorrect locked amount").to.eq("0"); + // console.log("locked amount is 0"); + // balance = await reportDomain.getBalance(); + // expect(balance?.toString(), "Balance should be 0").to.eq("0"); + // console.log("balance is 0"); + // let afterBal = await secondAdmin.provider?.getBalance(secondAdmin.address); + // console.log("secondAdmin after", { + // afterBal: ethers.utils + // .formatEther(afterBal?.toString() || "0") + // .toString(), + // }); + // expect(afterBal?.toString(), "second admin should have +5").to.eq( + // initialBal?.add(stakingAmount).toString() + // ); + + // let points = await reportDomain.points(secondAdmin.address); + // expect(points.toString(), "points should be 10").to.eq("10"); + // }); + + // it("report (REJECT)", async () => { + // let domain = "google.com"; + // let isScam = false; + // let evidences = ["scd", "sdvsdv"]; + // let comments = "sdasbvf"; + // let stakingAmount = await reportDomain.callStatic.stakingAmount(); + // let reportID = await reportDomain.callStatic.report( + // domain, + // isScam, + // evidences, + // comments, + // { value: stakingAmount.toString() } + // ); + // let tx = await reportDomain + // .connect(secondAdmin) + // .report(domain, isScam, evidences, comments, { + // value: stakingAmount.toString(), + // }); + // await tx.wait(); + + // let isReported = await reportDomain.callStatic.isReported(domain, isScam); + // expect(isReported, "is reported legit should be true").to.eq(true); + + // let isReported2 = await reportDomain.callStatic.isReported(domain, !isScam); + // expect(isReported2, "is reported scam should be false").to.eq(false); + + // let lockedAmount = await reportDomain.lockedAmount(); + // expect(lockedAmount.toString(), "incorrect lockek amount").to.eq( + // stakingAmount.toString() + // ); + + // let initialBal = await secondAdmin.provider?.getBalance( + // secondAdmin.address + // ); + // console.log("secondAdmin before", { + // initialBal: ethers.utils + // .formatEther(initialBal?.toString() || "0") + // .toString(), + // }); + + // let balance = await reportDomain.getBalance(); + // console.log({ balance }); + // expect(balance.toString(), "Balance should be 5ETH").to.eq( + // stakingAmount.toString() + // ); + + // tx = await reportDomain.validate(reportID, false, "my comments"); + // await tx.wait(); + + // lockedAmount = await reportDomain.lockedAmount(); + // expect(lockedAmount.toString(), "incorrect lockek amount").to.eq("0"); // lock released + + // balance = await reportDomain.getBalance(); + // expect(balance?.toString(), "Balance should be 0").to.eq("0"); + + // let afterBal = await secondAdmin.provider?.getBalance(secondAdmin.address); + // console.log("secondAdmin after", { + // afterBal: ethers.utils + // .formatEther(afterBal?.toString() || "0") + // .toString(), + // }); + // expect(afterBal?.toString(), "second admin should have +5").to.eq( + // initialBal?.toString() + // ); + // }); + + // it("report on same domain", async () => { + // let domain = "google.com"; + // let isScam = false; + // let evidences = ["scd", "sdvsdv"]; + // let comments = "sdasbvf"; + // let stakingAmount = await reportDomain.callStatic.stakingAmount(); + // let tx = await reportDomain + // .connect(secondAdmin) + // .report(domain, isScam, evidences, comments, { + // value: stakingAmount.toString(), + // }); + // await tx.wait(); + + // let isReported = await reportDomain.callStatic.isReported(domain, isScam); + // expect(isReported, "is reported legit should be true").to.eq(true); + + // let isReported2 = await reportDomain.callStatic.isReported(domain, !isScam); + // expect(isReported2, "is reported scam should be false").to.eq(false); + + // await expect( + // reportDomain + // .connect(secondAdmin) + // .callStatic.report(domain, isScam, evidences, comments, { + // value: stakingAmount.toString(), + // }) + // ).to.be.rejectedWith("Is Legit report already filed"); + // await expect( + // reportDomain + // .connect(secondAdmin) + // .callStatic.report(domain, !isScam, evidences, comments, { + // value: stakingAmount.toString(), + // }) + // ).to.be.rejectedWith("You already reported it as legit"); + // tx = await reportDomain.report(domain, !isScam, evidences, comments, { + // value: stakingAmount.toString(), + // }); + // await tx.wait(); + // console.log("reported again"); + // await expect( + // reportDomain.callStatic.report(domain, !isScam, evidences, comments, { + // value: stakingAmount.toString(), + // }) + // ).to.be.rejectedWith("Is Scam report already filed"); + // await expect( + // reportDomain.callStatic.report(domain, isScam, evidences, comments, { + // value: stakingAmount.toString(), + // }) + // ).to.be.rejectedWith("Is Legit report already filed"); + // }); + + // it("change Reward", async () => { + // let reward = await reportDomain.reward(); + // console.log({ reward }); + // let tx = await reportDomain.setreward(reward.add(1)); + // await tx.wait(); + // let newReward = await reportDomain.reward(); + // console.log({ newReward }); + // expect(newReward.toString(), "reward should be +1").to.eq( + // reward.add(1).toString() + // ); + // }); });