Skip to content

Commit

Permalink
Merge pull request #44 from Aut-Labs/test-dev-2
Browse files Browse the repository at this point in the history
- adds non-eoa P. logic admin
- allowlist tests
- base populate script
- abis
  • Loading branch information
parseb authored Oct 12, 2023
2 parents 3399b5e + 52a373c commit cc4e225
Show file tree
Hide file tree
Showing 213 changed files with 266,127 additions and 243,438 deletions.
17 changes: 10 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: wip-dev-ci

env:
FOUNDRY_PROFILE: "ci"

on:
push:
branches:
Expand Down Expand Up @@ -35,10 +38,10 @@ jobs:
- name: generate types
run: npx typechain --target ethers-v5 './out/*.sol/*'

- name: Commit changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
git add .
git commit -m "ci: forge test and typechain"
git push
# - name: Commit changes
# run: |
# git config --local user.email "[email protected]"
# git config --local user.name "GitHub Actions"
# git add .
# git commit -m "ci: forge test"
# git push
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
node_modules
**/*.DS_Store
.env
node_modules
coverage
coverage.json
typechain
tempNet
cache_forge
broadcast
test/testData/LRfuzzDataOut.csv
*.csv

#Hardhat files
cache
Expand Down
3 changes: 1 addition & 2 deletions contracts/LocalReputation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,7 @@ contract LocalReputation is ILocalReputation {
if (!INova(target_).isAdmin(_msgSender())) revert OnlyAdmin();

if (k * p == 0) revert ZeroUnallowed();
if (((k / 100) + (p / 100) + (penalty / 100)) > 0) revert Over100();
///@dev substitute with penalty not p
if (((k / 100) + (penalty / 100)) > 0) revert Over100();

uint256 context = getContextID(target_, target_);
getGS[context].k = k;
Expand Down
5 changes: 4 additions & 1 deletion contracts/daoUtils/abstracts/DAOMembers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ abstract contract DAOMembers is IDAOAdmin, IDAOMembership, IDAOMembershipSet, ID
/// @notice adds admins provided a member address. Plugins do not have to be members.
/// @param member address to add as member.
function addAdmin(address member) public override onlyAdmin {
if ((! isMember[member] ) && (IPluginRegistry(IDAOModules(address(this)).pluginRegistry()).tokenIdFromAddress(member) == 0) ) revert("Not a member");
if (
(!isMember[member])
&& (IPluginRegistry(IDAOModules(address(this)).pluginRegistry()).tokenIdFromAddress(member) == 0)
) revert("Not a member");
isAdmin[member] = true;
admins.push(member);
emit AdminMemberAdded(member);
Expand Down
5 changes: 2 additions & 3 deletions contracts/modules/registry/IModuleRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,10 @@ interface IModuleRegistry {
*/
function updateMetadataURI(uint256 moduleId, string calldata uri) external;


/// @notice checks if an address is authorised to perform maintenance functions
/// @param subject address to check
function isProtocolMaintaier(address subject) external view returns (bool);
function isProtocolMaintaier(address subject) external view returns (bool);

/// @notice
/// @notice
function getAllowListAddress() external view returns (address);
}
4 changes: 2 additions & 2 deletions contracts/modules/registry/ModuleRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import {IAllowlist} from "../../utils/IAllowlist.sol";
contract ModuleRegistry is IModuleRegistry, Ownable {
ModuleDefinition[] public modules;
IAllowlist AllowList;

constructor(address allList) {
_transferOwnership(msg.sender);
AllowList = IAllowlist(allList);

modules.push(ModuleDefinition("none", 0));
modules.push(ModuleDefinition("ipfs://bafkreia2si4nhqjdxg543z7pp5kchvx4auwm7gn54wftfa2vykfkjc4ppe", 1));
modules.push(ModuleDefinition("ipfs://bafkreihxcz6eytmf6lm5oyqee67jujxepuczl42lw2orlfsw6yds5gm46i", 2));
Expand Down Expand Up @@ -46,5 +47,4 @@ contract ModuleRegistry is IModuleRegistry, Ownable {
function getAllowListAddress() external view returns (address) {
return address(AllowList);
}

}
9 changes: 4 additions & 5 deletions contracts/nova/NovaRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ contract NovaRegistry is ERC2771Recipient, INovaRegistry {
_setTrustedForwarder(trustedForwarder);
pluginRegistry = _pluginRegistry;
deployerAddress = msg.sender;
AllowList = IAllowlist(IModuleRegistry(IPluginRegistry(_pluginRegistry).modulesRegistry()).getAllowListAddress());
AllowList =
IAllowlist(IModuleRegistry(IPluginRegistry(_pluginRegistry).modulesRegistry()).getAllowListAddress());
}

/// @notice Deploys a new Nova
Expand All @@ -42,8 +43,8 @@ contract NovaRegistry is ERC2771Recipient, INovaRegistry {
require(bytes(metadata).length > 0, "Missing Metadata URL");
require(commitment > 0 && commitment < 11, "Invalid commitment");
if (address(AllowList) != address(0)) {
if (!AllowList.isAllowed(_msgSender())) revert IAllowlist.Unallowed("Not on list");
if (!(novaDeployers[_msgSender()].length > 0)) revert IAllowlist.Unallowed("Already Deployed a Nova");
if (!AllowList.isAllowed(_msgSender())) revert IAllowlist.Unallowed();
if (!(novaDeployers[_msgSender()].length > 0)) revert IAllowlist.AlreadyDeployedANova();
}
address novaAddr = novaFactory.deployNova(_msgSender(), autIDAddr, market, metadata, commitment, pluginRegistry);
novas.push(novaAddr);
Expand All @@ -69,6 +70,4 @@ contract NovaRegistry is ERC2771Recipient, INovaRegistry {
function getNovaByDeployer(address deployer) public view returns (address[] memory) {
return novaDeployers[deployer];
}


}
5 changes: 1 addition & 4 deletions contracts/plugins/PluginRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import "../plugins/registry/IPluginRegistry.sol";
import "../daoUtils/interfaces/get/IDAOAdmin.sol";
import "../nova/interfaces/INova.sol";



/// @title PluginRegistry
/// @notice Stores all plugins available and allows them to be added to a dao
contract PluginRegistry is ERC721URIStorage, Ownable, ReentrancyGuard, IPluginRegistry {
Expand Down Expand Up @@ -64,7 +62,7 @@ contract PluginRegistry is ERC721URIStorage, Ownable, ReentrancyGuard, IPluginRe
uint256 fee = (pluginDefinition.price * feeBase1000) / 1000;

feeReciever.transfer(fee);
(bool s, ) = pluginDefinition.creator.call{value: msg.value - fee}("");
(bool s,) = pluginDefinition.creator.call{value: msg.value - fee}("");
if (!s) revert("Value transfer failed");

emit PluginAddedToDAO(tokenId, pluginDefinitionId, nova);
Expand Down Expand Up @@ -119,7 +117,6 @@ contract PluginRegistry is ERC721URIStorage, Ownable, ReentrancyGuard, IPluginRe
) external onlyOwner returns (uint256 pluginDefinitionId) {
require(bytes(metadataURI).length > 0, "AUT: Metadata URI is empty");
require(canBeStandalone || price == 0, "AUT: Should be free if not standalone");


_numPluginDefinitions++;
pluginDefinitionId = _numPluginDefinitions;
Expand Down
1 change: 1 addition & 0 deletions contracts/plugins/interactions/OpenTaskWithRep.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ contract OpenTaskWithRep is OpenTaskPlugin, InteractionModifier {
ILR.initialize(nova_);
}

/// @dev assigning weights to finalizeFor() should be for keccak256 `abi.encodePacked`
function finalizeFor(uint256 taskId, address submitter)
public
override
Expand Down
1 change: 0 additions & 1 deletion contracts/plugins/interactions/SocialBotPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ contract SocialBotPlugin is SimplePlugin, InteractionModifier {
uint256 when;
uint16 maxPointsPerUser;
}
/// add to available interaction as relevant to performance metric ammended via setWeights

SocialBotEvent[] allBotInteractions;

Expand Down
8 changes: 8 additions & 0 deletions contracts/plugins/interactions/SocialQuizPlugin.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//SPDX-License-Identifier: UNLICENCED
pragma solidity 0.8.19;

import "./SocialBotPlugin.sol";

contract SocialQuizPlugin is SocialBotPlugin {
constructor(address nova_) SocialBotPlugin(nova_) {}
}
38 changes: 24 additions & 14 deletions contracts/utils/Allowlist.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import "./IAllowlist.sol";

contract Allowlist is IAllowlist {
mapping(address => bool) public isOwner;
mapping(address => bool) allowlist;
mapping(address => address) plusOne;
mapping(address => bool) public isAllowListed;
mapping(address => address) public plusOne;

address deployer;

Expand All @@ -15,17 +15,17 @@ contract Allowlist is IAllowlist {
}

function isAllowed(address _addr) public view returns (bool) {
return allowlist[_addr];
return isAllowListed[_addr];
}

/////////// Modifiers
//////////////////////////////////////
modifier isSenderOwner() {
if (allowlist[msg.sender] && msg.sig == this.addToAllowlist.selector) {
if (msg.sig == this.addToAllowlist.selector && isAllowListed[msg.sender]) {
if (plusOne[msg.sender] != address(0)) revert AlreadyPlusOne();
_;
} else {
if (!isOwner[msg.sender]) revert Unallowed("Only Owner");
if (!isOwner[msg.sender]) revert Unallowed();
_;
}
}
Expand All @@ -36,17 +36,20 @@ contract Allowlist is IAllowlist {
/// @notice adds address to allowlist if user is on the allowlist or owner
/// @notice allowlisted addresses can only allowlist once and their target cannot allow another in turn
function addToAllowlist(address addrToAdd_) external isSenderOwner {
allowlist[addrToAdd_] = true;
if (!isOwner[msg.sender]) plusOne[msg.sender] = addrToAdd_;
plusOne[addrToAdd_] = msg.sender;
if (isAllowListed[addrToAdd_]) return;
isAllowListed[addrToAdd_] = true;
if (!isOwner[msg.sender]) {
plusOne[addrToAdd_] = msg.sender;
plusOne[msg.sender] = addrToAdd_;
}

emit AddedToAllowList(addrToAdd_);
}

//// @notice remvoes address from allowlist if sender is owner
//// @param addrsToAdd_ addresses to remove
function removeFromAllowlist(address addrToAdd_) external isSenderOwner {
allowlist[addrToAdd_] = false;
isAllowListed[addrToAdd_] = false;
emit RemovedFromAllowList(addrToAdd_);
}

Expand All @@ -55,11 +58,12 @@ contract Allowlist is IAllowlist {
function addBatchToAllowlist(address[] memory addrsToAdd_) external isSenderOwner {
uint256 i;
for (i; i < addrsToAdd_.length;) {
allowlist[addrsToAdd_[i]] = true;
unchecked {
++i;
}
emit AddedToAllowList(addrsToAdd_[i]);
if (isAllowListed[addrsToAdd_[i - 1]]) continue;
isAllowListed[addrsToAdd_[i - 1]] = true;
emit AddedToAllowList(addrsToAdd_[i - 1]);
}
}

Expand All @@ -68,7 +72,7 @@ contract Allowlist is IAllowlist {
function removeBatchFromAllowlist(address[] memory addrs_) external isSenderOwner {
uint256 i;
for (i; i < addrs_.length;) {
allowlist[addrs_[i]] = false;
isAllowListed[addrs_[i]] = false;
unchecked {
++i;
}
Expand All @@ -84,7 +88,13 @@ contract Allowlist is IAllowlist {

/// @notice checks if is owner for protocol maintainance priviledges
/// @param subject address to check
function isAllowedOwner(address subject) external view returns(bool) {
function isAllowedOwner(address subject) external view returns (bool) {
return isOwner[subject];
}
}

/// @notice checks if subject can allowlist another address. It can do so if owner or on allowlist and not already allowlisted another address
/// @param subject address to check if it can allowlist
function canAllowList(address subject) external view returns (bool) {
return (isOwner[subject] || (isAllowListed[subject] && (plusOne[subject] == address(0))));
}
}
10 changes: 7 additions & 3 deletions contracts/utils/IAllowlist.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
pragma solidity 0.8.19;

interface IAllowlist {
error Unallowed(string);
error Unallowed();
error AlreadyPlusOne();
error AlreadyDepolyedANova();
error AlreadyDeployedANova();

event AddedToAllowList(address who);
event RemovedFromAllowList(address who);
Expand All @@ -15,5 +15,9 @@ interface IAllowlist {
function addBatchToAllowlist(address[] memory addrsToAdd_) external;
function removeBatchFromAllowlist(address[] memory _addrs) external;
function addOwner(address owner_) external;
function isAllowedOwner(address subject) external view returns(bool);
function isAllowedOwner(address subject) external view returns (bool);
function plusOne(address) external view returns (address);
function canAllowList(address subject) external view returns (bool);
function isOwner(address subject) external view returns (bool);
function isAllowListed(address subject) external view returns (bool);
}
18 changes: 0 additions & 18 deletions deployments.txt
Original file line number Diff line number Diff line change
@@ -1,18 +0,0 @@

#######################################################################
####################### DEPLOYMENT ADDRESSES ##########################
#######################################################################

Deployed to network ID: 80001
At timestamp: 1696600468
####################################################################

AUTid----------------------------------------- : 0xf0e0BF135B8914A948c0F9D23E878128F8084b0c
Nova Factory----------------------------------------- : 0x126a42d49Cc650eE73b8872E45328bf36F951830
ModuleRegistry----------------------------------------- : 0x91b826F005B7791865aB7c914865d7d3FcE6798f
PluginRegistry----------------------------------------- : 0x9B105915e275dEcd8555a5E689457e834fF10830
NovaRegistry----------------------------------------- : 0xe288963fFFA26a08A6726eebE67923533956BE37
NovaRegistry----------------------------------------- : 0xe288963fFFA26a08A6726eebE67923533956BE37
LocalReputation----------------------------------------- : 0x1c8FE9eDa570A39323a4D4669A1C49796d4E38D2
AllowlistAddr----------------------------------------- : 0xA663f2a605Be9b6A3826A6FFd52612a25260F693
PluginIDs : 1 , 2 , 3 , 4
5 changes: 5 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ libs = ['node_modules', 'lib']
test = 'test'
cache_path = 'cache_forge'
fs_permissions = [{ access = "read-write", path = "test/testData/LRfuzzDataOut.csv"}, { access = "read-write", path = "deployments.txt"}, { access = "read-write", path = "script/DeploymentAddresses.sol"}]
optimizier_runs=10_000

[rpc_endpoints]
goerli = "${GOERLI_ALCHEMY}"
mumbai="${MUMBAI_ALCHEMY}"

[fuzz]
runs = 1000

[profile.ci]
verbosity = 2
fuzz.runs = 0
Loading

0 comments on commit cc4e225

Please sign in to comment.