diff --git a/README.md b/README.md index eeb7a4e..f64fe93 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ repositories { ``` ```groovy -implementation "ee.nx01.tonclient:ton-client-kotlin:0.0.20" +implementation "ee.nx01.tonclient:ton-client-kotlin:0.0.22" ``` ## 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 7897f82..39cfd33 100644 --- a/src/main/kotlin/ee/nx01/tonclient/abi/AbiModule.kt +++ b/src/main/kotlin/ee/nx01/tonclient/abi/AbiModule.kt @@ -44,6 +44,30 @@ class AbiModule(private val tonClient: TonClient) { return tonClient.request("abi.encode_message_body", params) } + /** + * ## encode_internal_message + + Encodes an internal ABI-compatible message + + Allows to encode deploy and function call messages. + + Use cases include messages of any possible type: + - deploy with initial function call (i.e. `constructor` or any other function that is used for some kind + of initialization); + - deploy without initial function call; + - simple function call + + There is an optional public key can be provided in deploy set in order to substitute one + in TVM file. + + Public key resolving priority: + 1. Public key from deploy set. + 2. Public key, specified in TVM file. + */ + suspend fun encodeInternalMessage(params: ParamsOfEncodeInternalMessage): ResultOfEncodeInternalMessage { + return tonClient.request("abi.encode_internal_message", params) + } + /** * ## decode_message_body * Decodes message body using provided body BOC and ABI. @@ -82,5 +106,3 @@ class AbiModule(private val tonClient: TonClient) { return tonClient.request("abi.attach_signature_to_message_body", params) } } - - diff --git a/src/main/kotlin/ee/nx01/tonclient/abi/Types.kt b/src/main/kotlin/ee/nx01/tonclient/abi/Types.kt index b04be1f..8f19766 100644 --- a/src/main/kotlin/ee/nx01/tonclient/abi/Types.kt +++ b/src/main/kotlin/ee/nx01/tonclient/abi/Types.kt @@ -41,7 +41,7 @@ data class StateInitParams( data class ParamsOfEncodeMessageBody( val abi: Abi, val callSet: CallSet, - val isInternal: Boolean = true, + val isInternal: Boolean = false, val signer: Signer, val processingTryIndex: Int? = null ) @@ -178,4 +178,20 @@ data class FunctionHeader( val expire: Long?, val time: Long?, val pubkey: String?, +) + +data class ParamsOfEncodeInternalMessage( + val abi: Abi, + val address: String? = null, + val deploySet: DeploySet? = null, + val callSet: CallSet? = null, + val value: String, + val bounce: Boolean? = null, + val enableIhr: Boolean? = null +) + +data class ResultOfEncodeInternalMessage( + val message: String, + val address: String, + val messageId: String ) \ No newline at end of file diff --git a/src/main/kotlin/ee/nx01/tonclient/tvm/Types.kt b/src/main/kotlin/ee/nx01/tonclient/tvm/Types.kt index da3a158..deb3de9 100644 --- a/src/main/kotlin/ee/nx01/tonclient/tvm/Types.kt +++ b/src/main/kotlin/ee/nx01/tonclient/tvm/Types.kt @@ -27,7 +27,8 @@ data class ParamsOfRunGet( val account: String, val functionName: String, val input: Map? = null, - val executionOptions: ExecutionOptions? = null + val executionOptions: ExecutionOptions? = null, + val tupleListAsArray: Boolean? = false ) data class ResultOfRunExecutor( diff --git a/src/main/resources/natives/linux_64/libtonclientjni.so b/src/main/resources/natives/linux_64/libtonclientjni.so index f351b7a..f5b69cb 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 f338ba4..b9b5ecb 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 56a062f..d434b8d 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/abi/AbiModuleTest.kt b/src/test/kotlin/ee/nx01/tonclient/abi/AbiModuleTest.kt index fe2944d..99ae7ec 100644 --- a/src/test/kotlin/ee/nx01/tonclient/abi/AbiModuleTest.kt +++ b/src/test/kotlin/ee/nx01/tonclient/abi/AbiModuleTest.kt @@ -73,6 +73,34 @@ class AbiModuleTest : StringSpec({ } + + "Should be able encode internal message" { + val client = TonClient() + + val params = ParamsOfEncodeInternalMessage( + abi = TonUtils.readAbi("setcodemultisig/SetcodeMultisigWallet.abi.json"), + address = "0:ee946898dee44b9b7d4ed452fae4dba773ec339974b2e75223e868214ac01dfe", + callSet = CallSet( + "submitTransaction", + input = mapOf( + "dest" to "0:ee946898dee44b9b7d4ed452fae4dba773ec339974b2e75223e868214ac01dfe", + "value" to TonUtils.convertToken(BigDecimal(0.1)), + "bounce" to false, + "allBalance" to false, + "payload" to "" + ), + header = null + ), + value = TonUtils.convertToken(BigDecimal.ONE).toString() + ) + + val response = client.abi.encodeInternalMessage(params) + + response shouldNotBe null + response.message shouldNotBe null + + } + "Should be able decode message body" { val client = TonClient() @@ -174,7 +202,7 @@ class AbiModuleTest : StringSpec({ client.abi.decodeMessage(ParamsOfDecodeMessage(abi, message)) } - exception.tonClientError.code shouldBe TonClientErrorCode.InvalidBase64 + exception.tonClientError.code shouldBe TonClientErrorCode.InvalidMessage } diff --git a/src/test/kotlin/ee/nx01/tonclient/crypto/CryptoModuleTest.kt b/src/test/kotlin/ee/nx01/tonclient/crypto/CryptoModuleTest.kt index 0c7d4ea..edc545f 100644 --- a/src/test/kotlin/ee/nx01/tonclient/crypto/CryptoModuleTest.kt +++ b/src/test/kotlin/ee/nx01/tonclient/crypto/CryptoModuleTest.kt @@ -168,7 +168,7 @@ class CryptoModuleTest : StringSpec({ ParamsOfHDKeyPublicFromXPrv("xprvA3rCvXp37apThYKCF3SQKDfQXH3mZKv2vo1z1tGG4kf5VAfCM6AJa3eg1XEJRbZ4jTjCUrNXzMv8ihqSrv928Uz1DautEjQsPQ6CioSbRzY") ) - response.public shouldBe "038919503f8e39a4ff0fc676870537e6b1481d67829582aa5a14914fbc251a55f0" + response.public shouldBe "7ef364d02bdf489a56714553dd66260666d52d4b03c5abd6ce62ec7ffbc0a2ca" }