#DAO proposal instruction builder

25 messages · Page 1 of 1 (latest)

sage flint
#

We are working on DAO proposal builder, specifically the instructions that are executed if proposal passes.

  1. First we input proposal name, description, deadline for voting and upload proposal doc to IPFS and then save url to soroban,

  2. Then we set minimum quorum for proposal to be executable.

  3. We specify instructions. This step is one that is very unattractive. In the video in 1:27 minute the way instructions are build is to pass the contract address, then the function that we want to execute and the argument the function needs.

This sort of approach is very error prone and quite tedious. I was wondering if there is anything more elegant that would speed up the process.

One "sort of" solution will be to have contract templates that are used the most in DAO proposals, but what about custom contracts?
Is there some way for example to input contract address that will fetch the list of its functions and arguments these functions take?

distant terrace
#

We are making one to make a cross contract call on execution, it is defined during proposal creation. But i still dont have it working properly... i can share it with you once it is

sage flint
distant terrace
#

Still working. I don't think anyone has implemented this fully yet... but there are these 2 repos from @worldly venture that might be useful to you... https://github.com/rahimklaber/soroban_dao#executing-a-proposal
and https://github.com/rahimklaber/soroban_token_dao/

GitHub

Contribute to rahimklaber/soroban_token_dao development by creating an account on GitHub.

GitHub

Contribute to rahimklaber/soroban_dao development by creating an account on GitHub.

#

I believe he has a way to execute proposals

worldly venture
#

I believe you can query the contract metadata to get information about the function signatures. The soroban cli repo probably contains some code that does this.

distant terrace
#

Yes you can off chain and that can help in the proposal creation for sure

#

In my contract execution code i was actually trying to design a way, that basically a execution is it's own contract, which can perform a set of functions, and when execute_proposal gets called after a vote, it executes that contract, this allows that cnotract to do damn near anything...

Another thing with communidao is that potentially a proposal execution could result in more than one action being taken. for example, it could first transfer funds from the trust to some address (the trust being like a treasury in most daos)
and then also make one or more cross contract calls.

sage flint
#

Ok this is awesome, thanks a lot @distant terrace @worldly venture
Diving straight into it

sage flint
worldly venture
#

I'm not a 100%, but I think it exctracts some data from the wasm file itself.

sage flint
#

Alright great, thanks a lot again 🙂
Will test this and see what kind of data I can get.

sage flint
distant terrace
# sage flint How can I query contract metadata offchain?

Well, for what you want to do, you should take a look at the soroban-tools repository because it can be done with soroban-cli... but i'm guessing you'll download the ledgerkey that has the wasm blob, then parse that blob somehow to get the interface. I would have to research it to figure out how, but was about to go to bed sorry

sage flint
distant terrace
#

you too! Please update here on the solution you find if you don't mind, and if i end up solving it I will do the same.

sage flint
#

@distant terrace @worldly venture Ok so I tested soroban-tools library.
Did simple cargo build and ran cargo run contract inspect command.

The command takes a path to contract wasm. So for example:
cargo run contract inspect --wasm './dao/target/wasm32-unknown-unknown/release/governance.wasm'

and the output is pretty impressive. It gets all sorts of data. Structs, functions, Enums, etc.

#

So pretty much it's what you said @distant terrace
Get the wasm blob and parse it reading the data.

sage flint
#

I think my next question is how do you get a ledgerkey?

#

Will test this one

distant terrace
sage flint
#

I got stuck on second step specifically this line of code:
const entry = xdr.LedgerEntryData.fromXDR( ledgerKey, "base64" );

It just shows nothing when trying it. Now this one which runs before the one above return XDR:
let ledgerKey = xdr.LedgerKey.contractData( new xdr.LedgerKeyContractData({ contract: new Address(contractId).toScAddress(), key: new xdr.ScVal.scvLedgerKeyContractInstance(), durability: xdr.ContractDataDurability.persistent() }) );

Problem I have with this one tho is this line: key: new xdr.ScVal.scvLedgerKeyContractInstance(),

It gives me error: new' expression, whose target lacks a construct signature, implicitly has an 'any' type.

So I tried without using new and that would give me XDR however if I console log('SorobanClient.xdr.ScVal.scvLedgerKeyContractInstance()') I get: ChildUnion { _switch: ChildEnum { name: 'scvLedgerKeyContractInstance', value: 20 }, _arm: [class Void extends XdrPrimitiveType], _armType: [class Void extends XdrPrimitiveType], _value: undefined }
So the value is undefined which I guess makes ledgerKey invalid.

I still checked the generated XDR in stellar laboratory under LedgeKey type and got:
LedgerKey: [contractData] contractData contract: [scAddressTypeContract] contractId: I28Iwb7mWu6sIV7Yi7Vp7QdfII2CfCuPIGJLy1AgLN8= key: [scvLedgerKeyContractInstance] durability: [object Object]