near-daos / sputnik-dao-contract

Smart contracts for https://app.astrodao.com
https://astrodao.com/
MIT License
107 stars 79 forks source link

Issues with returned policy format #159

Open OllieMurray opened 2 years ago

OllieMurray commented 2 years ago

sputnik dao contract - returns from view calls like get_policy are not provided in a format that can be re-submitted to the DAO using 'propose policy' . It is likely the case that returns to calls in all contracts on near are not formatted such that they could then be loaded to json files and submitted in function calls to near contracts. It could be useful to include functionality in near to format returns responses in the following format "roles": [ { "name": "Test", "kind": { "Member": ["nghiatutuan.near", "thalasith.near"] }, "permissions": [":"], "vote_policy": { "*": { "weight_kind": "TokenWeight", "quorum": "0", "threshold": "1" } } } ...

as opposed to the current format roles: [ { name: 'Test', kind: { 'Member' ... so that they can then be submitted to the contract for processing after user field modification without the need for formatting.

For clarity, the difference in formats between the above examples is that the format that can be submitted has " " around field names and their values. the current format only has ' ' around field values.

TrevorJTClarke commented 2 years ago

@OllieMurray interesting find, can you give more details on how you generated this example?

ctindogaru commented 2 years ago

@OllieMurray thanks for the report.

At the moment, we are returning a Policy struct when calling the get_policy method. From what I understand, you want us to return a JSON value instead. That's possible, but it would be a backward incompatible change and it might break existing users.

What I suggest is to create a different method called get_json_policy that would return a json representation of the policy. How does that sound?