Skip to content

Commit 9378974

Browse files
authored
0.4.1 (#128)
1 parent a02797e commit 9378974

File tree

84 files changed

+1559
-1421
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+1559
-1421
lines changed

.gitignore

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,59 @@ local.properties
2929
# Ignore Gradle build output directory
3030
build
3131

32-
.jreleaser/config.toml
32+
.jreleaser/config.tomlreplay_pid*
33+
.idea/**/workspace.xml
34+
.idea/**/tasks.xml
35+
.idea/**/usage.statistics.xml
36+
.idea/**/dictionaries
37+
.idea/**/shelf
38+
.idea/**/aws.xml
39+
.idea/**/contentModel.xml
40+
.idea/**/dataSources/
41+
.idea/**/dataSources.ids
42+
.idea/**/dataSources.local.xml
43+
.idea/**/sqlDataSources.xml
44+
.idea/**/dynamic.xml
45+
.idea/**/uiDesigner.xml
46+
.idea/**/dbnavigator.xml
47+
.idea/**/gradle.xml
48+
.idea/**/libraries
49+
cmake-build-*/
50+
.idea/**/mongoSettings.xml
51+
*.iws
52+
out/
53+
.idea_modules/
54+
atlassian-ide-plugin.xml
55+
.idea/replstate.xml
56+
.idea/sonarlint/
57+
com_crashlytics_export_strings.xml
58+
crashlytics.properties
59+
crashlytics-build.properties
60+
fabric.properties
61+
.idea/httpRequests
62+
.idea/caches/build_file_checksums.ser
63+
**/build/
64+
!src/**/build/
65+
gradle-app.setting
66+
!gradle-wrapper.jar
67+
!gradle-wrapper.properties
68+
.gradletasknamecache
69+
.project
70+
.classpath
71+
.DS_Store
72+
.AppleDouble
73+
.LSOverride
74+
Icon
75+
._*
76+
.DocumentRevisions-V100
77+
.fseventsd
78+
.Spotlight-V100
79+
.TemporaryItems
80+
.Trashes
81+
.VolumeIcon.icns
82+
.com.apple.timemachine.donotpresent
83+
.AppleDB
84+
.AppleDesktop
85+
Network Trash Folder
86+
Temporary Items
87+
.apdisk

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,28 @@
1010

1111
### Core components
1212

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

1717
### API Interfaces
1818

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

2222
### TL-B (TL-Binary)
2323

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

2828
## Documentation
2929

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

3232
<!-- Badges -->
3333

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

3636
[license]: LICENSE
3737

block-tlb/src/Account.kt

Lines changed: 80 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,86 @@
1-
@file:Suppress("OPT_IN_USAGE")
2-
31
package org.ton.block
42

5-
import kotlinx.serialization.json.JsonClassDiscriminator
6-
import org.ton.tlb.TlbCombinator
7-
import org.ton.tlb.TlbObject
8-
import org.ton.tlb.providers.TlbCombinatorProvider
3+
import org.ton.cell.CellBuilder
4+
import org.ton.cell.CellSlice
5+
import org.ton.cell.invoke
6+
import org.ton.tlb.*
7+
import org.ton.tlb.TlbConstructor
8+
9+
/**
10+
* Existing account data.
11+
*/
12+
public data class Account(
13+
/**
14+
* Account address.
15+
*/
16+
val address: MsgAddressInt,
17+
18+
/**
19+
* Storage statistics.
20+
*/
21+
val storageStat: StorageInfo,
22+
23+
/**
24+
* Logical time after the last transaction execution.
25+
*/
26+
val lastTransLt: Long,
27+
28+
/**
29+
* Account balance for all currencies.
30+
*/
31+
val balance: CurrencyCollection,
32+
33+
/**
34+
* Account state.
35+
*/
36+
val state: AccountState
37+
) {
38+
public companion object : TlbCodec<Account?> by AccountInfoTlbConstructor.asNullable()
939

10-
@JsonClassDiscriminator("@type")
40+
@Deprecated("Use fields lastTransLt, balance, state instead")
41+
val storage: AccountStorage // storage : AccountStorage
42+
get() = AccountStorage(lastTransLt.toULong(), balance, state)
1143

12-
public sealed interface Account : TlbObject {
13-
public companion object : TlbCombinatorProvider<Account> by AccountTlbCombinator
44+
@Deprecated("Use address instead", ReplaceWith("address"))
45+
val addr: MsgAddressInt
46+
get() = address
47+
48+
val isActive: Boolean get() = storage.state is AccountActive
49+
val isFrozen: Boolean get() = storage.state is AccountFrozen
50+
val isUninit: Boolean get() = storage.state is AccountUninit
1451
}
1552

16-
private object AccountTlbCombinator : TlbCombinator<Account>(
17-
Account::class,
18-
AccountNone::class to AccountNone,
19-
AccountInfo::class to AccountInfo
20-
)
53+
public val Account?.balance: CurrencyCollection
54+
get() = this?.balance ?: CurrencyCollection.ZERO
55+
56+
public val Account?.accountLastTransLt: Long
57+
get() = this?.lastTransLt ?: 0
58+
59+
public val Account?.status: AccountStatus
60+
get() = this?.state?.status ?: AccountStatus.NONEXIST
61+
62+
private object AccountInfoTlbConstructor : TlbConstructor<Account>(
63+
schema = "account\$1 addr:MsgAddressInt storage_stat:StorageInfo storage:AccountStorage = Account;"
64+
) {
65+
override fun storeTlb(
66+
cellBuilder: CellBuilder,
67+
value: Account
68+
) = cellBuilder {
69+
storeTlb(MsgAddressInt, value.addr)
70+
storeTlb(StorageInfo, value.storageStat)
71+
storeULong(value.lastTransLt.toULong())
72+
storeTlb(CurrencyCollection, value.balance)
73+
storeTlb(AccountState, value.state)
74+
}
75+
76+
override fun loadTlb(
77+
cellSlice: CellSlice
78+
): Account = cellSlice {
79+
val addr = loadTlb(MsgAddressInt)
80+
val storageStat = loadTlb(StorageInfo)
81+
val lastTransLt = loadULong().toLong()
82+
val balance = loadTlb(CurrencyCollection)
83+
val state = loadTlb(AccountState)
84+
Account(addr, storageStat, lastTransLt, balance, state)
85+
}
86+
}

block-tlb/src/AccountActive.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public value class AccountActive(
1919
@get:JvmName("value")
2020
public val value: StateInit
2121
) : AccountState {
22+
override val status: AccountStatus get() = AccountStatus.ACTIVE
23+
2224
override fun print(printer: TlbPrettyPrinter): TlbPrettyPrinter {
2325
return printer.type("account_active") {
2426
value.print(printer)

block-tlb/src/AccountFrozen.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public data class AccountFrozen(
2121
require(stateHash.size == 256) { "stateHash must be 256 bits long" }
2222
}
2323

24+
override val status: AccountStatus get() = AccountStatus.FROZEN
25+
2426
override fun print(printer: TlbPrettyPrinter): TlbPrettyPrinter = printer.type("account_frozen") {
2527
printer.field("state_hash", stateHash)
2628
}

block-tlb/src/AccountInfo.kt

Lines changed: 0 additions & 72 deletions
This file was deleted.

block-tlb/src/AccountNone.kt

Lines changed: 0 additions & 27 deletions
This file was deleted.

block-tlb/src/AccountState.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ import org.ton.tlb.providers.TlbCombinatorProvider
1010

1111
@JsonClassDiscriminator("@type")
1212
public sealed interface AccountState : TlbObject {
13+
/**
14+
* Account status.
15+
*/
16+
public val status: AccountStatus
17+
1318
public companion object : TlbCombinatorProvider<AccountState> by AccountStateTlbCombinator
1419
}
1520

block-tlb/src/AccountStorage.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import kotlin.jvm.JvmName
1111

1212
@SerialName("account_storage")
1313

14+
@Deprecated("Use fields from Account instead")
1415
public data class AccountStorage(
1516
@SerialName("last_trans_lt")
1617
@get:JvmName("lastTransLt")

block-tlb/src/AccountUninit.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import org.ton.tlb.providers.TlbConstructorProvider
1010

1111
@SerialName("account_uninit")
1212
public object AccountUninit : AccountState, TlbConstructorProvider<AccountUninit> by AccountUninitTlbConstructor {
13+
override val status: AccountStatus get() = AccountStatus.UNINIT
14+
1315
override fun print(printer: TlbPrettyPrinter): TlbPrettyPrinter {
1416
return printer.type("account_uninit")
1517
}

0 commit comments

Comments
 (0)