Skip to content

Commit

Permalink
apps
Browse files Browse the repository at this point in the history
  • Loading branch information
andyoknen committed Jul 8, 2024
1 parent 85c2811 commit cf2dfe9
Show file tree
Hide file tree
Showing 2 changed files with 177 additions and 0 deletions.
1 change: 1 addition & 0 deletions components/en/developers/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
* xref:release_process.adoc[Release Node Process]
* xref:api.adoc[Bastyon Cloud API Reference]
* xref:moderation.adoc[Bastyon Moderation System]
* xref:apps.adoc[Bastyon Mini Apps]
* xref:barteron.adoc[Bastyon Barter App]
176 changes: 176 additions & 0 deletions components/en/developers/modules/ROOT/pages/apps.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
= Bastyon Mini Apps
:author: Andy Oknen <andy.oknen@ya.ru>

== Pocketnet Transaction v2

В новой системе консенсуса предполагается гибкое использование транзакций. Это означает, что поля могут заполнятся клиентом в произвольном формате, кроме некоторых полей, которые используются для разрешения конфликтов консенсуса.

Поля верхнего уровня используются для реализации правил консенсуса и будут валидироваться на уровне узла. Поля второго уровня (объект `p`, `Payload`) могут заполняться в свободной форме для реализации функционала приложения.

Для реализации нештатной логики данные `Payload` могут быть использованы узлом для индексации дополнительных таблиц. Соглашения о структуре данных должны быть описаны и согласованы с кодом приложения.

.Общая структура полей транзакции
[,json]
----
{
"s1": <ADDRESS>, # Required
"s2": <VARIANT>,
"s3": <VARIANT>,
"s4": <VARIANT>,
"s5": <VARIANT>,
"i1": <VARIANT>,
"p": {
"s1": <CUSTOM>,
"s2": <CUSTOM>,
"s3": <CUSTOM>,
"s4": <CUSTOM>,
"s5": <CUSTOM>,
"s6": <CUSTOM>,
"s7": <CUSTOM>
}
}
----


== Application transaction

.OP_RETURN code
----
6d696e69617070
----

.Required payload elements:
[,json]
----
{
"s1": <ADDRESS>, # Required
"s2": <ROOT_TX_HASH>, # Required for editing
"p": {
"s1": "{\"n\":\"First app\",\"d\":\"First app description\",\"t\":[\"tag1\",\"tag2\"]}",
"s2": <UNIQUE_APP_ID> # Required
}
}
----

.`p.s1` is a JSON string with the following fields:
- `n` - Name of the app (Used for indexing the search)
- `d` - Description of the app (Used for indexing the search)
- `t` - Tags of the app (Used for filter by tags)
- ... any other fields


== API

=== Get apps

`/rpc/getapps { <arguments> }`

.Arguments:
[,json]
----
{
"tags": [1,2,3], // Tags for filter apps
"search": "String for fulltext search in Name and Description",
"topHeight": 100, // Top block height for start pagination
"pageStart": 0, // Number of first page
"pageSize": 10, // Count of apps in page
"orderBy": "height",
"orderDesc": true, // true | false
}
----

.Example answer:
[,json]
----
[
{
"hash": "a3c5f9ba693a9d399ab4a3c453dd6ee9d12e1a7ceb001d25622da2a45cb1d723",
"type": 221,
"height": 1051,
"blockHash": "f1885784d513141cecdca4cde5154e382f96e19510033853384a6e42191dff49",
"time": 1720427842,
"s1": "mppcM1GXMoePyLnFXothKHgjtGPo7dFVhe",
"s2": "a3c5f9ba693a9d399ab4a3c453dd6ee9d12e1a7ceb001d25622da2a45cb1d723",
"p": {
"s1": "{\"n\":\"First app\",\"d\":\"First app description\",\"u\":\"first_app.com\",\"e\":\"first_app@first_app.com\"}",
"s2": "first_app"
},
"ad": {
"r": 2
}
}
]
----


=== Get app scores

`/rpc/getappscores { <arguments> }`

.Arguments:
[,json]
----
{
"app": "a3c5f9ba693a9d399ab4a3c453dd6ee9d12e1a7ceb001d25622da2a45cb1d723", // Application tx (root) hash
"topHeight": 100, // Top block height for start pagination
"pageStart": 0, // Number of first page
"pageSize": 10, // Count of apps in page
"orderBy": "height",
"orderDesc": true, // true | false
}
----

.Example answer:
[,json]
----
[
{
"hash": "c9a0fade16e1386e7a39ea344d0ec1c371860c0b838d344883f36a2ad2f91dcf",
"type": 300,
"height": 1053,
"blockHash": "c0469c4f20d8719bf6d53404d8e58805b7c6945a2bd2dc4839b402e615dd3a1a",
"time": 1720427842,
"s1": "mv7NYsv4DgaouV7eTUkmAXz8EP5z9AwF6Q",
"s2": "a3c5f9ba693a9d399ab4a3c453dd6ee9d12e1a7ceb001d25622da2a45cb1d723", // App tx hash
"i1": 5
}
]
----


=== Get app comments

`/rpc/getappcomments { <arguments> }`

.Arguments:
[,json]
----
{
"app": "a3c5f9ba693a9d399ab4a3c453dd6ee9d12e1a7ceb001d25622da2a45cb1d723", // Application tx (root) hash
"topHeight": 100, // Top block height for start pagination
"pageStart": 0, // Number of first page
"pageSize": 10, // Count of apps in page
"orderBy": "height",
"orderDesc": true, // true | false
}
----

.Example answer:
[,json]
----
[
{
"hash": "6dd011619696548051bf266c8170522da8b7becdb87e6edebed4a9cfc9abc9f1",
"type": 204,
"height": 1054,
"blockHash": "a9de4f2b5a1498085049e8e55c3f8e542878b68473db82550a34fb80b44eb311",
"time": 1720427843,
"s1": "mv7NYsv4DgaouV7eTUkmAXz8EP5z9AwF6Q",
"s2": "6dd011619696548051bf266c8170522da8b7becdb87e6edebed4a9cfc9abc9f1", // Comment root tx hash
"s3": "a3c5f9ba693a9d399ab4a3c453dd6ee9d12e1a7ceb001d25622da2a45cb1d723", // App tx hash
"p": {
"s1": "comment message"
}
}
]
----

0 comments on commit cf2dfe9

Please sign in to comment.