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
@Test | |
fun `ton proof validation test`() { | |
val payload = """ | |
{ | |
"proof": { | |
"timestamp": 1678206305, | |
"domain": { | |
"lengthBytes": 10, | |
"value": "tonplay.io" | |
}, |
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
import org.ton.api.pk.PrivateKeyEd25519 | |
import org.ton.bigint.BigInt | |
import org.ton.block.* | |
import org.ton.boc.BagOfCells | |
import org.ton.cell.Cell | |
import org.ton.cell.CellBuilder | |
import org.ton.contract.wallet.WalletContract | |
import org.ton.contract.wallet.WalletTransfer |
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
import org.ton.api.pk.PrivateKeyEd25519 | |
import org.ton.bigint.BigInt | |
import org.ton.bitstring.BitString | |
import org.ton.block.* | |
import org.ton.boc.BagOfCells | |
import org.ton.cell.Cell | |
import org.ton.cell.CellBuilder | |
import org.ton.contract.wallet.WalletContract |
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
@Test | |
fun `get account info raw`() { | |
val liteClient = LiteClient( | |
liteClientConfigGlobal = LiteClientConfigGlobal( | |
liteServers = listOf( | |
LiteServerDesc(id = PublicKeyEd25519(base64("n4VDnSCUuSpjnCyUk9e3QOOd6o0ItSWYbTnW3Wnn8wk=")), ip = 84478511, port = 19949) | |
) | |
), | |
coroutineContext = Dispatchers.Default | |
) |
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
@Bean("liteClientExtended") | |
fun liteClient(tonChainConfigReader: TonChainConfigReader): LiteClient { | |
val configList = tonChainConfigReader.load().liteservers | |
val nearestNodesList = mutableListOf<TonChainConfigReader.TonNetConfig.LiteServerParams>() | |
configList.forEach { | |
val liteClient = LiteClient( | |
LiteClientConfigGlobal( | |
liteservers = listOf( | |
LiteServerDesc(id = PublicKeyEd25519(base64(it.id.key)), ip = it.ip, port = it.port) |
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
import org.springframework.data.domain.Page | |
class PageLite<T>(page: Page<T>) { | |
var content: List<T> = page.content | |
var pageable = PageableLite( | |
number = page.pageable.pageNumber + 1, | |
size = page.pageable.pageSize, | |
total = page.totalElements | |
) |
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
private fun isHostAvailable(ip: Int, port: Int): Boolean { | |
return kotlin.runCatching { | |
Socket(Utils.ipv4IntToStr(ip), port) | |
true | |
}.getOrNull() ?: false | |
} |
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
fun Any.toJsonV2(): String { | |
var fieldNameToAnnotatedNameMap = [email protected] { it.name }.associateWith { fieldName -> | |
val jsonFieldName = | |
this@toJsonV2::class.primaryConstructor?.parameters?.first { it.name == fieldName }?.annotations?.firstOrNull { it is JsonProperty } | |
val serializedName = if (jsonFieldName != null) (jsonFieldName as JsonProperty).value else fieldName | |
serializedName | |
} | |
return buildString { | |
append("{\n") |
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
import okhttp3.HttpUrl.Companion.toHttpUrl | |
import okhttp3.OkHttpClient | |
import okhttp3.Request | |
private inline fun < reified T: Any> downloadData(link: String, key: String, offset: String?): T { | |
val url = link.toHttpUrl() | |
offset?.let { url.newBuilder().addQueryParameter("offset", offset).build() } | |
val response = OkHttpClient().newCall( | |
Request.Builder() | |
.url(url) |
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
import kotlinx.coroutines.reactor.mono | |
import org.ton.api.tonnode.TonNodeBlockId | |
import org.ton.api.tonnode.TonNodeBlockIdExt | |
import org.ton.bigint.BigInt | |
import org.ton.block.* | |
import org.ton.crypto.base64 | |
import org.ton.lite.api.liteserver.LiteServerBlockTransactions | |
import org.ton.lite.api.liteserver.LiteServerTransactionId3 | |
import org.ton.lite.client.LiteClient | |
import reactor.kotlin.core.publisher.toFlux |
NewerOlder