Skip to content

Commit

Permalink
feat(predicates): update okp4/okp4d predicates documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
bot-anik committed Mar 21, 2024
1 parent 0c96ce2 commit 12ccfc4
Show file tree
Hide file tree
Showing 16 changed files with 417 additions and 136 deletions.
95 changes: 58 additions & 37 deletions predicates/bech32_address_2.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,15 @@ bech32_address(Address, 'okp415wn30a9z4uc692s0kkx5fp5d4qfr3ac7sj9dqn').
- **Then** the answer we get is:

``` yaml
has_more: false
variables: ["Address"]
results:
- substitutions:
- variable: Address
expression: "okp4-[163,167,23,244,162,175,49,162,170,15,181,141,68,134,141,168,18,56,247,30]"
height: 42
gas_used: 2222
answer:
has_more: false
variables: ["Address"]
results:
- substitutions:
- variable: Address
expression: "okp4-[163,167,23,244,162,175,49,162,170,15,181,141,68,134,141,168,18,56,247,30]"
```
### Decode Hrp and Address from a bech32 address
Expand All @@ -68,14 +71,17 @@ bech32_address(-(Hrp, Address), 'okp415wn30a9z4uc692s0kkx5fp5d4qfr3ac7sj9dqn').
- **Then** the answer we get is:

``` yaml
has_more: false
variables: ["Hrp", "Address"]
results:
- substitutions:
- variable: Hrp
expression: "okp4"
- variable: Address
expression: "[163,167,23,244,162,175,49,162,170,15,181,141,68,134,141,168,18,56,247,30]"
height: 42
gas_used: 2222
answer:
has_more: false
variables: ["Hrp", "Address"]
results:
- substitutions:
- variable: Hrp
expression: "okp4"
- variable: Address
expression: "[163,167,23,244,162,175,49,162,170,15,181,141,68,134,141,168,18,56,247,30]"
```
### Extract Address only for OKP4 bech32 address
Expand All @@ -95,12 +101,15 @@ bech32_address(-(okp4, Address), 'okp415wn30a9z4uc692s0kkx5fp5d4qfr3ac7sj9dqn').
- **Then** the answer we get is:

``` yaml
has_more: false
variables: ["Address"]
results:
- substitutions:
- variable: Address
expression: "[163,167,23,244,162,175,49,162,170,15,181,141,68,134,141,168,18,56,247,30]"
height: 42
gas_used: 2222
answer:
has_more: false
variables: ["Address"]
results:
- substitutions:
- variable: Address
expression: "[163,167,23,244,162,175,49,162,170,15,181,141,68,134,141,168,18,56,247,30]"
```
### Encode Address Pair into Bech32 Address
Expand All @@ -119,12 +128,15 @@ bech32_address(-('okp4', [163,167,23,244,162,175,49,162,170,15,181,141,68,134,14
- **Then** the answer we get is:

``` yaml
has_more: false
variables: ["Bech32"]
results:
- substitutions:
- variable: Bech32
expression: "okp415wn30a9z4uc692s0kkx5fp5d4qfr3ac7sj9dqn"
height: 42
gas_used: 2222
answer:
has_more: false
variables: ["Bech32"]
results:
- substitutions:
- variable: Bech32
expression: "okp415wn30a9z4uc692s0kkx5fp5d4qfr3ac7sj9dqn"
```

### Check if a bech32 address is part of the okp4 protocol
Expand All @@ -149,9 +161,12 @@ okp4_addr('okp41p8u47en82gmzfm259y6z93r9qe63l25dfwwng6').
- **Then** the answer we get is:

``` yaml
has_more: false
results:
- substitutions:
height: 42
gas_used: 2222
answer:
has_more: false
results:
- substitutions:
```

### Error on Incorrect Bech32 Address format
Expand All @@ -172,10 +187,13 @@ bech32_address(Address, okp4incorrect).
- **Then** the answer we get is:

``` yaml
has_more: false
variables: ["Address"]
results:
- error: "error(domain_error(encoding(bech32),okp4incorrect),[d,e,c,o,d,i,n,g, ,b,e,c,h,3,2, ,f,a,i,l,e,d,:, ,i,n,v,a,l,i,d, ,s,e,p,a,r,a,t,o,r, ,i,n,d,e,x, ,-,1],bech32_address/2)"
height: 42
gas_used: 2222
answer:
has_more: false
variables: ["Address"]
results:
- error: "error(domain_error(encoding(bech32),okp4incorrect),[d,e,c,o,d,i,n,g, ,b,e,c,h,3,2, ,f,a,i,l,e,d,:, ,i,n,v,a,l,i,d, ,s,e,p,a,r,a,t,o,r, ,i,n,d,e,x, ,-,1],bech32_address/2)"
```

### Error on Incorrect Bech32 Address type
Expand All @@ -196,8 +214,11 @@ bech32_address(-('okp4', X), foo(bar)).
- **Then** the answer we get is:

``` yaml
has_more: false
variables: ["X"]
results:
- error: "error(type_error(atom,foo(bar)),bech32_address/2)"
height: 42
gas_used: 2222
answer:
has_more: false
variables: ["X"]
results:
- error: "error(type_error(atom,foo(bar)),bech32_address/2)"
```
30 changes: 18 additions & 12 deletions predicates/block_height_1.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,15 @@ block_height(Height).
- **Then** the answer we get is:

``` yaml
has_more: false
variables: ["Height"]
results:
- substitutions:
- variable: Height
expression: "100"
height: 100
gas_used: 2222
answer:
has_more: false
variables: ["Height"]
results:
- substitutions:
- variable: Height
expression: "100"
```
### Check that the block height is greater than a certain value
Expand All @@ -75,10 +78,13 @@ Height > 100.
- **Then** the answer we get is:

``` yaml
has_more: false
variables: ["Height"]
results:
- substitutions:
- variable: Height
expression: "101"
height: 101
gas_used: 2223
answer:
has_more: false
variables: ["Height"]
results:
- substitutions:
- variable: Height
expression: "101"
```
30 changes: 18 additions & 12 deletions predicates/block_time_1.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,15 @@ block_time(Time).
- **Then** the answer we get is:

``` yaml
has_more: false
variables: ["Time"]
results:
- substitutions:
- variable: Time
expression: "1709550216"
height: 42
gas_used: 2222
answer:
has_more: false
variables: ["Time"]
results:
- substitutions:
- variable: Time
expression: "1709550216"
```
### Check that the block time is greater than a certain time
Expand Down Expand Up @@ -76,10 +79,13 @@ Time > 1709550216.
- **Then** the answer we get is:

``` yaml
has_more: false
variables: ["Time"]
results:
- substitutions:
- variable: Time
expression: "1709550217"
height: 42
gas_used: 2223
answer:
has_more: false
variables: ["Time"]
results:
- substitutions:
- variable: Time
expression: "1709550217"
```
61 changes: 35 additions & 26 deletions predicates/consult_1.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,15 @@ hello(Who).
- **Then** the answer we get is:

``` yaml
has_more: false
variables: ["Who"]
results:
- substitutions:
- variable: Who
expression: "['W',o,r,l,d,!]"
height: 42
gas_used: 2224
answer:
has_more: false
variables: ["Who"]
results:
- substitutions:
- variable: Who
expression: "['W',o,r,l,d,!]"
```
### Consult a Prolog program which also consults another Prolog program
Expand Down Expand Up @@ -117,23 +120,26 @@ response: |
- **Given** the query:

``` prolog
consult('cosmwasm:storage:okp415ekvz3qdter33mdnk98v8whv5qdr53yusksnfgc08xd26fpdn3ts8gddht?query=%7B%22object_data%22%3A%7B%22id%22%3A%20%224cbe36399aabfcc7158ee7a66cbfffa525bb0ceab33d1ff2cff08759fe0a9b05%22%7D%7D&base64Decode=false'),
program(X).
consult('cosmwasm:storage:okp415ekvz3qdter33mdnk98v8whv5qdr53yusksnfgc08xd26fpdn3ts8gddht?query=%7B%22object_data%22%3A%7B%22id%22%3A%20%224cbe36399aabfcc7158ee7a66cbfffa525bb0ceab33d1ff2cff08759fe0a9b05%22%7D%7D&base64Decode=false'),
program(X).
```

- **When** the query is run (limited to 2 solutions)
- **Then** the answer we get is:

``` yaml
has_more: false
variables: ["X"]
results:
- substitutions:
- variable: X
expression: "b"
- substitutions:
- variable: X
expression: "a"
height: 42
gas_used: 2223
answer:
has_more: false
variables: ["X"]
results:
- substitutions:
- variable: X
expression: "b"
- substitutions:
- variable: X
expression: "a"
```

### Consult several Prolog programs
Expand Down Expand Up @@ -187,13 +193,16 @@ source_file(File).
- **Then** the answer we get is:

``` yaml
has_more: false
variables: ["File"]
results:
- substitutions:
- variable: File
expression: "'cosmwasm:storage:okp412ssv28mzr02jffvy4x39akrpky9ykfafzyjzmvgsqqdw78yjevpqgmqnmk?query=%7B%22object_data%22%3A%7B%22id%22%3A%20%225d3933430d0a12794fae719e0db87b6ec5f549b2%22%7D%7D&base64Decode=false'"
- substitutions:
- variable: File
expression: "'cosmwasm:storage:okp415ekvz3qdter33mdnk98v8whv5qdr53yusksnfgc08xd26fpdn3ts8gddht?query=%7B%22object_data%22%3A%7B%22id%22%3A%20%224cbe36399aabfcc7158ee7a66cbfffa525bb0ceab33d1ff2cff08759fe0a9b05%22%7D%7D&base64Decode=false'"
height: 42
gas_used: 2223
answer:
has_more: false
variables: ["File"]
results:
- substitutions:
- variable: File
expression: "'cosmwasm:storage:okp412ssv28mzr02jffvy4x39akrpky9ykfafzyjzmvgsqqdw78yjevpqgmqnmk?query=%7B%22object_data%22%3A%7B%22id%22%3A%20%225d3933430d0a12794fae719e0db87b6ec5f549b2%22%7D%7D&base64Decode=false'"
- substitutions:
- variable: File
expression: "'cosmwasm:storage:okp415ekvz3qdter33mdnk98v8whv5qdr53yusksnfgc08xd26fpdn3ts8gddht?query=%7B%22object_data%22%3A%7B%22id%22%3A%20%224cbe36399aabfcc7158ee7a66cbfffa525bb0ceab33d1ff2cff08759fe0a9b05%22%7D%7D&base64Decode=false'"
```
Loading

0 comments on commit 12ccfc4

Please sign in to comment.