Skip to content

Commit

Permalink
socialBotPlugin, interaction comm out
Browse files Browse the repository at this point in the history
  • Loading branch information
parseb committed Sep 29, 2023
1 parent 0ed142e commit 5c00d67
Show file tree
Hide file tree
Showing 192 changed files with 499 additions and 1,303,975 deletions.
11 changes: 4 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,9 @@ jobs:
- name: Install dependencies
run: npm install

- name: Install Foundry
run: |
curl -L https://foundry.paradigm.xyz | bash
source /home/runner/.bashrc
foundryup
shell: bash
- name: "Install Foundry"
uses: "foundry-rs/foundry-toolchain@v1"


- name: Run Forge tests
run: forge t
Expand All @@ -45,5 +42,5 @@ jobs:
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
git add .
git commit -m "chore:gh CI test"
git commit -m "ci:gh test&abi gen"
git push
38 changes: 19 additions & 19 deletions contracts/IInteraction.sol
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
//SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
// //SPDX-License-Identifier: MIT
// pragma solidity 0.8.19;

import "@openzeppelin/contracts/utils/Counters.sol";
import "./daoUtils/interfaces/get/IDAOAdmin.sol";
// import "@openzeppelin/contracts/utils/Counters.sol";
// import "./daoUtils/interfaces/get/IDAOAdmin.sol";

interface IInteraction {
event InteractionIndexIncreased(address member, uint256 total);
event AddressAllowed(address addr);
// interface IInteraction {
// event InteractionIndexIncreased(address member, uint256 total);
// event AddressAllowed(address addr);

struct InteractionModel {
address member;
uint256 taskID;
address contractAddress;
}
// struct InteractionModel {
// address member;
// uint256 taskID;
// address contractAddress;
// }

function dao() external view returns (IDAOAdmin);
// function dao() external view returns (IDAOAdmin);

function allowAccess(address addr) external;
// function allowAccess(address addr) external;

function addInteraction(uint256 activityID, address member) external;
// function addInteraction(uint256 activityID, address member) external;

// view
function getInteraction(uint256 interactionID) external view returns (InteractionModel memory);
// // view
// function getInteraction(uint256 interactionID) external view returns (InteractionModel memory);

function getInteractionsIndexPerAddress(address user) external view returns (uint256);
}
// function getInteractionsIndexPerAddress(address user) external view returns (uint256);
// }
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,13 @@ interface ILocalReputation {
error PeriodUnelapsed();
error ZeroUnallawed();
error MaxK();
error k1MaxPointPerInteraction();

function initialize(address dao_) external;

function interaction(bytes calldata msgData, address agent) external;

function setInteractionWeights(address plugin_, bytes[] memory datas, uint8[] memory points) external;
function setInteractionWeights(address plugin_, bytes[] memory datas, uint16[] memory points) external;

function getGroupState(address nova_) external view returns (groupState memory);

Expand Down
80 changes: 40 additions & 40 deletions contracts/Interaction.sol
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
//SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
// //SPDX-License-Identifier: MIT
// pragma solidity 0.8.19;

import "@openzeppelin/contracts/utils/Counters.sol";
import "./daoUtils/interfaces/get/IDAOAdmin.sol";
import "./daoUtils/interfaces/get/IDAOModules.sol";
import "./IInteraction.sol";
// import "@openzeppelin/contracts/utils/Counters.sol";
// import "./daoUtils/interfaces/get/IDAOAdmin.sol";
// import "./daoUtils/interfaces/get/IDAOModules.sol";
// import "./IInteraction.sol";

contract Interaction is IInteraction {
using Counters for Counters.Counter;
// contract Interaction is IInteraction {
// using Counters for Counters.Counter;

Counters.Counter private idCounter;
// Counters.Counter private idCounter;

mapping(address => bool) isAllowed;
// mapping(address => bool) isAllowed;

modifier onlyAllowed() {
require(isAllowed[msg.sender], "Not allowed to transfer interactions");
_;
}
// modifier onlyAllowed() {
// require(isAllowed[msg.sender], "Not allowed to transfer interactions");
// _;
// }

mapping(uint256 => InteractionModel) interactions;
mapping(address => uint256) interactionsIndex;
// mapping(uint256 => InteractionModel) interactions;
// mapping(address => uint256) interactionsIndex;

IDAOAdmin public override dao;
// IDAOAdmin public override dao;

constructor() {
dao = IDAOAdmin(msg.sender);
}
// constructor() {
// dao = IDAOAdmin(msg.sender);
// }

function allowAccess(address addr) public override {
require(dao.isAdmin(msg.sender) || IDAOModules(address(dao)).pluginRegistry() == msg.sender, "Not allowed");
isAllowed[addr] = true;
// function allowAccess(address addr) public override {
// require(dao.isAdmin(msg.sender) || IDAOModules(address(dao)).pluginRegistry() == msg.sender, "Not allowed");
// isAllowed[addr] = true;

emit AddressAllowed(addr);
}
// emit AddressAllowed(addr);
// }

function addInteraction(uint256 activityID, address member) public override onlyAllowed {
InteractionModel memory model = InteractionModel(member, activityID, msg.sender);
// function addInteraction(uint256 activityID, address member) public override onlyAllowed {
// InteractionModel memory model = InteractionModel(member, activityID, msg.sender);

idCounter.increment();
interactions[idCounter.current()] = model;
interactionsIndex[member]++;
// idCounter.increment();
// interactions[idCounter.current()] = model;
// interactionsIndex[member]++;

emit InteractionIndexIncreased(member, interactionsIndex[member]);
}
// emit InteractionIndexIncreased(member, interactionsIndex[member]);
// }

// view
function getInteraction(uint256 interactionID) public view override returns (InteractionModel memory) {
return interactions[interactionID];
}
// // view
// function getInteraction(uint256 interactionID) public view override returns (InteractionModel memory) {
// return interactions[interactionID];
// }

function getInteractionsIndexPerAddress(address user) public view override returns (uint256) {
return interactionsIndex[user];
}
}
// function getInteractionsIndexPerAddress(address user) public view override returns (uint256) {
// return interactionsIndex[user];
// }
// }
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.19;

import {INova} from "../../nova/interfaces/INova.sol";
import {IAutID} from "../../IAutID.sol";
import {IPlugin} from "../IPlugin.sol";
import {INova} from "./nova/interfaces/INova.sol";
import {IAutID} from "./IAutID.sol";
import {IPlugin} from "./plugins/IPlugin.sol";

import "./ILocalReputation.sol";

/// @title Local Reputation Framework for ĀutID holders

contract LocalRep is ILocalReputation {
contract LocalReputation is ILocalReputation {
/// @notice stores plugin(or authorised address)-dao relation on initialization
mapping(address plugin => address dao) public daoOfPlugin;

Expand Down Expand Up @@ -66,7 +66,7 @@ contract LocalRep is ILocalReputation {
IAutID AutID = IAutID(Nova.getAutIDAddress());

address[] memory members = IAutID(INova(nova_).getAutIDAddress()).getAllActiveMembers(nova_);

if (members.length == 0) return commitments;
commitments = AutID.getCommitmentsOfFor(members, nova_);
bytes32 currentCommitment = keccak256(abi.encodePacked(commitments));
uint256 context = getContextID(nova_, nova_);
Expand Down Expand Up @@ -123,7 +123,7 @@ contract LocalRep is ILocalReputation {
/// @param who_ agent address to update local reputation for
/// @param group_ target group context for local repuatation update
function updateIndividualLR(address who_, address group_) public returns (uint256) {
if (!INova(group_).isAdmin(_msgSender())) revert OnlyAdmin();
if (!INova(group_).isAdmin(_msgSender())) revert Unauthorised();
uint256 Icontext = getContextID(who_, group_);
uint256 Gcontext = getContextID(group_, group_);
individualState memory ISS = getIS[Icontext];
Expand Down Expand Up @@ -212,17 +212,19 @@ contract LocalRep is ILocalReputation {
/// @param plugin_ plugin target
/// @param datas_, array of selector encoded (msg.data) bytes
/// @param points_, amount of points to be awared for each of datas_, 0 to remove and readjust for performance
function setInteractionWeights(address plugin_, bytes[] memory datas_, uint8[] memory points_) external {
function setInteractionWeights(address plugin_, bytes[] memory datas_, uint16[] memory points_) external {
if (daoOfPlugin[plugin_] == address(0)) revert UninitializedPair();
address nova = daoOfPlugin[plugin_];
if (!INova(nova).isAdmin(_msgSender())) revert OnlyAdmin();

if (!(INova(nova).isAdmin(_msgSender())) && (_msgSender() != plugin_)) revert OnlyAdmin();
if (datas_.length != points_.length) revert ArgLenMismatch();
uint256 interact;
uint256 i;

for (i; i < datas_.length;) {
interact = interactionID(plugin_, datas_[i]);
if (points_[i] > 1_000) revert k1MaxPointPerInteraction();
pointsPerInteraction[interact] = points_[i];

(pointsPerInteraction[interact] > 0 && points_[i] == 0)
? pointsPerInteraction[getContextID(nova, nova)] -= pointsPerInteraction[interact]
: pointsPerInteraction[getContextID(nova, nova)] += points_[i];
Expand All @@ -236,9 +238,13 @@ contract LocalRep is ILocalReputation {
/// @notice called only by plugin implementing interaction modifier to apply points for successfu execution
/// @param datas_ msg.data of called function
/// @param callerAgent_ address that called the function to be rewarded
function interaction(bytes memory datas_, address callerAgent_) external onlyPlugin {
function interaction(bytes calldata datas_, address callerAgent_) external onlyPlugin {
uint256 interactID = interactionID(_msgSender(), datas_);
uint256 repPoints = pointsPerInteraction[interactID];

if (datas_.length == 2) repPoints = uint256(bytes32(datas_[:32]));

if (repPoints == 0) return;
address dao = daoOfPlugin[_msgSender()];

getIS[getContextID(callerAgent_, dao)].GC += uint64(repPoints);
Expand Down
40 changes: 20 additions & 20 deletions contracts/daoUtils/abstracts/DAOInteractions.sol
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
//SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
// //SPDX-License-Identifier: MIT
// pragma solidity 0.8.19;

import "../interfaces/get/IDAOInteractions.sol";
import "../../Interaction.sol";
// import "../interfaces/get/IDAOInteractions.sol";
// import "../../Interaction.sol";

/// @title DAOExpander
/// @notice The extension of each DAO that integrates Aut
/// @dev The extension of each DAO that integrates Aut
abstract contract DAOInteractions is IDAOInteractions {
Interaction private interactions;
// /// @title DAOExpander
// /// @notice The extension of each DAO that integrates Aut
// /// @dev The extension of each DAO that integrates Aut
// abstract contract DAOInteractions is IDAOInteractions {
// Interaction private interactions;

function _deployInteractions() internal {
require(address(interactions) == address(0));
interactions = new Interaction();
}
// function _deployInteractions() internal {
// require(address(interactions) == address(0));
// interactions = new Interaction();
// }

function getInteractionsAddr() public view override returns (address) {
return address(interactions);
}
// function getInteractionsAddr() public view override returns (address) {
// return address(interactions);
// }

function getInteractionsPerUser(address member) public view override returns (uint256) {
return interactions.getInteractionsIndexPerAddress(member);
}
}
// function getInteractionsPerUser(address member) public view override returns (uint256) {
// return interactions.getInteractionsIndexPerAddress(member);
// }
// }
5 changes: 2 additions & 3 deletions contracts/expander/DAOExpander.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import "../daoUtils/abstracts/DAOModules.sol";
import "../daoUtils/abstracts/DAOMetadata.sol";
import "../daoUtils/abstracts/DAOCommitment.sol";
import "../daoUtils/abstracts/DAOMarket.sol";
import "../daoUtils/abstracts/DAOInteractions.sol";
// import "../daoUtils/abstracts/DAOInteractions.sol";
import "../daoUtils/abstracts/AutIDAddress.sol";
import "../expander/interfaces/IDAOExpander.sol";
import "../modules/onboarding/OnboardingModule.sol";
Expand All @@ -25,7 +25,7 @@ contract DAOExpander is
DAOMembers,
DAOUrls,
DAOMetadata,
DAOInteractions,
// DAOInteractions,
DAOCommitment,
DAOMarket,
DAOModules,
Expand Down Expand Up @@ -76,7 +76,6 @@ contract DAOExpander is
super._setAutIDAddress(IAutID(_autAddr));
super._setCommitment(_commitment);
super._setMetadataUri(_metadata);
super._deployInteractions();
super._setPluginRegistry(_pluginRegistry);
}

Expand Down
3 changes: 1 addition & 2 deletions contracts/expander/interfaces/IDAOExpander.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity 0.8.19;
import "../../daoUtils/interfaces/get/IDAOAdmin.sol";
import "../../daoUtils/interfaces/get/IDAOURL.sol";
import "../../daoUtils/interfaces/get/IAutIDAddress.sol";
import "../../daoUtils/interfaces/get/IDAOInteractions.sol";
// import "../../daoUtils/interfaces/get/IDAOInteractions.sol";
import "../../daoUtils/interfaces/get/IDAOCommitment.sol";

import "../../daoUtils/interfaces/set/IDAOAdminSet.sol";
Expand All @@ -24,7 +24,6 @@ interface IDAOExpander is
IDAOMetadataSet,
IDAOAdmin,
IDAOExpanderData,
IDAOInteractions,
IDAOExpanderMembership,
IDAOURL,
IDAOCommitment,
Expand Down
2 changes: 1 addition & 1 deletion contracts/modules/IModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ interface IModule {

/// @notice A plugin contract is deployed for each daoExpander that uses it. When a plugin is associated to a daoExpander, the address is set by the DAOExpander.
/// @return the address of the daoExpander contract that uses this module.
function daoAddress() external view returns (address);
function novaAddress() external view returns (address);
}
4 changes: 1 addition & 3 deletions contracts/nova/Nova.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ import "../daoUtils/abstracts/DAOModules.sol";
import "../daoUtils/abstracts/DAOMetadata.sol";
import "../daoUtils/abstracts/AutIDAddress.sol";
import "../daoUtils/abstracts/DAOCommitment.sol";
import "../daoUtils/abstracts/DAOInteractions.sol";

import "../modules/onboarding/OnboardingModule.sol";
import "./interfaces/INova.sol";

/// @title Nova
/// @notice
/// @dev
contract Nova is DAOMembers, DAOInteractions, DAOMetadata, DAOUrls, DAOMarket, DAOModules, DAOCommitment {
contract Nova is DAOMembers, DAOMetadata, DAOUrls, DAOMarket, DAOModules, DAOCommitment {
address public deployer;
address public onboardingAddr;

Expand All @@ -43,7 +42,6 @@ contract Nova is DAOMembers, DAOInteractions, DAOMetadata, DAOUrls, DAOMarket, D
_setAutIDAddress(_autAddr);
_setCommitment(_commitment);
_setMetadataUri(_metadata);
_deployInteractions();
_setPluginRegistry(_pluginRegistry);
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/plugins/IPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ interface IPlugin is IModule {
* @notice Returns the address of the DAO the plugin is associated with
* @return The address of the DAO
*/
function daoAddress() external view returns (address);
function novaAddress() external view returns (address);
}
Loading

0 comments on commit 5c00d67

Please sign in to comment.