Skip to content

Commit

Permalink
Merge pull request #496 from tonlabs/1.24.0-rc
Browse files Browse the repository at this point in the history
Version 1.24.0
  • Loading branch information
d3p authored Oct 25, 2021
2 parents 746c8ed + db48774 commit a84e86f
Show file tree
Hide file tree
Showing 26 changed files with 1,063 additions and 510 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

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

## [1.24.0] – 2021-10-18

### New
- `boc.get_boc_depth` function to get depth of the provided boc.
- `boc.decode_tvc` function returns additional fields `code_hash`, `code_depth`, `data_hash`, `data_depth` and `compiler_version`

- **Debot module**:
- added `parse` function to Json interface.

## [1.23.0] – 2021-10-05

### New
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.23.0"
version = "1.24.0"
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.23.0"
version = "1.24.0"
authors = ["TON DEV SOLUTIONS LTD <[email protected]>"]
edition = "2018"

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.23.0"
version = "1.24.0"
authors = ["TON DEV SOLUTIONS LTD <[email protected]>"]
edition = "2018"

Expand Down
78 changes: 74 additions & 4 deletions docs/mod_boc.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ BOC manipulation module.

[get_boc_hash](#get_boc_hash) – Calculates BOC root hash

[get_boc_depth](#get_boc_depth) – Calculates BOC depth

[get_code_from_tvc](#get_code_from_tvc) – Extracts code from TVC contract image

[cache_get](#cache_get) – Get BOC from cache
Expand Down Expand Up @@ -57,6 +59,10 @@ BOC manipulation module.

[ResultOfGetBocHash](#ResultOfGetBocHash)

[ParamsOfGetBocDepth](#ParamsOfGetBocDepth)

[ResultOfGetBocDepth](#ResultOfGetBocDepth)

[ParamsOfGetCodeFromTvc](#ParamsOfGetCodeFromTvc)

[ResultOfGetCodeFromTvc](#ResultOfGetCodeFromTvc)
Expand Down Expand Up @@ -287,14 +293,40 @@ function get_boc_hash(
): Promise<ResultOfGetBocHash>;
```
### Parameters
- `boc`: _string_ – BOC encoded as base64
- `boc`: _string_ – BOC encoded as base64 or BOC handle


### Result

- `hash`: _string_ – BOC root hash encoded with hex


## get_boc_depth

Calculates BOC depth

```ts
type ParamsOfGetBocDepth = {
boc: string
}

type ResultOfGetBocDepth = {
depth: number
}

function get_boc_depth(
params: ParamsOfGetBocDepth,
): Promise<ResultOfGetBocDepth>;
```
### Parameters
- `boc`: _string_ – BOC encoded as base64 or BOC handle


### Result

- `depth`: _number_ – BOC root cell depth


## get_code_from_tvc

Extracts code from TVC contract image
Expand Down Expand Up @@ -500,11 +532,16 @@ type ParamsOfDecodeTvc = {

type ResultOfDecodeTvc = {
code?: string,
code_hash?: string,
code_depth?: number,
data?: string,
data_hash?: string,
data_depth?: number,
library?: string,
tick?: boolean,
tock?: boolean,
split_depth?: number
split_depth?: number,
compiler_version?: string
}

function decode_tvc(
Expand All @@ -519,13 +556,18 @@ function decode_tvc(
### Result

- `code`?: _string_ – Contract code BOC encoded as base64 or BOC handle
- `code_hash`?: _string_ – Contract code hash
- `code_depth`?: _number_ – Contract code depth
- `data`?: _string_ – Contract data BOC encoded as base64 or BOC handle
- `data_hash`?: _string_ – Contract data hash
- `data_depth`?: _number_ – Contract data depth
- `library`?: _string_ – Contract library BOC encoded as base64 or BOC handle
- `tick`?: _boolean_`special.tick` field.
<br>Specifies the contract ability to handle tick transactions
- `tock`?: _boolean_`special.tock` field.
<br>Specifies the contract ability to handle tock transactions
- `split_depth`?: _number_ – Is present and non-zero only in instances of large smart contracts
- `compiler_version`?: _string_ – Compiler version, for example 'sol 0.49.0'


## encode_tvc
Expand Down Expand Up @@ -706,7 +748,7 @@ type ParamsOfGetBocHash = {
boc: string
}
```
- `boc`: _string_ – BOC encoded as base64
- `boc`: _string_ – BOC encoded as base64 or BOC handle
## ResultOfGetBocHash
Expand All @@ -718,6 +760,24 @@ type ResultOfGetBocHash = {
- `hash`: _string_ – BOC root hash encoded with hex
## ParamsOfGetBocDepth
```ts
type ParamsOfGetBocDepth = {
boc: string
}
```
- `boc`: _string_ – BOC encoded as base64 or BOC handle
## ResultOfGetBocDepth
```ts
type ResultOfGetBocDepth = {
depth: number
}
```
- `depth`: _number_ – BOC root cell depth
## ParamsOfGetCodeFromTvc
```ts
type ParamsOfGetCodeFromTvc = {
Expand Down Expand Up @@ -928,21 +988,31 @@ type ParamsOfDecodeTvc = {
```ts
type ResultOfDecodeTvc = {
code?: string,
code_hash?: string,
code_depth?: number,
data?: string,
data_hash?: string,
data_depth?: number,
library?: string,
tick?: boolean,
tock?: boolean,
split_depth?: number
split_depth?: number,
compiler_version?: string
}
```
- `code`?: _string_ – Contract code BOC encoded as base64 or BOC handle
- `code_hash`?: _string_ – Contract code hash
- `code_depth`?: _number_ – Contract code depth
- `data`?: _string_ – Contract data BOC encoded as base64 or BOC handle
- `data_hash`?: _string_ – Contract data hash
- `data_depth`?: _number_ – Contract data depth
- `library`?: _string_ – Contract library BOC encoded as base64 or BOC handle
- `tick`?: _boolean_ – `special.tick` field.
<br>Specifies the contract ability to handle tick transactions
- `tock`?: _boolean_ – `special.tock` field.
<br>Specifies the contract ability to handle tock transactions
- `split_depth`?: _number_ – Is present and non-zero only in instances of large smart contracts
- `compiler_version`?: _string_ – Compiler version, for example 'sol 0.49.0'
## ParamsOfEncodeTvc
Expand Down
2 changes: 2 additions & 0 deletions docs/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ Where:

[get_boc_hash](mod_boc.md#get_boc_hash) – Calculates BOC root hash

[get_boc_depth](mod_boc.md#get_boc_depth) – Calculates BOC depth

[get_code_from_tvc](mod_boc.md#get_code_from_tvc) – Extracts code from TVC contract image

[cache_get](mod_boc.md#cache_get) – Get BOC from cache
Expand Down
16 changes: 9 additions & 7 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.23.0"
version = "1.24.0"
authors = ["TON DEV SOLUTIONS LTD <[email protected]>"]
edition = "2018"
license = "Apache-2.0"
Expand All @@ -20,12 +20,12 @@ api_derive = { path = "../api/derive" }
api_info = { path = "../api/info" }
ton_sdk = { path = "../ton_sdk", default-features = false }

ton_abi = { git = "https://github.com/tonlabs/ton-labs-abi.git" }
ton_block = { git = "https://github.com/tonlabs/ton-labs-block.git" }
ton_block_json = { git = "https://github.com/tonlabs/ton-labs-block-json.git" }
ton_executor = { git = "https://github.com/tonlabs/ton-labs-executor.git", default-features = false }
ton_types = { git = "https://github.com/tonlabs/ton-labs-types.git" }
ton_vm = { git = "https://github.com/tonlabs/ton-labs-vm.git", default-features = false }
ton_abi = { git = "https://github.com/tonlabs/ton-labs-abi.git", tag = "2.1.1" }
ton_block = { git = "https://github.com/tonlabs/ton-labs-block.git", tag = "1.7.27" }
ton_block_json = { git = "https://github.com/tonlabs/ton-labs-block-json.git", tag = "0.6.24" }
ton_executor = { git = "https://github.com/tonlabs/ton-labs-executor.git", tag = "1.15.31", default-features = false }
ton_types = { git = "https://github.com/tonlabs/ton-labs-types.git", tag = "1.10.10" }
ton_vm = { git = "https://github.com/tonlabs/ton-labs-vm.git", tag = "1.8.19", default-features = false }

lockfree = { git = "https://github.com/tonlabs/lockfree.git", package = "lockfree" }
sodalite = { git = "https://github.com/tonlabs/sodalite.git", features = ["rand"] }
Expand Down Expand Up @@ -63,6 +63,8 @@ serde_repr = "0.1.7"
sha2 = "0.9.5"
tokio = { version = "0.2.13", features = ["sync", "stream"], default-features = false }
zstd = { version = "0.7.0", default-features = false }
# TODO: remove fixed versioning when indexmap compilation issue is resolved
indexmap = "=1.6.2"
# TODO: remove fixed versioning when tiny-bip39 compilation issue is resolved
tiny-bip39 = "=0.7.3"

Expand Down
2 changes: 2 additions & 0 deletions ton_client/src/boc/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ use super::Error;
use lru::LruCache;
use std::collections::{HashMap, HashSet};
use std::sync::Arc;
#[allow(unused_imports)]
use std::str::FromStr;
use tokio::sync::{Mutex, RwLock};
use ton_types::{Cell, UInt256};

Expand Down
26 changes: 25 additions & 1 deletion ton_client/src/boc/hash.rs → ton_client/src/boc/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::error::ClientResult;

#[derive(Serialize, Deserialize, Clone, ApiType, Default)]
pub struct ParamsOfGetBocHash {
/// BOC encoded as base64
/// BOC encoded as base64 or BOC handle
pub boc: String,
}

Expand All @@ -37,3 +37,27 @@ pub async fn get_boc_hash(
let hash = cell.repr_hash().as_hex_string();
Ok(ResultOfGetBocHash { hash })
}

#[derive(Serialize, Deserialize, Clone, ApiType, Default)]
pub struct ParamsOfGetBocDepth {
/// BOC encoded as base64 or BOC handle
pub boc: String,
}

#[derive(Serialize, Deserialize, Clone, ApiType, Default)]
pub struct ResultOfGetBocDepth {
/// BOC root cell depth
pub depth: u32,
}

/// Calculates BOC depth
#[api_function]
pub async fn get_boc_depth(
context: std::sync::Arc<ClientContext>,
params: ParamsOfGetBocDepth,
) -> ClientResult<ResultOfGetBocDepth> {
let (_, cell) = deserialize_cell_from_boc(&context, &params.boc, "").await?;
Ok(ResultOfGetBocDepth {
depth: cell.repr_depth() as u32
})
}
4 changes: 3 additions & 1 deletion ton_client/src/boc/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
* limitations under the License.
*/

use crate::{ClientContext};
use crate::ClientContext;
use crate::boc::{BocCacheType, Error};
use crate::error::ClientResult;
#[allow(unused_imports)]
use std::str::FromStr;
use ton_block::{Deserializable, Serializable};
use ton_types::{UInt256, deserialize_tree_of_cells};

Expand Down
7 changes: 5 additions & 2 deletions ton_client/src/boc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub(crate) mod blockchain_config;
pub(crate) mod cache;
pub(crate) mod encode;
mod errors;
pub(crate) mod hash;
pub(crate) mod common;
pub(crate) mod internal;
pub(crate) mod parse;
pub(crate) mod tvc;
Expand All @@ -34,7 +34,10 @@ pub use cache::{
};
pub use encode::{encode_boc, BuilderOp, ParamsOfEncodeBoc, ResultOfEncodeBoc};
pub use errors::{Error, ErrorCode};
pub use hash::{get_boc_hash, ParamsOfGetBocHash, ResultOfGetBocHash};
pub use common::{
get_boc_depth, get_boc_hash,
ParamsOfGetBocDepth, ResultOfGetBocDepth, ParamsOfGetBocHash, ResultOfGetBocHash,
};
pub use parse::{
parse_account, parse_block, parse_message, parse_shardstate, parse_transaction, required_boc,
source_boc, ParamsOfParse, ParamsOfParseShardstate, ResultOfParse,
Expand Down
30 changes: 27 additions & 3 deletions ton_client/src/boc/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,20 @@ fn get_boc_hash() {
);
}

#[test]
fn get_boc_depth() {
let client = TestClient::new();

let result: super::ResultOfGetBocDepth = client.request(
"boc.get_boc_depth",
super::ParamsOfGetBocDepth {
boc: base64::encode(include_bytes!("test_data/account.boc"))
}
).unwrap();

assert_eq!(result.depth, 8);
}

#[test]
fn get_code_from_tvc() {
let client = TestClient::new();
Expand Down Expand Up @@ -667,26 +681,36 @@ fn check_encode_tvc(client: &TestClient, tvc: String, decoded: ResultOfDecodeTvc
fn test_tvc_encode() {
let client = TestClient::new();

let tvc = TestClient::tvc(crate::tests::GIVER_V2, Some(2));
let tvc = TestClient::tvc("t24_initdata", Some(2));
let decoded = ResultOfDecodeTvc {
code: Some(String::from("te6ccgECFAEAA6EAAib/APSkICLAAZL0oOGK7VNYMPShAwEBCvSkIPShAgAAAgEgBgQB/P9/Ie1E0CDXScIBn9P/0wD0Bfhqf/hh+Gb4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PgP8gCAB1pwIccAnSLQc9ch1wsAwAGQkOLgIdcNH5LyPOFTEcAAkODBAyKCEP////28sZLyPOAB8AH4R26S8jzeg=")),
data: Some(String::from("te6ccgEBBQEANQABAcABAgPPIAQCAQHeAwAD0CAAQdgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABA==")),
code: Some(String::from("te6ccgECEAEAAYkABCSK7VMg4wMgwP/jAiDA/uMC8gsNAgEPAoTtRNDXScMB+GYh2zzTAAGfgQIA1xgg+QFY+EL5EPKo3tM/AfhDIbnytCD4I4ED6KiCCBt3QKC58rT4Y9MfAds88jwFAwNK7UTQ10nDAfhmItDXCwOpOADcIccA4wIh1w0f8rwh4wMB2zzyPAwMAwIoIIIQBoFGw7rjAiCCEGi1Xz+64wIIBAIiMPhCbuMA+Ebyc9H4ANs88gAFCQIW7UTQ10nCAYqOgOILBgFccO1E0PQFcSGAQPQOk9cLB5Fw4vhqciGAQPQPjoDf+GuAQPQO8r3XC//4YnD4YwcBAogPA3Aw+Eby4Ez4Qm7jANHbPCKOICTQ0wH6QDAxyM+HIM6AYs9AXgHPkhoFGw7LB8zJcPsAkVvi4wDyAAsKCQAq+Ev4SvhD+ELIy//LP8+DywfMye1UAAj4SvhLACztRNDT/9M/0wAx0wfU0fhr+Gr4Y/hiAAr4RvLgTAIK9KQg9KEPDgAUc29sIDAuNTEuMAAA")),
code_depth: Some(7),
code_hash: Some(String::from("0ad23f96d7b1c1ce78dae573ac8cdf71523dc30f36316b5aaa5eb3cc540df0e0")),
data: Some(String::from("te6ccgEBAgEAKAABAcABAEPQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAg")),
data_depth: Some(1),
data_hash: Some(String::from("55a703465a160dce20481375de2e5b830c841c2787303835eb5821d62d65ca9d")),
library: None,
split_depth: None,
tick: None,
tock: None,
compiler_version: Some("sol 0.51.0".to_owned()),
};

check_encode_tvc(&client, tvc, decoded);

let tvc = base64::encode(include_bytes!("test_data/state_init_lib.boc"));
let decoded = ResultOfDecodeTvc {
code: Some(String::from("te6ccgEBBAEAhwABFP8A9KQT9LzyyAsBAgEgAwIA36X//3aiaGmP6f/o5CxSZ4WPkOeF/+T2qmRnxET/s2X/wQgC+vCAfQFANeegZLh9gEB354V/wQgD39JAfQFANeegZLhkZ82JA6Mrm6RBCAOt5or9AUA156BF6kMrY2N5YQO7e5NjIQxni2S4fYB9gEAAAtI=")),
code_depth: Some(2),
code_hash: Some(String::from("45910e27fe37d8dcf1fac777ebb3bda38ae1ea8389f81bfb1bc0079f3f67ef5b")),
data: Some(String::from("te6ccgEBAQEAJgAASBHvVgMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==")),
data_depth: Some(0),
data_hash: Some(String::from("97bfef744b0d45f78b901e2997fb55f6dbc1d396a8d2f8f4c3a5468c010db67a")),
library: Some(String::from("te6ccgEBBgEAYAACAWIEAQFCv0EkKSBepm1vIATt+lcPb1az6F5ZuqG++8c7faXVW9xhAgEEEjQDAARWeAFCv1ou71BWd19blXL/OtY90qcdH7KByhd6Xhx0cw7MsuUTBQAPq6yrrausq6g=")),
split_depth: None,
tick: Some(true),
tock: Some(true),
compiler_version: None,
};

check_encode_tvc(&client, tvc, decoded);
Expand Down
Loading

0 comments on commit a84e86f

Please sign in to comment.