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

Allows to pass more parameters to templates #119

Merged
merged 30 commits into from
Jul 26, 2019

Conversation

eternauta1337
Copy link
Contributor

@eternauta1337 eternauta1337 commented Jul 25, 2019

🏁 Ready for Review 🏁
Fix #111

Tasks (In reputation, membership, company and company-board templates):

  • Token name and symbol
  • Vote duration
  • Vote support
  • Vote acceptance
  • Finance period

Copy link
Contributor

@facuspagnuolo facuspagnuolo left a 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 👏

templates/company-board/contracts/CompanyBoardTemplate.sol Outdated Show resolved Hide resolved
@eternauta1337 eternauta1337 changed the title Allows to pass more parameters to templates (WIP) Allows to pass more parameters to templates Jul 25, 2019
@eternauta1337 eternauta1337 changed the title (WIP) Allows to pass more parameters to templates Allows to pass more parameters to templates Jul 26, 2019
Copy link
Contributor

@facuspagnuolo facuspagnuolo left a 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

templates/company-board/contracts/CompanyBoardTemplate.sol Outdated Show resolved Hide resolved
templates/company/contracts/CompanyTemplate.sol Outdated Show resolved Hide resolved
Copy link
Contributor

@facuspagnuolo facuspagnuolo left a 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);
Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Contributor

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

Copy link
Contributor Author

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.

@eternauta1337
Copy link
Contributor Author

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?

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.

@eternauta1337 eternauta1337 merged commit 495af37 into master Jul 26, 2019
@delete-merged-branch delete-merged-branch bot deleted the parameterize_templates branch July 26, 2019 16:59
eternauta1337 added a commit that referenced this pull request Jul 26, 2019
* 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
Copy link
Contributor

@sohkai sohkai left a 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";
Copy link
Contributor

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)

Copy link
Contributor Author

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');
Copy link
Contributor

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 :)

Copy link
Contributor Author

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,
Copy link
Contributor

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parameterize new templates app settings
3 participants