diff --git a/README.md b/README.md index bcc7f1d..233ab2d 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/main/kotlin/ee/nx01/tonclient/abi/AbiModule.kt b/src/main/kotlin/ee/nx01/tonclient/abi/AbiModule.kt index 8300f3f..528e28d 100644 --- a/src/main/kotlin/ee/nx01/tonclient/abi/AbiModule.kt +++ b/src/main/kotlin/ee/nx01/tonclient/abi/AbiModule.kt @@ -1,7 +1,6 @@ package ee.nx01.tonclient.abi import ee.nx01.tonclient.TonClient -import ee.nx01.tonclient.boc.BocCacheType /** # Module abi @@ -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) + } +} \ No newline at end of file diff --git a/src/main/kotlin/ee/nx01/tonclient/abi/Types.kt b/src/main/kotlin/ee/nx01/tonclient/abi/Types.kt index 00d0e36..8dbee14 100644 --- a/src/main/kotlin/ee/nx01/tonclient/abi/Types.kt +++ b/src/main/kotlin/ee/nx01/tonclient/abi/Types.kt @@ -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 ) \ No newline at end of file diff --git a/src/main/resources/natives/linux_64/libtonclientjni.so b/src/main/resources/natives/linux_64/libtonclientjni.so index 6c8b00f..4085267 100644 Binary files a/src/main/resources/natives/linux_64/libtonclientjni.so and b/src/main/resources/natives/linux_64/libtonclientjni.so differ diff --git a/src/main/resources/natives/osx_64/libtonclientjni.dylib b/src/main/resources/natives/osx_64/libtonclientjni.dylib index 22d3f11..6898809 100644 Binary files a/src/main/resources/natives/osx_64/libtonclientjni.dylib and b/src/main/resources/natives/osx_64/libtonclientjni.dylib differ diff --git a/src/main/resources/natives/windows_64/tonclientjni.dll b/src/main/resources/natives/windows_64/tonclientjni.dll index 5fcd0f5..dc88554 100644 Binary files a/src/main/resources/natives/windows_64/tonclientjni.dll and b/src/main/resources/natives/windows_64/tonclientjni.dll differ diff --git a/src/test/kotlin/ee/nx01/tonclient/TestConstants.kt b/src/test/kotlin/ee/nx01/tonclient/TestConstants.kt index 8479096..7890e75 100644 --- a/src/test/kotlin/ee/nx01/tonclient/TestConstants.kt +++ b/src/test/kotlin/ee/nx01/tonclient/TestConstants.kt @@ -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" diff --git a/src/test/kotlin/ee/nx01/tonclient/abi/AbiModuleTest.kt b/src/test/kotlin/ee/nx01/tonclient/abi/AbiModuleTest.kt index bb843ae..7c47d2a 100644 --- a/src/test/kotlin/ee/nx01/tonclient/abi/AbiModuleTest.kt +++ b/src/test/kotlin/ee/nx01/tonclient/abi/AbiModuleTest.kt @@ -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 @@ -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 + + } + }) \ No newline at end of file