Skip to content

Commit

Permalink
docs: affine and regenerate
Browse files Browse the repository at this point in the history
  • Loading branch information
amimart committed Feb 22, 2024
1 parent dcaef7a commit 8deb368
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 38 deletions.
8 changes: 3 additions & 5 deletions contracts/okp4-law-stone/examples/multiple-sources/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ Where:

- `{contract_name}`: Only informative, represents the corresponding smart contract name or type (e.g. `okp4-objectarium`);
- `{contract_address}`: The smart contract to query, concerning the `okp4-law-stone` it must be a `okp4-objectarium` contract;
- `{contract_query}`: The JSON query to perform on the targeted smart contract, URL encoded. In our case an `ObjectData` query, for example: `%7B%22object_data%22%3A%7B%22id%22%3A%20%224cbe36399aabfcc7158ee7a66cbfffa525bb0ceab33d1ff2cff08759fe0a9b05%22%7D%7D`;
- `{contract_query}`: The JSON query to perform on the targeted smart contract, URL encoded. In our case an `ObjectData` query, for example: `%7B%22object_data%22%3A%7B%22id%22%3A%22b118d79b4a368028b34d564448e5f1082e098613434370f3c15d6a2bf9979dfc%22%7D%7D`;

## Instantiate

First the `template.pl` program must be stored on a `okp4-objectarium` and the `gov.pl` updated with the right URI in the `consult(File).` predicate, the URI should be in the form:

```bash
cosmwasm:okp4-objectarium:${STORAGE_ADDRESS}?query=%7B%22object_data%22%3A%7B%22id%22%3A%221a88ca1632c7323c0aa594000cda26ed9f48b36351c29c3d1e35e0a0474e862e%22%7D%7D
cosmwasm:okp4-objectarium:${STORAGE_ADDRESS}?query=%7B%22object_data%22%3A%7B%22id%22%3A%22b118d79b4a368028b34d564448e5f1082e098613434370f3c15d6a2bf9979dfc%22%7D%7D
```

The instantiate will take as parameters the base64 encoded program and the address of a `okp4-objectarium` contract, on which the program will be stored and pinned, the `template.pl` object will also be pinned to ensure all the needed resources stays available:
Expand All @@ -41,7 +41,6 @@ okp4d tx wasm instantiate $CODE_ID \
--from $ADDR \
--admin $ADMIN_ADDR \
--gas 1000000 \
--broadcast-mode block \
"{\"program\":\"$(cat gov.pl | base64)\", \"storage_address\": \"$STORAGE_ADDR\"}"
```

Expand All @@ -53,7 +52,7 @@ By using the `Ask` query we can provide Prolog predicates to be evaluated agains

```bash
okp4d query wasm contract-state smart $CONTRACT_ADDR \
"{\"ask\": {\"query\": \"can('change_governance', 'did:key:okp41p8u47en82gmzfm259y6z93r9qe63l25dfwwng6').\"}}"
"{\"ask\": {\"query\": \"can('change_governance', 'did:example:okp41p8u47en82gmzfm259y6z93r9qe63l25dfwwng6').\"}}"
```

## Break
Expand All @@ -68,6 +67,5 @@ By breaking the stone, you will not be able to query it anymore.
okp4d tx wasm execute $CONTRACT_ADDR \
--from $ADDR \
--gas 1000000 \
--broadcast-mode block \
'"break_stone"'
```
4 changes: 2 additions & 2 deletions contracts/okp4-law-stone/examples/multiple-sources/gov.pl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
:- consult('cosmwasm:okp4-objectarium:${STORAGE_ADDRESS}?query=%7B%22object_data%22%3A%7B%22id%22%3A%221a88ca1632c7323c0aa594000cda26ed9f48b36351c29c3d1e35e0a0474e862e%22%7D%7D').
:- consult('cosmwasm:okp4-objectarium:${STORAGE_ADDRESS}?query=%7B%22object_data%22%3A%7B%22id%22%3A%22b118d79b4a368028b34d564448e5f1082e098613434370f3c15d6a2bf9979dfc%22%7D%7D').

admin_addr('okp41p8u47en82gmzfm259y6z93r9qe63l25dfwwng6').

allow_denom('uknow').
allow_did_method('key').
allow_did_method('example').
allow_addr(Addr) :- bech32_address(-('okp4', _), Addr).

min_exec_workflow_amount(1000000).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
valid_did(DID, Addr) :-
did_components(DID, did(Method, Addr, _, _, _)),
did_components(DID, did_components(Method, Addr, _, _, _)),
allow_did_method(Method),
allow_addr(Addr).

Expand Down
8 changes: 3 additions & 5 deletions contracts/okp4-law-stone/examples/single-source/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ The spirit here is to provide a `okp4-law-stone` smart contract instance providi

You'll find in the [gov.pl](gov.pl) Prolog program some predicates defining the rules allowing to perform some typical Dataspaces actions.

The `can(Action, DID)` predicate will allow or not an action for a `did` (i.e. Decentralized Identifier), a `did` being expected to have the form: `did:key:${OKP4_ADDRESS}`. We can describe the action rules as follows:
The `can(Action, DID)` predicate will allow or not an action for a `did` (i.e. Decentralized Identifier), a `did` being expected to have the form: `did:example:${OKP4_ADDRESS}`. We can describe the action rules as follows:

- `change_governance`: Only the did admin can do it: `did:key:okp41p8u47en82gmzfm259y6z93r9qe63l25dfwwng6`;
- `change_governance`: Only the did admin can do it: `did:example:okp41p8u47en82gmzfm259y6z93r9qe63l25dfwwng6`;
- `exec_workflow`: Only a valid DID having a minimum spendable of `1000000uknow`;
- `create_dataset` Only a valid DID having a minimum spendable of `10000uknow`;
- `create_service` Only a valid DID having a minimum spendable of `100000uknow`;
Expand All @@ -25,7 +25,6 @@ okp4d tx wasm instantiate $CODE_ID \
--from $ADDR \
--admin $ADMIN_ADDR \
--gas 1000000 \
--broadcast-mode block \
"{\"program\":\"$(cat gov.pl | base64)\", \"storage_address\": \"$STORAGE_ADDR\"}"
```

Expand All @@ -37,7 +36,7 @@ By using the `Ask` query we can provide Prolog predicates to be evaluated agains

```bash
okp4d query wasm contract-state smart $CONTRACT_ADDR \
"{\"ask\": {\"query\": \"can('change_governance', 'did:key:okp41p8u47en82gmzfm259y6z93r9qe63l25dfwwng6').\"}}"
"{\"ask\": {\"query\": \"can('change_governance', 'did:example:okp41p8u47en82gmzfm259y6z93r9qe63l25dfwwng6').\"}}"
```

## Break
Expand All @@ -52,6 +51,5 @@ By breaking the stone, you will not be able to query it anymore.
okp4d tx wasm execute $CONTRACT_ADDR \
--from $ADDR \
--gas 1000000 \
--broadcast-mode block \
'"break_stone"'
```
4 changes: 2 additions & 2 deletions contracts/okp4-law-stone/examples/single-source/gov.pl
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
admin_addr('okp41p8u47en82gmzfm259y6z93r9qe63l25dfwwng6').

allow_denom('uknow').
allow_did_method('key').
allow_did_method('example').
allow_addr(Addr) :- bech32_address(-('okp4', _), Addr).

valid_did(DID, Addr) :-
did_components(DID, did(Method, Addr, _, _, _)),
did_components(DID, did_components(Method, Addr, _, _, _)),
allow_did_method(Method),
allow_addr(Addr).

Expand Down
5 changes: 0 additions & 5 deletions contracts/okp4-objectarium/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ okp4d tx wasm instantiate $CODE_ID \
--from $ADDR \
--admin $ADMIN_ADDR \
--gas 1000000 \
--broadcast-mode block \
'{"bucket":"my-bucket"}'
```

Expand All @@ -75,7 +74,6 @@ We can store an object by providing its data in base64 encoded, we can pin the s
okp4d tx wasm execute $CONTRACT_ADDR \
--from $ADDR \
--gas 1000000 \
--broadcast-mode block \
"{\"store_object\":{\"data\": \"$(cat my-data | base64)\",\"pin\":true}}"
```

Expand All @@ -87,13 +85,11 @@ With the following commands we can pin and unpin existing objects:
okp4d tx wasm execute $CONTRACT_ADDR \
--from $ADDR \
--gas 1000000 \
--broadcast-mode block \
"{\"pin_object\":{\"id\": \"$OBJECT_ID\"}}"

okp4d tx wasm execute $CONTRACT_ADDR \
--from $ADDR \
--gas 1000000 \
--broadcast-mode block \
"{\"unpin_object\":{\"id\": \"$OBJECT_ID\"}}"
```

Expand All @@ -103,7 +99,6 @@ And if an object is not pinned, or pinned by the sender of transaction, we can r
okp4d tx wasm execute $CONTRACT_ADDR \
--from $ADDR \
--gas 1000000 \
--broadcast-mode block \
"{\"forget_object\":{\"id\": \"$OBJECT_ID\"}}"
```

Expand Down
18 changes: 6 additions & 12 deletions docs/okp4-law-stone.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ This is only needed as serde-json-\{core,wasm\} has a horrible encoding for Vec&

| property | description |
| ----------- | -------------------------------------------------- |
| `error` | **string\|null**. |
| `has_more` | _(Required.) _ **boolean**. |
| `results` | _(Required.) _ **Array<[Result](#result)>**. |
| `success` | _(Required.) _ **boolean**. |
Expand All @@ -120,18 +121,11 @@ A string containing Base64-encoded data.

### Substitution

| property | description |
| ---------- | -------------------------- |
| `term` | _(Required.) _ **object**. |
| `variable` | _(Required.) _ **string**. |

### Term

| property | description |
| ----------- | ---------------------------------------------- |
| `arguments` | _(Required.) _ **Array<[Term](#term)>**. |
| `name` | _(Required.) _ **string**. |
| property | description |
| ------------ | -------------------------- |
| `expression` | _(Required.) _ **string**. |
| `variable` | _(Required.) _ **string**. |

---

_Rendered by [Fadroma](https://fadroma.tech) ([@fadroma/schema 1.1.0](https://www.npmjs.com/package/@fadroma/schema)) from `okp4-law-stone.json` (`175af2aa8dc69420`)_
_Rendered by [Fadroma](https://fadroma.tech) ([@fadroma/schema 1.1.0](https://www.npmjs.com/package/@fadroma/schema)) from `okp4-law-stone.json` (`b4af0e49e5a861ed`)_
7 changes: 1 addition & 6 deletions docs/okp4-objectarium.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ okp4d tx wasm instantiate $CODE_ID \
--from $ADDR \
--admin $ADMIN_ADDR \
--gas 1000000 \
--broadcast-mode block \
'{"bucket":"my-bucket"}'
```

Expand All @@ -75,7 +74,6 @@ We can store an object by providing its data in base64 encoded, we can pin the s
okp4d tx wasm execute $CONTRACT_ADDR \
--from $ADDR \
--gas 1000000 \
--broadcast-mode block \
"{\"store_object\":{\"data\": \"$(cat my-data | base64)\",\"pin\":true}}"
```

Expand All @@ -87,13 +85,11 @@ With the following commands we can pin and unpin existing objects:
okp4d tx wasm execute $CONTRACT_ADDR \
--from $ADDR \
--gas 1000000 \
--broadcast-mode block \
"{\"pin_object\":{\"id\": \"$OBJECT_ID\"}}"

okp4d tx wasm execute $CONTRACT_ADDR \
--from $ADDR \
--gas 1000000 \
--broadcast-mode block \
"{\"unpin_object\":{\"id\": \"$OBJECT_ID\"}}"
```

Expand All @@ -103,7 +99,6 @@ And if an object is not pinned, or pinned by the sender of transaction, we can r
okp4d tx wasm execute $CONTRACT_ADDR \
--from $ADDR \
--gas 1000000 \
--broadcast-mode block \
"{\"forget_object\":{\"id\": \"$OBJECT_ID\"}}"
```

Expand Down Expand Up @@ -516,4 +511,4 @@ A string containing a 128-bit integer in decimal representation.

---

_Rendered by [Fadroma](https://fadroma.tech) ([@fadroma/schema 1.1.0](https://www.npmjs.com/package/@fadroma/schema)) from `okp4-objectarium.json` (`2b01e2531b94fc0e`)_
_Rendered by [Fadroma](https://fadroma.tech) ([@fadroma/schema 1.1.0](https://www.npmjs.com/package/@fadroma/schema)) from `okp4-objectarium.json` (`37a6830a8446a597`)_

0 comments on commit 8deb368

Please sign in to comment.