Skip to content

Commit

Permalink
0.4.1 (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreypfau authored Feb 11, 2025
1 parent a02797e commit 9378974
Show file tree
Hide file tree
Showing 84 changed files with 1,559 additions and 1,421 deletions.
57 changes: 56 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,59 @@ local.properties
# Ignore Gradle build output directory
build

.jreleaser/config.toml
.jreleaser/config.tomlreplay_pid*
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
.idea/**/aws.xml
.idea/**/contentModel.xml
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
.idea/**/gradle.xml
.idea/**/libraries
cmake-build-*/
.idea/**/mongoSettings.xml
*.iws
out/
.idea_modules/
atlassian-ide-plugin.xml
.idea/replstate.xml
.idea/sonarlint/
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
.idea/httpRequests
.idea/caches/build_file_checksums.ser
**/build/
!src/**/build/
gradle-app.setting
!gradle-wrapper.jar
!gradle-wrapper.properties
.gradletasknamecache
.project
.classpath
.DS_Store
.AppleDouble
.LSOverride
Icon
._*
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,28 @@

### Core components

* `org.ton.kotlin:ton-kotlin-tvm:0.4.0` - TVM Primitives (Cells, BOC, etc.)
* `org.ton.kotlin:ton-kotlin-crypto:0.4.0` - Crypto primitives for TON (ED25519, SHA, etc.)
* `org.ton.kotlin:ton-kotlin-adnl:0.4.0` - ADNL (Abstract Datagram Network Layer) TON Network implementation
* `org.ton.kotlin:ton-kotlin-tvm:0.4.1` - TVM Primitives (Cells, BOC, etc.)
* `org.ton.kotlin:ton-kotlin-crypto:0.4.1` - Crypto primitives for TON (ED25519, SHA, etc.)
* `org.ton.kotlin:ton-kotlin-adnl:0.4.1` - ADNL (Abstract Datagram Network Layer) TON Network implementation

### API Interfaces

* `org.ton.kotlin:ton-kotlin-contract:0.4.0` - Smart-contracts API interface
* `org.ton.kotlin:ton-kotlin-liteclient:0.4.0` - Lite-client API implementation
* `org.ton.kotlin:ton-kotlin-contract:0.4.1` - Smart-contracts API interface
* `org.ton.kotlin:ton-kotlin-liteclient:0.4.1` - Lite-client API implementation

### TL-B (TL-Binary)

* `org.ton.kotlin:ton-kotlin-tlb:0.4.0` - TON TL-B (TL-Binary) serialization/deserialization
* `org.ton.kotlin:ton-kotlin-block-tlb:0.4.0` - Pre-generated TL-B schemas for TON Blockchain
* `org.ton.kotlin:ton-kotlin-hashmap-tlb:0.4.0` - Pre-generated TL-B schemas for TON Hashmap (also known as Dictionary)
* `org.ton.kotlin:ton-kotlin-tlb:0.4.1` - TON TL-B (TL-Binary) serialization/deserialization
* `org.ton.kotlin:ton-kotlin-block-tlb:0.4.1` - Pre-generated TL-B schemas for TON Blockchain
* `org.ton.kotlin:ton-kotlin-hashmap-tlb:0.4.1` - Pre-generated TL-B schemas for TON Hashmap (also known as Dictionary)

## Documentation

https://github.com/andreypfau/ton-kotlin/wiki/TON-Kotlin-documentation

<!-- Badges -->

[maven-central]: https://central.sonatype.com/artifact/org.ton.kotlin/ton-kotlin-tvm/0.4.0
[maven-central]: https://central.sonatype.com/artifact/org.ton/ton-kotlin-tvm/0.4.1

[license]: LICENSE

Expand Down
94 changes: 80 additions & 14 deletions block-tlb/src/Account.kt
Original file line number Diff line number Diff line change
@@ -1,20 +1,86 @@
@file:Suppress("OPT_IN_USAGE")

package org.ton.block

import kotlinx.serialization.json.JsonClassDiscriminator
import org.ton.tlb.TlbCombinator
import org.ton.tlb.TlbObject
import org.ton.tlb.providers.TlbCombinatorProvider
import org.ton.cell.CellBuilder
import org.ton.cell.CellSlice
import org.ton.cell.invoke
import org.ton.tlb.*
import org.ton.tlb.TlbConstructor

/**
* Existing account data.
*/
public data class Account(
/**
* Account address.
*/
val address: MsgAddressInt,

/**
* Storage statistics.
*/
val storageStat: StorageInfo,

/**
* Logical time after the last transaction execution.
*/
val lastTransLt: Long,

/**
* Account balance for all currencies.
*/
val balance: CurrencyCollection,

/**
* Account state.
*/
val state: AccountState
) {
public companion object : TlbCodec<Account?> by AccountInfoTlbConstructor.asNullable()

@JsonClassDiscriminator("@type")
@Deprecated("Use fields lastTransLt, balance, state instead")
val storage: AccountStorage // storage : AccountStorage
get() = AccountStorage(lastTransLt.toULong(), balance, state)

public sealed interface Account : TlbObject {
public companion object : TlbCombinatorProvider<Account> by AccountTlbCombinator
@Deprecated("Use address instead", ReplaceWith("address"))
val addr: MsgAddressInt
get() = address

val isActive: Boolean get() = storage.state is AccountActive
val isFrozen: Boolean get() = storage.state is AccountFrozen
val isUninit: Boolean get() = storage.state is AccountUninit
}

private object AccountTlbCombinator : TlbCombinator<Account>(
Account::class,
AccountNone::class to AccountNone,
AccountInfo::class to AccountInfo
)
public val Account?.balance: CurrencyCollection
get() = this?.balance ?: CurrencyCollection.ZERO

public val Account?.accountLastTransLt: Long
get() = this?.lastTransLt ?: 0

public val Account?.status: AccountStatus
get() = this?.state?.status ?: AccountStatus.NONEXIST

private object AccountInfoTlbConstructor : TlbConstructor<Account>(
schema = "account\$1 addr:MsgAddressInt storage_stat:StorageInfo storage:AccountStorage = Account;"
) {
override fun storeTlb(
cellBuilder: CellBuilder,
value: Account
) = cellBuilder {
storeTlb(MsgAddressInt, value.addr)
storeTlb(StorageInfo, value.storageStat)
storeULong(value.lastTransLt.toULong())
storeTlb(CurrencyCollection, value.balance)
storeTlb(AccountState, value.state)
}

override fun loadTlb(
cellSlice: CellSlice
): Account = cellSlice {
val addr = loadTlb(MsgAddressInt)
val storageStat = loadTlb(StorageInfo)
val lastTransLt = loadULong().toLong()
val balance = loadTlb(CurrencyCollection)
val state = loadTlb(AccountState)
Account(addr, storageStat, lastTransLt, balance, state)
}
}
2 changes: 2 additions & 0 deletions block-tlb/src/AccountActive.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public value class AccountActive(
@get:JvmName("value")
public val value: StateInit
) : AccountState {
override val status: AccountStatus get() = AccountStatus.ACTIVE

override fun print(printer: TlbPrettyPrinter): TlbPrettyPrinter {
return printer.type("account_active") {
value.print(printer)
Expand Down
2 changes: 2 additions & 0 deletions block-tlb/src/AccountFrozen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public data class AccountFrozen(
require(stateHash.size == 256) { "stateHash must be 256 bits long" }
}

override val status: AccountStatus get() = AccountStatus.FROZEN

override fun print(printer: TlbPrettyPrinter): TlbPrettyPrinter = printer.type("account_frozen") {
printer.field("state_hash", stateHash)
}
Expand Down
72 changes: 0 additions & 72 deletions block-tlb/src/AccountInfo.kt

This file was deleted.

27 changes: 0 additions & 27 deletions block-tlb/src/AccountNone.kt

This file was deleted.

5 changes: 5 additions & 0 deletions block-tlb/src/AccountState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import org.ton.tlb.providers.TlbCombinatorProvider

@JsonClassDiscriminator("@type")
public sealed interface AccountState : TlbObject {
/**
* Account status.
*/
public val status: AccountStatus

public companion object : TlbCombinatorProvider<AccountState> by AccountStateTlbCombinator
}

Expand Down
1 change: 1 addition & 0 deletions block-tlb/src/AccountStorage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import kotlin.jvm.JvmName

@SerialName("account_storage")

@Deprecated("Use fields from Account instead")
public data class AccountStorage(
@SerialName("last_trans_lt")
@get:JvmName("lastTransLt")
Expand Down
2 changes: 2 additions & 0 deletions block-tlb/src/AccountUninit.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import org.ton.tlb.providers.TlbConstructorProvider

@SerialName("account_uninit")
public object AccountUninit : AccountState, TlbConstructorProvider<AccountUninit> by AccountUninitTlbConstructor {
override val status: AccountStatus get() = AccountStatus.UNINIT

override fun print(printer: TlbPrettyPrinter): TlbPrettyPrinter {
return printer.type("account_uninit")
}
Expand Down
12 changes: 6 additions & 6 deletions block-tlb/src/TrActionPhase.kt → block-tlb/src/ActionPhase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import org.ton.tlb.providers.TlbConstructorProvider

@SerialName("tr_phase_action")

public data class TrActionPhase(
public data class ActionPhase(
val success: Boolean,
val valid: Boolean,
@SerialName("no_funds") val noFunds: Boolean,
Expand Down Expand Up @@ -57,10 +57,10 @@ public data class TrActionPhase(

override fun toString(): String = print().toString()

public companion object : TlbConstructorProvider<TrActionPhase> by TrActionPhaseTlbConstructor
public companion object : TlbConstructorProvider<ActionPhase> by TrActionPhaseTlbConstructor
}

private object TrActionPhaseTlbConstructor : TlbConstructor<TrActionPhase>(
private object TrActionPhaseTlbConstructor : TlbConstructor<ActionPhase>(
schema = "tr_phase_action\$_ success:Bool valid:Bool no_funds:Bool " +
"status_change:AccStatusChange " +
"total_fwd_fees:(Maybe Coins) total_action_fees:(Maybe Coins) " +
Expand All @@ -74,7 +74,7 @@ private object TrActionPhaseTlbConstructor : TlbConstructor<TrActionPhase>(

override fun storeTlb(
cellBuilder: CellBuilder,
value: TrActionPhase
value: ActionPhase
) = cellBuilder {
storeBit(value.success)
storeBit(value.valid)
Expand All @@ -94,7 +94,7 @@ private object TrActionPhaseTlbConstructor : TlbConstructor<TrActionPhase>(

override fun loadTlb(
cellSlice: CellSlice
): TrActionPhase = cellSlice {
): ActionPhase = cellSlice {
val success = loadBit()
val valid = loadBit()
val noFunds = loadBit()
Expand All @@ -109,7 +109,7 @@ private object TrActionPhaseTlbConstructor : TlbConstructor<TrActionPhase>(
val msgCreated = loadUInt(16).toInt()
val actionListHash = loadBits(256)
val totMsgSize = loadTlb(StorageUsedShort)
TrActionPhase(
ActionPhase(
success,
valid,
noFunds,
Expand Down
Loading

0 comments on commit 9378974

Please sign in to comment.