solana-labs / governance-ui

https://realms.today
Apache License 2.0
299 stars 550 forks source link

Allow proposing any anchor instruction #351

Open mschneider opened 2 years ago

mschneider commented 2 years ago

User supplies program id, governance automatically detects idl and generates remaining form based on it.

RaymondDashWu commented 2 years ago

Could you clarify what would be generated? My understanding is that the current workflow is to go to the place below (screenshot). These options seem pretty specific to a DAO.

image

mschneider commented 2 years ago

the above form is to create a new governance. governances can execute arbitrary solana instructions, anchor's idl is a way to describe those instructions so that clients can be generated. it is stored deterministic on-chain so that providing the program id is enough to select the client

Once example could be to initialize an escrow: https://github.com/project-serum/anchor/blob/master/tests/escrow/programs/escrow/src/lib.rs#L30

In this case the form would provide inputs to specify:

1) the program id, once added, idl is downloaded and parsed and more fields appear. 2) deposit_token_account a token account under the realms' governances 3) receive_token_account another token account under the realms' governances 4) initializer_amount & taker_amount as number inputs

RaymondDashWu commented 2 years ago

Thanks for the example. I'll need to do research into other types of use cases. However, for now, I wanted to know if there was a way to fetch idls with the current dependencies. I tried querying random verified and unverified programs on anchor's api. All of them gave me this: image

mschneider commented 2 years ago

The IDL is stored in a buffer on-chain.

RaymondDashWu commented 2 years ago

After talking with Sebastian, this is the idea we came up with since IDL isn't strictly necessary for users. An extra option to "Execute IDL instructions" that will auto populate. What are your thoughts?

image

Potential blockers for me will be auto populating these instructions with all the details (ex: show accounts but without labels) based off the IDL image

mschneider commented 2 years ago

anchor has a new spec for deriving PDAs from idls, that should take care of most of the account issues