Skip to content

Commit

Permalink
Fixed aggregate collections (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdorofeev authored Aug 8, 2021
1 parent 8d43825 commit 80a2573
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/kotlin/ee/nx01/tonclient/net/NetModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class NetModule(private val tonClient: TonClient) {
* Aggregates collection data.
* Aggregates values from the specified fields for records that satisfies the filter conditions,
*/
suspend fun aggregateCollection(params: ParamsOfAggregateCollection): ResultOfQuery {
suspend fun aggregateCollection(params: ParamsOfAggregateCollection): ResultOfAggregateCollection {
return tonClient.request("net.aggregate_collection", params)
}

Expand Down
6 changes: 5 additions & 1 deletion src/main/kotlin/ee/nx01/tonclient/net/Types.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ data class EndpointsSet(
data class ParamsOfAggregateCollection(
val collection: String,
val filter: Any? = null,
val fields: List<FieldAggregation>
val fields: List<FieldAggregation>? = listOf()
)

data class FieldAggregation(
Expand All @@ -43,6 +43,10 @@ data class ResultOfQuery(
val result: Any
)

data class ResultOfAggregateCollection(
val values: Any
)


data class ParamsOfFindLastShardBlock(
val address: String
Expand Down
9 changes: 9 additions & 0 deletions src/test/kotlin/ee/nx01/tonclient/net/NetModuletTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ class NetModuletTest : StringSpec({

}

"Should be able call aggregate collection" {
val client = TonClient()

val response = client.net.aggregateCollection(ParamsOfAggregateCollection("transactions"))

response.values shouldNotBe null

}

"Should be able get block with block iterator" {
val client = TonClient(TonClientConfig(NetworkConfig(endpoints = listOf("main.ton.dev"))))

Expand Down

0 comments on commit 80a2573

Please sign in to comment.