Skip to content

Commit

Permalink
Merge pull request #518 from tonlabs/1.26.0-rc
Browse files Browse the repository at this point in the history
Version 1.26.0
  • Loading branch information
d3p authored Nov 25, 2021
2 parents 88ecc11 + 5bff949 commit 412d24c
Show file tree
Hide file tree
Showing 47 changed files with 2,039 additions and 522 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

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

## [1.26.0] – 2021-11-25

### New
- **Debot module**:
- Аdded `allow_no_signature` parameter to `decode_and_fix_ext_msg()` and
`onerror_id` return value to `prepare_ext_in_message()` inner functions used in TS4.
- Added support for async external calls.
- `Query` interface extended with `waitForCollection` and `query` methods. `waitForCollection` allows to wait
for completion of async external calls.
- Added support for DeBots with ABI 2.2.
- Function [`proofs.proof_message_data`](./docs/reference/types-and-methods/mod_proofs.md#proof_message_data) which proves message data, retrieved
from Graphql API.

## [1.25.0] – 2021-11-08

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

Expand Down
8 changes: 6 additions & 2 deletions docs/reference/types-and-methods/mod_debot.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ enum DebotErrorCode {
DebotInvalidMsg = 809,
DebotExternalCallFailed = 810,
DebotBrowserCallbackFailed = 811,
DebotOperationRejected = 812
DebotOperationRejected = 812,
DebotNoCode = 813
}
```
One of the following value:
Expand All @@ -243,6 +244,7 @@ One of the following value:
- `DebotExternalCallFailed = 810`
- `DebotBrowserCallbackFailed = 811`
- `DebotOperationRejected = 812`
- `DebotNoCode = 813`


## DebotHandle
Expand Down Expand Up @@ -293,7 +295,8 @@ type DebotInfo = {
language?: string,
dabi?: string,
icon?: string,
interfaces: string[]
interfaces: string[],
dabiVersion: string
}
```
- `name`?: _string_ – DeBot short name.
Expand All @@ -307,6 +310,7 @@ type DebotInfo = {
- `dabi`?: _string_ – String with DeBot ABI.
- `icon`?: _string_ – DeBot icon.
- `interfaces`: _string[]_ – Vector with IDs of DInterfaces used by DeBot.
- `dabiVersion`: _string_ – ABI version ("x.y") supported by DeBot
## DebotActivity
Expand Down
57 changes: 49 additions & 8 deletions docs/reference/types-and-methods/mod_proofs.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@

[proof_transaction_data](#proof_transaction_data) – Proves that a given transaction's data, which is queried from TONOS API, can be trusted.

[proof_message_data](#proof_message_data) – Proves that a given message's data, which is queried from TONOS API, can be trusted.

## Types
[ProofsErrorCode](#proofserrorcode)

[ParamsOfProofBlockData](#paramsofproofblockdata)

[ParamsOfProofTransactionData](#paramsofprooftransactiondata)

[ParamsOfProofMessageData](#paramsofproofmessagedata)


# Functions
## proof_block_data
Expand Down Expand Up @@ -94,25 +98,20 @@ function proof_block_data(

Proves that a given transaction's data, which is queried from TONOS API, can be trusted.

This function requests the corresponding block, checks block proofs, ensures that given transaction
exists in the proven block and compares given data with the proven.
This function requests the corresponding block, checks block proofs, ensures that given
transaction exists in the proven block and compares given data with the proven.
If the given data differs from the proven, the exception will be thrown.
The input parameter is a single transaction's JSON object (see params description),
which was queried from TONOS API using functions such as `net.query`, `net.query_collection`
or `net.wait_for_collection`.

If transaction's BOC and/or `block_id` are not provided in the JSON, they will be queried from
TONOS API (in this case it is required to provide at least `id` of transaction).
TONOS API.

Please note, that joins (like `account`, `in_message`, `out_messages`, etc. in `Transaction`
entity) are separated entities and not supported, so function will throw an exception in a case
if JSON being checked has such entities in it.

If `cache_in_local_storage` in config is set to `true` (default), downloaded proofs and
master-chain BOCs are saved into the persistent local storage (e.g. file system for native
environments or browser's IndexedDB for the web); otherwise all the data is cached only in
memory in current client's context and will be lost after destruction of the client.

For more information about proofs checking, see description of `proof_block_data` function.

```ts
Expand All @@ -128,6 +127,39 @@ function proof_transaction_data(
- `transaction`: _any_ – Single transaction's data as queried from DApp server, without modifications. The required fields are `id` and/or top-level `boc`, others are optional. In order to reduce network requests count, it is recommended to provide `block_id` and `boc` of transaction.


## proof_message_data

Proves that a given message's data, which is queried from TONOS API, can be trusted.

This function first proves the corresponding transaction, ensures that the proven transaction
refers to the given message and compares given data with the proven.
If the given data differs from the proven, the exception will be thrown.
The input parameter is a single message's JSON object (see params description),
which was queried from TONOS API using functions such as `net.query`, `net.query_collection`
or `net.wait_for_collection`.

If message's BOC and/or non-null `src_transaction.id` or `dst_transaction.id` are not provided
in the JSON, they will be queried from TONOS API.

Please note, that joins (like `block`, `dst_account`, `dst_transaction`, `src_account`,
`src_transaction`, etc. in `Message` entity) are separated entities and not supported,
so function will throw an exception in a case if JSON being checked has such entities in it.

For more information about proofs checking, see description of `proof_block_data` function.

```ts
type ParamsOfProofMessageData = {
message: any
}

function proof_message_data(
params: ParamsOfProofMessageData,
): Promise<void>;
```
### Parameters
- `message`: _any_ – Single message's data as queried from DApp server, without modifications. The required fields are `id` and/or top-level `boc`, others are optional. In order to reduce network requests count, it is recommended to provide at least `boc` of message and non-null `src_transaction.id` or `dst_transaction.id`.


# Types
## ProofsErrorCode
```ts
Expand Down Expand Up @@ -164,3 +196,12 @@ type ParamsOfProofTransactionData = {
- `transaction`: _any_ – Single transaction's data as queried from DApp server, without modifications. The required fields are `id` and/or top-level `boc`, others are optional. In order to reduce network requests count, it is recommended to provide `block_id` and `boc` of transaction.
## ParamsOfProofMessageData
```ts
type ParamsOfProofMessageData = {
message: any
}
```
- `message`: _any_ – Single message's data as queried from DApp server, without modifications. The required fields are `id` and/or top-level `boc`, others are optional. In order to reduce network requests count, it is recommended to provide at least `boc` of message and non-null `src_transaction.id` or `dst_transaction.id`.
2 changes: 2 additions & 0 deletions docs/reference/types-and-methods/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,5 @@ Where:

[proof_transaction_data](mod_proofs.md#proof_transaction_data) – Proves that a given transaction's data, which is queried from TONOS API, can be trusted.

[proof_message_data](mod_proofs.md#proof_message_data) – Proves that a given message's data, which is queried from TONOS API, can be trusted.

2 changes: 1 addition & 1 deletion ton_client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ton_client"
version = "1.25.0"
version = "1.26.0"
authors = ["TON DEV SOLUTIONS LTD <[email protected]>"]
edition = "2018"
license = "Apache-2.0"
Expand Down
6 changes: 3 additions & 3 deletions ton_client/build-lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ function root_path(...items) {

const ton_client_toml = fs.readFileSync(path.join(__dirname, '..', 'ton_client', 'Cargo.toml'))
.toString();
const toml_version = /^\s*version\s*=\s*"([0-9.]+)"\s*$/gm.exec(ton_client_toml)[1] || '';
const version = toml_version.split('.').join('_');
const tomlVersion = /^\s*version\s*=\s*['"]([0-9.]+)['"]\s*$/gm.exec(ton_client_toml)[1] || '';
const version = tomlVersion.split('.').join('_');


function spawnProcess(name, args, options) {
Expand Down Expand Up @@ -198,7 +198,7 @@ module.exports = {
main,
postBuild,
gz,
toml_version,
tomlVersion,
version,
root_path,
devOut,
Expand Down
20 changes: 14 additions & 6 deletions ton_client/src/debot/base64_interface.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
use super::dinterface::{
decode_answer_id, get_arg, get_string_arg, DebotInterface, InterfaceResult,
decode_answer_id, get_arg, DebotInterface, InterfaceResult,
};
use crate::abi::Abi;
use serde_json::Value;

const ABI: &str = r#"
{
"ABI version": 2,
"version": "2.2",
"header": ["time"],
"functions": [
{
"name": "encode",
"id": "0x31d9f12c",
"inputs": [
{"name":"answerId","type":"uint32"},
{"name":"data","type":"bytes"}
],
"outputs": [
{"name":"base64","type":"bytes"}
{"name":"base64","type":"string"}
]
},
{
"name": "decode",
"id": "0x5992a05b",
"inputs": [
{"name":"answerId","type":"uint32"},
{"name":"base64","type":"bytes"}
{"name":"base64","type":"string"}
],
"outputs": [
{"name":"data","type":"bytes"}
Expand All @@ -40,6 +43,11 @@ const ABI: &str = r#"
"data": [
],
"events": [
],
"fields": [
{"name":"_pubkey","type":"uint256"},
{"name":"_timestamp","type":"uint64"},
{"name":"_constructorFlag","type":"bool"}
]
}
"#;
Expand All @@ -59,16 +67,16 @@ impl Base64Interface {
let encoded = base64::encode(&data_to_encode);
Ok((
answer_id,
json!({ "base64": hex::encode(encoded.as_bytes()) }),
json!({ "base64": encoded }),
))
}

fn decode(&self, args: &Value) -> InterfaceResult {
let answer_id = decode_answer_id(args)?;
let str_to_decode = get_string_arg(args, "base64")?;
let str_to_decode = get_arg(args, "base64")?;
let decoded =
base64::decode(&str_to_decode).map_err(|e| format!("invalid base64: {}", e))?;
Ok((answer_id, json!({ "data": hex::encode(&decoded) })))
Ok((answer_id, json!({ "data": hex::encode(decoded) })))
}
}

Expand Down
Loading

0 comments on commit 412d24c

Please sign in to comment.