forked from EthereansOS/Organizations-Core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit bdc83ff
Showing
21 changed files
with
1,846 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
pragma solidity ^0.6.0; | ||
|
||
import "./ICommonUtilities.sol"; | ||
|
||
contract CommonUtilities is ICommonUtilities { | ||
|
||
function toString(address _addr) public override pure returns(string memory) { | ||
bytes32 value = bytes32(uint256(_addr)); | ||
bytes memory alphabet = "0123456789abcdef"; | ||
|
||
bytes memory str = new bytes(42); | ||
str[0] = '0'; | ||
str[1] = 'x'; | ||
for (uint i = 0; i < 20; i++) { | ||
str[2+i*2] = alphabet[uint(uint8(value[i + 12] >> 4))]; | ||
str[3+i*2] = alphabet[uint(uint8(value[i + 12] & 0x0f))]; | ||
} | ||
return string(str); | ||
} | ||
|
||
function toString(uint _i) public override pure returns(string memory) { | ||
if (_i == 0) { | ||
return "0"; | ||
} | ||
uint j = _i; | ||
uint len; | ||
while (j != 0) { | ||
len++; | ||
j /= 10; | ||
} | ||
bytes memory bstr = new bytes(len); | ||
uint k = len - 1; | ||
while (_i != 0) { | ||
bstr[k--] = byte(uint8(48 + _i % 10)); | ||
_i /= 10; | ||
} | ||
return string(bstr); | ||
} | ||
|
||
function toUint256(bytes memory bs) public override pure returns(uint256 x) { | ||
if(bs.length >= 32) { | ||
assembly { | ||
x := mload(add(bs, add(0x20, 0))) | ||
} | ||
} | ||
} | ||
|
||
function toAddress(bytes memory b) public override pure returns (address addr) { | ||
if(b.length > 0) { | ||
assembly { | ||
addr := mload(add(b,20)) | ||
} | ||
} | ||
} | ||
|
||
function compareStrings(string memory a, string memory b) public override pure returns(bool) { | ||
return keccak256(abi.encodePacked(a)) == keccak256(abi.encodePacked(b)); | ||
} | ||
|
||
function getFirstJSONPart(address sourceLocation, uint256 sourceLocationId, address location) public override pure returns(bytes memory) { | ||
return abi.encodePacked( | ||
'"sourceLocation":"', | ||
toString(sourceLocation), | ||
'","sourceLocationId":', | ||
toString(sourceLocationId), | ||
',"location":"', | ||
toString(location) | ||
); | ||
} | ||
|
||
function formatReturnAbiParametersArray(string memory m) public override pure returns(string memory) { | ||
bytes memory b = bytes(m); | ||
if(b.length < 2) { | ||
return "[]"; | ||
} | ||
if(b[0] != bytes1("[")) { | ||
return "[]"; | ||
} | ||
if(b[b.length - 1] != bytes1("]")) { | ||
return "[]"; | ||
} | ||
return m; | ||
} | ||
|
||
function toLowerCase(string memory str) public override pure returns(string memory) { | ||
bytes memory bStr = bytes(str); | ||
for (uint i = 0; i < bStr.length; i++) { | ||
bStr[i] = bStr[i] >= 0x41 && bStr[i] <= 0x5A ? bytes1(uint8(bStr[i]) + 0x20) : bStr[i]; | ||
} | ||
return string(bStr); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
pragma solidity ^0.6.0; | ||
|
||
struct Functionality { | ||
string codeName; | ||
address sourceLocation; | ||
uint256 sourceLocationId; | ||
address location; | ||
bool submitable; | ||
string methodSignature; | ||
string returnAbiParametersArray; | ||
bool isInternal; | ||
bool needsSender; | ||
address proposalAddress; | ||
bool active; | ||
uint256 position; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
pragma solidity ^0.6.0; | ||
|
||
interface ICommonUtilities { | ||
function toString(address _addr) external pure returns(string memory); | ||
function toString(uint _i) external pure returns(string memory); | ||
function toUint256(bytes calldata bs) external pure returns(uint256 x); | ||
function toAddress(bytes calldata b) external pure returns (address addr); | ||
function compareStrings(string calldata a, string calldata b) external pure returns(bool); | ||
function getFirstJSONPart(address sourceLocation, uint256 sourceLocationId, address location) external pure returns(bytes memory); | ||
function formatReturnAbiParametersArray(string calldata m) external pure returns(string memory); | ||
function toLowerCase(string calldata str) external pure returns(string memory); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
pragma solidity ^0.6.0; | ||
|
||
interface IERC20 { | ||
function totalSupply() external view returns (uint256); | ||
function balanceOf(address account) external view returns (uint256); | ||
function transfer(address recipient, uint256 amount) external returns (bool); | ||
function allowance(address owner, address spender) external view returns (uint256); | ||
function approve(address spender, uint256 amount) external returns (bool); | ||
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); | ||
|
||
event Transfer(address indexed from, address indexed to, uint256 value); | ||
event Approval(address indexed owner, address indexed spender, uint256 value); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
pragma solidity ^0.6.0; | ||
|
||
interface IMVDFunctionalitiesManager { | ||
|
||
function getProxy() external view returns (address); | ||
function setProxy() external; | ||
|
||
function init(address sourceLocation, | ||
uint256 getMinimumBlockNumberSourceLocationId, address getMinimumBlockNumberFunctionalityAddress, | ||
uint256 getEmergencyMinimumBlockNumberSourceLocationId, address getEmergencyMinimumBlockNumberFunctionalityAddress, | ||
uint256 getEmergencySurveyStakingSourceLocationId, address getEmergencySurveyStakingFunctionalityAddress, | ||
uint256 checkVoteResultSourceLocationId, address checkVoteResultFunctionalityAddress) external; | ||
|
||
function addFunctionality(string calldata codeName, address sourceLocation, uint256 sourceLocationId, address location, bool submitable, string calldata methodSignature, string calldata returnAbiParametersArray, bool isInternal, bool needsSender) external; | ||
function addFunctionality(string calldata codeName, address sourceLocation, uint256 sourceLocationId, address location, bool submitable, string calldata methodSignature, string calldata returnAbiParametersArray, bool isInternal, bool needsSender, uint256 position) external; | ||
function removeFunctionality(string calldata codeName) external returns(bool removed, uint256 position); | ||
function isValidFunctionality(address functionality) external view returns(bool); | ||
function isAuthorizedFunctionality(address functionality) external view returns(bool); | ||
function setCallingContext(address location) external returns(bool); | ||
function clearCallingContext() external; | ||
function getFunctionalityData(string calldata codeName) external view returns(address, uint256, string memory); | ||
function hasFunctionality(string calldata codeName) external view returns(bool); | ||
function getFunctionalitiesAmount() external view returns(uint256); | ||
function functionalitiesToJSON() external view returns(string memory functionsJSONArray); | ||
function functionalitiesToJSON(uint256 start, uint256 l) external view returns(string memory functionsJSONArray); | ||
|
||
function preConditionCheck(string calldata codeName, bytes calldata data, uint8 submitable, address sender, uint256 value) external view returns(address location, bytes memory payload); | ||
|
||
function setupFunctionality(address proposalAddress) external; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pragma solidity ^0.6.0; | ||
|
||
interface IMVDFunctionalityModelsManager { | ||
function init() external; | ||
function checkWellKnownFunctionalities(string calldata codeName, bool submitable, string calldata methodSignature, string calldata returnAbiParametersArray, bool isInternal, bool needsSender, string calldata replaces) external view; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
pragma solidity ^0.6.0; | ||
|
||
interface IMVDFunctionalityProposal { | ||
|
||
function init(string calldata codeName, address location, string calldata methodSignature, string calldata returnAbiParametersArray, string calldata replaces, address proxy) external; | ||
function setCollateralData(bool emergency, address sourceLocation, uint256 sourceLocationId, bool submitable, bool isInternal, bool needsSender, address proposer) external; | ||
|
||
function getProxy() external view returns(address); | ||
function getCodeName() external view returns(string memory); | ||
function isEmergency() external view returns(bool); | ||
function getSourceLocation() external view returns(address); | ||
function getSourceLocationId() external view returns(uint256); | ||
function getLocation() external view returns(address); | ||
function isSubmitable() external view returns(bool); | ||
function getMethodSignature() external view returns(string memory); | ||
function getReturnAbiParametersArray() external view returns(string memory); | ||
function isInternal() external view returns(bool); | ||
function needsSender() external view returns(bool); | ||
function getReplaces() external view returns(string memory); | ||
function getProposer() external view returns(address); | ||
function getSurveyEndBlock() external view returns(uint256); | ||
function getSurveyDuration() external view returns(uint256); | ||
function toJSON() external view returns(string memory); | ||
function getVote(address addr) external view returns(uint256 accept, uint256 refuse); | ||
function getVotes() external view returns(uint256, uint256); | ||
function start() external; | ||
function disable() external; | ||
function isDisabled() external view returns(bool); | ||
function isTerminated() external view returns(bool); | ||
function accept(uint256 amount) external; | ||
function retireAccept(uint256 amount) external; | ||
function moveToAccept(uint256 amount) external; | ||
function refuse(uint256 amount) external; | ||
function retireRefuse(uint256 amount) external; | ||
function moveToRefuse(uint256 amount) external; | ||
function retireAll() external; | ||
function withdraw() external; | ||
function terminate() external; | ||
function set() external; | ||
|
||
event Accept(address indexed voter, uint256 amount); | ||
event RetireAccept(address indexed voter, uint256 amount); | ||
event MoveToAccept(address indexed voter, uint256 amount); | ||
event Refuse(address indexed voter, uint256 amount); | ||
event RetireRefuse(address indexed voter, uint256 amount); | ||
event MoveToRefuse(address indexed voter, uint256 amount); | ||
event RetireAll(address indexed voter, uint256 amount); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
pragma solidity ^0.6.0; | ||
|
||
interface IMVDFunctionalityProposalManager { | ||
function newProposal(string calldata codeName, address location, string calldata methodSignature, string calldata returnAbiParametersArray, string calldata replaces) external returns(address); | ||
function checkProposal(address proposalAddress) external; | ||
function disableProposal(address proposalAddress) external; | ||
function getProxy() external view returns (address); | ||
function setProxy() external; | ||
function isValidProposal(address proposal) external view returns (bool); | ||
function getPendingProposal(string calldata codeName) external view returns(address proposalAddress, bool isReallyPending); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
pragma solidity ^0.6.0; | ||
|
||
interface IMVDProxy { | ||
|
||
function init(address votingTokenAddress, address stateHolderAddress, address functionalityModelsManagerAddress, address functionalityProposalManagerAddress, address functionalitiesManagerAddress) external; | ||
|
||
function getToken() external view returns(address); | ||
function setToken(address newAddress) external; | ||
function getStateHolderAddress() external view returns(address); | ||
function setStateHolderAddress(address newAddress) external; | ||
function getMVDFunctionalityProposalManagerAddress() external view returns(address); | ||
function setMVDFunctionalityProposalManagerAddress(address newAddress) external; | ||
function getMVDFunctionalityModelsManagerAddress() external view returns(address); | ||
function setMVDFunctionalityModelsManagerAddress(address newAddress) external; | ||
function getMVDFunctionalitiesManagerAddress() external view returns(address); | ||
function setMVDFunctionalitiesManagerAddress(address newAddress) external; | ||
function changeProxy(address payable newAddress) external payable; | ||
function getFunctionalitiesAmount() external view returns(uint256); | ||
function isValidProposal(address proposal) external view returns (bool); | ||
function isValidFunctionality(address functionality) external view returns(bool); | ||
function isAuthorizedFunctionality(address functionality) external view returns(bool); | ||
function getFunctionalityAddress(string calldata codeName) external view returns(address); | ||
function hasFunctionality(string calldata codeName) external view returns(bool); | ||
function functionalitiesToJSON() external view returns(string memory functionsJSONArray); | ||
function functionalitiesToJSON(uint256 start, uint256 l) external view returns(string memory functionsJSONArray); | ||
function getPendingProposal(string calldata codeName) external view returns(address proposalAddress, bool isPending); | ||
function newProposal(string calldata codeName, bool emergency, address sourceLocation, uint256 sourceLocationId, address location, bool submitable, string calldata methodSignature, string calldata returnParametersJSONArray, bool isInternal, bool needsSender, string calldata replaces) external returns(address proposalAddress); | ||
function startProposal(address proposalAddress) external; | ||
function disableProposal(address proposalAddress) external; | ||
function transfer(address receiver, uint256 value, address token) external; | ||
function setProposal() external; | ||
function read(string calldata codeName, bytes calldata data) external view returns(bytes memory returnData); | ||
function submit(string calldata codeName, bytes calldata data) external payable returns(bytes memory returnData); | ||
function callFromManager(address location, bytes calldata payload) external returns(bool, bytes memory); | ||
function emitFromManager(string calldata codeName, uint256 position, address proposal, string calldata replaced, address location, bool submitable, string calldata methodSignature, bool isInternal, bool needsSender, address proposalAddress, uint256 replacedPosition) external; | ||
|
||
function emitEvent(string calldata eventSignature, bytes calldata firstIndex, bytes calldata secondIndex, bytes calldata data) external; | ||
|
||
event TokenChanged(address indexed oldAddress, address indexed newAddress); | ||
event MVDFunctionalityProposalManagerChanged(address indexed oldAddress, address indexed newAddress); | ||
event MVDFunctionalityModelsManagerChanged(address indexed oldAddress, address indexed newAddress); | ||
event MVDFunctionalitiesManagerChanged(address indexed oldAddress, address indexed newAddress); | ||
event StateHolderChanged(address indexed oldAddress, address indexed newAddress); | ||
event ProxyChanged(address indexed newAddress); | ||
|
||
event PaymentReceived(address indexed sender, uint256 value); | ||
event Proposal(address proposal); | ||
event ProposalSet(address indexed proposal, bool success); | ||
event FunctionalitySet(string indexed codeName, uint256 position, address proposal, string indexed replaced, address replacedLocation, bool replacedWasSubmitable, string replacedMethodSignature, bool replacedWasInternal, bool replacedNeededSender, address replacedProposal, uint256 replacedPosition); | ||
|
||
event Event(string indexed key, bytes32 indexed firstIndex, bytes32 indexed secondIndex, bytes data); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
pragma solidity ^0.6.0; | ||
|
||
interface IStateHolder { | ||
|
||
function init() external; | ||
|
||
function getProxy() external view returns (address); | ||
function setProxy() external; | ||
function getState(uint256 i) external view returns (string memory name, string memory dataType, bytes memory value); | ||
function getInfo(string calldata varName) external view returns (string memory dataType, bytes memory value, uint256 position); | ||
function getStateSize() external view returns (uint256); | ||
function exists(string calldata varName) external view returns(bool); | ||
function getDataType(string calldata varName) external view returns(string memory dataType); | ||
function clear(string calldata varName) external returns(string memory oldDataType, bytes memory oldVal); | ||
function setBytes(string calldata varName, bytes calldata val) external returns(bytes memory); | ||
function getBytes(string calldata varName) external view returns(bytes memory); | ||
function setString(string calldata varName, string calldata val) external returns(string memory); | ||
function getString(string calldata varName) external view returns (string memory); | ||
function setBool(string calldata varName, bool val) external returns(bool); | ||
function getBool(string calldata varName) external view returns (bool); | ||
function getUint256(string calldata varName) external view returns (uint256); | ||
function setUint256(string calldata varName, uint256 val) external returns(uint256); | ||
function getAddress(string calldata varName) external view returns (address); | ||
function setAddress(string calldata varName, address val) external returns (address); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
pragma solidity ^0.6.0; | ||
|
||
interface IVotingToken { | ||
function init(string calldata name, string calldata symbol, uint256 decimals, uint256 totalSupply) external; | ||
|
||
function getProxy() external view returns (address); | ||
function setProxy() external; | ||
|
||
function name() external view returns(string memory); | ||
function symbol() external view returns(string memory); | ||
function decimals() external view returns(uint256); | ||
|
||
function mint(uint256 amount) external; | ||
function burn(uint256 amount) external; | ||
|
||
function increaseAllowance(address spender, uint256 addedValue) external returns (bool); | ||
function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 Robe | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Oops, something went wrong.