Skip to content

Commit 0e49a7f

Browse files
hosseinkarami-devGitHub Actions Bot
andauthored
chore: regenerate client from OpenAPI (#110)
Co-authored-by: GitHub Actions Bot <automation@github.com>
1 parent dd66e85 commit 0e49a7f

File tree

12 files changed

+508
-0
lines changed

12 files changed

+508
-0
lines changed

client/src/main/kotlin/io/github/hosseinkarami_dev/near/rpc/client/NearClient.kt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import io.github.hosseinkarami_dev.near.rpc.models.JsonRpcRequestForExperimental
2121
import io.github.hosseinkarami_dev.near.rpc.models.JsonRpcRequestForExperimentalMaintenanceWindows
2222
import io.github.hosseinkarami_dev.near.rpc.models.JsonRpcRequestForExperimentalProtocolConfig
2323
import io.github.hosseinkarami_dev.near.rpc.models.JsonRpcRequestForExperimentalReceipt
24+
import io.github.hosseinkarami_dev.near.rpc.models.JsonRpcRequestForExperimentalReceiptToTx
2425
import io.github.hosseinkarami_dev.near.rpc.models.JsonRpcRequestForExperimentalSplitStorageInfo
2526
import io.github.hosseinkarami_dev.near.rpc.models.JsonRpcRequestForExperimentalTxStatus
2627
import io.github.hosseinkarami_dev.near.rpc.models.JsonRpcRequestForExperimentalValidatorsOrdered
@@ -59,6 +60,7 @@ import io.github.hosseinkarami_dev.near.rpc.models.JsonRpcResponseForRpcNetworkI
5960
import io.github.hosseinkarami_dev.near.rpc.models.JsonRpcResponseForRpcProtocolConfigResponseAndRpcProtocolConfigError
6061
import io.github.hosseinkarami_dev.near.rpc.models.JsonRpcResponseForRpcQueryResponseAndRpcQueryError
6162
import io.github.hosseinkarami_dev.near.rpc.models.JsonRpcResponseForRpcReceiptResponseAndRpcReceiptError
63+
import io.github.hosseinkarami_dev.near.rpc.models.JsonRpcResponseForRpcReceiptToTxResponseAndRpcReceiptToTxError
6264
import io.github.hosseinkarami_dev.near.rpc.models.JsonRpcResponseForRpcSplitStorageInfoResponseAndRpcSplitStorageInfoError
6365
import io.github.hosseinkarami_dev.near.rpc.models.JsonRpcResponseForRpcStateChangesInBlockByTypeResponseAndRpcStateChangesError
6466
import io.github.hosseinkarami_dev.near.rpc.models.JsonRpcResponseForRpcStateChangesInBlockResponseAndRpcStateChangesError
@@ -109,6 +111,9 @@ import io.github.hosseinkarami_dev.near.rpc.models.RpcQueryResponse
109111
import io.github.hosseinkarami_dev.near.rpc.models.RpcReceiptError
110112
import io.github.hosseinkarami_dev.near.rpc.models.RpcReceiptRequest
111113
import io.github.hosseinkarami_dev.near.rpc.models.RpcReceiptResponse
114+
import io.github.hosseinkarami_dev.near.rpc.models.RpcReceiptToTxError
115+
import io.github.hosseinkarami_dev.near.rpc.models.RpcReceiptToTxRequest
116+
import io.github.hosseinkarami_dev.near.rpc.models.RpcReceiptToTxResponse
112117
import io.github.hosseinkarami_dev.near.rpc.models.RpcSendTransactionRequest
113118
import io.github.hosseinkarami_dev.near.rpc.models.RpcSplitStorageInfoError
114119
import io.github.hosseinkarami_dev.near.rpc.models.RpcSplitStorageInfoRequest
@@ -486,6 +491,37 @@ public class NearClient(
486491
}
487492
}
488493

494+
/**
495+
* Resolves a receipt ID back to the originating transaction hash and sender account
496+
*
497+
* @see path: /EXPERIMENTAL_receipt_to_tx (method: post) — operationId: EXPERIMENTAL_receipt_to_tx
498+
*
499+
* @param rpcReceiptToTxRequest Request parameters: `io.github.hosseinkarami_dev.near.rpc.models.RpcReceiptToTxRequest` (required).
500+
* @return Response: `RpcResponse<RpcReceiptToTxResponse>`.
501+
*/
502+
public suspend fun experimentalReceiptToTx(rpcReceiptToTxRequest: RpcReceiptToTxRequest): RpcResponse<RpcReceiptToTxResponse> {
503+
val request = JsonRpcRequestForExperimentalReceiptToTx(
504+
id = nextId(),
505+
jsonrpc = "2.0",
506+
method = JsonRpcRequestForExperimentalReceiptToTx.Method.EXPERIMENTAL_RECEIPT_TO_TX,
507+
params = rpcReceiptToTxRequest
508+
)
509+
510+
return callRpc(
511+
httpClient,
512+
baseUrl,
513+
request,
514+
JsonRpcRequestForExperimentalReceiptToTx.serializer(),
515+
JsonRpcResponseForRpcReceiptToTxResponseAndRpcReceiptToTxError.serializer(),
516+
RpcReceiptToTxError.serializer()
517+
) { decoded ->
518+
when (decoded) {
519+
is JsonRpcResponseForRpcReceiptToTxResponseAndRpcReceiptToTxError.Result -> RpcResponse.Success(decoded.result)
520+
is JsonRpcResponseForRpcReceiptToTxResponseAndRpcReceiptToTxError.Error -> RpcResponse.Failure(ErrorResult.Rpc(error = decoded.error))
521+
}
522+
}
523+
}
524+
489525
/**
490526
* Contains the split storage information. More info on split storage [here](https://near-nodes.io/archival/split-storage-archival)
491527
*

client/src/test/kotlin/io/github/hosseinkarami_dev/near/rpc/client/ModelSerializationTests.kt

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,6 +1207,22 @@ class ModelSerializationTests {
12071207
}
12081208
}
12091209

1210+
@Test
1211+
fun testErrorWrapperForRpcReceiptToTxErrorEncodeDecode() {
1212+
val data = loadMockJson("ErrorWrapperForRpcReceiptToTxError.json")
1213+
assertNotNull(data, "Mock file ErrorWrapperForRpcReceiptToTxError.json does not exist!")
1214+
1215+
try {
1216+
val decoded = json.decodeFromString(io.github.hosseinkarami_dev.near.rpc.models.ErrorWrapperForRpcReceiptToTxError.serializer(), data)
1217+
val encoded = json.encodeToString(io.github.hosseinkarami_dev.near.rpc.models.ErrorWrapperForRpcReceiptToTxError.serializer(), decoded)
1218+
val decoded2 = json.decodeFromString(io.github.hosseinkarami_dev.near.rpc.models.ErrorWrapperForRpcReceiptToTxError.serializer(), encoded)
1219+
assertEquals(decoded, decoded2)
1220+
} catch (e: Exception) {
1221+
e.printStackTrace()
1222+
fail("Serialization test failed for ErrorWrapperForRpcReceiptToTxError: ${e.message}")
1223+
}
1224+
}
1225+
12101226
@Test
12111227
fun testErrorWrapperForRpcSplitStorageInfoErrorEncodeDecode() {
12121228
val data = loadMockJson("ErrorWrapperForRpcSplitStorageInfoError.json")
@@ -1991,6 +2007,22 @@ class ModelSerializationTests {
19912007
}
19922008
}
19932009

2010+
@Test
2011+
fun testJsonRpcRequestForExperimentalReceiptToTxEncodeDecode() {
2012+
val data = loadMockJson("JsonRpcRequestForExperimentalReceiptToTx.json")
2013+
assertNotNull(data, "Mock file JsonRpcRequestForExperimentalReceiptToTx.json does not exist!")
2014+
2015+
try {
2016+
val decoded = json.decodeFromString(io.github.hosseinkarami_dev.near.rpc.models.JsonRpcRequestForExperimentalReceiptToTx.serializer(), data)
2017+
val encoded = json.encodeToString(io.github.hosseinkarami_dev.near.rpc.models.JsonRpcRequestForExperimentalReceiptToTx.serializer(), decoded)
2018+
val decoded2 = json.decodeFromString(io.github.hosseinkarami_dev.near.rpc.models.JsonRpcRequestForExperimentalReceiptToTx.serializer(), encoded)
2019+
assertEquals(decoded, decoded2)
2020+
} catch (e: Exception) {
2021+
e.printStackTrace()
2022+
fail("Serialization test failed for JsonRpcRequestForExperimentalReceiptToTx: ${e.message}")
2023+
}
2024+
}
2025+
19942026
@Test
19952027
fun testJsonRpcRequestForExperimentalSplitStorageInfoEncodeDecode() {
19962028
val data = loadMockJson("JsonRpcRequestForExperimentalSplitStorageInfo.json")
@@ -2711,6 +2743,22 @@ class ModelSerializationTests {
27112743
}
27122744
}
27132745

2746+
@Test
2747+
fun testJsonRpcResponseForRpcReceiptToTxResponseAndRpcReceiptToTxErrorEncodeDecode() {
2748+
val data = loadMockJson("JsonRpcResponseForRpcReceiptToTxResponseAndRpcReceiptToTxError.json")
2749+
assertNotNull(data, "Mock file JsonRpcResponseForRpcReceiptToTxResponseAndRpcReceiptToTxError.json does not exist!")
2750+
2751+
try {
2752+
val decoded = json.decodeFromString(io.github.hosseinkarami_dev.near.rpc.models.JsonRpcResponseForRpcReceiptToTxResponseAndRpcReceiptToTxError.serializer(), data)
2753+
val encoded = json.encodeToString(io.github.hosseinkarami_dev.near.rpc.models.JsonRpcResponseForRpcReceiptToTxResponseAndRpcReceiptToTxError.serializer(), decoded)
2754+
val decoded2 = json.decodeFromString(io.github.hosseinkarami_dev.near.rpc.models.JsonRpcResponseForRpcReceiptToTxResponseAndRpcReceiptToTxError.serializer(), encoded)
2755+
assertEquals(decoded, decoded2)
2756+
} catch (e: Exception) {
2757+
e.printStackTrace()
2758+
fail("Serialization test failed for JsonRpcResponseForRpcReceiptToTxResponseAndRpcReceiptToTxError: ${e.message}")
2759+
}
2760+
}
2761+
27142762
@Test
27152763
fun testJsonRpcResponseForRpcSplitStorageInfoResponseAndRpcSplitStorageInfoErrorEncodeDecode() {
27162764
val data = loadMockJson("JsonRpcResponseForRpcSplitStorageInfoResponseAndRpcSplitStorageInfoError.json")
@@ -3959,6 +4007,54 @@ class ModelSerializationTests {
39594007
}
39604008
}
39614009

4010+
@Test
4011+
fun testRpcReceiptToTxErrorEncodeDecode() {
4012+
val data = loadMockJson("RpcReceiptToTxError.json")
4013+
assertNotNull(data, "Mock file RpcReceiptToTxError.json does not exist!")
4014+
4015+
try {
4016+
val decoded = json.decodeFromString(io.github.hosseinkarami_dev.near.rpc.models.RpcReceiptToTxError.serializer(), data)
4017+
val encoded = json.encodeToString(io.github.hosseinkarami_dev.near.rpc.models.RpcReceiptToTxError.serializer(), decoded)
4018+
val decoded2 = json.decodeFromString(io.github.hosseinkarami_dev.near.rpc.models.RpcReceiptToTxError.serializer(), encoded)
4019+
assertEquals(decoded, decoded2)
4020+
} catch (e: Exception) {
4021+
e.printStackTrace()
4022+
fail("Serialization test failed for RpcReceiptToTxError: ${e.message}")
4023+
}
4024+
}
4025+
4026+
@Test
4027+
fun testRpcReceiptToTxRequestEncodeDecode() {
4028+
val data = loadMockJson("RpcReceiptToTxRequest.json")
4029+
assertNotNull(data, "Mock file RpcReceiptToTxRequest.json does not exist!")
4030+
4031+
try {
4032+
val decoded = json.decodeFromString(io.github.hosseinkarami_dev.near.rpc.models.RpcReceiptToTxRequest.serializer(), data)
4033+
val encoded = json.encodeToString(io.github.hosseinkarami_dev.near.rpc.models.RpcReceiptToTxRequest.serializer(), decoded)
4034+
val decoded2 = json.decodeFromString(io.github.hosseinkarami_dev.near.rpc.models.RpcReceiptToTxRequest.serializer(), encoded)
4035+
assertEquals(decoded, decoded2)
4036+
} catch (e: Exception) {
4037+
e.printStackTrace()
4038+
fail("Serialization test failed for RpcReceiptToTxRequest: ${e.message}")
4039+
}
4040+
}
4041+
4042+
@Test
4043+
fun testRpcReceiptToTxResponseEncodeDecode() {
4044+
val data = loadMockJson("RpcReceiptToTxResponse.json")
4045+
assertNotNull(data, "Mock file RpcReceiptToTxResponse.json does not exist!")
4046+
4047+
try {
4048+
val decoded = json.decodeFromString(io.github.hosseinkarami_dev.near.rpc.models.RpcReceiptToTxResponse.serializer(), data)
4049+
val encoded = json.encodeToString(io.github.hosseinkarami_dev.near.rpc.models.RpcReceiptToTxResponse.serializer(), decoded)
4050+
val decoded2 = json.decodeFromString(io.github.hosseinkarami_dev.near.rpc.models.RpcReceiptToTxResponse.serializer(), encoded)
4051+
assertEquals(decoded, decoded2)
4052+
} catch (e: Exception) {
4053+
e.printStackTrace()
4054+
fail("Serialization test failed for RpcReceiptToTxResponse: ${e.message}")
4055+
}
4056+
}
4057+
39624058
@Test
39634059
fun testRpcRequestValidationErrorKindEncodeDecode() {
39644060
val data = loadMockJson("RpcRequestValidationErrorKind.json")

client/src/test/kotlin/io/github/hosseinkarami_dev/near/rpc/client/NearClientUnitTests.kt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,33 @@ class NearClientUnitTests {
295295
}
296296
}
297297

298+
@Test
299+
fun testExperimentalReceiptToTx() = runTest {
300+
val data = loadMockJson("JsonRpcRequestForExperimentalReceiptToTx.json")
301+
assertNotNull(data, "Mock file JsonRpcRequestForExperimentalReceiptToTx.json does not exist!")
302+
303+
304+
val mockEngine = MockEngine { req ->
305+
when (req.url.fullPath) {
306+
else -> respond(data, headers = headersOf("Content-Type" to listOf(ContentType.Application.Json.toString())))
307+
}
308+
}
309+
310+
val client = HttpClient(mockEngine) {
311+
install(ContentNegotiation) { json(Json { ignoreUnknownKeys = true }) }
312+
}
313+
314+
val nearClient = io.github.hosseinkarami_dev.near.rpc.client.NearClient(client, "http://mock")
315+
316+
try {
317+
val requestObj = json.decodeFromString(io.github.hosseinkarami_dev.near.rpc.models.JsonRpcRequestForExperimentalReceiptToTx.serializer(), data)
318+
val response = nearClient.experimentalReceiptToTx(requestObj.params)
319+
assertNotNull(response)
320+
} catch (e: Exception) {
321+
fail("Test for ExperimentalReceiptToTx failed: ${e.message}")
322+
}
323+
}
324+
298325
@Test
299326
fun testExperimentalSplitStorageInfo() = runTest {
300327
val data = loadMockJson("JsonRpcRequestForExperimentalSplitStorageInfo.json")
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package io.github.hosseinkarami_dev.near.rpc.models
2+
3+
import io.github.hosseinkarami_dev.near.rpc.serializers.ErrorWrapperForRpcReceiptToTxErrorSerializer
4+
import kotlinx.serialization.SerialName
5+
import kotlinx.serialization.Serializable
6+
7+
@Serializable(with = ErrorWrapperForRpcReceiptToTxErrorSerializer::class)
8+
public sealed class ErrorWrapperForRpcReceiptToTxError {
9+
@Serializable
10+
public data class RequestValidationError(
11+
@SerialName("cause")
12+
public val cause: RpcRequestValidationErrorKind,
13+
/**
14+
* * Possible values: REQUEST_VALIDATION_ERROR
15+
*/
16+
@SerialName("name")
17+
public val name: Name,
18+
) : ErrorWrapperForRpcReceiptToTxError() {
19+
/**
20+
* * Possible values: REQUEST_VALIDATION_ERROR
21+
*/
22+
@Serializable
23+
public enum class Name {
24+
@SerialName("REQUEST_VALIDATION_ERROR")
25+
REQUEST_VALIDATION_ERROR,
26+
}
27+
}
28+
29+
@Serializable
30+
public data class HandlerError(
31+
@SerialName("cause")
32+
public val cause: RpcReceiptToTxError,
33+
/**
34+
* * Possible values: HANDLER_ERROR
35+
*/
36+
@SerialName("name")
37+
public val name: Name,
38+
) : ErrorWrapperForRpcReceiptToTxError() {
39+
/**
40+
* * Possible values: HANDLER_ERROR
41+
*/
42+
@Serializable
43+
public enum class Name {
44+
@SerialName("HANDLER_ERROR")
45+
HANDLER_ERROR,
46+
}
47+
}
48+
49+
@Serializable
50+
public data class InternalError(
51+
@SerialName("cause")
52+
public val cause: io.github.hosseinkarami_dev.near.rpc.models.InternalError,
53+
/**
54+
* * Possible values: INTERNAL_ERROR
55+
*/
56+
@SerialName("name")
57+
public val name: Name,
58+
) : ErrorWrapperForRpcReceiptToTxError() {
59+
/**
60+
* * Possible values: INTERNAL_ERROR
61+
*/
62+
@Serializable
63+
public enum class Name {
64+
@SerialName("INTERNAL_ERROR")
65+
INTERNAL_ERROR,
66+
}
67+
}
68+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package io.github.hosseinkarami_dev.near.rpc.models
2+
3+
import kotlin.String
4+
import kotlinx.serialization.SerialName
5+
import kotlinx.serialization.Serializable
6+
7+
@Serializable
8+
public data class JsonRpcRequestForExperimentalReceiptToTx(
9+
@SerialName("id")
10+
public val id: String,
11+
@SerialName("jsonrpc")
12+
public val jsonrpc: String,
13+
/**
14+
* * Possible values: EXPERIMENTAL_receipt_to_tx
15+
*/
16+
@SerialName("method")
17+
public val method: Method,
18+
@SerialName("params")
19+
public val params: RpcReceiptToTxRequest,
20+
) {
21+
/**
22+
* * Possible values: EXPERIMENTAL_receipt_to_tx
23+
*/
24+
@Serializable
25+
public enum class Method {
26+
@SerialName("EXPERIMENTAL_receipt_to_tx")
27+
EXPERIMENTAL_RECEIPT_TO_TX,
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package io.github.hosseinkarami_dev.near.rpc.models
2+
3+
import io.github.hosseinkarami_dev.near.rpc.serializers.JsonRpcResponseForRpcReceiptToTxResponseAndRpcReceiptToTxErrorSerializer
4+
import kotlin.String
5+
import kotlinx.serialization.SerialName
6+
import kotlinx.serialization.Serializable
7+
8+
@Serializable(with = JsonRpcResponseForRpcReceiptToTxResponseAndRpcReceiptToTxErrorSerializer::class)
9+
public sealed class JsonRpcResponseForRpcReceiptToTxResponseAndRpcReceiptToTxError {
10+
@Serializable
11+
public data class Result(
12+
@SerialName("result")
13+
public val result: RpcReceiptToTxResponse,
14+
@SerialName("id")
15+
public val id: String,
16+
@SerialName("jsonrpc")
17+
public val jsonrpc: String,
18+
) : JsonRpcResponseForRpcReceiptToTxResponseAndRpcReceiptToTxError()
19+
20+
@Serializable
21+
public data class Error(
22+
@SerialName("error")
23+
public val error: ErrorWrapperForRpcReceiptToTxError,
24+
@SerialName("id")
25+
public val id: String,
26+
@SerialName("jsonrpc")
27+
public val jsonrpc: String,
28+
) : JsonRpcResponseForRpcReceiptToTxResponseAndRpcReceiptToTxError()
29+
}

0 commit comments

Comments
 (0)