Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 5 additions & 96 deletions docs/reference/dapi-endpoints-platform-endpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -2707,7 +2707,7 @@ grpcurl -proto protos/platform/v0/platform.proto \

| Name | Type | Required | Description |
| ------- | ------- | -------- | ----------- |
| `start_epoch` | Bytes | No | First epoch being requested
| `start_epoch` | Integer | No | First epoch being requested
| `count` | Integer | No | Number of records to request
| `ascending` | Boolean | No | Set to `true` to query in ascending order. Results are returned in descending order by default.
| `prove` | Boolean | No | Set to `true` to receive a proof that contains the requested data contracts
Expand Down Expand Up @@ -3029,101 +3029,10 @@ grpcurl -proto protos/platform/v0/platform.proto \
:::
::::

### getProofs

:::::{dropdown} ⚠️ For internal use only

This endpoint is only used for communication between DAPI and Drive. All external requests are rejected.

**Returns**: Proof information for the requested identities, contracts, and/or document(s)

**Parameters**:

A combination of one or more of the following are required fields are required:

| Field | Type | Required | Description |
| - | - | - | - |
| `identities` | `IdentityRequest` | No | List of identity requests
| `contracts` | `ContractRequest` | No | List of contract requests
| `documents` | `DocumentRequest` | No | List of document requests

**Request type details**

| Field | Type | Required | Description |
| - | - | - | - |
| **IdentityRequest** | | |
| `identity_id` | Bytes | Yes | Identity ID
| `request_type` | Type (enum) | Yes | Type of identity proof data to request (options: FULL_IDENTITY, BALANCE, KEYS)
| --------------- | | |
| **ContractRequest** | | |
| `contract_id` | Bytes | Yes | A contract ID
| --------------- | | |
| **DocumentRequest** | | |
| `contract_id` | Bytes | Yes | A contract ID
| `document_type` | String | Yes | Type of contract document
| `document_type_keeps_history` | Boolean | No |Indicates if the document type maintains a history
| `document_id` | Bytes | Yes | Document ID

**Example Request and Response**

::::{tab-set}
:::{tab-item} gRPCurl
:sync: grpcurl
```shell
# Request proofs for an identity and a data contract
# `identity_id` and `contract_id` must be represented in base64
grpcurl -proto protos/platform/v0/platform.proto \
-d '{
"v0": {
"identities": [
{
"request_type": "FULL_IDENTITY",
"identity_id": "HxUSbKaFxbuvTUprfr5a0yU6u4EasTdSWvSxOwKjmxw="
}
],
"contracts": [
{
"contract_id": "5mjGWa9mruHnLBht3ntbfgodcSoJxA1XIfYiv1PFMVU="
}
],
"documents": []
}
}' \
seed-1.testnet.networks.dash.org:1443 \
org.dash.platform.dapi.v0.Platform/getProofs
```
:::
::::
::::{tab-set}
:::{tab-item} Response (gRPCurl)
:sync: grpcurl
```json
// GroveDB proof for the requested identity and contract
{
"v0": {
"proof": {
"grovedbProof": "AQYAAQDuAgHx2HzoF4wSud2eE4a+j9LczjcgboCJsEZJK+Bl/97hLAQBIAAkAgEgn2WlCmdZa3aGIz7NDvWCqFa+KfeLcarKW0WH8vLbYZgAAJpItikQWz3TcDudnxxiJSY5h5Ndejq2UOkZPubKDN0QAfhJDycGmgAM67TyQkPU3kuavJLc7wlcbvBD48JEelqeEQQBQAAkAgEgoqG0rG/vIuoqGmjoEjZEs1eHX2tBLBgQkoHBRueycbwA1L5TY2e0nwaAJolrXP7S6qWDVVTGeFpz4cjXIHoOPUoQAY6uNnLUV0nQB1qQqQWBLRyaJZfu/o/kBIBYXq4egeakBAFgAC0EASCfZaUKZ1lrdoYjPs0O9YKoVr4p94txqspbRYfy8tthmP3KiDkEJD0hAACXwGQWS6E+DOmhhxAd6xNjdVGeulgD5i3dNpt5nRiwGxABMwg2kOcA+9xQ3NhoBqze6XaeidN/5COubSCHkp+bZ9wREQEBIN0CAduEoBne86ZfsX2HwXtJ9jM/ghzM4rJqnUNLkRV/wom8As3l9skVhNWf85H1JsVvK8PkRe3fO83N0QjZ9StB5QNQEAFviDbTTGTvt2tyoqGNJydjW32VQs0vs5XVc8d/M5FJpQQgMBLBm5jsADOt2zbNZLf1EGcPKjUaQwS19plBRChu/awACQIBAQIBAwAAAKWXTEBAq5u+FwX5AZapJ7qj7G7SIxP3mYey+otzvhefEA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Rk0v0/UW0amfTj5Q3RgNXsCy34jIVuLie5yXuiKURfQQgMBLBm5jsADOt2zbNZLf1EGcPKjUaQwS19plBRChu/awACwP9eCCC7wkAAAAApQ40uU7eIE6Lc7gSiikQMybwd7ICds9JRkR7mN9dsKsQAS6QXX9hmpIEs9jEW3eAXNz9stWYGeSq/BnIm9Y+L8XMERECiTcgqXvEL2837Y7t1JcjkYGVIFZ7NkS80ZLVeDUZzS0QAfdYjSzg2BIkhpiPAHQ5W4aN0OlpO7pNjwx46JLVtF5HEQLIaUC5PRYEMoQrfMJnG3PgKokrA37sdKCgo7Hxar/TcRABMapwxTKSfBkDooZq35By87R1c8Y4h4LvZXgOwY+CNfQR",
"quorumHash": "AAAAu4I2BiBDnydSZOLs2bV45yWb+vJFEKQi9wTc3hg=",
"signature": "t6IYrtqREmhCMGQva67DMYpqoY+4fIPB0245y/vhrs0L4qqv7+jDYFoppC7TzFCnCpXLxwOL15u8AOmGFsuMn7FA7qtz/rzJT0124Va1EL5ioeD0DwPVVCAEfQcN/7+6",
"round": 1,
"blockIdHash": "R6LgAhbTCMP2bbiktIm1nLnJ4csO0UvaK6vArGJ2ghs=",
"quorumType": 6
},
"metadata": {
"height": "9350",
"coreChainLockedHeight": 929436,
"epoch": 943,
"timeMs": "1702317747792",
"protocolVersion": 1,
"chainId": "dash-testnet-37"
}
}
}

```
:::
::::
:::::
```{eval-rst}
..
Internal use only - getProofs is used for DAPI-to-Drive communication only; all external requests are rejected
```

### getProtocolVersionUpgradeState

Expand Down
1 change: 0 additions & 1 deletion docs/reference/dapi-endpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ Security groups provide a way to distribute token configuration and update autho
| [`getFinalizedEpochInfos`](../reference/dapi-endpoints-platform-endpoints.md#getfinalizedepochinfos) | **Added in Dash Platform v2.0.0**<br>Retrieves finalized epoch information within a specified index range |
| [`getPathElements`](../reference/dapi-endpoints-platform-endpoints.md#getpathelements) | *Added in Dash Platform v1.0.0*<br>Returns elements for a specified path in the Platform |
| [`getPrefundedSpecializedBalance`](../reference/dapi-endpoints-platform-endpoints.md#getprefundedspecializedbalance) | *Added in Dash Platform v1.0.0*<br>Returns the pre-funded specialized balance for a specific identity |
| `getProofs` | **Disabled for external use in Dash Platform v1.0.0**<br>Returns proof information for the requested identities, contracts, and/or document(s) |
| [`getProtocolVersionUpgradeState`](../reference/dapi-endpoints-platform-endpoints.md#getprotocolversionupgradestate) | Returns the number of votes cast for each protocol version |
| [`getProtocolVersionUpgradeVoteStatus`](../reference/dapi-endpoints-platform-endpoints.md#getprotocolversionupgradevotestatus) | Returns protocol version upgrade status |
| [`getStatus`](../reference/dapi-endpoints-platform-endpoints.md#getstatus) | *Added in Dash Platform v1.2.0*<br>Retrieves status information related to Dash Platform |
Expand Down
71 changes: 59 additions & 12 deletions docs/reference/query-syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Generally queries will consist of a `where` clause plus optional [modifiers](#qu

## Where Clause

The Where clause must be a non-empty array containing not more than 10 conditions. For some operators, `value` will be an array. All fields referenced in a query's where clause must be defined in the same index. This includes `$createdAt` and `$updatedAt`. See the following general syntax example:
The Where clause is an optional array of conditions. If omitted or empty, all documents of the queried type are returned (subject to `limit`). For some operators, `value` will be an array. All fields referenced in a query's where clause must be defined in the same index. This includes system timestamp fields (e.g., `$createdAt`, `$updatedAt`, `$transferredAt`, and their block-height variants such as `$createdAtBlockHeight` and `$createdAtCoreBlockHeight`). See the following general syntax example:

```json Syntax
{
Expand All @@ -27,7 +27,7 @@ Valid fields consist of the indices defined for the document being queried. For

| Index Field(s) | Index Type | Unique |
| - | - | :-: |
| [normalizedParentDomainName, normalizedLabel](https://github.com/dashpay/platform/blob/master/packages/dpns-contract/schema/v1/dpns-contract-documents.json#L5-L16) | Compound | Yes |
| [normalizedParentDomainName, normalizedLabel](https://github.com/dashpay/platform/blob/master/packages/dpns-contract/schema/v1/dpns-contract-documents.json#L11-L18) | Compound | Yes |
| [records.identity](https://github.com/dashpay/platform/blob/master/packages/dpns-contract/schema/v1/dpns-contract-documents.json#L31-L39) | Single Field | No |

```{eval-rst}
Expand All @@ -46,7 +46,7 @@ Valid fields consist of the indices defined for the document being queried. For

| Name | Description |
| :-: | - |
| == | Matches values that are equal to a specified value |
| == (or =) | Matches values that are equal to a specified value |

#### Range

Expand All @@ -57,9 +57,13 @@ Valid fields consist of the indices defined for the document being queried. For
| >= | Matches values that are greater than or equal to a specified value |
| > | Matches values that are greater than a specified value |
| in | Matches all document(s) where the value of the field equals any value in the specified array <br>Array may include up to 100 (unique) elements |
| Between | Matches values between two bounds (inclusive on both sides) — value must be a two-element array `[lower, upper]` with `lower < upper` |
| BetweenExcludeBounds | Matches values strictly between two bounds (exclusive on both sides) |
| BetweenExcludeLeft | Matches values between two bounds, excluding the lower bound |
| BetweenExcludeRight | Matches values between two bounds, excluding the upper bound |

:::{tip}
- Only one range operator is allowed in a query (except for between behavior)
- Only one range operator is allowed in a query. `Between` and its variants are single operators that replace a `>=`/`<=` pair — the engine also normalizes two range operators on the same field into the equivalent `Between*` form automatically
- The `in` operator is only allowed for last two indexed properties
- Range operators are only allowed after `==` and `in` operators
- Range operators are only allowed for the last two fields used in the where condition
Expand All @@ -70,7 +74,7 @@ Valid fields consist of the indices defined for the document being queried. For

| Name | Description |
| :-: | - |
| startsWith | Selects documents where the value of a field begins with the specified characters (string, <= 255 characters). Must include an `orderBy` statement. |
| startsWith | Selects documents where the value of a field begins with the specified characters. Must include an `orderBy` statement. |

### Operator Examples

Expand All @@ -85,6 +89,21 @@ Valid fields consist of the indices defined for the document being queried. For
```
:::

:::{tab-item} Between
```json
{
where: [
["normalizedParentDomainName", "==", "dash"],
// Return names between "alice" and "carol" (inclusive)
["normalizedLabel", "Between", ["alice", "carol"]],
],
orderBy: [
["normalizedLabel", "asc"],
]
}
```
:::

:::{tab-item} in
```json in
{
Expand Down Expand Up @@ -120,9 +139,10 @@ The query modifiers described here determine how query results will be sorted an
| Modifier | Effect | Example |
| - | - | - |
| `limit` | Restricts the number of results returned (maximum: 100) | `limit: 10` |
| `orderBy` | Returns records sorted by the field(s) provided (maximum: 2). Sorting must be by the last indexed property. Can only be used with `>`, `<`, `>=`, `<=`, and `startsWith` queries. | `orderBy: [['normalizedLabel', 'asc']]` |
| `startAt` | Returns records beginning with the document ID provided | `startAt: Buffer.from(Identifier.from(<document ID>))` |
| `startAfter` | Returns records beginning after the document ID provided | `startAfter: Buffer.from(Identifier.from(<document ID>))` |
| `orderBy` | Returns records sorted by the field(s) provided. Sorting must be by the last indexed property. Can only be used with `>`, `<`, `>=`, `<=`, `Between`, `BetweenExcludeBounds`, `BetweenExcludeLeft`, `BetweenExcludeRight`, and `startsWith` queries. | `orderBy: [['normalizedLabel', 'asc']]` |
| `startAt` | Returns records beginning with the document ID provided | `startAt: '<document ID>'` |
| `startAfter` | Returns records beginning after the document ID provided | `startAfter: '<document ID>'` |
| `offset` | Skips the first N matching results (available at the CBOR/DAPI layer; not exposed in the JS SDK) | `offset: 10` |

:::{attention}
For indices composed of multiple fields ([example from the DPNS data contract](https://github.com/dashpay/platform/blob/master/packages/dpns-contract/schema/v1/dpns-contract-documents.json)), the sort order in an `orderBy` must either match the order defined in the data contract OR be the inverse order.
Expand All @@ -132,20 +152,47 @@ For indices composed of multiple fields ([example from the DPNS data contract](h

The following query combines both a where clause and query modifiers.

::::{tab-set}
:::{tab-item} Query object
```javascript
const query = {
limit: 5,
startAt: '4Qp3menV9QjE92hc3BzkUCusAmHLxh1AU6gsVsPF4L2q',
where: [
['normalizedParentDomainName', '==', 'dash'],
['normalizedLabel', 'startsWith', 'test'],
],
orderBy: [
['normalizedLabel', 'asc'],
],
}
```
:::

:::{tab-item} Evo SDK example
```javascript
import Dash from "dash"
import { EvoSDK } from '@dashevo/evo-sdk';

const { Essentials: { Buffer }, PlatformProtocol: { Identifier } } = Dash;
const sdk = EvoSDK.testnetTrusted();
await sdk.connect();

const query = {
const results = await sdk.documents.query({
dataContractId: 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec',
documentTypeName: 'domain',
limit: 5,
startAt: Buffer.from(Identifier.from('4Qp3menV9QjE92hc3BzkUCusAmHLxh1AU6gsVsPF4L2q')),
startAt: '4etYFuWbXRXB74gTDp53eLUqjLEAtNSfUX2XtrQ1uMdT',
where: [
['normalizedParentDomainName', '==', 'dash'],
['normalizedLabel', 'startsWith', 'test'],
],
orderBy: [
['normalizedLabel', 'asc'],
],
});

for (const [id, doc] of results) {
console.log(id.toString(), doc?.toJSON());
}
```
:::
::::
Loading