Skip to content

Commit 6c46b17

Browse files
fixed some bugs
1 parent e6a8f80 commit 6c46b17

File tree

2 files changed

+31
-122
lines changed
  • app/src/main/kotlin/io/github/hosseinkarami_dev/near/rpc/client_app
  • client/src/test/kotlin/io/github/hosseinkarami_dev/near/rpc/client

2 files changed

+31
-122
lines changed

app/src/main/kotlin/io/github/hosseinkarami_dev/near/rpc/client_app/MainActivity.kt

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,10 @@ package io.github.hosseinkarami_dev.near.rpc.client_app
22

33
import android.os.Bundle
44
import androidx.core.app.ComponentActivity
5-
import androidx.lifecycle.lifecycleScope
6-
import io.github.hosseinkarami_dev.near.rpc.client.NearClient
7-
import io.github.hosseinkarami_dev.near.rpc.client.RpcResponse
8-
import io.github.hosseinkarami_dev.near.rpc.models.RpcTransactionStatusRequest
9-
import io.github.hosseinkarami_dev.near.rpc.models.SignedTransaction
10-
import io.github.hosseinkarami_dev.near.rpc.models.TxExecutionStatus
115
import io.ktor.client.HttpClient
126
import io.ktor.client.engine.cio.CIO
137
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
148
import io.ktor.serialization.kotlinx.json.json
15-
import kotlinx.coroutines.launch
169

1710
class MainActivity : ComponentActivity() {
1811
override fun onCreate(savedInstanceState: Bundle?) {
@@ -24,31 +17,31 @@ class MainActivity : ComponentActivity() {
2417
}
2518
}
2619

27-
val nearClient = NearClient(
28-
httpClient = httpClient,
29-
baseUrl = "https://rpc.mainnet.near.org" // or testnet: https://rpc.testnet.near.org
30-
)
31-
32-
lifecycleScope.launch {
33-
val response = nearClient.tx(
34-
RpcTransactionStatusRequest.SignedTxBase64(
35-
signedTxBase64 = SignedTransaction("FtzDPgG7BnX3g6WV7w951TZ1UErFahfp6NwQKiTE9dMp"),
36-
waitUntil = TxExecutionStatus.Final
37-
))
38-
// val response = nearClient.status()
39-
// val response = nearClient.gasPrice(RpcGasPriceRequest(blockId = null))
40-
41-
when (response) {
42-
is RpcResponse.Failure -> {
43-
println("Error: ${response.error}")
44-
}
45-
46-
is RpcResponse.Success -> {
47-
val result = response.result
48-
println("Result: $result")
49-
50-
}
51-
}
52-
}
20+
// val nearClient = NearClient(
21+
// httpClient = httpClient,
22+
// baseUrl = "https://rpc.mainnet.near.org" // or testnet: https://rpc.testnet.near.org
23+
// )
24+
//
25+
// lifecycleScope.launch {
26+
// val response = nearClient.tx(
27+
// RpcTransactionStatusRequest.SignedTxBase64(
28+
// signedTxBase64 = SignedTransaction("FtzDPgG7BnX3g6WV7w951TZ1UErFahfp6NwQKiTE9dMp"),
29+
// waitUntil = TxExecutionStatus.Final
30+
// ))
31+
// // val response = nearClient.status()
32+
//// val response = nearClient.gasPrice(RpcGasPriceRequest(blockId = null))
33+
//
34+
// when (response) {
35+
// is RpcResponse.Failure -> {
36+
// println("Error: ${response.error}")
37+
// }
38+
//
39+
// is RpcResponse.Success -> {
40+
// val result = response.result
41+
// println("Result: $result")
42+
//
43+
// }
44+
// }
45+
// }
5346
}
5447
}
Lines changed: 5 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
package io.github.hosseinkarami_dev.near.rpc.client
22

3-
import io.github.hosseinkarami_dev.near.rpc.models.AccountId
4-
import io.github.hosseinkarami_dev.near.rpc.models.BlockId
5-
import io.github.hosseinkarami_dev.near.rpc.models.CryptoHash
6-
import io.github.hosseinkarami_dev.near.rpc.models.RpcBlockRequest
7-
import io.github.hosseinkarami_dev.near.rpc.models.RpcMaintenanceWindowsRequest
8-
import io.github.hosseinkarami_dev.near.rpc.models.RpcStateChangesInBlockByTypeRequest
9-
import io.github.hosseinkarami_dev.near.rpc.models.RpcTransactionStatusRequest
10-
import io.github.hosseinkarami_dev.near.rpc.models.SignedTransaction
113
import io.ktor.client.HttpClient
124
import io.ktor.client.engine.cio.CIO
135
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
@@ -22,89 +14,13 @@ class NearClientTest {
2214
json()
2315
}
2416
}
25-
26-
private val nearClient = NearClient(
27-
httpClient = httpClient,
28-
baseUrl = "https://rpc.mainnet.near.org"
29-
)
17+
//
18+
// private val nearClient = NearClient(
19+
// httpClient = httpClient,
20+
// baseUrl = "https://rpc.mainnet.near.org"
21+
// )
3022

3123
@Test
3224
fun testTransactionStatus() = runTest {
33-
// val response = nearClient.query(
34-
// RpcQueryRequest.ViewAccessKeyListByFinality(
35-
// finality = Finality.FINAL,
36-
// accountId = AccountId("neardome2340.near"),
37-
// // publicKey = PublicKey("ed25519:EddTahJwZpJjYPPmat7DBm1m2vdrFBzVv7e3T4hzkENd"),
38-
// requestType = RpcQueryRequest.ViewAccessKeyListByFinality.RequestType.VIEW_ACCESS_KEY_LIST
39-
// )
40-
// )
41-
42-
val response = nearClient.experimentalTxStatus(
43-
RpcTransactionStatusRequest.SignedTxBase64(
44-
SignedTransaction("Gz2YwFsq12yZDAVmA8M53DZM4ih56z6Ybhwd9QNa8A94")
45-
46-
)
47-
// RpcMaintenanceWindowsRequest(
48-
// AccountId("neardome2340.near")
49-
// )
50-
)
51-
52-
when (response) {
53-
is RpcResponse.Failure -> {
54-
println(response.error)
55-
println("hiiiiiiiii")
56-
}
57-
58-
is RpcResponse.Success -> {
59-
println(response.result)
60-
// val accessKeyList = response.getResultOrNull<RpcQueryResponse.AccountView>()
61-
// println(accessKeyList)
62-
}
63-
}
64-
65-
// val response = nearClient.experimentalProtocolConfig(
66-
// RpcProtocolConfigRequest.Finality(finality = Finality.FINAL)
67-
// )
68-
69-
// when (response) {
70-
// is RpcResponse.Failure -> {
71-
// println(response.error)
72-
// }
73-
//
74-
// is RpcResponse.Success<*> -> {
75-
// println(response)
76-
//
77-
// }
78-
// }
79-
80-
81-
//val response = nearClient.status()
82-
// val response = nearClient.changes(
83-
// RpcStateChangesInBlockByTypeRequest.DataChangesByFinality(
84-
// changesType = RpcStateChangesInBlockByTypeRequest.DataChangesByFinality.ChangesType.DATA_CHANGES,
85-
// finality = Finality.FINAL,
86-
// accountIds = listOf(AccountId("contract.rpc-examples.testnet")),
87-
// keyPrefixBase64 = StoreKey("c29tZV9wcmVmaXg="),
88-
// )
89-
// )
90-
// val response = nearClient.tx(
91-
// RpcTransactionStatusRequest.SignedTxBase64(
92-
// signedTxBase64 = SignedTransaction("FtzDPgG7BnX3g6WV7w951TZ1UErFahfp6NwQKiTE9dMp"),
93-
// waitUntil = null,
94-
// // waitUntil = TxExecutionStatus.Final
95-
// )
96-
// )
97-
//
98-
// when (response) {
99-
// is RpcResponse.Failure -> {
100-
// println("Error: ${response.error.code} ${response.error.message}")
101-
// assert(false)
102-
// }
103-
//
104-
// is RpcResponse.Success -> {
105-
// println("Result: ${response.result}")
106-
// assert(true)
107-
// }
108-
// }
10925
}
11026
}

0 commit comments

Comments
 (0)