Skip to content

Commit

Permalink
Merge pull request #36 from radianceteam/develop
Browse files Browse the repository at this point in the history
1.41.0 implementation
  • Loading branch information
sdvornik authored Feb 16, 2023
2 parents 68ab2dd + f4031fc commit 1ad15ad
Show file tree
Hide file tree
Showing 25 changed files with 986 additions and 194 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
**Community links:**

[![Chat on Telegram](https://img.shields.io/badge/chat-on%20telegram-9cf.svg)](https://t.me/RADIANCE_TON_SDK)
[![SDK version](https://img.shields.io/badge/TON%20SDK%20version-1.38.0-green)](https://github.com/tonlabs/ever-sdk/tree/1.38.0)
[![SDK version](https://img.shields.io/badge/TON%20SDK%20version-1.41.0-green)](https://github.com/tonlabs/ever-sdk/tree/1.41.0)

**Everscale scala client** is a simple scala binding to the [ever-sdk](https://github.com/tonlabs/ever-sdk).

Features:
* All methods of the ever-sdk v 1.38.0
* All methods of the ever-sdk v 1.41.0
* Interaction with the ever-sdk through synchronous an asynchronous calls
* The every method contains inline-doc
* The automatic download of the ever-sdk library for the current environment
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ val root = project in file(".")
lazy val `everscale-client-scala` = project
.settings(
scalaVersion := "2.13.4",
version := "1.38.0",
version := "1.41.0",
libraryDependencies ++= Seq(
"io.circe" %% "circe-core" % circeVersion,
"io.circe" %% "circe-derivation" % circeDerivationVersion,
Expand Down
2 changes: 1 addition & 1 deletion ever-sdk
Original file line number Diff line number Diff line change
Expand Up @@ -150,26 +150,34 @@ class AbiModule(ctx: Context) {

/**
* Decodes message body using provided message BOC and ABI.
*
* @param abi
* abi
* @param message
* message
* @param allow_partial
* allow_partial
* @param function_name
* function_name
* @param data_layout
* data_layout
*/
def decodeMessage(
abi: AbiADT.Abi,
message: String,
allow_partial: Option[Boolean]
allow_partial: Option[Boolean],
function_name: Option[String],
data_layout: Option[DataLayoutEnum.DataLayout]
): Future[Either[Throwable, DecodedMessageBody]] = {
ctx.execAsync[ParamsOfDecodeMessage, DecodedMessageBody](
"abi.decode_message",
ParamsOfDecodeMessage(abi, message, allow_partial)
ParamsOfDecodeMessage(abi, message, allow_partial, function_name, data_layout)
)
}

/**
* Decodes message body using provided body BOC and ABI.
*
* @param abi
* abi
* @param body
Expand All @@ -178,16 +186,22 @@ class AbiModule(ctx: Context) {
* is_internal
* @param allow_partial
* allow_partial
* @param function_name
* function_name
* @param data_layout
* data_layout
*/
def decodeMessageBody(
abi: AbiADT.Abi,
body: String,
is_internal: Boolean,
allow_partial: Option[Boolean]
allow_partial: Option[Boolean],
function_name: Option[String],
data_layout: Option[DataLayoutEnum.DataLayout]
): Future[Either[Throwable, DecodedMessageBody]] = {
ctx.execAsync[ParamsOfDecodeMessageBody, DecodedMessageBody](
"abi.decode_message_body",
ParamsOfDecodeMessageBody(abi, body, is_internal, allow_partial)
ParamsOfDecodeMessageBody(abi, body, is_internal, allow_partial, function_name, data_layout)
)
}

Expand Down Expand Up @@ -363,25 +377,21 @@ class AbiModule(ctx: Context) {
* parameter with default value here>
*
* Default value is 0.
* @param signature_id
* signature_id
*/
def encodeMessage(
abi: AbiADT.Abi,
address: Option[String],
deploy_set: Option[DeploySet],
call_set: Option[CallSet],
signer: SignerADT.Signer,
processing_try_index: Option[Long]
processing_try_index: Option[Long],
signature_id: Option[Int]
): Future[Either[Throwable, ResultOfEncodeMessage]] = {
ctx.execAsync[ParamsOfEncodeMessage, ResultOfEncodeMessage](
"abi.encode_message",
ParamsOfEncodeMessage(
abi,
address,
deploy_set,
call_set,
signer,
processing_try_index
)
ParamsOfEncodeMessage(abi, address, deploy_set, call_set, signer, processing_try_index, signature_id)
)
}

Expand All @@ -408,25 +418,42 @@ class AbiModule(ctx: Context) {
* @param address
* Since ABI version 2.3 destination address of external inbound message is used in message body signature
* calculation. Should be provided when signed external inbound message body is created. Otherwise can be omitted.
* @param signature_id
* signature_id
*/
def encodeMessageBody(
abi: AbiADT.Abi,
call_set: CallSet,
is_internal: Boolean,
signer: SignerADT.Signer,
processing_try_index: Option[Long],
address: Option[String]
address: Option[String],
signature_id: Option[Int]
): Future[Either[Throwable, ResultOfEncodeMessageBody]] = {
ctx.execAsync[ParamsOfEncodeMessageBody, ResultOfEncodeMessageBody](
"abi.encode_message_body",
ParamsOfEncodeMessageBody(
abi,
call_set,
is_internal,
signer,
processing_try_index,
address
)
ParamsOfEncodeMessageBody(abi, call_set, is_internal, signer, processing_try_index, address, signature_id)
)
}

/**
* Extracts signature from message body and calculates hash to verify the signature
*
* @param abi
* abi
* @param message
* message
* @param signature_id
* signature_id
*/
def getSignatureData(
abi: AbiADT.Abi,
message: String,
signature_id: Option[Int]
): Future[Either[Throwable, ResultOfGetSignatureData]] = {
ctx.execAsync[ParamsOfGetSignatureData, ResultOfGetSignatureData](
"abi.get_signature_data",
ParamsOfGetSignatureData(abi, message, signature_id)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,23 @@ object CallSet {
implicit val encoder: Encoder[CallSet] = deriveEncoder[CallSet]
}

object DataLayoutEnum {
sealed trait DataLayout

/**
* Decode message body as function input parameters.
*/
case object Input extends DataLayout

/**
* Decode message body as function output.
*/
case object Output extends DataLayout

implicit val codec: Codec[DataLayout] =
extras.semiauto.deriveEnumerationCodec[DataLayout]
}

case class DecodedMessageBody(
body_type: MessageBodyTypeEnum.MessageBodyType,
name: String,
Expand Down Expand Up @@ -296,7 +313,13 @@ object ParamsOfDecodeInitialData {
deriveEncoder[ParamsOfDecodeInitialData]
}

case class ParamsOfDecodeMessage(abi: AbiADT.Abi, message: String, allow_partial: Option[Boolean])
case class ParamsOfDecodeMessage(
abi: AbiADT.Abi,
message: String,
allow_partial: Option[Boolean],
function_name: Option[String],
data_layout: Option[DataLayoutEnum.DataLayout]
)

object ParamsOfDecodeMessage {
implicit val encoder: Encoder[ParamsOfDecodeMessage] =
Expand All @@ -307,7 +330,9 @@ case class ParamsOfDecodeMessageBody(
abi: AbiADT.Abi,
body: String,
is_internal: Boolean,
allow_partial: Option[Boolean]
allow_partial: Option[Boolean],
function_name: Option[String],
data_layout: Option[DataLayoutEnum.DataLayout]
)

object ParamsOfDecodeMessageBody {
Expand Down Expand Up @@ -362,7 +387,8 @@ case class ParamsOfEncodeMessage(
deploy_set: Option[DeploySet],
call_set: Option[CallSet],
signer: SignerADT.Signer,
processing_try_index: Option[Long]
processing_try_index: Option[Long],
signature_id: Option[Int]
)

object ParamsOfEncodeMessage {
Expand All @@ -376,14 +402,22 @@ case class ParamsOfEncodeMessageBody(
is_internal: Boolean,
signer: SignerADT.Signer,
processing_try_index: Option[Long],
address: Option[String]
address: Option[String],
signature_id: Option[Int]
)

object ParamsOfEncodeMessageBody {
implicit val encoder: Encoder[ParamsOfEncodeMessageBody] =
deriveEncoder[ParamsOfEncodeMessageBody]
}

case class ParamsOfGetSignatureData(abi: AbiADT.Abi, message: String, signature_id: Option[Int])

object ParamsOfGetSignatureData {
implicit val encoder: Encoder[ParamsOfGetSignatureData] =
deriveEncoder[ParamsOfGetSignatureData]
}

case class ParamsOfUpdateInitialData(
abi: Option[AbiADT.Abi],
data: String,
Expand Down Expand Up @@ -493,6 +527,13 @@ object ResultOfEncodeMessageBody {
deriveDecoder[ResultOfEncodeMessageBody]
}

case class ResultOfGetSignatureData(signature: String, unsigned: String)

object ResultOfGetSignatureData {
implicit val decoder: Decoder[ResultOfGetSignatureData] =
deriveDecoder[ResultOfGetSignatureData]
}

case class ResultOfUpdateInitialData(data: String)

object ResultOfUpdateInitialData {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.radiance.jvm.client

import com.radiance.jvm._
import com.radiance.jvm.crypto._
import io.circe._
import io.circe.derivation._
import io.circe.generic.extras
Expand Down Expand Up @@ -28,6 +29,12 @@ object AppRequestResultADT {
extras.semiauto.deriveConfiguredEncoder[AppRequestResult]
}

case class BindingConfig(library: Option[String], version: Option[String])

object BindingConfig {
implicit val codec: Codec[BindingConfig] = deriveCodec[BindingConfig]
}

case class BocConfig(cache_max_size: Option[Long])

object BocConfig {
Expand All @@ -42,6 +49,7 @@ object BuildInfoDependency {
}

case class ClientConfig(
binding: Option[BindingConfig],
network: Option[NetworkConfig],
crypto: Option[CryptoConfig] = None,
abi: Option[AbiConfig] = None,
Expand Down Expand Up @@ -134,6 +142,10 @@ object ClientErrorCodeEnum {
val code: String = "17"
}

case object InvalidData extends ClientErrorCode {
override val code: String = "36"
}

case object InvalidHandle extends ClientErrorCode {
override val code: String = "34"
}
Expand Down Expand Up @@ -209,10 +221,9 @@ object ClientErrorCodeEnum {
}

case class CryptoConfig(
mnemonic_dictionary: Option[Long],
mnemonic_dictionary: Option[MnemonicDictionaryEnum.MnemonicDictionary],
mnemonic_word_count: Option[Long],
hdkey_derivation_path: Option[String],
hdkey_compliant: Option[Boolean]
hdkey_derivation_path: Option[String]
)

object CryptoConfig {
Expand All @@ -236,6 +247,7 @@ case class NetworkConfig(
queries_protocol: Option[NetworkQueriesProtocolEnum.NetworkQueriesProtocol] = None,
first_remp_status_timeout: Option[Long] = None,
next_remp_status_timeout: Option[Long] = None,
signature_id: Option[Int] = None,
access_key: Option[String] = None
)

Expand All @@ -256,7 +268,8 @@ object NetworkQueriesProtocolEnum {
case object HTTP extends NetworkQueriesProtocol

/**
* All GraphQL queries will be served using single web socket connection.
* All GraphQL queries will be served using single web socket connection. SDK is tested to reliably handle 5000
* parallel network requests (sending and processing messages, quering and awaiting blockchain data)
*/
case object WS extends NetworkQueriesProtocol

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ class CryptoModule(private val ctx: Context) {
*/
def hdkeyXprvFromMnemonic(
phrase: String,
dictionary: Option[Long],
dictionary: Option[MnemonicDictionaryEnum.MnemonicDictionary],
word_count: Option[Long]
): Either[Throwable, ResultOfHDKeyXPrvFromMnemonic] =
ctx.execSync[ParamsOfHDKeyXPrvFromMnemonic, ResultOfHDKeyXPrvFromMnemonic](
Expand All @@ -359,7 +359,7 @@ class CryptoModule(private val ctx: Context) {
def mnemonicDeriveSignKeys(
phrase: String,
path: Option[String],
dictionary: Option[Long],
dictionary: Option[MnemonicDictionaryEnum.MnemonicDictionary],
word_count: Option[Long]
): Either[Throwable, KeyPair] =
ctx.execSync[ParamsOfMnemonicDeriveSignKeys, KeyPair](
Expand All @@ -378,7 +378,7 @@ class CryptoModule(private val ctx: Context) {
*/
def mnemonicFromEntropy(
entropy: String,
dictionary: Option[Long],
dictionary: Option[MnemonicDictionaryEnum.MnemonicDictionary],
word_count: Option[Long]
): Either[Throwable, ResultOfMnemonicFromEntropy] =
ctx.execSync[ParamsOfMnemonicFromEntropy, ResultOfMnemonicFromEntropy](
Expand All @@ -392,7 +392,7 @@ class CryptoModule(private val ctx: Context) {
* Mnemonic word count
*/
def mnemonicFromRandom(
dictionary: Option[Long],
dictionary: Option[MnemonicDictionaryEnum.MnemonicDictionary],
word_count: Option[Long]
): Either[Throwable, ResultOfMnemonicFromRandom] =
ctx.execSync[ParamsOfMnemonicFromRandom, ResultOfMnemonicFromRandom](
Expand All @@ -412,7 +412,7 @@ class CryptoModule(private val ctx: Context) {
*/
def mnemonicVerify(
phrase: String,
dictionary: Option[Long],
dictionary: Option[MnemonicDictionaryEnum.MnemonicDictionary],
word_count: Option[Long]
): Either[Throwable, ResultOfMnemonicVerify] =
ctx.execSync[ParamsOfMnemonicVerify, ResultOfMnemonicVerify](
Expand All @@ -426,7 +426,7 @@ class CryptoModule(private val ctx: Context) {
* Dictionary identifier
*/
def mnemonicWords(
dictionary: Option[Long]
dictionary: Option[MnemonicDictionaryEnum.MnemonicDictionary]
): Either[Throwable, ResultOfMnemonicWords] =
ctx
.execSync[ParamsOfMnemonicWords, ResultOfMnemonicWords](
Expand Down
Loading

0 comments on commit 1ad15ad

Please sign in to comment.