Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions dao-contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,24 @@ npx istanbul check-coverage --lines 80

## Deployment

### Hardhat
### Hardhat (`localhost`)

```shell
npx hardhat node
```
```shell
npx hardhat ignition deploy ./ignition/modules/ELIMU.ts --network hardhat
npx hardhat ignition deploy ./ignition/modules/gELIMU.ts --network hardhat
npx hardhat ignition deploy ./ignition/modules/Languages.ts --network hardhat
npx hardhat ignition deploy ./ignition/modules/Roles.ts --network hardhat
```

### Sepolia
### Sepolia (Chain ID `11155111`)

```shell
npx hardhat ignition deploy ./ignition/modules/ELIMU.ts --network sepolia --reset --verify
npx hardhat ignition deploy ./ignition/modules/gELIMU.ts --network sepolia --verify
npx hardhat ignition deploy ./ignition/modules/Languages.ts --network sepolia --verify
```

```shell
npx hardhat ignition deploy ./ignition/modules/Roles.ts --network sepolia --verify
```

Expand Down
20 changes: 20 additions & 0 deletions dao-contracts/contracts/Languages.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,35 @@ import { ILanguages } from "@elimu-ai/dao-contracts/ILanguages.sol";

/// @notice This smart contract stores the languages currently supported by the Ξlimu DAO (see https://github.com/elimu-ai/model).
contract Languages is ILanguages {
address public owner;

/// @notice The ISO 639-2 language code of each language, in upper-case letters. E.g. "ENG" for English.
mapping(string => bool) private languageCodes;

event OwnerUpdated(address);
event LanguageCodeAdded(string);
event LanguageCodeRemoved(string);

constructor() {
owner = msg.sender;
}

function updateOwner(address owner_) public {
require(msg.sender == owner, "Only the current owner can set a new owner");
owner = owner_;
emit OwnerUpdated(owner_);
}

function addSupportedLanguage(string calldata languageCode) external {
require(msg.sender == owner, "Only the current owner can add a language");
languageCodes[languageCode] = true;
emit LanguageCodeAdded(languageCode);
}

function removeSupportedLanguage(string calldata languageCode) external {
require(msg.sender == owner, "Only the current owner can remove a language");
languageCodes[languageCode] = false;
emit LanguageCodeRemoved(languageCode);
}

function isSupportedLanguage(string calldata languageCode) external view returns (bool) {
Expand Down
10 changes: 6 additions & 4 deletions dao-contracts/hardhat-gas-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,21 @@
································|·················|···············|·················|················|···············
| Languages · │
································|·················|···············|·················|················|···············
| addSupportedLanguage · - · - · 44,216 · 3 · - │
| addSupportedLanguage · - · - · 48,062 · 4 · - │
································|·················|···············|·················|················|···············
| removeSupportedLanguage · - · - · 22,338 · 1 · - │
| removeSupportedLanguage · - · - · 26,228 · 1 · - │
································|·················|···············|·················|················|···············
| updateOwner · - · - · 27,983 · 3 · - │
································|·················|···············|·················|················|···············
| Lock · │
································|·················|···············|·················|················|···············
| withdraw · - · - · 33,820 · 7 · - │
································|·················|···············|·················|················|···············
| Deployments · · % of limit · │
································|·················|···············|·················|················|···············
| DummyERC20 · 558,532 · 558,676 · 558,604 · 1.9 % · - │
| DummyERC20 · 558,540 · 558,684 · 558,612 · 1.9 % · - │
································|·················|···············|·················|················|···············
| Languages · - · - · 151,721 · 0.5 % · - │
| Languages · - · - · 332,730 · 1.1 % · - │
································|·················|···············|·················|················|···············
| Lock · - · - · 204,541 · 0.7 % · - │
································|·················|···············|·················|················|···············
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,50 @@
"contractName": "Languages",
"sourceName": "contracts/Languages.sol",
"abi": [
{
"inputs": [],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "string",
"name": "",
"type": "string"
}
],
"name": "LanguageCodeAdded",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "string",
"name": "",
"type": "string"
}
],
"name": "LanguageCodeRemoved",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "OwnerUpdated",
"type": "event"
},
{
"inputs": [
{
Expand Down Expand Up @@ -36,19 +80,13 @@
"type": "function"
},
{
"inputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"name": "languageCodes",
"inputs": [],
"name": "owner",
"outputs": [
{
"internalType": "bool",
"internalType": "address",
"name": "",
"type": "bool"
"type": "address"
}
],
"stateMutability": "view",
Expand All @@ -66,10 +104,23 @@
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "owner_",
"type": "address"
}
],
"name": "updateOwner",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
],
"bytecode": "0x6080604052348015600f57600080fd5b506102d08061001f6000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c8063655c50e01461005157806366ac7d5e14610078578063a239346f1461008d578063b7737701146100bb575b600080fd5b61006461005f366004610147565b6100ce565b604051901515815260200160405180910390f35b61008b610086366004610147565b6100fc565b005b61006461009b3660046101d1565b805160208183018101805160008252928201919093012091525460ff1681565b61008b6100c9366004610147565b610134565b60008083836040516100e192919061028a565b9081526040519081900360200190205460ff16905092915050565b60016000838360405161011092919061028a565b908152604051908190036020019020805491151560ff199092169190911790555050565b600080838360405161011092919061028a565b6000806020838503121561015a57600080fd5b823567ffffffffffffffff81111561017157600080fd5b8301601f8101851361018257600080fd5b803567ffffffffffffffff81111561019957600080fd5b8560208284010111156101ab57600080fd5b6020919091019590945092505050565b634e487b7160e01b600052604160045260246000fd5b6000602082840312156101e357600080fd5b813567ffffffffffffffff8111156101fa57600080fd5b8201601f8101841361020b57600080fd5b803567ffffffffffffffff811115610225576102256101bb565b604051601f8201601f19908116603f0116810167ffffffffffffffff81118282101715610254576102546101bb565b60405281815282820160200186101561026c57600080fd5b81602084016020830137600091810160200191909152949350505050565b818382376000910190815291905056fea26469706673582212207d5403cc4125199b3376ecdf86b89fa7f4a98e7c8e9ff3c91821cbf1e9daa25b64736f6c634300081c0033",
"deployedBytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c8063655c50e01461005157806366ac7d5e14610078578063a239346f1461008d578063b7737701146100bb575b600080fd5b61006461005f366004610147565b6100ce565b604051901515815260200160405180910390f35b61008b610086366004610147565b6100fc565b005b61006461009b3660046101d1565b805160208183018101805160008252928201919093012091525460ff1681565b61008b6100c9366004610147565b610134565b60008083836040516100e192919061028a565b9081526040519081900360200190205460ff16905092915050565b60016000838360405161011092919061028a565b908152604051908190036020019020805491151560ff199092169190911790555050565b600080838360405161011092919061028a565b6000806020838503121561015a57600080fd5b823567ffffffffffffffff81111561017157600080fd5b8301601f8101851361018257600080fd5b803567ffffffffffffffff81111561019957600080fd5b8560208284010111156101ab57600080fd5b6020919091019590945092505050565b634e487b7160e01b600052604160045260246000fd5b6000602082840312156101e357600080fd5b813567ffffffffffffffff8111156101fa57600080fd5b8201601f8101841361020b57600080fd5b803567ffffffffffffffff811115610225576102256101bb565b604051601f8201601f19908116603f0116810167ffffffffffffffff81118282101715610254576102546101bb565b60405281815282820160200186101561026c57600080fd5b81602084016020830137600091810160200191909152949350505050565b818382376000910190815291905056fea26469706673582212207d5403cc4125199b3376ecdf86b89fa7f4a98e7c8e9ff3c91821cbf1e9daa25b64736f6c634300081c0033",
"bytecode": "0x6080604052348015600f57600080fd5b50600080546001600160a01b031916331790556104a6806100316000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c8063655c50e01461005c57806366ac7d5e14610084578063880cdc31146100995780638da5cb5b146100ac578063b7737701146100d7575b600080fd5b61006f61006a36600461038d565b6100ea565b60405190151581526020015b60405180910390f35b61009761009236600461038d565b610119565b005b6100976100a7366004610401565b6101f9565b6000546100bf906001600160a01b031681565b6040516001600160a01b03909116815260200161007b565b6100976100e536600461038d565b6102ba565b6000600183836040516100fe929190610431565b9081526040519081900360200190205460ff16905092915050565b6000546001600160a01b0316331461018a5760405162461bcd60e51b815260206004820152602960248201527f4f6e6c79207468652063757272656e74206f776e65722063616e206164642061604482015268206c616e677561676560b81b60648201526084015b60405180910390fd5b600180838360405161019d929190610431565b908152604051908190036020018120805492151560ff19909316929092179091557f4b2d80c160e1549f17427a391bef700094a21a5127e049cca43a6bb6916077a3906101ed9084908490610441565b60405180910390a15050565b6000546001600160a01b031633146102665760405162461bcd60e51b815260206004820152602a60248201527f4f6e6c79207468652063757272656e74206f776e65722063616e207365742061604482015269103732bb9037bbb732b960b11b6064820152608401610181565b600080546001600160a01b0319166001600160a01b0383169081179091556040519081527f4ffd725fc4a22075e9ec71c59edf9c38cdeb588a91b24fc5b61388c5be41282b9060200160405180910390a150565b6000546001600160a01b031633146103295760405162461bcd60e51b815260206004820152602c60248201527f4f6e6c79207468652063757272656e74206f776e65722063616e2072656d6f7660448201526b652061206c616e677561676560a01b6064820152608401610181565b60006001838360405161033d929190610431565b908152604051908190036020018120805492151560ff19909316929092179091557f46c668663309029d8cb32030ec6c19be9f2d2b1b25cbd59d53382c932c32c995906101ed9084908490610441565b600080602083850312156103a057600080fd5b823567ffffffffffffffff8111156103b757600080fd5b8301601f810185136103c857600080fd5b803567ffffffffffffffff8111156103df57600080fd5b8560208284010111156103f157600080fd5b6020919091019590945092505050565b60006020828403121561041357600080fd5b81356001600160a01b038116811461042a57600080fd5b9392505050565b8183823760009101908152919050565b60208152816020820152818360408301376000818301604090810191909152601f909201601f1916010191905056fea26469706673582212200ff8bf09e81d66e09ef5163f137da3c4aa4e530b2718e84d7cbf9fa1457e83e264736f6c634300081c0033",
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100575760003560e01c8063655c50e01461005c57806366ac7d5e14610084578063880cdc31146100995780638da5cb5b146100ac578063b7737701146100d7575b600080fd5b61006f61006a36600461038d565b6100ea565b60405190151581526020015b60405180910390f35b61009761009236600461038d565b610119565b005b6100976100a7366004610401565b6101f9565b6000546100bf906001600160a01b031681565b6040516001600160a01b03909116815260200161007b565b6100976100e536600461038d565b6102ba565b6000600183836040516100fe929190610431565b9081526040519081900360200190205460ff16905092915050565b6000546001600160a01b0316331461018a5760405162461bcd60e51b815260206004820152602960248201527f4f6e6c79207468652063757272656e74206f776e65722063616e206164642061604482015268206c616e677561676560b81b60648201526084015b60405180910390fd5b600180838360405161019d929190610431565b908152604051908190036020018120805492151560ff19909316929092179091557f4b2d80c160e1549f17427a391bef700094a21a5127e049cca43a6bb6916077a3906101ed9084908490610441565b60405180910390a15050565b6000546001600160a01b031633146102665760405162461bcd60e51b815260206004820152602a60248201527f4f6e6c79207468652063757272656e74206f776e65722063616e207365742061604482015269103732bb9037bbb732b960b11b6064820152608401610181565b600080546001600160a01b0319166001600160a01b0383169081179091556040519081527f4ffd725fc4a22075e9ec71c59edf9c38cdeb588a91b24fc5b61388c5be41282b9060200160405180910390a150565b6000546001600160a01b031633146103295760405162461bcd60e51b815260206004820152602c60248201527f4f6e6c79207468652063757272656e74206f776e65722063616e2072656d6f7660448201526b652061206c616e677561676560a01b6064820152608401610181565b60006001838360405161033d929190610431565b908152604051908190036020018120805492151560ff19909316929092179091557f46c668663309029d8cb32030ec6c19be9f2d2b1b25cbd59d53382c932c32c995906101ed9084908490610441565b600080602083850312156103a057600080fd5b823567ffffffffffffffff8111156103b757600080fd5b8301601f810185136103c857600080fd5b803567ffffffffffffffff8111156103df57600080fd5b8560208284010111156103f157600080fd5b6020919091019590945092505050565b60006020828403121561041357600080fd5b81356001600160a01b038116811461042a57600080fd5b9392505050565b8183823760009101908152919050565b60208152816020820152818360408301376000818301604090810191909152601f909201601f1916010191905056fea26469706673582212200ff8bf09e81d66e09ef5163f137da3c4aa4e530b2718e84d7cbf9fa1457e83e264736f6c634300081c0033",
"linkReferences": {},
"deployedLinkReferences": {}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"LanguagesModule#Languages": "0x9A3033D2e237376a09d7e19A7479622F8Ae38557",
"ELIMUModule#DummyERC20": "0xf4B2e968d9715Fbc0CD57E306A71036D2023bAD0",
"gELIMUModule#DummyERC20": "0x544096415caD910d528465503655AAcfAAf7deaA",
"RolesModule#Roles": "0x3c32D6016928A83522F8836c80116b7F2b978268"
"ELIMUModule#DummyERC20": "0xFf7b7C3815D84E90CF497dFFCda4E1d36D262Ac1",
"gELIMUModule#DummyERC20": "0x5D1582b1117Af3A0aD3fe23ac6a35d77754D9c23",
"LanguagesModule#Languages": "0x3Ad5e98f590BfEB36371076f6d595A0d3C4cD57e",
"RolesModule#Roles": "0x4f5e980F74286013b9c4583236eBC9dCC3d48009"
}
6 changes: 2 additions & 4 deletions dao-contracts/ignition/modules/Roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@ const RolesModule = buildModule("RolesModule", (m) => {

let elimuAddress = ethers.ZeroAddress;
if (network.name == "sepolia") {
// .../deployments/chain-11155111/deployed_addresses.json
elimuAddress = "0xf4B2e968d9715Fbc0CD57E306A71036D2023bAD0";
elimuAddress = require("../deployments/chain-11155111/deployed_addresses.json")["ELIMUModule#DummyERC20"];
} else if (network.name == "mainnet") {
elimuAddress = "0xe29797910D413281d2821D5d9a989262c8121CC2";
}
console.log("elimuAddress:", elimuAddress);

let gElimuAddress = ethers.ZeroAddress;
if (network.name == "sepolia") {
// .../deployments/chain-11155111/deployed_addresses.json
gElimuAddress = "0x544096415caD910d528465503655AAcfAAf7deaA";
gElimuAddress = require("../deployments/chain-11155111/deployed_addresses.json")["gELIMUModule#DummyERC20"];
} else if (network.name == "mainnet") {
gElimuAddress = "0xBeC06361c9451C8C493e74D6a1Df8428cdce5D53";
}
Expand Down
Loading