Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Seonghun committed Aug 29, 2023
1 parent 6152265 commit 327f8ee
Show file tree
Hide file tree
Showing 5 changed files with 475 additions and 175 deletions.
2 changes: 2 additions & 0 deletions app/src/main/java/io/kthulu/sdk/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)


launch {
withContext(Dispatchers.IO) {

}
}
}
Expand Down
42 changes: 26 additions & 16 deletions app/src/main/java/io/kthulu/sdk/account.kt
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,10 @@ suspend fun getTokenInfoAsync(
suspend fun getTokenHistoryAsync(
network: String,
owner_account: String,
token_address: String = "0x0000000000000000000000000000000000000000"
token_address: String? = "0x0000000000000000000000000000000000000000",
sort: String? = "DESC",
limit: Int? = 1000,
page_number: Int? = 0
) : JSONObject = withContext(Dispatchers.IO) {
val resultArray = JSONArray()
var jsonData = JSONObject()
Expand All @@ -401,7 +404,7 @@ suspend fun getTokenHistoryAsync(
val dbConnector = DBConnector()
dbConnector.connect()
val connection = dbConnector.getConnection()

var total_count = 0
val query =
"SELECT " +
" network," +
Expand All @@ -420,7 +423,10 @@ suspend fun getTokenHistoryAsync(
"WHERE " +
" network = '$network' AND token_address = '$token_address' AND (`from` ='$owner_account' OR `to` ='$owner_account')" +
"ORDER BY " +
" block_number DESC"
" block_number $sort " +
"LIMIT $limit" +
" OFFSET ${(page_number!!) * limit!!}"

connection?.use {
val dbQueryExecutor = DBQueryExector(it)
val resultSet = dbQueryExecutor.executeQuery(query)
Expand All @@ -438,11 +444,15 @@ suspend fun getTokenHistoryAsync(
put("gas_used", it.getString("gas_used"))
put("symbol", it.getString("symbol"))
put("decimals", it.getString("decimals"))
total_count++

}
resultArray.put(jsonData)
}
resultData.put("result", "OK")
resultData.put("sum", total_count)
resultData.put("sort", sort)
resultData.put("page_count", page_number)
resultData.put("value", resultArray)
}
}
Expand Down Expand Up @@ -515,8 +525,8 @@ suspend fun getTokenListAsync(
network: String,
ownerAddress: String,
sort: String? = "DESC",
limit: Int? = null,
page_number: Int? = null): JSONObject = withContext(Dispatchers.IO) {
limit: Int? = 1000,
page_number: Int? = 0): JSONObject = withContext(Dispatchers.IO) {
val resultArray = JSONArray()
var jsonData = JSONObject()
val resultData = JSONObject().apply {
Expand All @@ -528,7 +538,7 @@ suspend fun getTokenListAsync(
val dbConnector = DBConnector()
dbConnector.connect()
val connection = dbConnector.getConnection()

var total_count = 0
val resultArray = JSONArray()
val resultData = JSONObject().apply {
put("result", "FAIL")
Expand All @@ -547,18 +557,15 @@ suspend fun getTokenListAsync(
" balance AS balance," +
" (SELECT decimals FROM token_table WHERE network = t.network AND token_address = t.token_address LIMIT 1) AS decimals," +
" (SELECT token_symbol FROM token_table WHERE network = t.network AND token_address = t.token_address LIMIT 1) AS symbol," +
" (SELECT token_name FROM token_table WHERE network = t.network AND token_address = t.token_address LIMIT 1) AS name," +
" (SELECT COUNT(*) FROM token_owner_table WHERE network = '$network' AND owner_account = '$ownerAddress') AS sum " +
" (SELECT token_name FROM token_table WHERE network = t.network AND token_address = t.token_address LIMIT 1) AS name " +
" FROM" +
" token_owner_table t" +
" WHERE" +
" network = '$network' AND owner_account = '$ownerAddress'" +
" ORDER BY" +
" idx $sort";

if(offset != 0) {
query += " LIMIT $limit OFFSET $offset";
}
"LIMIT $limit" +
" OFFSET ${(page_number!!) * limit!!}"

connection?.use {
val dbQueryExecutor = DBQueryExector(it)
Expand All @@ -573,12 +580,14 @@ suspend fun getTokenListAsync(
put("decimals", it.getString("decimals"))
put("symbol", it.getString("symbol"))
put("name", it.getString("name"))
total_count ++
}
resultArray.put(jsonData)
sum = it.getInt("sum")
}
resultData.put("result", "OK")
resultData.put("sum", sum)
resultData.put("sum", total_count)
resultData.put("sort", sort)
resultData.put("page_count", page_number)
resultData.put("value", resultArray)
}
}
Expand All @@ -593,9 +602,9 @@ suspend fun getTokenListAsync(
}

suspend fun signMessage(
network: String,
fromAddress: String,
collection_id: String,
network: String,
token_id: String,
prefix: String
): String {
Expand Down Expand Up @@ -634,10 +643,10 @@ suspend fun signMessage(
}

suspend fun getSignerAddressFromSignature(
network: String,
signature: String,
fromAddress: String,
collection_id: String,
network: String,
token_id: String,
prefix: String
): String {
Expand Down Expand Up @@ -668,3 +677,4 @@ suspend fun getSignerAddressFromSignature(




16 changes: 14 additions & 2 deletions app/src/main/java/io/kthulu/sdk/global.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ import java.util.Base64
import javax.crypto.Cipher

suspend fun kthuluSdkVersion(){
println("SDK version:0.0.87, Connect OK")
println("SDK version:1.0.0, Connect OK")
val resultArray = JSONArray()
var resultData = JSONObject()
val jsonData = JSONObject()
jsonData.put("version", "SDK version:0.0.87, Connect OK")
jsonData.put("version", "SDK version:1.0.0, Connect OK")
resultArray.put(jsonData)
resultData.put("result", "OK")
resultData.put("value", resultArray)
Expand All @@ -49,6 +49,7 @@ var rpcUrl ="";
var bridgeConfigContractAddress = "";
var bridgeContractAddress = "";
var nftTransferContractAddress = "";
var bridgeSetupContractAddress = "";
var uniswapV2RouterAddress = "";
var uniswapV2FactoryAddress = "";
var maxPriorityFeePerGas = "";
Expand Down Expand Up @@ -131,6 +132,17 @@ fun networkSettings(network: String) {
"tbnb" -> ""
else -> throw IllegalArgumentException("Invalid main network type")
}
bridgeSetupContractAddress = when (network) {
"ethereum" -> "0x3cf93d43251324c527346abf3e0559f4c7a713d1"
"cypress" -> "0x41ec118425e4d13b509382e97cdc3f09dbba8fd9"
"polygon" -> "0x4f5d095ccda117e168ea58bcccffafb9c3617491"
"bnb" -> ""
"goerli" -> ""
"baobab" -> ""
"mumbai" -> ""
"tbnb" -> ""
else -> throw IllegalArgumentException("Invalid main network type")
}
}

// Create RSA key
Expand Down
Loading

0 comments on commit 327f8ee

Please sign in to comment.