-
Notifications
You must be signed in to change notification settings - Fork 246
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
encodeParam and encodeParams functions #456
Open
leftab
wants to merge
53
commits into
aragon:next
Choose a base branch
from
leftab:dev
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
37b2612
Add encodeParam to ACLHelpers
leftab 85dda17
Move Op and Param structs from ACL to ACLHelpers
leftab e3b49ea
Add encoreParams and encodeParam for Param structs
leftab bc0e525
Add TestACLHelpers
leftab a97c86d
Remove encodeParam with uint params
leftab fee7fc1
Add AclHelpers js launch test
leftab ecf2f5c
Add encodeParams test
leftab 8542235
Add brackets around for loop
leftab a85c5aa
Remove ACL import and inheritance
leftab b3ba05d
Move Op and Param to ACLParams contract
leftab 79100ce
Add encodeOperator and encodeIfElse tests
leftab 9b4f8f3
Compact params
leftab b056828
Expose ACLHelpers functions
leftab 0aa8d3c
Fix linter issues
leftab e96f7c0
chore: update license text (#467)
sohkai 1fa2b95
Merge branch 'master' into dev
sohkai da862e2
KernelProxy: emit SetApp event on construction (#466)
sohkai 480b2f6
Add encodeParam to ACLHelpers
leftab bdeee78
Move Op and Param structs from ACL to ACLHelpers
leftab 04c2048
Add encoreParams and encodeParam for Param structs
leftab 2530b15
Add TestACLHelpers
leftab 45727e3
Remove encodeParam with uint params
leftab 97327f3
Add AclHelpers js launch test
leftab c44a025
Add encodeParams test
leftab b647866
Add brackets around for loop
leftab aa08e27
Remove ACL import and inheritance
leftab b05c010
Move Op and Param to ACLParams contract
leftab 9c84dc3
Add encodeOperator and encodeIfElse tests
leftab dbce97e
Compact params
leftab dd2f8f2
Expose ACLHelpers functions
leftab 22ec764
Fix linter issues
leftab 93e5ba1
Fix spaces and array size
leftab ad1b7f7
Use loop for testEncodeParams
leftab 3a8fb64
Merge branch 'dev' of https://github.com/leftab/aragonOS into dev
leftab c4e0fb1
chore: pin ganache-cli to 6.2.3 (#472)
sohkai a026e22
feat: Add SafeERC20 (#469)
sohkai 5c61d10
tests: Coverage improvements (#474)
sohkai c37d4fd
4.1.0-rc.1
sohkai 3d8c54f
chore: upgrade solium (#476)
sohkai 9734f9c
Merge with dev
leftab 8cf6039
Convert back ACLHelpers functions to internal
leftab 3c909ef
Expose encodeOperator and encodeIfElse in ACLHelpers
leftab 584f4bc
Add MIT license to ACLParams
leftab 05d3d26
Rename ACLHelper to ACLOracleHelper
leftab d2268c8
VaultRecoverable: emit event on successful recovery (#480)
sohkai 722e25e
test: remove accidentally placed .only() in tests (#483)
sohkai dbb0e06
feat: Add radspec strings to ENSSubdomainRegistrar
usetech-llc db9342f
fix: update radspec strings (#489)
sohkai b18c1a5
Create CONTRIBUTING.md
a33bcn 37f8eff
chore: update readme.md
sohkai 9ff0bda
Merge branch 'dev' into leftab-dev
sohkai 032f577
fix: move ACLHelpers to its own file
sohkai 7366642
feat: move ACL param IDs to ACLParams
sohkai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,72 @@ | ||
# Contributing to aragonOS | ||
|
||
:tada: Thank you for being interested in contributing to aragonOS! :tada: | ||
|
||
Feel welcome and read the following sections in order to know how to ask questions and how to work on something. | ||
|
||
There are many ways to contribute, from writing tutorials or blog posts, improving the documentation, submitting bug reports and feature requests or writing code which can be incorporated into the project. | ||
|
||
All members of our community are expected to follow our [Code of Conduct](https://wiki.aragon.org/documentation/Code_of_Conduct/). Please make sure you are welcoming and friendly in all of our spaces. | ||
|
||
## Your first contribution | ||
|
||
Unsure where to begin contributing to aragonOS? | ||
|
||
You can start with a [Good First Issue](https://github.com/aragon/aragonOS/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) | ||
|
||
> Good first issues are usually for small features, additional tests, spelling / grammar fixes, formatting changes, or other clean up. | ||
|
||
Start small, pick a subject you care about, are familiar with, or want to learn. | ||
|
||
If you're not already familiar with git or Github, here are a couple of friendly tutorials: [First Contributions](https://github.com/firstcontributions/first-contributions), [Open Source Guide](https://opensource.guide/), and [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github). | ||
|
||
## How to file an issue or report a bug | ||
|
||
If you see a problem, you can report it in our [issue tracker](https://github.com/aragon/aragonOS/issues). | ||
|
||
Please take a quick look to see if the issue doesn't already exist before filing yours. | ||
|
||
Do your best to include as many details as needed in order for someone else to fix the problem and resolve the issue. | ||
|
||
#### If you find a security vulnerability, do NOT open an issue. Email security@aragon.org instead. | ||
|
||
In order to determine whether you are dealing with a security issue, ask yourself these two questions: | ||
|
||
- Can I access or steal something that's not mine, or access something I shouldn't have access to? | ||
- Can I disable something for other people? | ||
|
||
If the answer to either of those two questions are "yes", then you're probably dealing with a security issue. Note that even if you answer "no" to both questions, you may still be dealing with a security issue, so if you're unsure, please send a email. | ||
|
||
#### A [bug bounty program](https://wiki.aragon.org/dev/bug_bounty/) is available for rewarding contributors who find security vulnerabilities with payouts up to $50,000. | ||
|
||
## Fixing issues | ||
|
||
1. [Find an issue](https://github.com/aragon/aragonOS/issues) that you are interested in. | ||
- You may want to ask on the issue or on Aragon Chat's [#dev channel](https://aragon.chat/channel/dev) if anyone has already started working on the issue. | ||
1. Fork and clone a local copy of the repository. | ||
1. Make the appropriate changes for the issue you are trying to address or the feature that you want to add. | ||
- Make sure to add tests! | ||
1. Push the changes to the remote repository. | ||
1. Submit a pull request in Github, explaining any changes and further questions you may have. | ||
1. Wait for the pull request to be reviewed. | ||
1. Make changes to the pull request if the maintainer recommends them. | ||
1. Celebrate your success after your pull request is merged! | ||
|
||
It's OK if your pull request is not perfect (no pull request is). | ||
The reviewer will be able to help you fix any problems and improve it! | ||
|
||
You can also edit a page directly through your browser by clicking the "EDIT" link in the top-right corner of any page and then clicking the pencil icon in the github copy of the page. | ||
|
||
## Styleguide and development processes | ||
|
||
We generally follow [Solidity's style guide](https://solidity.readthedocs.io/en/v0.4.24/style-guide.html) and have set up [Ethlint](https://github.com/duaraghav8/Ethlint) to automatically lint the project. | ||
|
||
Due to the sensitive nature of Solidity, usually at least two reviewers are required before merging any pull request with code changes. | ||
|
||
### Licensing | ||
|
||
aragonOS is generally meant to be used as a library by developers but includes core components that are not generally useful to extend. Any interfaces or contracts meant to be used by other developers are licensed as MIT and have their Solidity pragmas left unpinned. All other contracts are licensed as GPL-3 and are pinned to a specific Solidity version. | ||
|
||
## Community | ||
|
||
If you need help, please reach out to Aragon core contributors and community members in the Aragon Chat [#dev](https://aragon.chat/channel/dev) [#dev-help](https://aragon.chat/channel/dev-help) channels. We'd love to hear from you and know what you're working on! |
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
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,46 @@ | ||
/* | ||
* SPDX-License-Identitifer: MIT | ||
*/ | ||
|
||
pragma solidity ^0.4.24; | ||
|
||
import "./ACLParams.sol"; | ||
|
||
|
||
contract ACLHelpers is ACLParams { | ||
function decodeParamOp(uint256 _x) internal pure returns (uint8 b) { | ||
return uint8(_x >> (8 * 30)); | ||
} | ||
|
||
function decodeParamId(uint256 _x) internal pure returns (uint8 b) { | ||
return uint8(_x >> (8 * 31)); | ||
} | ||
|
||
function decodeParamsList(uint256 _x) internal pure returns (uint32 a, uint32 b, uint32 c) { | ||
a = uint32(_x); | ||
b = uint32(_x >> (8 * 4)); | ||
c = uint32(_x >> (8 * 8)); | ||
} | ||
|
||
function encodeParams(Param[] params) internal pure returns (uint256[]) { | ||
uint256[] memory encodedParams = new uint256[](params.length); | ||
|
||
for (uint i = 0; i < params.length; i++) { | ||
encodedParams[i] = encodeParam(params[i]); | ||
} | ||
|
||
return encodedParams; | ||
} | ||
|
||
function encodeParam(Param param) internal pure returns (uint256) { | ||
return uint256(param.id) << 248 | uint256(param.op) << 240 | param.value; | ||
} | ||
|
||
function encodeOperator(uint256 param1, uint256 param2) internal pure returns (uint240) { | ||
return uint240(param1 + (param2 << 32) + (0 << 64)); | ||
} | ||
|
||
function encodeIfElse(uint256 condition, uint256 successParam, uint256 failureParam) internal pure returns (uint240) { | ||
return uint240(condition + (successParam << 32) + (failureParam << 64)); | ||
} | ||
} |
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,28 @@ | ||
/* | ||
* SPDX-License-Identitifer: MIT | ||
*/ | ||
|
||
pragma solidity ^0.4.24; | ||
|
||
|
||
contract ACLParams { | ||
// Op types | ||
enum Op { NONE, EQ, NEQ, GT, LT, GTE, LTE, RET, NOT, AND, OR, XOR, IF_ELSE } | ||
|
||
// Op IDs | ||
uint8 internal constant BLOCK_NUMBER_PARAM_ID = 200; | ||
uint8 internal constant TIMESTAMP_PARAM_ID = 201; | ||
// 202 is unused | ||
uint8 internal constant ORACLE_PARAM_ID = 203; | ||
uint8 internal constant LOGIC_OP_PARAM_ID = 204; | ||
uint8 internal constant PARAM_VALUE_PARAM_ID = 205; | ||
// TODO: Add execution times param type? | ||
|
||
struct Param { | ||
uint8 id; | ||
uint8 op; | ||
uint240 value; // even though value is an uint240 it can store addresses | ||
// in the case of 32 byte hashes losing 2 bytes precision isn't a huge deal | ||
// op and id take less than 1 byte each so it can be kept in 1 sstore | ||
} | ||
} |
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
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
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
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add the MIT header here (e.g. see https://github.com/aragon/aragonOS/blob/dev/contracts/acl/IACL.sol#L1)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! ;) Is there a rule of thumb on which file an MIT header should be added?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to write more documentation on this, but on all the unpinned contracts (since they're the only ones meant to be used by apps, which frees them up to use any licensing model they want).