-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b7fdb85
commit 0ba5b90
Showing
83 changed files
with
1,503 additions
and
1,420 deletions.
There are no files selected for viewing
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
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
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) | ||
} | ||
} |
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
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
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
Oops, something went wrong.