Skip to content

cosmostation/suikotlin

Repository files navigation

sui kotlin

Android SDK for Sui

Requirement

  • Android API 26
  • Kotlin

Dependency

implementation 'com.github.cosmostation:suikotlin:0.0.2'

Initialize

Initialize for security.

SuiClient.initialize(applicationContext)

API

Using api like below.

SuiCLient.instance.{API}

Generate new mnemonic

fun generateMnemonic(): String

Get address from mnemonic

fun getAddress(mnemonic: String): String

Get address from KeyPair

fun getAddress(keyPair: EdDSAKeyPair): String

Get KeyPair from mnemonic

fun getKeyPair(mnemonic: String): EdDSAKeyPair

Sign data bytearray with KeyPair

fun sign(keyPair: EdDSAKeyPair, data: ByteArray): ByteArray

Get objects by address

suspend fun getObjectsByOwner(address: String): List<SuiObjectInfo>?

Get object details from sui objects

//@TODO parse string
suspend fun getObjectDetails(objectInfos: List<SuiObjectInfo>): List<String>?

Get transactions

suspend fun getTransactions(
    transactionQuery: TransactionQuery,
    nextOffset: String? = null,
    limit: Int? = null,
    descending: Boolean = false
): SuiTransactionDigest?

Get transaction details from transaction digests

suspend fun getTransactionDetails(digests: List<String>): List<String>?

Fetch custom request(support sui json-rpc specs.)

suspend fun fetchCustomRequest(requests: JsonRpcRequest): JsonRpcResponse

Fetch custom request list(support sui json-rpc specs.)

suspend fun fetchCustomRequests(requests: List<JsonRpcRequest>): List<JsonRpcResponse>

Faucet

//@TODO parse string 
suspend fun faucet(address: String): Any

Transfer object

suspend fun transferObject(
    objectId: String, receiver: String, sender: String, gasBudget: Int, gasObjectId: String? = null)
): SuiWrappedTxBytes?

Move Call

suspend fun moveCall(
    sender: String,
    packageObjectId: String,
    module: String,
    function: String,
    typeArguments: List<String> = listOf(),
    arguments: List<String> = listOf(),
    gasPayment: String? = null,
    gasBudget: Int
): SuiWrappedTxBytes?

Transfer sui

suspend fun transferSui(
    objectId: String, receiver: String, sender: String, gasBudget: Int, amount: Int? = null
): SuiWrappedTxBytes?

Execute signed transaction

//@TODO parse string 
suspend fun executeTransaction(
    txBytes: ByteArray, signedBytes: ByteArray, keyPair: EdDSAKeyPair
): Any?