Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for solidity config #904

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

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

## Version: 0.30.2

### New
- Added ABI parameter to `update_config` command for solidity config contract;

## Version: 0.30.1

### New
Expand Down
20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ license = 'Apache-2.0'
name = 'tonos-cli'
readme = 'README.md'
repository = 'https://github.com/tonlabs/tonos-cli'
version = '0.32.0'
version = '0.32.1'
default-run = 'tonos-cli'

[features]
Expand Down Expand Up @@ -48,15 +48,15 @@ log = { features = [ 'std' ], version = '0.4' }
serde = { features = [ 'derive' ], version = '1.0' }
tokio = { default-features = false, features = [ 'full' ], version = '1.21' }
url = '2.3.1'
ton_abi = { git = 'https://github.com/tonlabs/ton-labs-abi.git', tag = '2.3.54' }
ton_block = { git = 'https://github.com/tonlabs/ton-labs-block.git', tag = '1.9.18' }
ton_block_json = { git = 'https://github.com/tonlabs/ton-labs-block-json.git', tag = '0.7.83' }
ton_client = { git = 'https://github.com/tonlabs/TON-SDK.git', tag = '1.40.0' }
ton_executor = { git = 'https://github.com/tonlabs/ton-labs-executor.git', tag = '1.15.154' }
ton_labs_assembler = { git = 'https://github.com/tonlabs/ton-labs-assembler.git', tag = '1.2.77' }
ton_sdk = { git = 'https://github.com/tonlabs/TON-SDK.git', tag = '1.40.0' }
ton_types = { git = 'https://github.com/tonlabs/ton-labs-types.git', tag = '1.12.6' }
ton_vm = { git = 'https://github.com/tonlabs/ton-labs-vm.git', tag = '1.8.96' }
ton_abi = { git = 'https://github.com/tonlabs/ever-abi.git', tag = '2.3.65' }
ton_block = { git = 'https://github.com/tonlabs/ever-block.git', tag = '1.9.28' }
ton_block_json = { git = 'https://github.com/tonlabs/ever-block-json.git', tag = '0.7.95' }
ton_client = { git = 'https://github.com/tonlabs/ever-sdk.git', tag = '1.41.0' }
ton_executor = { git = 'https://github.com/tonlabs/ever-executor.git', tag = '1.15.173' }
ton_labs_assembler = { git = 'https://github.com/tonlabs/ever-assembler.git', tag = '1.2.84' }
ton_sdk = { git = 'https://github.com/tonlabs/ever-sdk.git', tag = '1.41.0' }
ton_types = { git = 'https://github.com/tonlabs/ever-types.git', tag = '1.12.7' }
ton_vm = { git = 'https://github.com/tonlabs/ever-vm.git', tag = '1.8.114' }
sold = { git = 'https://github.com/tonlabs/TON-Solidity-Compiler.git', tag = '0.66.0', optional = true }

[dev-dependencies]
Expand Down
45 changes: 43 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1379,7 +1379,7 @@ Result: {

```

## 4.5. Generate encrypted message offline
## 4.5.1. Generate encrypted message offline

An internet connection is not required to create an encrypted message. Use the following command to do it:

Expand Down Expand Up @@ -1433,6 +1433,45 @@ Expire at: Sat, 08 May 2021 16:42:03 +0300
Message saved to file message.boc
```

## 4.5.2. Generate payload for internal message

An internet connection is not required to create an payload for message. Use the following command to do it:

```bash
tonos-cli body [--output <path_to_file>] [--abi <contract.abi.json>] <method> <params>
```

`--output <path_to_file>` - specify path to file where the raw message should be written to, instead of printing it to terminal.

`<contract.abi.json>` - contract interface file.

`<method>` - the method being called.

`<params>` - parameters of the called method.

The TONOS-CLI utility displays encrypted message text and a QR code that also contains the message. Copy the message text or scan the QR code and broadcast the message online.

Example (raw boc of create new multisig transaction message with a lifetime of 1 hour saved to file):

```bash
$ tonos-cli message --raw --output message.boc --sign k1.keys.json --abi SafeMultisigWallet.abi.json 0:a4629d617df931d8ad86ed24f4cac3d321788ba082574144f5820f2894493fbc submitTransaction '{"dest":"-1:0c5d5215317ec8eef1b84c43cbf08523c33f69677365de88fe3d96a0b31b59c6","value":234000000,"bounce":false,"allBalance":false,"payload":""}' --lifetime 3600
Config: /home/user/tonos-cli.conf.json
Input arguments:
address: 0:a4629d617df931d8ad86ed24f4cac3d321788ba082574144f5820f2894493fbc
method: submitTransaction
params: {"dest":"-1:0c5d5215317ec8eef1b84c43cbf08523c33f69677365de88fe3d96a0b31b59c6","value":234000000,"bounce":false,"allBalance":false,"payload":""}
abi: SafeMultisigWallet.abi.json
keys: k1.keys.json
lifetime: 3600
output: message.boc
Generating external inbound message...

MessageId: 59d698efe871cf9ffa8f6eb4c784b294538cd2223b4c876bb4e999a8edf8d410
Expire at: Sat, 08 May 2021 16:42:03 +0300
Message saved to file message.boc
```


## 4.6. Broadcast previously generated message

Use the following command to send a previously generated message, that is not in raw format, and not in a file:
Expand Down Expand Up @@ -2618,9 +2657,11 @@ Succeeded.
Use the following command to update one parameter of the blockchain global config, that is stored in a .json file:

```bash
tonos-cli update_config <seqno> <config_master_key_file> <new_param_file>
tonos-cli update_config [--abi <config.abi.json>] <seqno> <config_master_key_file> <new_param_file>
```

`<config.abi.json>` – ABI json file for solidity config contract, in this case `seqno` is not used and must be `0`

`<seqno>` – current seqno of config contract. It can get from command `seqno` on config account.

`<config_master_key_file>` – prefix of config master files. There should be two files: `<config_master_key_file>.addr` with address of config master and `<config_master_key_file>.pk` with private key of config master.
Expand Down
8 changes: 4 additions & 4 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,26 @@ fn main() {
let mut build_time = String::from("Unknown");

let branch = Command::new("git")
.args(&["rev-parse", "--abbrev-ref", "HEAD"])
.args(["rev-parse", "--abbrev-ref", "HEAD"])
.output();

if let Ok(branch) = branch {
git_branch = String::from_utf8(branch.stdout).unwrap_or_else(|_| "Unknown".to_string());
}

let last = Command::new("git").args(&["rev-parse", "HEAD"]).output();
let last = Command::new("git").args(["rev-parse", "HEAD"]).output();
if let Ok(last) = last {
git_commit = String::from_utf8(last.stdout).unwrap_or_else(|_| "Unknown".to_string());
}

let time = Command::new("git")
.args(&["log", "-1", "--date=iso", "--pretty=format:%cd"])
.args(["log", "-1", "--date=iso", "--pretty=format:%cd"])
.output();
if let Ok(time) = time {
commit_date = String::from_utf8(time.stdout).unwrap_or_else(|_| "Unknown".to_string());
}

let b_time = Command::new("date").args(&["+%Y-%m-%d %T %z"]).output();
let b_time = Command::new("date").args(["+%Y-%m-%d %T %z"]).output();
if let Ok(b_time) = b_time {
build_time = String::from_utf8(b_time.stdout).unwrap_or_else(|_| "Unknown".to_string());
}
Expand Down
45 changes: 21 additions & 24 deletions src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ const ACCOUNT_FIELDS: &str = r#"

const DEFAULT_PATH: &str = ".";

async fn query_accounts(config: &Config, addresses: Vec<String>, fields: &str) -> Result<Vec<Value>, String> {
let ton = create_client_verbose(&config)?;
fn query_accounts(config: &Config, addresses: Vec<String>, fields: &str) -> Result<Vec<Value>, String> {
let ton = create_client_verbose(config)?;

if !config.is_json {
println!("Processing...");
Expand All @@ -55,16 +55,17 @@ async fn query_accounts(config: &Config, addresses: Vec<String>, fields: &str) -
});
}
it += cnt;
let mut query_result = query_collection(
ton.clone(),
ParamsOfQueryCollection {
collection: "accounts".to_owned(),
filter: Some(filter),
result: fields.to_string(),
limit: Some(cnt as u32),
..Default::default()
},
).await.map_err(|e| format!("failed to query account info: {}", e))?;
let context = ton.clone();
let params = ParamsOfQueryCollection {
collection: "accounts".to_owned(),
filter: Some(filter),
result: fields.to_string(),
limit: Some(cnt as u32),
..Default::default()
};
let mut query_result = crate::RUNTIME.block_on(async move {
query_collection(context, params).await
}).map_err(|e| format!("failed to query account info: {}", e))?;
res.append(query_result.result.as_mut());
}
Ok(res)
Expand All @@ -86,7 +87,7 @@ pub async fn get_account(config: &Config, addresses: Vec<String>, dumptvc: Optio
}
return Ok(());
}
let accounts = query_accounts(&config, addresses.clone(), ACCOUNT_FIELDS).await?;
let accounts = query_accounts(config, addresses.clone(), ACCOUNT_FIELDS)?;
if !config.is_json {
println!("Succeeded.");
}
Expand Down Expand Up @@ -156,7 +157,7 @@ pub async fn get_account(config: &Config, addresses: Vec<String>, dumptvc: Optio
);
} else {
print_account(
&config,
config,
Some(acc_type),
Some(address.clone()),
Some(balance),
Expand All @@ -170,7 +171,7 @@ pub async fn get_account(config: &Config, addresses: Vec<String>, dumptvc: Optio
} else if config.is_json {
json_res[address.clone()] = json_account(Some(acc_type), Some(address.clone()), None, None, None, None, None, None);
} else {
print_account(&config, Some(acc_type), Some(address.clone()), None, None, None, None, None, None);
print_account(config, Some(acc_type), Some(address.clone()), None, None, None, None, None, None);
}
if !config.is_json {
println!();
Expand All @@ -195,11 +196,7 @@ pub async fn get_account(config: &Config, addresses: Vec<String>, dumptvc: Optio
} else if config.is_json {
println!("{{\n}}");
} else {
if config.is_json {
println!("{{\n}}");
} else {
println!("Account not found.");
}
println!("Account not found.");
}

if dumptvc.is_some() || dumpboc.is_some() && addresses.len() == 1 && accounts.len() == 1 {
Expand Down Expand Up @@ -232,7 +229,7 @@ pub async fn get_account(config: &Config, addresses: Vec<String>, dumptvc: Optio
}

pub async fn calc_storage(config: &Config, addr: &str, period: u32) -> Result<(), String> {
let ton = create_client_verbose(&config)?;
let ton = create_client_verbose(config)?;

if !config.is_json {
println!("Processing...");
Expand All @@ -242,7 +239,7 @@ pub async fn calc_storage(config: &Config, addr: &str, period: u32) -> Result<()
ton.clone(),
addr,
"boc",
).await.map_err(|e| e)?;
)?;

let res = calc_storage_fee(
ton.clone(),
Expand All @@ -265,7 +262,7 @@ pub async fn calc_storage(config: &Config, addr: &str, period: u32) -> Result<()
}

pub async fn dump_accounts(config: &Config, addresses: Vec<String>, path: Option<&str>) -> Result<(), String> {
let accounts = query_accounts(&config, addresses.clone(), "id boc").await?;
let accounts = query_accounts(config, addresses.clone(), "id boc")?;
let mut addresses = addresses.clone();
check_dir(path.unwrap_or(""))?;
for account in accounts.iter() {
Expand Down Expand Up @@ -310,7 +307,7 @@ fn extract_last_trans_lt(v: &serde_json::Value) -> Option<&str> {
pub async fn wait_for_change(config: &Config, account_address: &str, wait_secs: u64) -> Result<(), String> {
let context = create_client_verbose(config)?;

let query = ton_client::net::query_collection(
let query = query_collection(
context.clone(),
ParamsOfQueryCollection {
collection: "accounts".to_owned(),
Expand Down
Loading