You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the dao-params.json schema is loosely defined. In order for developers to understand the full schema, they could look at the example dao-params.json in the repo, but this lacks completeness. To gain a full understanding they would have to look through how the dao-params are being used in the migrate-dao.js script.
I've tried to remedy this a bit by creating the sanitize.js script that defines a jsonschema for dao-params, but this is still a bit incomplete and hard to work with IMO. Reasons:
I've encountered issues using jsonschema's node package, where it does not traverse the document's AST and apply the schema correctly.
jsonschema doesn't provide a solution for serializing / deserializing.
jsonschema schemas defined in javascript do not give you typescript types to utilize else where.
In the DAOcreator I've solved the above by creating a serialize of forms that implement the dao-params schema. This form library uses an extended version formstate. These forms can be used to deserialize -> validate -> serialze. I propose that we adopt this form library.
Here's the DAO Form class which implements the schema.
Here's an example usage:
constdaoParams=`{ ...json string}`constdao=newDAOForm()// deserializedao.fromJson(daoParams)// modifydao.$.orgName.value='something'dao.$.founders.$.value=[]// validateconstres=awaitdao.validate()console.log(res.hasError)// trueconsole.log(res.error)// founders must contain at least 1 item// serializeconstjson=dao.toJson()
Currently the dao-params.json schema is loosely defined. In order for developers to understand the full schema, they could look at the example dao-params.json in the repo, but this lacks completeness. To gain a full understanding they would have to look through how the dao-params are being used in the
migrate-dao.js
script.I've tried to remedy this a bit by creating the
sanitize.js
script that defines ajsonschema
for dao-params, but this is still a bit incomplete and hard to work with IMO. Reasons:In the DAOcreator I've solved the above by creating a serialize of forms that implement the dao-params schema. This form library uses an extended version
formstate
. These forms can be used to deserialize -> validate -> serialze. I propose that we adopt this form library.Here's the DAO Form class which implements the schema.
Here's an example usage:
Custom validators can be written to verify single properties, or cross verify multiple properties together. This is used in the DAOcreator to ensure these conditions for the genesis protocol are met: https://github.com/daostack/infra/blob/a09e9a524fbacc9fb39d5d1de8986dcf45c4889c/contracts/votingMachines/GenesisProtocolLogic.sol#L259-L264
The text was updated successfully, but these errors were encountered: