-
Notifications
You must be signed in to change notification settings - Fork 84
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
Allows to pass more parameters to templates #119
Conversation
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.
Looking good! Left one small comment 👏
…tRequired as parameters
…nAcceptanceQuorum as parameters
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.
Looking good! I realized a simple optimization we can do for the company-board template that will improve gas costs. LMKYT, maybe it will also make sense to replicate it for the rest of the templates
…d tests (Will not compile until rebased on #119)
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.
Looking good, left another comment on how we can optimize the cache for the company-board template... WDYT about replicating the voting settings thing for the rest of the templates?
(TokenManager boardTokenManager, Voting boardVoting) = _setupBoard(_boardMembers, _boardVoteSettings[0], _boardVoteSettings[1], _boardVoteSettings[2]); | ||
(TokenManager shareTokenManager, Voting shareVoting) = _setupShare(_shareHolders, _shareStakes, _shareVoteSettings[0], _shareVoteSettings[1], _shareVoteSettings[2]); | ||
_setupPermissions(boardVoting, boardTokenManager, shareVoting, shareTokenManager, agent, finance); | ||
_registerDAO(_id); |
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'm sure we can optimize the caching here a little bit. Probably you can pop up the cache at the beginning and pass the dao/acl by parameter to the rest of the functions instead of loading the cache on each sub function
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.
Yeah, I had tried this before but it "caused stack too deep" errors. I uploaded that version in case you want to see. I failed at the linked line: https://github.com/aragon/dao-templates/blob/parameterize_templates_simpler_cache/templates/company-board/contracts/CompanyBoardTemplate.sol#L65
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.
Ofc that indexing variables at that level won't help, you should pass the array to the internal function and check it there
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.
Yes, you're right! Still, I just tried changing that, and the stack too deep error persists. I've pushed it to that temporary branch nonetheless, so that we may use this code as reference for a future gas optimization.
TBH, I think that using an array for all voting settings is less explicit in function interfaces that dedicated parameters per setting. I wouldn't use it unless it's necessary. Now, if we put consistency before all other things, yes, we'd have to do it, but it would make the other templates just a bit less clear. |
* Implemented agent/vault selection in ReputationTemplate contract and tests * Refactored how ReputationTemplate tests handle agent/vault * Implemented agent/vault selection in MembershipTemplate contract and tests * Implemented agent/vault selection in CompanyTemplate contract and tests * Implemented agent/vault selection in CompanyBoardTemplate contract and tests (Will not compile until rebased on #119) * Updated READMEs for useAgentAsVault option * Minor change on reputation template tests * Fixed some linting errors in contracts
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.
A couple notes on small things, great job @ajsantander :).
|
||
bool constant private BOARD_TRANSFERABLE = false; | ||
string constant private BOARD_TOKEN_NAME = "Board Token"; | ||
string constant private BOARD_TOKEN_NAME = "Board Token"; |
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.
Note that there's some extra whitespace lingering in most of the contract files.
(LMK if your editor doesn't have an easy way to remove them, I use this vim command to fix it automatically)
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.
Oops! Thanks for catching that. I believe that @facuspagnuolo already fixed this in #123
I was planning on installing a linter to avoid this sort of stuff, but didn't find the time last week. Anyways, I installed that plugin for the mean time. Love it :D
const totalGas = prepareGas + setupGas; | ||
assert.isAtMost(prepareGas, 5.0e6, 'prepare script should cost almost 5.0e6 gas') | ||
assert.isAtMost(setupGas, 5.4e6, 'setup script should cost almost 5.4e6 gas') | ||
assert.isAtMost(totalGas, 10.4e6, 'prepare + setup scripts should cost almost 10.4e6 gas'); |
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.
Note on the trailing ;
too, generally we don't use them anymore :)
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'll also be setting up my linter for JS this week to comply with the team's JS coding style.
address[] _holders, | ||
uint256[] _stakes, | ||
string _tokenName, | ||
string _tokenSymbol, |
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.
Super small thing, but the parameter order may be a little bit more obvious if we had the arguments in the same order they would be used in, i.e. _tokenName,
_tokenSymbol,
_id,
_holders`, ...
That way a frontend could conceivably do something like creationArgs = [].concat(tokenArgs, instanceArgs)
and it'd just work (not that we would likely be this loose in our own frontend).
🏁 Ready for Review 🏁
Fix #111
Tasks (In reputation, membership, company and company-board templates):