Skip to content

Commit

Permalink
Update to TON-SDK 1.28.0 (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdorofeev authored Jan 2, 2022
1 parent b3a66d6 commit 9837c50
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ repositories {
```

```groovy
implementation "ee.nx-01.tonclient:ton-client-kotlin:0.0.38"
implementation "ee.nx-01.tonclient:ton-client-kotlin:0.0.43"
```

## Supported OS
Expand Down
11 changes: 9 additions & 2 deletions src/main/kotlin/ee/nx01/tonclient/abi/AbiModule.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package ee.nx01.tonclient.abi

import ee.nx01.tonclient.TonClient
import ee.nx01.tonclient.boc.BocCacheType

/**
# Module abi
Expand Down Expand Up @@ -133,4 +132,12 @@ class AbiModule(private val tonClient: TonClient) {
suspend fun decodeInitialData(params: ParamsOfDecodeInitialData): ResultOfDecodeInitialData {
return tonClient.request("abi.decode_initial_data", params)
}
}

/**
* Encodes initial account data with initial values for the contract's static variables and owner's public key
* into a data BOC that can be passed to encode_tvc function afterwards
*/
suspend fun encodeInitialData(params: ParamsOfEncodeInitialData): ResultOfEncodeInitialData {
return tonClient.request("abi.encode_initial_data", params)
}
}
11 changes: 11 additions & 0 deletions src/main/kotlin/ee/nx01/tonclient/abi/Types.kt
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,15 @@ data class ParamsOfUpdateInitialData(

data class ResultOfUpdateInitialData(
val data: String
)

data class ParamsOfEncodeInitialData(
val abi: Abi? = null,
val initialData: Any? = null,
val initialPubkey: String? = null,
val bocCache: BocCacheType? = null
)

data class ResultOfEncodeInitialData(
val data: String
)
Binary file modified src/main/resources/natives/linux_64/libtonclientjni.so
Binary file not shown.
Binary file modified src/main/resources/natives/osx_64/libtonclientjni.dylib
Binary file not shown.
Binary file modified src/main/resources/natives/windows_64/tonclientjni.dll
Binary file not shown.
6 changes: 3 additions & 3 deletions src/test/kotlin/ee/nx01/tonclient/TestConstants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package ee.nx01.tonclient
object TestConstants {
val WALLET_PHRASE = "defense talent layer admit setup virus deer buffalo timber ethics symbol cover"
val WALLET_ADDRESS = "0:7f458ae01e28573a181e2227dc77710d6421d4e103fdd3e023200aa4bce83950"
val MESSAGE_ID = "240e0219663b7253c41e76d581919a62cf447d0b8b5330b6da133b77acabc64b"
val BLOCK_ID = 35664f
val MESSAGE_ID = "3bb0b9c0d883c554ea072d5c7baae1d95b4e1f8648d4618e427ac478fccde2b7"
val BLOCK_ID = 461728f
val TRANSACTION_ID = "c289bae33734e680b73d5ec61c98baa6c8bc929b4536a2d43e7940d193d87e3c"
val KEY_BLOCK_ID = "3fbe311e2bb04c758d041e6890a000039039de3177f13aff0897587aeb25bb0e"
val KEY_BLOCK_ID = "ca4d47f585e5cefd90ba91ab3fed22d0ffd0bfa21f7c0f530bb7d381df8db7c5"
val WALLET_SECRET = "db16e21ee91b5064f6e31d9a2fb4771ce7f8acf14fe6d6ffade8ffcbeec31d69"
val WALLET_PUBLIC = "335c317bfef32545749a665bfec97f692fdc107d0867a1a1e1b2d2906b40d24c"

Expand Down
16 changes: 12 additions & 4 deletions src/test/kotlin/ee/nx01/tonclient/abi/AbiModuleTest.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package ee.nx01.tonclient.abi

import ee.nx01.tonclient.TonClient
import ee.nx01.tonclient.TonClientErrorCode
import ee.nx01.tonclient.TonClientException
import ee.nx01.tonclient.TonUtils
import ee.nx01.tonclient.*
import io.kotest.assertions.throwables.shouldThrow
import io.kotest.core.spec.style.StringSpec
import io.kotest.matchers.shouldBe
Expand Down Expand Up @@ -225,4 +222,15 @@ class AbiModuleTest : StringSpec({

}

"Should be able encode initial account data " {
val client = TonClient()

val abi = TonUtils.readAbi("setcodemultisig/SetcodeMultisigWallet.abi.json")

val response = client.abi.encodeInitialData(ParamsOfEncodeInitialData(initialData = mapOf("test" to "test"), abi = abi, initialPubkey = TestConstants.WALLET_PUBLIC))

response shouldNotBe null

}

})

0 comments on commit 9837c50

Please sign in to comment.