Skip to content

Commit 856e186

Browse files
committed
feat(contracts): update axone-protocol/contracts contracts documentation
1 parent cfa7d38 commit 856e186

File tree

1 file changed

+40
-9
lines changed

1 file changed

+40
-9
lines changed

contracts/axone-gov.md

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,15 @@ This contract follows AXONE development patterns and uses the cargo-make build s
2222

2323
Instantiate message.
2424

25-
`constitution` is the Prolog program (UTF-8 bytes) that defines the governance rules. The contract validates that it provides the required predicates (`decide/2` and `decide/3`) during instantiation.
25+
This contract stores a governance constitution as a Prolog program on the resource AA. The constitution defines governance rules using Prolog predicates. The `constitution` field must contain a UTF-8 encoded Prolog program.
2626

27-
| variant | description |
28-
| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
29-
| InstantiateMsg | **object**. Instantiate message.<br /><br />`constitution` is the Prolog program (UTF-8 bytes) that defines the governance rules. The contract validates that it provides the required predicates (`decide/2` and `decide/3`) during instantiation. |
27+
During instantiation, the contract validates that the constitution defines the required predicates: - `decide/2` which takes a `Case` argument and returns a verdict term. - `decide/3` which takes a `Case` argument and returns both a verdict and a motivation term.
28+
29+
The `decide/2` predicate returns a verdict Prolog term indicating the decision outcome. The `decide/3` predicate returns both a verdict and a motivation term providing reasoning for the decision.
30+
31+
| variant | description |
32+
| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
33+
| InstantiateMsg | **object**. Instantiate message.<br /><br />This contract stores a governance constitution as a Prolog program on the resource AA. The constitution defines governance rules using Prolog predicates. The `constitution` field must contain a UTF-8 encoded Prolog program.<br /><br />During instantiation, the contract validates that the constitution defines the required predicates: - `decide/2` which takes a `Case` argument and returns a verdict term. - `decide/3` which takes a `Case` argument and returns both a verdict and a motivation term.<br /><br />The `decide/2` predicate returns a verdict Prolog term indicating the decision outcome. The `decide/3` predicate returns both a verdict and a motivation term providing reasoning for the decision. |
3034

3135
## ExecuteMsg
3236

@@ -46,12 +50,30 @@ Query messages.
4650

4751
### QueryMsg::constitution
4852

49-
Return the stored governance constitution program.
53+
Return the stored governance constitution program bytes.
5054

5155
| parameter | description |
5256
| -------------- | -------------------------- |
5357
| `constitution` | _(Required.) _ **object**. |
5458

59+
### QueryMsg::decide
60+
61+
Decide a case using the constitution's `decide/2` or `decide/3` predicate.
62+
63+
The `case` parameter is a Prolog dict term string that represents the decision context. This string is passed as the `Case` argument to the `decide` predicate.
64+
65+
Example of a case dict: `ctx{action:read, user:"did:example:123", object:"obj:42"}`
66+
67+
The `verdict` returned is an arbitrary Prolog term (which can be an atom or a compound term, e.g., `permitted` or `pay(user_1)`), representing the decision outcome.
68+
69+
If `motivated` is true, the contract calls `decide/3` and returns both `verdict` and `motivation`. The `motivation` is a Prolog term that provides reasoning behind the decision.
70+
71+
| parameter | description |
72+
| ------------------ | --------------------------- |
73+
| `decide` | _(Required.) _ **object**. |
74+
| `decide.case` | _(Required.) _ **string**. |
75+
| `decide.motivated` | _(Required.) _ **boolean**. |
76+
5577
## MigrateMsg
5678

5779
Migrate message.
@@ -73,9 +95,18 @@ Reserved for future migrations.
7395

7496
Response returned by `QueryMsg::Constitution`.
7597

76-
| property | description |
77-
| ------------ | ----------------------------------------------------------------------- |
78-
| `governance` | _(Required.) _ **[Binary](#binary)**. Stored Prolog governance program. |
98+
| property | description |
99+
| ------------ | ---------------------------------------------------------------------------------------------- |
100+
| `governance` | _(Required.) _ **[Binary](#binary)**. The stored Prolog governance constitution program bytes. |
101+
102+
### decide
103+
104+
Response returned by `QueryMsg::Decide`.
105+
106+
| property | description |
107+
| ------------ | ---------------------------------------------------------------------------------------- |
108+
| `motivation` | **string\|null**. Optional motivation term returned as the third argument by `decide/3`. |
109+
| `verdict` | _(Required.) _ **string**. The decision verdict as a Prolog term string. |
79110

80111
## Definitions
81112

@@ -89,4 +120,4 @@ A string containing Base64-encoded data.
89120

90121
---
91122

92-
_Rendered by [Fadroma](https://fadroma.tech) ([@fadroma/schema 1.1.0](https://www.npmjs.com/package/@fadroma/schema)) from `axone-gov.json` (`51c999a033214538`)_
123+
_Rendered by [Fadroma](https://fadroma.tech) ([@fadroma/schema 1.1.0](https://www.npmjs.com/package/@fadroma/schema)) from `axone-gov.json` (`7b8b444e2a0cab26`)_

0 commit comments

Comments
 (0)