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

Simplify Creation of parameter declarations #4005

Merged
merged 2 commits into from
Oct 27, 2021
Merged

Conversation

Chris-Hibbert
Copy link
Contributor

@dtribble suggested this simplification from #3448 while it was under review.

Description

These helper functions reduce the call to declare a governed parameter from

const governedParameterInitialValues = [
  {
    name: MALLEABLE_NUMBER,
    value: 602214090000000000000000n,
    type: ParamType.NAT,
  },
];

to

const governedParameterInitialValues = [
  makeGovernedNat('MalleableNumber', 602214090000000000000000n),
];

which is a pretty substantial reduction for the first thing that a contract author has to do to add governed parameters.

Security Considerations

Nothing substantial. This doesn't change the API for controlling parameters, and it reduces complexity for readers.

Documentation Considerations

We need more thorough documentation for how contract developers can add governance, but this PR simplifies the task to be explained.

Testing Considerations

None.

@Chris-Hibbert Chris-Hibbert added enhancement New feature or request Small devex developer experience Governance Governance labels Oct 26, 2021
@Chris-Hibbert Chris-Hibbert added this to the Mainnet: Phase 1 - Treasury Launch milestone Oct 26, 2021
@Chris-Hibbert Chris-Hibbert self-assigned this Oct 26, 2021
@dckc
Copy link
Member

dckc commented Oct 27, 2021

This makeGovernedNat style seems like it could address some of the dynamic typing woes. Here's hoping...

Copy link
Member

@dckc dckc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a small forward step...

Comment on lines +5 to +7
// It might be cleaner if these returned objects with behavior that included the
// type assertion from paramManager, and other polymorphism, but this is enough
// to get us a much simpler calling style.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah. not tackling as much as I hoped. But still, forward progress...

@Chris-Hibbert Chris-Hibbert added the automerge:no-update (expert!) Automatically merge without updates label Oct 27, 2021
@mergify mergify bot merged commit d17a266 into master Oct 27, 2021
@mergify mergify bot deleted the cleanUpParamDecl branch October 27, 2021 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:no-update (expert!) Automatically merge without updates devex developer experience enhancement New feature or request Governance Governance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants