Skip to content

Commit 8324ec3

Browse files
hosseinkarami-devGitHub Actions Bot
andauthored
chore: regenerate client from OpenAPI (#89)
Co-authored-by: GitHub Actions Bot <automation@github.com>
1 parent 0201992 commit 8324ec3

File tree

85 files changed

+11688
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+11688
-6
lines changed

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

Lines changed: 608 additions & 0 deletions
Large diffs are not rendered by default.

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

Lines changed: 768 additions & 0 deletions
Large diffs are not rendered by default.

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

Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,33 @@ class NearClientUnitTests {
2525
return if (f.exists()) f.readText() else null
2626
}
2727

28+
@Test
29+
fun testExperimentalCallFunction() = runTest {
30+
val data = loadMockJson("JsonRpcRequestForExperimentalCallFunction.json")
31+
assertNotNull(data, "Mock file JsonRpcRequestForExperimentalCallFunction.json does not exist!")
32+
33+
34+
val mockEngine = MockEngine { req ->
35+
when (req.url.fullPath) {
36+
else -> respond(data, headers = headersOf("Content-Type" to listOf(ContentType.Application.Json.toString())))
37+
}
38+
}
39+
40+
val client = HttpClient(mockEngine) {
41+
install(ContentNegotiation) { json(Json { ignoreUnknownKeys = true }) }
42+
}
43+
44+
val nearClient = io.github.hosseinkarami_dev.near.rpc.client.NearClient(client, "http://mock", json)
45+
46+
try {
47+
val requestObj = json.decodeFromString(io.github.hosseinkarami_dev.near.rpc.models.JsonRpcRequestForExperimentalCallFunction.serializer(), data)
48+
val response = nearClient.experimentalCallFunction(requestObj.params)
49+
assertNotNull(response)
50+
} catch (e: Exception) {
51+
fail("Test for ExperimentalCallFunction failed: ${e.message}")
52+
}
53+
}
54+
2855
@Test
2956
fun testExperimentalChanges() = runTest {
3057
val data = loadMockJson("JsonRpcRequestForExperimentalChanges.json")
@@ -349,6 +376,195 @@ class NearClientUnitTests {
349376
}
350377
}
351378

379+
@Test
380+
fun testExperimentalViewAccessKey() = runTest {
381+
val data = loadMockJson("JsonRpcRequestForExperimentalViewAccessKey.json")
382+
assertNotNull(data, "Mock file JsonRpcRequestForExperimentalViewAccessKey.json does not exist!")
383+
384+
385+
val mockEngine = MockEngine { req ->
386+
when (req.url.fullPath) {
387+
else -> respond(data, headers = headersOf("Content-Type" to listOf(ContentType.Application.Json.toString())))
388+
}
389+
}
390+
391+
val client = HttpClient(mockEngine) {
392+
install(ContentNegotiation) { json(Json { ignoreUnknownKeys = true }) }
393+
}
394+
395+
val nearClient = io.github.hosseinkarami_dev.near.rpc.client.NearClient(client, "http://mock", json)
396+
397+
try {
398+
val requestObj = json.decodeFromString(io.github.hosseinkarami_dev.near.rpc.models.JsonRpcRequestForExperimentalViewAccessKey.serializer(), data)
399+
val response = nearClient.experimentalViewAccessKey(requestObj.params)
400+
assertNotNull(response)
401+
} catch (e: Exception) {
402+
fail("Test for ExperimentalViewAccessKey failed: ${e.message}")
403+
}
404+
}
405+
406+
@Test
407+
fun testExperimentalViewAccessKeyList() = runTest {
408+
val data = loadMockJson("JsonRpcRequestForExperimentalViewAccessKeyList.json")
409+
assertNotNull(data, "Mock file JsonRpcRequestForExperimentalViewAccessKeyList.json does not exist!")
410+
411+
412+
val mockEngine = MockEngine { req ->
413+
when (req.url.fullPath) {
414+
else -> respond(data, headers = headersOf("Content-Type" to listOf(ContentType.Application.Json.toString())))
415+
}
416+
}
417+
418+
val client = HttpClient(mockEngine) {
419+
install(ContentNegotiation) { json(Json { ignoreUnknownKeys = true }) }
420+
}
421+
422+
val nearClient = io.github.hosseinkarami_dev.near.rpc.client.NearClient(client, "http://mock", json)
423+
424+
try {
425+
val requestObj = json.decodeFromString(io.github.hosseinkarami_dev.near.rpc.models.JsonRpcRequestForExperimentalViewAccessKeyList.serializer(), data)
426+
val response = nearClient.experimentalViewAccessKeyList(requestObj.params)
427+
assertNotNull(response)
428+
} catch (e: Exception) {
429+
fail("Test for ExperimentalViewAccessKeyList failed: ${e.message}")
430+
}
431+
}
432+
433+
@Test
434+
fun testExperimentalViewAccount() = runTest {
435+
val data = loadMockJson("JsonRpcRequestForExperimentalViewAccount.json")
436+
assertNotNull(data, "Mock file JsonRpcRequestForExperimentalViewAccount.json does not exist!")
437+
438+
439+
val mockEngine = MockEngine { req ->
440+
when (req.url.fullPath) {
441+
else -> respond(data, headers = headersOf("Content-Type" to listOf(ContentType.Application.Json.toString())))
442+
}
443+
}
444+
445+
val client = HttpClient(mockEngine) {
446+
install(ContentNegotiation) { json(Json { ignoreUnknownKeys = true }) }
447+
}
448+
449+
val nearClient = io.github.hosseinkarami_dev.near.rpc.client.NearClient(client, "http://mock", json)
450+
451+
try {
452+
val requestObj = json.decodeFromString(io.github.hosseinkarami_dev.near.rpc.models.JsonRpcRequestForExperimentalViewAccount.serializer(), data)
453+
val response = nearClient.experimentalViewAccount(requestObj.params)
454+
assertNotNull(response)
455+
} catch (e: Exception) {
456+
fail("Test for ExperimentalViewAccount failed: ${e.message}")
457+
}
458+
}
459+
460+
@Test
461+
fun testExperimentalViewCode() = runTest {
462+
val data = loadMockJson("JsonRpcRequestForExperimentalViewCode.json")
463+
assertNotNull(data, "Mock file JsonRpcRequestForExperimentalViewCode.json does not exist!")
464+
465+
466+
val mockEngine = MockEngine { req ->
467+
when (req.url.fullPath) {
468+
else -> respond(data, headers = headersOf("Content-Type" to listOf(ContentType.Application.Json.toString())))
469+
}
470+
}
471+
472+
val client = HttpClient(mockEngine) {
473+
install(ContentNegotiation) { json(Json { ignoreUnknownKeys = true }) }
474+
}
475+
476+
val nearClient = io.github.hosseinkarami_dev.near.rpc.client.NearClient(client, "http://mock", json)
477+
478+
try {
479+
val requestObj = json.decodeFromString(io.github.hosseinkarami_dev.near.rpc.models.JsonRpcRequestForExperimentalViewCode.serializer(), data)
480+
val response = nearClient.experimentalViewCode(requestObj.params)
481+
assertNotNull(response)
482+
} catch (e: Exception) {
483+
fail("Test for ExperimentalViewCode failed: ${e.message}")
484+
}
485+
}
486+
487+
@Test
488+
fun testExperimentalViewGasKey() = runTest {
489+
val data = loadMockJson("JsonRpcRequestForExperimentalViewGasKey.json")
490+
assertNotNull(data, "Mock file JsonRpcRequestForExperimentalViewGasKey.json does not exist!")
491+
492+
493+
val mockEngine = MockEngine { req ->
494+
when (req.url.fullPath) {
495+
else -> respond(data, headers = headersOf("Content-Type" to listOf(ContentType.Application.Json.toString())))
496+
}
497+
}
498+
499+
val client = HttpClient(mockEngine) {
500+
install(ContentNegotiation) { json(Json { ignoreUnknownKeys = true }) }
501+
}
502+
503+
val nearClient = io.github.hosseinkarami_dev.near.rpc.client.NearClient(client, "http://mock", json)
504+
505+
try {
506+
val requestObj = json.decodeFromString(io.github.hosseinkarami_dev.near.rpc.models.JsonRpcRequestForExperimentalViewGasKey.serializer(), data)
507+
val response = nearClient.experimentalViewGasKey(requestObj.params)
508+
assertNotNull(response)
509+
} catch (e: Exception) {
510+
fail("Test for ExperimentalViewGasKey failed: ${e.message}")
511+
}
512+
}
513+
514+
@Test
515+
fun testExperimentalViewGasKeyList() = runTest {
516+
val data = loadMockJson("JsonRpcRequestForExperimentalViewGasKeyList.json")
517+
assertNotNull(data, "Mock file JsonRpcRequestForExperimentalViewGasKeyList.json does not exist!")
518+
519+
520+
val mockEngine = MockEngine { req ->
521+
when (req.url.fullPath) {
522+
else -> respond(data, headers = headersOf("Content-Type" to listOf(ContentType.Application.Json.toString())))
523+
}
524+
}
525+
526+
val client = HttpClient(mockEngine) {
527+
install(ContentNegotiation) { json(Json { ignoreUnknownKeys = true }) }
528+
}
529+
530+
val nearClient = io.github.hosseinkarami_dev.near.rpc.client.NearClient(client, "http://mock", json)
531+
532+
try {
533+
val requestObj = json.decodeFromString(io.github.hosseinkarami_dev.near.rpc.models.JsonRpcRequestForExperimentalViewGasKeyList.serializer(), data)
534+
val response = nearClient.experimentalViewGasKeyList(requestObj.params)
535+
assertNotNull(response)
536+
} catch (e: Exception) {
537+
fail("Test for ExperimentalViewGasKeyList failed: ${e.message}")
538+
}
539+
}
540+
541+
@Test
542+
fun testExperimentalViewState() = runTest {
543+
val data = loadMockJson("JsonRpcRequestForExperimentalViewState.json")
544+
assertNotNull(data, "Mock file JsonRpcRequestForExperimentalViewState.json does not exist!")
545+
546+
547+
val mockEngine = MockEngine { req ->
548+
when (req.url.fullPath) {
549+
else -> respond(data, headers = headersOf("Content-Type" to listOf(ContentType.Application.Json.toString())))
550+
}
551+
}
552+
553+
val client = HttpClient(mockEngine) {
554+
install(ContentNegotiation) { json(Json { ignoreUnknownKeys = true }) }
555+
}
556+
557+
val nearClient = io.github.hosseinkarami_dev.near.rpc.client.NearClient(client, "http://mock", json)
558+
559+
try {
560+
val requestObj = json.decodeFromString(io.github.hosseinkarami_dev.near.rpc.models.JsonRpcRequestForExperimentalViewState.serializer(), data)
561+
val response = nearClient.experimentalViewState(requestObj.params)
562+
assertNotNull(response)
563+
} catch (e: Exception) {
564+
fail("Test for ExperimentalViewState failed: ${e.message}")
565+
}
566+
}
567+
352568
@Test
353569
fun testBlock() = runTest {
354570
val data = loadMockJson("JsonRpcRequestForBlock.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.ErrorWrapperForRpcCallFunctionErrorSerializer
4+
import kotlinx.serialization.SerialName
5+
import kotlinx.serialization.Serializable
6+
7+
@Serializable(with = ErrorWrapperForRpcCallFunctionErrorSerializer::class)
8+
public sealed class ErrorWrapperForRpcCallFunctionError {
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+
) : ErrorWrapperForRpcCallFunctionError() {
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: RpcCallFunctionError,
33+
/**
34+
* * Possible values: HANDLER_ERROR
35+
*/
36+
@SerialName("name")
37+
public val name: Name,
38+
) : ErrorWrapperForRpcCallFunctionError() {
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+
) : ErrorWrapperForRpcCallFunctionError() {
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: 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.ErrorWrapperForRpcViewAccessKeyErrorSerializer
4+
import kotlinx.serialization.SerialName
5+
import kotlinx.serialization.Serializable
6+
7+
@Serializable(with = ErrorWrapperForRpcViewAccessKeyErrorSerializer::class)
8+
public sealed class ErrorWrapperForRpcViewAccessKeyError {
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+
) : ErrorWrapperForRpcViewAccessKeyError() {
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: RpcViewAccessKeyError,
33+
/**
34+
* * Possible values: HANDLER_ERROR
35+
*/
36+
@SerialName("name")
37+
public val name: Name,
38+
) : ErrorWrapperForRpcViewAccessKeyError() {
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+
) : ErrorWrapperForRpcViewAccessKeyError() {
59+
/**
60+
* * Possible values: INTERNAL_ERROR
61+
*/
62+
@Serializable
63+
public enum class Name {
64+
@SerialName("INTERNAL_ERROR")
65+
INTERNAL_ERROR,
66+
}
67+
}
68+
}

0 commit comments

Comments
 (0)