-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from solana-mobile/get-account-info
Add getAccountInfo, getMultipleAccounts, getProgramAccounts RPC Methods
- Loading branch information
Showing
13 changed files
with
899 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
rpccore/src/commonMain/kotlin/com/solana/rpccore/JsonRpcDriver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
solanaclient/src/commonMain/kotlin/com/solana/rpc/AccountInfo.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package com.solana.rpc | ||
|
||
import com.solana.publickey.SolanaPublicKey | ||
import com.solana.serializers.* | ||
import com.solana.serializers.BorshAsAsEncodedDataArrayDeserializer | ||
import com.solana.serializers.ByteArrayAsEncodedDataArrayDeserializer | ||
import kotlinx.serialization.DeserializationStrategy | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
import kotlinx.serialization.builtins.ListSerializer | ||
import kotlinx.serialization.builtins.nullable | ||
|
||
@Serializable | ||
data class AccountInfo<D>( | ||
val data: D?, | ||
val executable: Boolean, | ||
val lamports: ULong, | ||
val owner: SolanaPublicKey, | ||
val rentEpoch: ULong, | ||
val size: ULong? = null | ||
) | ||
|
||
@Serializable | ||
data class AccountInfoWithPublicKey<P>( | ||
val account: AccountInfo<P>, | ||
@SerialName("pubkey") val publicKey: String | ||
) | ||
|
||
fun SolanaAccountDeserializer() = | ||
SolanaResponseDeserializer( | ||
AccountInfo.serializer( | ||
ByteArrayAsEncodedDataArrayDeserializer.asSerializer() | ||
) | ||
) | ||
|
||
fun <A> SolanaAccountDeserializer(deserializer: DeserializationStrategy<A>) = | ||
SolanaResponseDeserializer( | ||
AccountInfo.serializer( | ||
BorshAsAsEncodedDataArrayDeserializer(deserializer).asSerializer() | ||
) | ||
) | ||
|
||
fun MultipleAccountsDeserializer() = | ||
SolanaResponseDeserializer( | ||
ListSerializer( | ||
AccountInfo.serializer( | ||
ByteArrayAsEncodedDataArrayDeserializer.asSerializer() | ||
).nullable | ||
) | ||
) | ||
|
||
fun <A> MultipleAccountsDeserializer(deserializer: DeserializationStrategy<A>) = | ||
SolanaResponseDeserializer( | ||
ListSerializer( | ||
AccountInfo.serializer( | ||
BorshAsAsEncodedDataArrayDeserializer(deserializer).asSerializer() | ||
).nullable | ||
) | ||
) | ||
|
||
fun ProgramAccountsDeserializer() = | ||
SolanaResponseDeserializer( | ||
ListSerializer( | ||
AccountInfoWithPublicKey.serializer( | ||
ByteArrayAsEncodedDataArrayDeserializer.asSerializer() | ||
) | ||
) | ||
) | ||
|
||
fun <A> ProgramAccountsDeserializer(deserializer: DeserializationStrategy<A>) = | ||
SolanaResponseDeserializer( | ||
ListSerializer( | ||
AccountInfoWithPublicKey.serializer( | ||
BorshAsAsEncodedDataArrayDeserializer(deserializer).asSerializer() | ||
) | ||
) | ||
) |
Oops, something went wrong.