generated from okp4/template-oss
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #444 from okp4/feat/add-okp4d-predicates-doc
Feat/add okp4d predicates doc
- Loading branch information
Showing
22 changed files
with
1,325 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
34 changes: 34 additions & 0 deletions
34
predicates_versioned_docs/version-v7.0.0/bank_balances_2.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
sidebar_position: 1 | ||
--- | ||
[//]: # (This file is auto-generated. Please do not modify it yourself.) | ||
|
||
# bank_balances/2 | ||
|
||
## Description | ||
|
||
`bank_balances/2` is a predicate which unifies the given terms with the list of balances \(coins\) of the given account. | ||
|
||
The signature is as follows: | ||
|
||
```text | ||
bank_balances(?Account, ?Balances) | ||
``` | ||
|
||
where: | ||
|
||
- Account represents the account address \(in Bech32 format\). | ||
- Balances represents the balances of the account as a list of pairs of coin denomination and amount. | ||
|
||
## Examples | ||
|
||
```text | ||
# Query the balances of the account. | ||
- bank_balances('okp41ffd5wx65l407yvm478cxzlgygw07h79sq0m3fm', X). | ||
# Query the balances of all accounts. The result is a list of pairs of account address and balances. | ||
- bank_balances(X, Y). | ||
# Query the first balance of the given account by unifying the denomination and amount with the given terms. | ||
- bank_balances('okp41ffd5wx65l407yvm478cxzlgygw07h79sq0m3fm', [-(D, A), _]). | ||
``` |
34 changes: 34 additions & 0 deletions
34
predicates_versioned_docs/version-v7.0.0/bank_locked_balances_2.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
sidebar_position: 2 | ||
--- | ||
[//]: # (This file is auto-generated. Please do not modify it yourself.) | ||
|
||
# bank_locked_balances/2 | ||
|
||
## Description | ||
|
||
`bank_locked_balances/2` is a predicate which unifies the given terms with the list of locked coins of the given account. | ||
|
||
The signature is as follows: | ||
|
||
```text | ||
bank_locked_balances(?Account, ?Balances) | ||
``` | ||
|
||
where: | ||
|
||
- Account represents the account address \(in Bech32 format\). | ||
- Balances represents the locked balances of the account as a list of pairs of coin denomination and amount. | ||
|
||
## Examples | ||
|
||
```text | ||
# Query the locked coins of the account. | ||
- bank_locked_balances('okp41ffd5wx65l407yvm478cxzlgygw07h79sq0m3fm', X). | ||
# Query the locked balances of all accounts. The result is a list of pairs of account address and balances. | ||
- bank_locked_balances(X, Y). | ||
# Query the first locked balances of the given account by unifying the denomination and amount with the given terms. | ||
- bank_locked_balances('okp41ffd5wx65l407yvm478cxzlgygw07h79sq0m3fm', [-(D, A), _]). | ||
``` |
34 changes: 34 additions & 0 deletions
34
predicates_versioned_docs/version-v7.0.0/bank_spendable_balances_2.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
sidebar_position: 3 | ||
--- | ||
[//]: # (This file is auto-generated. Please do not modify it yourself.) | ||
|
||
# bank_spendable_balances/2 | ||
|
||
## Description | ||
|
||
`bank_spendable_balances/2` is a predicate which unifies the given terms with the list of spendable coins of the given account. | ||
|
||
The signature is as follows: | ||
|
||
```text | ||
bank_spendable_balances(?Account, ?Balances) | ||
``` | ||
|
||
where: | ||
|
||
- Account represents the account address \(in Bech32 format\). | ||
- Balances represents the spendable balances of the account as a list of pairs of coin denomination and amount. | ||
|
||
## Examples | ||
|
||
```text | ||
# Query the spendable balances of the account. | ||
- bank_spendable_balances('okp41ffd5wx65l407yvm478cxzlgygw07h79sq0m3fm', X). | ||
# Query the spendable balances of all accounts. The result is a list of pairs of account address and balances. | ||
- bank_spendable_balances(X, Y). | ||
# Query the first spendable balances of the given account by unifying the denomination and amount with the given terms. | ||
- bank_spendable_balances('okp41ffd5wx65l407yvm478cxzlgygw07h79sq0m3fm', [-(D, A), _]). | ||
``` |
203 changes: 203 additions & 0 deletions
203
predicates_versioned_docs/version-v7.0.0/bech32_address_2.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,203 @@ | ||
--- | ||
sidebar_position: 4 | ||
--- | ||
[//]: # (This file is auto-generated. Please do not modify it yourself.) | ||
|
||
# bech32_address/2 | ||
|
||
## Description | ||
|
||
`bech32_address/2` is a predicate that convert a [bech32](<https://docs.cosmos.network/main/build/spec/addresses/bech32#hrp-table>) encoded string into [base64](<https://fr.wikipedia.org/wiki/Base64>) bytes and give the address prefix, or convert a prefix \(HRP\) and [base64](<https://fr.wikipedia.org/wiki/Base64>) encoded bytes to [bech32](<https://docs.cosmos.network/main/build/spec/addresses/bech32#hrp-table>) encoded string. | ||
|
||
## Signature | ||
|
||
```text | ||
bech32_address(-Address, +Bech32) is det | ||
bech32_address(+Address, -Bech32) is det | ||
``` | ||
|
||
where: | ||
|
||
- Address is a pair of the HRP \(Human\-Readable Part\) which holds the address prefix and a list of numbers ranging from 0 to 255 that represent the base64 encoded bech32 address string. | ||
- Bech32 is an Atom or string representing the bech32 encoded string address | ||
|
||
## Examples | ||
|
||
### Decode Bech32 Address into its Address Pair representation | ||
|
||
This scenario demonstrates how to parse a provided bech32 address string into its `Address` pair representation. | ||
An `Address` is a compound term `-` with two arguments, the first being the human-readable part (Hrp) and the second | ||
being the numeric address as a list of integers ranging from 0 to 255 representing the bytes of the address in | ||
base 64. | ||
|
||
Here's the steps of the scenario: | ||
|
||
- **Given** the query: | ||
|
||
``` prolog | ||
bech32_address(Address, 'okp415wn30a9z4uc692s0kkx5fp5d4qfr3ac7sj9dqn'). | ||
``` | ||
|
||
- **When** the query is run | ||
- **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]" | ||
``` | ||
### Decode Hrp and Address from a bech32 address | ||
This scenario illustrates how to decode a bech32 address into the human-readable part (Hrp) and the numeric address. | ||
The process extracts these components from a given bech32 address string, showcasing the ability to parse and | ||
separate the address into its constituent parts. | ||
Here's the steps of the scenario: | ||
- **Given** the query: | ||
``` prolog | ||
bech32_address(-(Hrp, Address), 'okp415wn30a9z4uc692s0kkx5fp5d4qfr3ac7sj9dqn'). | ||
``` | ||
|
||
- **When** the query is run | ||
- **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]" | ||
``` | ||
### Extract Address only for OKP4 bech32 address | ||
This scenario demonstrates how to extract the address from a bech32 address string, specifically for a known | ||
protocol, in this case, the okp4 protocol. | ||
Here's the steps of the scenario: | ||
- **Given** the query: | ||
``` prolog | ||
bech32_address(-(okp4, Address), 'okp415wn30a9z4uc692s0kkx5fp5d4qfr3ac7sj9dqn'). | ||
``` | ||
|
||
- **When** the query is run | ||
- **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]" | ||
``` | ||
### Encode Address Pair into Bech32 Address | ||
This scenario demonstrates how to encode an `Address` pair representation into a bech32 address string. | ||
|
||
Here's the steps of the scenario: | ||
|
||
- **Given** the query: | ||
|
||
``` prolog | ||
bech32_address(-('okp4', [163,167,23,244,162,175,49,162,170,15,181,141,68,134,141,168,18,56,247,30]), Bech32). | ||
``` | ||
|
||
- **When** the query is run | ||
- **Then** the answer we get is: | ||
|
||
``` yaml | ||
has_more: false | ||
variables: ["Bech32"] | ||
results: | ||
- substitutions: | ||
- variable: Bech32 | ||
expression: "okp415wn30a9z4uc692s0kkx5fp5d4qfr3ac7sj9dqn" | ||
``` | ||
|
||
### Check if a bech32 address is part of the okp4 protocol | ||
|
||
This scenario shows how to check if a bech32 address is part of the okp4 protocol. | ||
|
||
Here's the steps of the scenario: | ||
|
||
- **Given** the program: | ||
|
||
``` prolog | ||
okp4_addr(Addr) :- bech32_address(-('okp4', _), Addr). | ||
``` | ||
|
||
- **Given** the query: | ||
|
||
``` prolog | ||
okp4_addr('okp41p8u47en82gmzfm259y6z93r9qe63l25dfwwng6'). | ||
``` | ||
|
||
- **When** the query is run | ||
- **Then** the answer we get is: | ||
|
||
``` yaml | ||
has_more: false | ||
results: | ||
- substitutions: | ||
``` | ||
|
||
### Error on Incorrect Bech32 Address format | ||
|
||
This scenario demonstrates the system's response to an incorrect bech32 address format. | ||
In this case, the system generates a `domain_error`, indicating that the provided argument does not meet the | ||
expected format for a bech32 address. | ||
|
||
Here's the steps of the scenario: | ||
|
||
- **Given** the query: | ||
|
||
``` prolog | ||
bech32_address(Address, okp4incorrect). | ||
``` | ||
|
||
- **When** the query is run | ||
- **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)" | ||
``` | ||
|
||
### Error on Incorrect Bech32 Address type | ||
|
||
This scenario demonstrates the system's response to an incorrect bech32 address type. | ||
In this case, the system generates a `type_error`, indicating that the provided argument does not meet the | ||
expected type. | ||
|
||
Here's the steps of the scenario: | ||
|
||
- **Given** the query: | ||
|
||
``` prolog | ||
bech32_address(-('okp4', X), foo(bar)). | ||
``` | ||
|
||
- **When** the query is run | ||
- **Then** the answer we get is: | ||
|
||
``` yaml | ||
has_more: false | ||
variables: ["X"] | ||
results: | ||
- error: "error(type_error(atom,foo(bar)),bech32_address/2)" | ||
``` |
27 changes: 27 additions & 0 deletions
27
predicates_versioned_docs/version-v7.0.0/block_height_1.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
sidebar_position: 5 | ||
--- | ||
[//]: # (This file is auto-generated. Please do not modify it yourself.) | ||
|
||
# block_height/1 | ||
|
||
## Description | ||
|
||
`block_height/1` is a predicate which unifies the given term with the current block height. | ||
|
||
The signature is as follows: | ||
|
||
```text | ||
block_height(?Height) | ||
``` | ||
|
||
where: | ||
|
||
- Height represents the current chain height at the time of the query. | ||
|
||
## Examples | ||
|
||
```text | ||
# Query the current block height. | ||
- block_height(Height). | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
sidebar_position: 6 | ||
--- | ||
[//]: # (This file is auto-generated. Please do not modify it yourself.) | ||
|
||
# block_time/1 | ||
|
||
## Description | ||
|
||
`block_time/1` is a predicate which unifies the given term with the current block time. | ||
|
||
The signature is as follows: | ||
|
||
```text | ||
block_time(?Time) | ||
``` | ||
|
||
where: | ||
|
||
- Time represents the current chain time at the time of the query. | ||
|
||
## Examples | ||
|
||
```text | ||
# Query the current block time. | ||
- block_time(Time). | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
sidebar_position: 7 | ||
--- | ||
[//]: # (This file is auto-generated. Please do not modify it yourself.) | ||
|
||
# chain_id/1 | ||
|
||
## Description | ||
|
||
`chain_id/1` is a predicate which unifies the given term with the current chain ID. The signature is: | ||
|
||
The signature is as follows: | ||
|
||
```text | ||
chain_id(?ID) | ||
``` | ||
|
||
where: | ||
|
||
- ID represents the current chain ID at the time of the query. | ||
|
||
## Examples | ||
|
||
```text | ||
# Query the current chain ID. | ||
- chain_id(ID). | ||
``` |
Oops, something went wrong.