Skip to content

Commit

Permalink
Update to SDK 1.9 (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdorofeev authored Mar 6, 2021
1 parent 57518b2 commit c15f18b
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 7 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.nx01.tonclient:ton-client-kotlin:0.0.20"
implementation "ee.nx01.tonclient:ton-client-kotlin:0.0.22"
```

## Supported OS
Expand Down
26 changes: 24 additions & 2 deletions src/main/kotlin/ee/nx01/tonclient/abi/AbiModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -82,5 +106,3 @@ class AbiModule(private val tonClient: TonClient) {
return tonClient.request("abi.attach_signature_to_message_body", params)
}
}


18 changes: 17 additions & 1 deletion src/main/kotlin/ee/nx01/tonclient/abi/Types.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -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
)
3 changes: 2 additions & 1 deletion src/main/kotlin/ee/nx01/tonclient/tvm/Types.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ data class ParamsOfRunGet(
val account: String,
val functionName: String,
val input: Map<String, Any>? = null,
val executionOptions: ExecutionOptions? = null
val executionOptions: ExecutionOptions? = null,
val tupleListAsArray: Boolean? = false
)

data class ResultOfRunExecutor(
Expand Down
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.
30 changes: 29 additions & 1 deletion src/test/kotlin/ee/nx01/tonclient/abi/AbiModuleTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class CryptoModuleTest : StringSpec({
ParamsOfHDKeyPublicFromXPrv("xprvA3rCvXp37apThYKCF3SQKDfQXH3mZKv2vo1z1tGG4kf5VAfCM6AJa3eg1XEJRbZ4jTjCUrNXzMv8ihqSrv928Uz1DautEjQsPQ6CioSbRzY")
)

response.public shouldBe "038919503f8e39a4ff0fc676870537e6b1481d67829582aa5a14914fbc251a55f0"
response.public shouldBe "7ef364d02bdf489a56714553dd66260666d52d4b03c5abd6ce62ec7ffbc0a2ca"

}

Expand Down

0 comments on commit c15f18b

Please sign in to comment.