Skip to content

Commit

Permalink
Merge pull request #419 from tonlabs/1.16.1-rc
Browse files Browse the repository at this point in the history
Version 1.16.1
  • Loading branch information
d3p authored Jun 17, 2021
2 parents cc80fea + f46c85e commit b4db499
Show file tree
Hide file tree
Showing 33 changed files with 764 additions and 116 deletions.
18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,28 @@

All notable changes to this project will be documented in this file.

## [1.16.1] – 2021-06-16

### New
- `timeout` option to `query_transaction_tree` – timeout used to limit waiting time for the next
message and transaction in the transaction tree.

### Improved

- Improved error messages regarding ABI and JSON interface. SDK now shows additional tips for the user in cases of
errors.

### Fixed
- Warnings in Rust 1.52+. Little fixes in the documentation.
- `total_output` field in fees was always 0.
- `query_transaction_tree` didn't wait for messages.

## [1.16.0] – 2021-05-25

### New

- `query_transaction_tree` function that returns messages and transactions tree produced
by the specified message was added to `query` module. [See the documentation](docs/mod_net.md#query_transaction_tree)
by the specified message was added to `net` module. [See the documentation](docs/mod_net.md#query_transaction_tree)

### Fixed

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ DApp etc.
Client Library exposes all the functionality through a few of exported functions. All
interaction with library is performed using JSON-RPC like protocol.

Library works over [GraphQL API](https://docs.ton.dev/86757ecb2/p/70a850-introduction) of [TON OS DApp Server](https://github.com/tonlabs/TON-OS-DApp-Server).
Library works over [GraphQL API](https://docs.ton.dev/86757ecb2/p/793337-ton-os-api) of [TON OS DApp Server](https://github.com/tonlabs/TON-OS-DApp-Server).
So, it can be used to interact directly with TON OS Clouds:
- [Freeton](https://main.ton.dev/graphql)
- [Devnet](https://net.ton.dev/graphql)
Expand Down
2 changes: 1 addition & 1 deletion api/derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "api_derive"
version = "1.16.0"
version = "1.16.1"
authors = ["TON DEV SOLUTIONS LTD <[email protected]>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion api/info/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "api_info"
version = "1.16.0"
version = "1.16.1"
authors = ["TON DEV SOLUTIONS LTD <[email protected]>"]
edition = "2018"

Expand Down
24 changes: 24 additions & 0 deletions api/info/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ pub struct API {
pub modules: Vec<Module>,
}

impl API {
pub fn find_type(&self, name: &str) -> Option<&Field> {
// TODO: Searching now is O(n), can speed up, if needed
for module in &self.modules {
if let Some(field) = module.find_type(name) {
return Some(field);
}
}
None
}
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Module {
pub name: String,
Expand All @@ -15,6 +27,18 @@ pub struct Module {
pub functions: Vec<Function>,
}

impl Module {
pub fn find_type(&self, name: &str) -> Option<&Field> {
// TODO: Searching now is O(n), can speed up, if needed
for field in &self.types {
if field.name == name {
return Some(field);
}
}
None
}
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Function {
pub name: String,
Expand Down
2 changes: 1 addition & 1 deletion api/test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "api_test"
version = "1.16.0"
version = "1.16.1"
authors = ["TON DEV SOLUTIONS LTD <[email protected]>"]
edition = "2018"

Expand Down
8 changes: 5 additions & 3 deletions api/test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ pub enum EnumWithTypes {
Baz { a: String, b: String },
}

#[doc(summary = "Foo")]
/// Foo
///
/// Foo struct
#[derive(Serialize, Deserialize, ApiType, Default)]
pub struct Foo {
Expand All @@ -38,8 +39,9 @@ pub struct Foo {

#[derive(Serialize, Deserialize, ApiType, Default)]
struct Bar {
#[doc(summary = "summary")]
#[doc = "description"]
/// summary
///
/// description
pub abi: Option<serde_json::Value>,
pub function_name: Option<String>,
pub message: Foo,
Expand Down
40 changes: 29 additions & 11 deletions docs/mod_crypto.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Crypto functions.


## Functions
[factorize](#factorize)Performs prime factorization – decomposition of a composite number into a product of smaller prime integers (factors). See [https://en.wikipedia.org/wiki/Integer_factorization]
[factorize](#factorize)Integer factorization

[modular_power](#modular_power)Performs modular exponentiation for big integers (`base`^`exponent` mod `modulus`). See [https://en.wikipedia.org/wiki/Modular_exponentiation]
[modular_power](#modular_power)Modular exponentiation

[ton_crc16](#ton_crc16) – Calculates CRC16 using TON algorithm.

Expand All @@ -24,7 +24,7 @@ Crypto functions.

[sha512](#sha512) – Calculates SHA512 hash of the specified data.

[scrypt](#scrypt)Derives key from `password` and `key` using `scrypt` algorithm. See [https://en.wikipedia.org/wiki/Scrypt].
[scrypt](#scrypt)Perform `scrypt` encryption

[nacl_sign_keypair_from_secret_key](#nacl_sign_keypair_from_secret_key) – Generates a key pair for signing from the secret key

Expand All @@ -50,13 +50,13 @@ Crypto functions.

[mnemonic_words](#mnemonic_words) – Prints the list of words from the specified dictionary

[mnemonic_from_random](#mnemonic_from_random) – Generates a random mnemonic from the specified dictionary and word count
[mnemonic_from_random](#mnemonic_from_random) – Generates a random mnemonic

[mnemonic_from_entropy](#mnemonic_from_entropy) – Generates mnemonic from pre-generated entropy

[mnemonic_verify](#mnemonic_verify)The phrase supplied will be checked for word length and validated according to the checksum specified in BIP0039.
[mnemonic_verify](#mnemonic_verify)Validates a mnemonic phrase

[mnemonic_derive_sign_keys](#mnemonic_derive_sign_keys)Validates the seed phrase, generates master key and then derives the key pair from the master key and the specified path
[mnemonic_derive_sign_keys](#mnemonic_derive_sign_keys)Derives a key pair for signing from the seed phrase

[hdkey_xprv_from_mnemonic](#hdkey_xprv_from_mnemonic) – Generates an extended master private key that will be the root for all the derived keys

Expand Down Expand Up @@ -213,7 +213,11 @@ Crypto functions.
# Functions
## factorize

Performs prime factorization – decomposition of a composite number into a product of smaller prime integers (factors). See [https://en.wikipedia.org/wiki/Integer_factorization]
Integer factorization

Performs prime factorization – decomposition of a composite number
into a product of smaller prime integers (factors).
See [https://en.wikipedia.org/wiki/Integer_factorization]

```ts
type ParamsOfFactorize = {
Expand All @@ -239,7 +243,10 @@ function factorize(

## modular_power

Performs modular exponentiation for big integers (`base`^`exponent` mod `modulus`). See [https://en.wikipedia.org/wiki/Modular_exponentiation]
Modular exponentiation

Performs modular exponentiation for big integers (`base`^`exponent` mod `modulus`).
See [https://en.wikipedia.org/wiki/Modular_exponentiation]

```ts
type ParamsOfModularPower = {
Expand Down Expand Up @@ -482,7 +489,10 @@ function sha512(

## scrypt

Derives key from `password` and `key` using `scrypt` algorithm. See [https://en.wikipedia.org/wiki/Scrypt].
Perform `scrypt` encryption

Derives key from `password` and `key` using `scrypt` algorithm.
See [https://en.wikipedia.org/wiki/Scrypt].

# Arguments
- `log_n` - The log2 of the Scrypt parameter `N`
Expand Down Expand Up @@ -889,6 +899,8 @@ function mnemonic_words(

## mnemonic_from_random

Generates a random mnemonic

Generates a random mnemonic from the specified dictionary and word count

```ts
Expand Down Expand Up @@ -948,7 +960,10 @@ function mnemonic_from_entropy(

## mnemonic_verify

The phrase supplied will be checked for word length and validated according to the checksum specified in BIP0039.
Validates a mnemonic phrase

The phrase supplied will be checked for word length and validated according to the checksum
specified in BIP0039.

```ts
type ParamsOfMnemonicVerify = {
Expand Down Expand Up @@ -978,7 +993,10 @@ function mnemonic_verify(

## mnemonic_derive_sign_keys

Validates the seed phrase, generates master key and then derives the key pair from the master key and the specified path
Derives a key pair for signing from the seed phrase

Validates the seed phrase, generates master key and then derives
the key pair from the master key and the specified path

```ts
type ParamsOfMnemonicDeriveSignKeys = {
Expand Down
10 changes: 8 additions & 2 deletions docs/mod_net.md
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,8 @@ So the application have to continue retrieval for missing messages if it require
```ts
type ParamsOfQueryTransactionTree = {
in_msg: string,
abi_registry?: Abi[]
abi_registry?: Abi[],
timeout?: number
}

type ResultOfQueryTransactionTree = {
Expand All @@ -523,6 +524,8 @@ function query_transaction_tree(
### Parameters
- `in_msg`: _string_ – Input message id.
- `abi_registry`?: _[Abi](mod_abi.md#Abi)[]_ – List of contract ABIs that will be used to decode message bodies. Library will try to decode each returned message body using any ABI from the registry.
- `timeout`?: _number_ – Timeout used to limit waiting time for the missing messages and transaction.
<br>If some of the following messages and transactions are missing yet<br>The maximum waiting time is regulated by this option.<br><br>Default value is 60000 (1 min).


### Result
Expand Down Expand Up @@ -915,11 +918,14 @@ type ParamsOfQueryCounterparties = {
```ts
type ParamsOfQueryTransactionTree = {
in_msg: string,
abi_registry?: Abi[]
abi_registry?: Abi[],
timeout?: number
}
```
- `in_msg`: _string_ – Input message id.
- `abi_registry`?: _[Abi](mod_abi.md#Abi)[]_ – List of contract ABIs that will be used to decode message bodies. Library will try to decode each returned message body using any ABI from the registry.
- `timeout`?: _number_ – Timeout used to limit waiting time for the missing messages and transaction.
<br>If some of the following messages and transactions are missing yet<br>The maximum waiting time is regulated by this option.<br><br>Default value is 60000 (1 min).
## ResultOfQueryTransactionTree
Expand Down
4 changes: 2 additions & 2 deletions docs/mod_processing.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function wait_for_transaction(
<br>You must provide the same value as the `send_message` has returned.
- `send_events`: _boolean_ – Flag that enables/disables intermediate events
- `sending_endpoints`?: _string[]_ – The list of endpoints to which the message was sent.
<br>You must provide the same value as the `send_message` has returned.
<br>Use this field to get more informative errors.<br>Provide the same value as the `send_message` has returned.<br>If the message was not delivered (expired), SDK will log the endpoint URLs, used for its sending.
- `responseHandler`?: _[ResponseHandler](modules.md#ResponseHandler)_ – additional responses handler.

### Result
Expand Down Expand Up @@ -450,7 +450,7 @@ type ParamsOfWaitForTransaction = {
<br>You must provide the same value as the `send_message` has returned.
- `send_events`: _boolean_ – Flag that enables/disables intermediate events
- `sending_endpoints`?: _string[]_ – The list of endpoints to which the message was sent.
<br>You must provide the same value as the `send_message` has returned.
<br>Use this field to get more informative errors.<br>Provide the same value as the `send_message` has returned.<br>If the message was not delivered (expired), SDK will log the endpoint URLs, used for its sending.
## ParamsOfProcessMessage
Expand Down
12 changes: 6 additions & 6 deletions docs/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ Where:

## [crypto](mod_crypto.md) – Crypto functions.

[factorize](mod_crypto.md#factorize)Performs prime factorization – decomposition of a composite number into a product of smaller prime integers (factors). See [https://en.wikipedia.org/wiki/Integer_factorization]
[factorize](mod_crypto.md#factorize)Integer factorization

[modular_power](mod_crypto.md#modular_power)Performs modular exponentiation for big integers (`base`^`exponent` mod `modulus`). See [https://en.wikipedia.org/wiki/Modular_exponentiation]
[modular_power](mod_crypto.md#modular_power)Modular exponentiation

[ton_crc16](mod_crypto.md#ton_crc16) – Calculates CRC16 using TON algorithm.

Expand All @@ -43,7 +43,7 @@ Where:

[sha512](mod_crypto.md#sha512) – Calculates SHA512 hash of the specified data.

[scrypt](mod_crypto.md#scrypt)Derives key from `password` and `key` using `scrypt` algorithm. See [https://en.wikipedia.org/wiki/Scrypt].
[scrypt](mod_crypto.md#scrypt)Perform `scrypt` encryption

[nacl_sign_keypair_from_secret_key](mod_crypto.md#nacl_sign_keypair_from_secret_key) – Generates a key pair for signing from the secret key

Expand All @@ -69,13 +69,13 @@ Where:

[mnemonic_words](mod_crypto.md#mnemonic_words) – Prints the list of words from the specified dictionary

[mnemonic_from_random](mod_crypto.md#mnemonic_from_random) – Generates a random mnemonic from the specified dictionary and word count
[mnemonic_from_random](mod_crypto.md#mnemonic_from_random) – Generates a random mnemonic

[mnemonic_from_entropy](mod_crypto.md#mnemonic_from_entropy) – Generates mnemonic from pre-generated entropy

[mnemonic_verify](mod_crypto.md#mnemonic_verify)The phrase supplied will be checked for word length and validated according to the checksum specified in BIP0039.
[mnemonic_verify](mod_crypto.md#mnemonic_verify)Validates a mnemonic phrase

[mnemonic_derive_sign_keys](mod_crypto.md#mnemonic_derive_sign_keys)Validates the seed phrase, generates master key and then derives the key pair from the master key and the specified path
[mnemonic_derive_sign_keys](mod_crypto.md#mnemonic_derive_sign_keys)Derives a key pair for signing from the seed phrase

[hdkey_xprv_from_mnemonic](mod_crypto.md#hdkey_xprv_from_mnemonic) – Generates an extended master private key that will be the root for all the derived keys

Expand Down
4 changes: 2 additions & 2 deletions ton_client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ton_client"
version = "1.16.0"
version = "1.16.1"
authors = ["TON DEV SOLUTIONS LTD <[email protected]>"]
edition = "2018"
license = "Apache-2.0"
Expand Down Expand Up @@ -59,7 +59,7 @@ serde_derive = "1.0.91"
serde_json = "1.0.41"
sha2 = "0.8"
tokio = { version = "0.2.13", features = ["sync", "stream"], default-features = false }
zstd = { version = "0.7.0+zstd.1.4.9", default-features = false }
zstd = { version = "0.7.0", default-features = false }

# optional for std
reqwest = { version = "0.10.4", optional = true }
Expand Down
3 changes: 2 additions & 1 deletion ton_client/src/abi/decode_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ fn decode_body(
)
} else {
Err(Error::invalid_message_for_decode(
"The message body does not match the specified ABI",
"The message body does not match the specified ABI.\n
Tip: Please check that you specified message's body, not full BOC.",
))
}
}
35 changes: 35 additions & 0 deletions ton_client/src/abi/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -787,3 +787,38 @@ async fn test_encode_internal_message_deploy(

Ok(())
}

#[test]
fn test_tips() {
let client = TestClient::new();
let (abi, _tvc) = TestClient::package(EVENTS, Some(2));
let err = client.request::<_, DecodedMessageBody>(
"abi.decode_message",
ParamsOfDecodeMessage {
abi: abi.clone(),
message: "te6ccgEBAgEAlgAB4a3f2/jCeWWvgMoAXOakv3VSD56sQrDPT76n1cbrSvpZ0BCs0KEUy2Duvo3zPExePONW3TYy0MCA1i+FFRXcSIXTHxAj/Hd67jWQF7peccWoU/dbMCBJBB6YdPCVZcJlJkAAAF0ZyXLg19VzGQVviwSgAQBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=".into(),
..Default::default()
},
).expect_err("Error expected");

assert!(
err.message.contains("Tip: Please check that you have specified the message's BOC, not body, as a parameter."),
"{}",
err.message
);

let err = client.request::<_, DecodedMessageBody>(
"abi.decode_message_body",
ParamsOfDecodeMessageBody {
abi: abi.clone(),
body: "te6ccgEBAwEAvAABRYgAC31qq9KF9Oifst6LU9U6FQSQQRlCSEMo+A3LN5MvphIMAQHhrd/b+MJ5Za+AygBc5qS/dVIPnqxCsM9PvqfVxutK+lnQEKzQoRTLYO6+jfM8TF4841bdNjLQwIDWL4UVFdxIhdMfECP8d3ruNZAXul5xxahT91swIEkEHph08JVlwmUmQAAAXRnJcuDX1XMZBW+LBKACAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==".into(),
..Default::default()
},
).expect_err("Error expected");

assert!(
err.message.contains("Tip: Please check that you specified message's body, not full BOC."),
"{}",
err.message
);
}
Loading

0 comments on commit b4db499

Please sign in to comment.