File tree Expand file tree Collapse file tree 3 files changed +44
-1
lines changed
commonMain/kotlin/net/avianlabs/solana/methods
commonTest/kotlin/net/avianlabs/solana/domain/program Expand file tree Collapse file tree 3 files changed +44
-1
lines changed Original file line number Diff line number Diff line change
1
+ package net.avianlabs.solana.methods
2
+
3
+ import kotlinx.serialization.Serializable
4
+ import kotlinx.serialization.json.addJsonObject
5
+ import kotlinx.serialization.json.buildJsonArray
6
+ import kotlinx.serialization.json.put
7
+ import net.avianlabs.solana.SolanaClient
8
+ import net.avianlabs.solana.client.RpcResponse
9
+ import net.avianlabs.solana.domain.core.Commitment
10
+
11
+ /* *
12
+ * Returns the latest blockhash
13
+ *
14
+ * @param commitment Optional [Commitment] level
15
+ */
16
+ public suspend fun SolanaClient.getLatestBlockhash (
17
+ commitment : Commitment ? = null,
18
+ ): LatestBlockHash {
19
+ val result = invoke<RpcResponse .RPC <LatestBlockHash >>(
20
+ method = " getLatestBlockhash" ,
21
+ params = buildJsonArray {
22
+ commitment?.let {
23
+ addJsonObject {
24
+ put(" commitment" , it.value)
25
+ }
26
+ }
27
+ }
28
+ )
29
+ return result!! .value!!
30
+ }
31
+
32
+ @Serializable
33
+ public data class LatestBlockHash (
34
+ val blockhash : String ,
35
+ val lastValidBlockHeight : Long ,
36
+ )
Original file line number Diff line number Diff line change @@ -13,7 +13,14 @@ import net.avianlabs.solana.domain.core.FeeCalculator
13
13
* Returns the latest blockhash
14
14
*
15
15
* @param commitment Optional [Commitment] level
16
+ *
17
+ * @deprecated Use [getLatestBlockhash] instead
16
18
*/
19
+ @Deprecated(
20
+ " No longer a part of solana-core after 2.0. Use getLatestBlockhash instead" ,
21
+ ReplaceWith (" getLatestBlockhash" ),
22
+ DeprecationLevel .ERROR ,
23
+ )
17
24
public suspend fun SolanaClient.getRecentBlockhash (
18
25
commitment : Commitment ? = null,
19
26
): RecentBlockHash {
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ class SystemProgramTest {
34
34
35
35
val rentExempt = client.getMinimumBalanceForRentExemption(SystemProgram .NONCE_ACCOUNT_LENGTH )
36
36
37
- val blockhash = client.getRecentBlockhash ()
37
+ val blockhash = client.getLatestBlockhash ()
38
38
39
39
val initTransaction = Transaction ()
40
40
.addInstruction(
You can’t perform that action at this time.
0 commit comments