Skip to content

Commit f70e3a9

Browse files
authored
Merge pull request #1012 from tonlabs/1.44.0-rc
Version 1.44.0
2 parents 49ebb97 + 7478254 commit f70e3a9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+705
-567
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,23 @@
33
All notable changes to this project will be documented in this file.
44

55

6+
## [1.44.0] – 2023-07-12
7+
8+
### New
9+
10+
- Ability to call async functions via `tc_request_sync`.
11+
- In rust API, the following functions become sync (slight breaking):
12+
`abi::encode_internal_message`, `abi::attach_signature_to_message_body`, `abi::attach_signature`,
13+
`abi::decode_message`, `abi::decode_message_body`, `abi::decode_account_data`,
14+
`abi::update_initial_data`, `abi::encode_initial_data`, `abi::decode_initial_data`,
15+
`abi::decode_boc`, `abi::encode_boc`, `boc::decode_tvc`, `boc::parse_message`, `boc::parse_transaction`,
16+
`boc::parse_account`, `boc::parse_block`, `boc::parse_shardstate`, `boc::get_blockchain_config`,
17+
`boc::get_boc_hash`, `boc::get_code_from_tvc`, `boc::cache_get`, `boc::cache_set`, `boc::cache_unpin`,
18+
`boc::encode_boc`, `boc::get_code_salt`, `boc::set_code_salt`, `boc::decode_state_init`, `boc::encode_state_init`,
19+
`boc::encode_external_in_message`, `boc::get_compiler_version`, `processing::monitor_messages`,
20+
`processing::get_monitor_info`, `processing::cancel_monitor`
21+
- Code generator for `modules.ts` produces `_sync` wrapper for all API functions.
22+
623
## [1.43.3] – 2023-06-24
724

825
### Fixed

Cargo.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/derive/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
authors = [ 'TON Labs LTD <[email protected]>' ]
33
edition = '2018'
44
name = 'api_derive'
5-
version = '1.43.3'
5+
version = '1.44.0'
66

77
[dependencies]
88
quote = '1.0.26'

api/info/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
authors = [ 'TON Labs LTD <[email protected]>' ]
33
edition = '2018'
44
name = 'api_info'
5-
version = '1.43.3'
5+
version = '1.44.0'
66

77
[dependencies]
88
serde = '1.0.115'

api/test/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
authors = [ 'TON Labs LTD <[email protected]>' ]
33
edition = '2018'
44
name = 'api_test'
5-
version = '1.43.3'
5+
version = '1.44.0'
66

77
[dependencies]
88
serde = '1.0.115'

ton_client/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = 'ton_client'
3-
version = '1.43.3'
3+
version = '1.44.0'
44
authors = [ 'TON Labs LTD <[email protected]>' ]
55
edition = '2018'
66
license = 'Apache-2.0'

ton_client/src/abi/decode_boc.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub struct ParamsOfDecodeBoc {
1818
pub boc: String,
1919
// Do not check if all BOC data is parsed by provided parameters set
2020
// Set it to `true` if don't need to decode the whole BOC data or if you need
21-
// to handle conditional parsing (when TLB constructor or flags should be
21+
// to handle conditional parsing (when TLB constructor or flags should be
2222
// checked to decide how to parse remaining BOC data)
2323
pub allow_partial: bool,
2424
}
@@ -30,29 +30,29 @@ pub struct ResultOfDecodeBoc {
3030
}
3131

3232
/// Decodes BOC into JSON as a set of provided parameters.
33-
///
34-
/// Solidity functions use ABI types for [builder encoding](https://github.com/tonlabs/TON-Solidity-Compiler/blob/master/API.md#tvmbuilderstore).
35-
/// The simplest way to decode such a BOC is to use ABI decoding.
36-
/// ABI has it own rules for fields layout in cells so manually encoded
37-
/// BOC can not be described in terms of ABI rules.
38-
///
39-
/// To solve this problem we introduce a new ABI type `Ref(<ParamType>)`
40-
/// which allows to store `ParamType` ABI parameter in cell reference and, thus,
41-
/// decode manually encoded BOCs. This type is available only in `decode_boc` function
33+
///
34+
/// Solidity functions use ABI types for [builder encoding](https://github.com/tonlabs/TON-Solidity-Compiler/blob/master/API.md#tvmbuilderstore).
35+
/// The simplest way to decode such a BOC is to use ABI decoding.
36+
/// ABI has it own rules for fields layout in cells so manually encoded
37+
/// BOC can not be described in terms of ABI rules.
38+
///
39+
/// To solve this problem we introduce a new ABI type `Ref(<ParamType>)`
40+
/// which allows to store `ParamType` ABI parameter in cell reference and, thus,
41+
/// decode manually encoded BOCs. This type is available only in `decode_boc` function
4242
/// and will not be available in ABI messages encoding until it is included into some ABI revision.
43-
///
44-
/// Such BOC descriptions covers most users needs. If someone wants to decode some BOC which
45-
/// can not be described by these rules (i.e. BOC with TLB containing constructors of flags
46-
/// defining some parsing conditions) then they can decode the fields up to fork condition,
47-
/// check the parsed data manually, expand the parsing schema and then decode the whole BOC
43+
///
44+
/// Such BOC descriptions covers most users needs. If someone wants to decode some BOC which
45+
/// can not be described by these rules (i.e. BOC with TLB containing constructors of flags
46+
/// defining some parsing conditions) then they can decode the fields up to fork condition,
47+
/// check the parsed data manually, expand the parsing schema and then decode the whole BOC
4848
/// with the full schema.
4949
5050
#[api_function]
51-
pub async fn decode_boc(
51+
pub fn decode_boc(
5252
context: Arc<ClientContext>,
5353
params: ParamsOfDecodeBoc,
5454
) -> ClientResult<ResultOfDecodeBoc> {
55-
let (_, data) = deserialize_cell_from_boc(&context, &params.boc, "").await?;
55+
let (_, data) = deserialize_cell_from_boc(&context, &params.boc, "")?;
5656

5757
let mut abi_params = Vec::with_capacity(params.params.len());
5858
for param in params.params {

ton_client/src/abi/decode_data.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ pub struct ResultOfDecodeAccountData {
3535
///
3636
/// Note: this feature requires ABI 2.1 or higher.
3737
#[api_function]
38-
pub async fn decode_account_data(
38+
pub fn decode_account_data(
3939
context: Arc<ClientContext>,
4040
params: ParamsOfDecodeAccountData,
4141
) -> ClientResult<ResultOfDecodeAccountData> {
42-
let (_, data) = deserialize_cell_from_boc(&context, &params.data, "contract data").await?;
42+
let (_, data) = deserialize_cell_from_boc(&context, &params.data, "contract data")?;
4343
let abi = params.abi.abi()?;
4444

4545
let tokens = abi.decode_storage_fields(slice_from_cell(data)?, params.allow_partial)

ton_client/src/abi/decode_message.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -100,19 +100,19 @@ pub struct ParamsOfDecodeMessage {
100100
/// Function name or function id if is known in advance
101101
pub function_name: Option<String>,
102102

103-
// For external (inbound and outbound) messages data_layout parameter is ignored.
104-
// For internal: by default SDK tries to decode as output and then if decode is not successfull - tries as input.
105-
// If explicitly specified then tries only the specified layout.
103+
// For external (inbound and outbound) messages data_layout parameter is ignored.
104+
// For internal: by default SDK tries to decode as output and then if decode is not successfull - tries as input.
105+
// If explicitly specified then tries only the specified layout.
106106
pub data_layout: Option<DataLayout>,
107107
}
108108

109109
/// Decodes message body using provided message BOC and ABI.
110110
#[api_function]
111-
pub async fn decode_message(
111+
pub fn decode_message(
112112
context: Arc<ClientContext>,
113113
params: ParamsOfDecodeMessage,
114114
) -> ClientResult<DecodedMessageBody> {
115-
let (abi, message) = prepare_decode(&context, &params).await?;
115+
let (abi, message) = prepare_decode(&context, &params)?;
116116
if let Some(body) = message.body() {
117117
let data_layout = match message.header() {
118118
ton_block::CommonMsgInfo::ExtInMsgInfo(_) => Some(DataLayout::Input),
@@ -151,29 +151,28 @@ pub struct ParamsOfDecodeMessageBody {
151151
pub function_name: Option<String>,
152152

153153
// By default SDK tries to decode as output and then if decode is not successfull - tries as input.
154-
// If explicitly specified then tries only the specified layout.
154+
// If explicitly specified then tries only the specified layout.
155155
pub data_layout: Option<DataLayout>,
156156
}
157157

158158
/// Decodes message body using provided body BOC and ABI.
159159
#[api_function]
160-
pub async fn decode_message_body(
160+
pub fn decode_message_body(
161161
context: Arc<ClientContext>,
162162
params: ParamsOfDecodeMessageBody,
163163
) -> ClientResult<DecodedMessageBody> {
164164
let abi = params.abi.abi()?;
165-
let (_, body) = deserialize_cell_from_boc(&context, &params.body, "message body").await?;
165+
let (_, body) = deserialize_cell_from_boc(&context, &params.body, "message body")?;
166166
let body = slice_from_cell(body)?;
167167
decode_body(abi, body, params.is_internal, params.allow_partial, params.function_name, params.data_layout)
168168
}
169169

170-
async fn prepare_decode(
170+
fn prepare_decode(
171171
context: &ClientContext,
172172
params: &ParamsOfDecodeMessage,
173173
) -> ClientResult<(AbiContract, ton_block::Message)> {
174174
let abi = params.abi.abi()?;
175175
let message = deserialize_object_from_boc(context, &params.message, "message")
176-
.await
177176
.map_err(|x| Error::invalid_message_for_decode(x))?;
178177
Ok((abi, message.object))
179178
}
@@ -300,7 +299,7 @@ fn decode_with_function(
300299
function_name,
301300
tokens: decoded,
302301
};
303-
DecodedMessageBody::new(MessageBodyType::Event, decoded, None)
302+
DecodedMessageBody::new(MessageBodyType::Event, decoded, None)
304303
}
305304
}
306305
}
@@ -358,7 +357,7 @@ pub async fn get_signature_data(
358357
params: ParamsOfGetSignatureData,
359358
) -> ClientResult<ResultOfGetSignatureData> {
360359
let abi = params.abi.abi()?;
361-
let message: ton_block::Message = deserialize_object_from_boc(&context, &params.message, "message").await?.object;
360+
let message: ton_block::Message = deserialize_object_from_boc(&context, &params.message, "message")?.object;
362361
if let Some(body) = message.body() {
363362
let address = message.dst()
364363
.ok_or_else(|| Error::invalid_message_for_decode(
@@ -367,13 +366,13 @@ pub async fn get_signature_data(
367366
let (signature, hash) = abi.get_signature_data(body, Some(address))
368367
.map_err(|err| Error::invalid_message_for_decode(err))?;
369368
let unsigned = extend_data_to_sign(&context, params.signature_id, Some(hash)).await?;
370-
Ok(ResultOfGetSignatureData {
371-
signature: hex::encode(&signature),
369+
Ok(ResultOfGetSignatureData {
370+
signature: hex::encode(&signature),
372371
unsigned: base64::encode(&unsigned.unwrap()),
373372
})
374373
} else {
375374
Err(Error::invalid_message_for_decode(
376375
"The message body is empty",
377376
))
378377
}
379-
}
378+
}

ton_client/src/abi/encode_account.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,25 +84,25 @@ async fn state_init_from_message(
8484
let (message, _) = message.encode(context).await?;
8585
let message = deserialize_object_from_boc::<ton_block::Message>(
8686
context, &message, "message"
87-
).await?.object;
87+
)?.object;
8888
message
8989
.state_init()
9090
.map(|x| x.clone())
9191
.ok_or(Error::invalid_message_for_decode("missing `state_init`"))
9292
}
9393

94-
async fn state_init_from_bocs(
94+
fn state_init_from_bocs(
9595
context: &ClientContext,
9696
code: &String,
9797
data: &String,
9898
library: &Option<String>,
9999
) -> ClientResult<StateInit> {
100100
Ok(StateInit {
101-
code: Some(deserialize_cell_from_boc(context, code, "account code").await?.1),
102-
data: Some(deserialize_cell_from_boc(context, data, "account data").await?.1),
101+
code: Some(deserialize_cell_from_boc(context, code, "account code")?.1),
102+
data: Some(deserialize_cell_from_boc(context, data, "account data")?.1),
103103
library: if let Some(library) = library {
104104
StateInitLib::with_hashmap(
105-
Some(deserialize_cell_from_boc(context, library, "library").await?.1)
105+
Some(deserialize_cell_from_boc(context, library, "library")?.1)
106106
)
107107
} else {
108108
StateInitLib::default()
@@ -112,13 +112,13 @@ async fn state_init_from_bocs(
112112
})
113113
}
114114

115-
async fn state_init_from_tvc(
115+
fn state_init_from_tvc(
116116
context: &ClientContext,
117117
tvc: &String,
118118
public_key: &Option<String>,
119119
init_params: &Option<StateInitParams>,
120120
) -> ClientResult<StateInit> {
121-
let (_, cell) = deserialize_cell_from_boc(context, tvc, "TVC image").await?;
121+
let (_, cell) = deserialize_cell_from_boc(context, tvc, "TVC image")?;
122122
let public_key = public_key
123123
.as_ref()
124124
.map(|x| decode_public_key(x))
@@ -160,12 +160,12 @@ pub async fn encode_account(
160160
code,
161161
data,
162162
library,
163-
} => state_init_from_bocs(&context, code, data, library).await,
163+
} => state_init_from_bocs(&context, code, data, library),
164164
StateInitSource::Tvc {
165165
tvc,
166166
public_key,
167167
init_params,
168-
} => state_init_from_tvc(&context, tvc, public_key, init_params).await,
168+
} => state_init_from_tvc(&context, tvc, public_key, init_params),
169169
}?;
170170
let id = state_init.hash().map_err(|err| Error::invalid_tvc_image(err))?;
171171
let address = MsgAddressInt::with_standart(None, 0, id.clone().into()).unwrap();
@@ -175,7 +175,7 @@ pub async fn encode_account(
175175
.map_err(|err| Error::invalid_tvc_image(err))?;
176176
account.set_last_tr_time(params.last_trans_lt.unwrap_or(0));
177177
Ok(ResultOfEncodeAccount {
178-
account: serialize_object_to_boc(&context, &account, "account", params.boc_cache).await?,
178+
account: serialize_object_to_boc(&context, &account, "account", params.boc_cache)?,
179179
id: id.as_hex_string(),
180180
})
181181
}

0 commit comments

Comments
 (0)