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
3 changes: 3 additions & 0 deletions smart-contracts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### TODO
- hardhat deploy script
- unit test
Copy link
Contributor

Choose a reason for hiding this comment

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

The TODO list mentions the need for a hardhat deploy script and unit tests.

Would you like assistance in implementing these tasks? Additionally, it might be beneficial to open GitHub issues to track the progress of these tasks. Shall I proceed with creating them?

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"
}
]
47 changes: 47 additions & 0 deletions smart-contracts/dao.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.19;

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

// 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 roleExists;

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

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

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

// 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..."
}
4 changes: 4 additions & 0 deletions smart-contracts/deployments/polygon-goerli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"ContractName1": "0x...",
"ContractName2": "0x..."
}
4 changes: 4 additions & 0 deletions smart-contracts/deployments/scroll-sepolia.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"ContractName1": "0x...",
"ContractName2": "0x..."
}
Loading