solana-labs / governance-program-library

Other
53 stars 42 forks source link

Composability of gateway plugin #62

Closed dankelleher closed 2 years ago

dankelleher commented 2 years ago

This PR brings composability (the ability to chain plugins) to the Civic Gateway plugin.

Specifically, the plugin registrar now accepts a "predecessor" plugin program id. If set, the plugin "inherits" the voter weight from the predecessor plugin. If not set, the plugin inherits the weight from the deposited governance tokens.

Note, the latter requires a slight change in core spl-gov to allow deposits when using a plugin (this is currently disabled). Until this change is made, this PR includes a built .so artifact of spl-governance that enables this (spl_governance_allow_deposits.so).

dankelleher commented 2 years ago

Thanks very much @joncinque ! Here's a follow-up PR to address your comments. https://github.com/solana-labs/governance-program-library/pull/63 . enum_dispatch is cool.

I just have one concern about the use of copied() here. It is needed to extract the Option<&Pubkey> into an Option. Is there a better way of doing this?

joncinque commented 2 years ago

I just have one concern about the use of copied() here. It is needed to extract the Option<&Pubkey> into an Option. Is there a better way of doing this?

Not that I can think of, the tiniest nit is that you could maybe use cloned to make it a bit clearer, and in case Pubkey no longer implements Copy in the future. Either way, you have to copy from the remaining_account and into the struct.