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

Split Proposal interface into two parts #3570

Closed
mossid opened this issue Feb 9, 2019 · 1 comment
Closed

Split Proposal interface into two parts #3570

mossid opened this issue Feb 9, 2019 · 1 comment
Assignees
Milestone

Comments

@mossid
Copy link
Contributor

mossid commented Feb 9, 2019

Summary

type TextProposal in gov consists of two parts:

  1. Data that can be customized by the external party, Title, Description and ProposalType
  2. Data used internally by gov logic, all the other fields

In prior to apply #3565, we have to split the current interface to move minimal parts without moving definitions related to the internal logic. It is not safe to let the third party modules to implement the method related to internal logic, such as GetDepositEndTime() and GetTotalDeposit(), as it can return arbitrary value to skip(or somehow manipulate) the governance process. Those fields should be accessible only by the governance module.

Implementation

type ProposalProcess struct is replacing current type Proposal interface, as it is now stored in the state while the proposal is processed.

type ProposalProcess struct {
    Proposal Proposal
    ProposalID uint64
    Status ProposalStatus
    FinalTallyResult TallyResult
    //...
}

type Proposal interface is the part which the other custom proposal type can implement, and will be moved into types/

type Proposal interface {
    GetTitle() string
    GetDescription() string
    ProposalType() ProposalKind
    String() string
}

New method SubmitProposal is introduced where the other modules can call to submit a new proposal. When it is called, the keeper internally wraps it with ProposalProcess, thus no access to the internal parameters from the other modules.

func (k Keeper) SubmitProposal(ctx sdk.Context, proposal Proposal) error {}
@alexanderbez
Copy link
Contributor

At a high level, this looks reasonable to me. Thanks @mossid

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

No branches or pull requests

2 participants