Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: contract and abi #15

Merged
merged 10 commits into from
Mar 22, 2024
192 changes: 192 additions & 0 deletions smart-contracts/abi/dao.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
[
{
"inputs": [
{
"internalType": "address",
"name": "member",
"type": "address"
}
],
"name": "addMember",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "string",
"name": "role",
"type": "string"
}
],
"name": "addRole",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "ratee",
"type": "address"
},
{
"internalType": "string",
"name": "role",
"type": "string"
},
{
"internalType": "address",
"name": "rater",
"type": "address"
},
{
"internalType": "uint8",
"name": "value",
"type": "uint8"
}
],
"name": "rateMember",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [],
"name": "getMembersCount",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getRolesCount",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"name": "hasRole",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "isMember",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "members",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
},
{
"internalType": "string",
"name": "",
"type": "string"
},
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "rates",
"outputs": [
{
"internalType": "uint8",
"name": "",
"type": "uint8"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "roles",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
}
]
52 changes: 52 additions & 0 deletions smart-contracts/dao.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.9.0;

contract Dao {
// dao member => role => rater => rate
mapping(address => mapping(string => mapping(address => uint8))) public rates;

// all members of the dao
address[] public members;
mapping(address => bool) public isMember;

// roles of a given dao member
string[] public roles;
mapping(string => bool) public hasRole;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mapping(string => bool) public hasRole;
mapping(string => bool) public roleExists;

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated as suggested.


constructor() {
members.push(msg.sender);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
members.push(msg.sender);

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Constructer removed.

isMember[msg.sender] = true;
}

function addMember(address member) public {
if (isMember[member] == false) {
isMember[member] = true;
members.push(member);
}
}

function addRole(string memory role) public {
if (hasRole[role] == false) {
hasRole[role] = true;
roles.push(role);
}
}

function rateMember(address ratee, string memory role, address rater, uint8 value) public {
rates[ratee][role][rater] = value;
}

// Function to get the length of members array
function getMembersCount() public view returns (uint256) {
return members.length;
}

// Function to get the length of roles array
function getRolesCount() public view returns (uint256) {
return roles.length;
}
}



2 changes: 1 addition & 1 deletion smart-contracts/deployments/optimism-sepolia.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"ContractName1": "0x...",
"dao_contract": "0x43A30DB2d6962c37a702E869FbD15cFc4f86f621",
"ContractName2": "0x..."
}
Loading