Skip to content

Commit

Permalink
Merge pull request #411 from tonlabs/1.16.0-rc
Browse files Browse the repository at this point in the history
Version 1.16.0
  • Loading branch information
d3p authored May 25, 2021
2 parents 1a12fda + 052c0b0 commit cc80fea
Show file tree
Hide file tree
Showing 24 changed files with 1,041 additions and 73 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

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

## [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)

### Fixed

- `AbiData.key` type changed to u32.
- attempt to use `orderBy` instead of `order` in `query_collection` will raise error.

## [1.15.0] – 2021-05-18

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

Expand Down
4 changes: 2 additions & 2 deletions docs/mod_abi.md
Original file line number Diff line number Diff line change
Expand Up @@ -797,13 +797,13 @@ type AbiEvent = {
## AbiData
```ts
type AbiData = {
key: bigint,
key: number,
name: string,
type: string,
components?: AbiParam[]
}
```
- `key`: _bigint_
- `key`: _number_
- `name`: _string_
- `type`: _string_
- `components`?: _[AbiParam](mod_abi.md#AbiParam)[]_
Expand Down
124 changes: 124 additions & 0 deletions docs/mod_net.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Network access.

[query_counterparties](#query_counterparties) – Allows to query and paginate through the list of accounts that the specified account has interacted with, sorted by the time of the last internal message between accounts

[query_transaction_tree](#query_transaction_tree) – Returns transactions tree for specific message.

## Types
[NetErrorCode](#NetErrorCode)

Expand All @@ -45,6 +47,10 @@ Network access.

[AggregationFn](#AggregationFn)

[TransactionNode](#TransactionNode)

[MessageNode](#MessageNode)

[ParamsOfQuery](#ParamsOfQuery)

[ResultOfQuery](#ResultOfQuery)
Expand Down Expand Up @@ -79,6 +85,10 @@ Network access.

[ParamsOfQueryCounterparties](#ParamsOfQueryCounterparties)

[ParamsOfQueryTransactionTree](#ParamsOfQueryTransactionTree)

[ResultOfQueryTransactionTree](#ResultOfQueryTransactionTree)


# Functions
## query
Expand Down Expand Up @@ -476,6 +486,51 @@ function query_counterparties(
- `result`: _any[]_ – Objects that match the provided criteria


## query_transaction_tree

Returns transactions tree for specific message.

Performs recursive retrieval of the transactions tree produced by the specific message:
in_msg -> dst_transaction -> out_messages -> dst_transaction -> ...

All retrieved messages and transactions will be included
into `result.messages` and `result.transactions` respectively.

The retrieval process will stop when the retrieved transaction count is more than 50.

It is guaranteed that each message in `result.messages` has the corresponding transaction
in the `result.transactions`.

But there are no guaranties that all messages from transactions `out_msgs` are
presented in `result.messages`.
So the application have to continue retrieval for missing messages if it requires.

```ts
type ParamsOfQueryTransactionTree = {
in_msg: string,
abi_registry?: Abi[]
}

type ResultOfQueryTransactionTree = {
messages: MessageNode[],
transactions: TransactionNode[]
}

function query_transaction_tree(
params: ParamsOfQueryTransactionTree,
): Promise<ResultOfQueryTransactionTree>;
```
### 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.


### Result

- `messages`: _[MessageNode](mod_net.md#MessageNode)[]_ – Messages.
- `transactions`: _[TransactionNode](mod_net.md#TransactionNode)[]_ – Transactions.


# Types
## NetErrorCode
```ts
Expand Down Expand Up @@ -620,6 +675,53 @@ One of the following value:
- `AVERAGE = "AVERAGE"` – Returns an average value for a field in filtered records


## TransactionNode
```ts
type TransactionNode = {
id: string,
in_msg: string,
out_msgs: string[],
account_addr: string,
total_fees: string,
aborted: boolean,
exit_code?: number
}
```
- `id`: _string_ – Transaction id.
- `in_msg`: _string_ – In message id.
- `out_msgs`: _string[]_ – Out message ids.
- `account_addr`: _string_ – Account address.
- `total_fees`: _string_ – Transactions total fees.
- `aborted`: _boolean_ – Aborted flag.
- `exit_code`?: _number_ – Compute phase exit code.
## MessageNode
```ts
type MessageNode = {
id: string,
src_transaction_id?: string,
dst_transaction_id?: string,
src?: string,
dst?: string,
value?: string,
bounce: boolean,
decoded_body?: DecodedMessageBody
}
```
- `id`: _string_ – Message id.
- `src_transaction_id`?: _string_ – Source transaction id.
<br>This field is missing for an external inbound messages.
- `dst_transaction_id`?: _string_ – Destination transaction id.
<br>This field is missing for an external outbound messages.
- `src`?: _string_ – Source address.
- `dst`?: _string_ – Destination address.
- `value`?: _string_ – Transferred tokens value.
- `bounce`: _boolean_ – Bounce flag.
- `decoded_body`?: _[DecodedMessageBody](mod_abi.md#DecodedMessageBody)_ – Decoded body.
<br>Library tries to decode message body using provided `params.abi_registry`.<br>This field will be missing if none of the provided abi can be used to decode.
## ParamsOfQuery
```ts
type ParamsOfQuery = {
Expand Down Expand Up @@ -809,3 +911,25 @@ type ParamsOfQueryCounterparties = {
- `after`?: _string_ – `cursor` field of the last received result
## ParamsOfQueryTransactionTree
```ts
type ParamsOfQueryTransactionTree = {
in_msg: string,
abi_registry?: Abi[]
}
```
- `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.
## ResultOfQueryTransactionTree
```ts
type ResultOfQueryTransactionTree = {
messages: MessageNode[],
transactions: TransactionNode[]
}
```
- `messages`: _[MessageNode](mod_net.md#MessageNode)[]_ – Messages.
- `transactions`: _[TransactionNode](mod_net.md#TransactionNode)[]_ – Transactions.
2 changes: 2 additions & 0 deletions docs/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ Where:

[query_counterparties](mod_net.md#query_counterparties) – Allows to query and paginate through the list of accounts that the specified account has interacted with, sorted by the time of the last internal message between accounts

[query_transaction_tree](mod_net.md#query_transaction_tree) – Returns transactions tree for specific message.

## [debot](mod_debot.md)[UNSTABLE](UNSTABLE.md) Module for working with debot.

[init](mod_debot.md#init)[UNSTABLE](UNSTABLE.md) Creates and instance of DeBot.
Expand Down
62 changes: 32 additions & 30 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.15.0"
version = "1.16.0"
authors = ["TON DEV SOLUTIONS LTD <[email protected]>"]
edition = "2018"
license = "Apache-2.0"
Expand All @@ -12,61 +12,63 @@ crate-type = ["cdylib", "rlib", "staticlib"]

[build-dependencies]
serde = "1.0.117"
serde_json = "1.0.59"
serde_derive = "1.0.117"
serde_json = "1.0.59"

[dependencies]
ton_sdk = { path = "../ton_sdk", default-features = false }
api_info = { path = "../api/info" }
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_types = { git = "https://github.com/tonlabs/ton-labs-types.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 }
sodalite = { git = "https://github.com/tonlabs/sodalite.git", features = ["rand"] }

bip39 = { git = "https://github.com/tonlabs/bip39-rs.git" }
lockfree = { git = "https://github.com/tonlabs/lockfree.git", package = "lockfree" }
sodalite = { git = "https://github.com/tonlabs/sodalite.git", features = ["rand"] }

rand = "0.7.3"
hex = "0.3.2"
serde_json = "1.0.41"
serde_derive = "1.0.91"
serde = "1.0.91"
ed25519-dalek = "1.0.0"
sha2 = "0.8"
async-trait = "0.1.40"
base58 = "0.1.0"
base64 = "0.10.0"
lazy_static = "1.1.0"
num-bigint = "0.2.2"
byteorder = "1.3.2"
chacha20 = "0.6.0"
chrono = "0.4.6"
scrypt = { version = "0.2.0", default-features = false }
crc-any = "2.2.3"
ed25519-dalek = "1.0.0"
failure = "0.1"
futures = "0.3.4"
hex = "0.3.2"
hmac = "0.7.1"
chacha20 = "0.6.0"
base58 = "0.1.0"
pbkdf2 = { version = "0.3.0", default-features = false }
byteorder = "1.3.2"
lazy_static = "1.1.0"
libsecp256k1 = "0.3.5"
log = "0.4.11"
crc-any = "2.2.3"
failure = "0.1"
num-traits = "0.2"
lru = "0.6.3"
num-bigint = "0.2.2"
num-derive = "0.3"
async-trait = "0.1.40"
futures = "0.3.4"
num-traits = "0.2"
pbkdf2 = { version = "0.3.0", default-features = false }
rand = "0.7.3"
regex = "1.5.4"
scrypt = { version = "0.2.0", default-features = false }
serde = "1.0.91"
serde_derive = "1.0.91"
serde_json = "1.0.41"
sha2 = "0.8"
tokio = { version = "0.2.13", features = ["sync", "stream"], default-features = false }
lru = "0.6.3"
lockfree = { git = "https://github.com/tonlabs/lockfree.git", package = "lockfree" }
zstd = { version = "0.7.0", default-features = false }
zstd = { version = "0.7.0+zstd.1.4.9", default-features = false }

# optional for std
reqwest = { version = "0.10.4", optional = true }
tokio-tungstenite = { version = "0.11.0", features = ["tls"], optional = true }

# optional for wasm
js-sys = { version = "0.3.50", optional = true }
wasm-bindgen = { version = "0.2.73", features = ["serde-serialize"], optional = true }
wasm-bindgen-futures = { version = "0.4.15", optional = true }
js-sys = { version = "0.3.50", optional = true }

[dependencies.web-sys]
version = "0.3.42"
Expand All @@ -85,8 +87,8 @@ features = [
]

[dev-dependencies]
log4rs = "^0"
dirs = "2.0.2"
log4rs = "^0"
pretty_assertions = "0.6.1"


Expand Down
2 changes: 1 addition & 1 deletion ton_client/src/abi/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub struct AbiEvent {

#[derive(Serialize, Deserialize, Clone, Debug, ApiType, Default)]
pub struct AbiData {
pub key: u64,
pub key: u32,
pub name: String,
#[serde(rename = "type")]
pub param_type: String,
Expand Down
15 changes: 14 additions & 1 deletion ton_client/src/client/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::crypto::keys::strip_secret;
use crate::error::ClientError;
use std::fmt::{Debug, Display};

Expand Down Expand Up @@ -45,6 +46,11 @@ fn error(code: ErrorCode, message: String) -> ClientError {

pub const CANNOT_SERIALIZE_RESULT: &str = r#"{ "code": 18, "message": "Can not serialize result"}"#;

lazy_static! {
static ref SECRET_REGEX: regex::Regex =
regex::Regex::new(r#""secret"\s*:\s*"([0-9a-f]{64})""#).unwrap();
}

impl Error {
pub fn is_network_error(error: &ClientError) -> bool {
error.code == ErrorCode::WebsocketConnectError as u32
Expand Down Expand Up @@ -178,9 +184,16 @@ impl Error {
}

pub fn invalid_params(params_json: &str, err: impl Display) -> ClientError {
let mut params_json_stripped = params_json.to_owned();
while let Some(captures) = SECRET_REGEX.captures(&params_json_stripped) {
let key = captures.get(1).unwrap().as_str();
let stripped = strip_secret(key);
params_json_stripped = params_json_stripped.replace(key, stripped.as_str());
}

error(
ErrorCode::InvalidParams,
format!("Invalid parameters: {}\nparams: {}", err, params_json),
format!("Invalid parameters: {}\nparams: {}", err, params_json_stripped),
)
}

Expand Down
Loading

0 comments on commit cc80fea

Please sign in to comment.