diff --git a/Cargo.lock b/Cargo.lock index 4000210b..00344a9a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -217,13 +217,13 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.80" +version = "0.1.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" +checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.70", ] [[package]] @@ -410,9 +410,9 @@ checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" [[package]] name = "cc" -version = "1.0.104" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74b6a57f98764a267ff415d50a25e6e166f3831a5071af4995296ea97d210490" +checksum = "eaff6f8ce506b9773fa786672d63fc7a191ffea1be33f72bbd4aeacefca9ffc8" dependencies = [ "jobserver", "libc", @@ -489,9 +489,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.8" +version = "4.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84b3edb18336f4df585bc9aa31dd99c036dfa5dc5e9a2939a722a188f3a8970d" +checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462" dependencies = [ "clap_builder", "clap_derive", @@ -499,9 +499,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.8" +version = "4.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1c09dd5ada6c6c78075d6fd0da3f90d8080651e2d6cc8eb2f1aaa4034ced708" +checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942" dependencies = [ "anstream", "anstyle", @@ -518,7 +518,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.70", ] [[package]] @@ -722,7 +722,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.70", ] [[package]] @@ -848,7 +848,7 @@ dependencies = [ [[package]] name = "ever-cli" -version = "0.37.1" +version = "0.38.0" dependencies = [ "assert_cmd", "async-trait", @@ -920,7 +920,7 @@ name = "ever_assembler" version = "1.5.9" source = "git+https://github.com/everx-labs/ever-assembler.git?tag=1.5.9#3813f5aa2683d2f06fc2f7608c16e3798f3326b2" dependencies = [ - "clap 4.5.8", + "clap 4.5.9", "ever_block", "ever_vm 2.1.9", "failure", @@ -1158,7 +1158,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.70", ] [[package]] @@ -1388,9 +1388,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "0.14.29" +version = "0.14.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f361cde2f109281a220d4307746cdfd5ee3f410da58a70377762396775634b33" +checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" dependencies = [ "bytes", "futures-channel", @@ -1663,7 +1663,7 @@ checksum = "38b4faf00617defe497754acde3024865bc143d44a86799b24e191ecff91354f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.70", ] [[package]] @@ -1866,7 +1866,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.70", ] [[package]] @@ -1966,7 +1966,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.70", ] [[package]] @@ -2391,22 +2391,22 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.70", ] [[package]] @@ -2429,7 +2429,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.70", ] [[package]] @@ -2619,9 +2619,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.68" +version = "2.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" +checksum = "2f0209b68b3613b093e0ec905354eccaedcfe83b8cb37cbdeae64026c3064c16" dependencies = [ "proc-macro2", "quote", @@ -2720,7 +2720,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.70", ] [[package]] @@ -2784,9 +2784,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6b6a2fb3a985e99cebfaefa9faa3024743da73304ca1c683a36429613d3d22" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" dependencies = [ "tinyvec_macros", ] @@ -2824,7 +2824,7 @@ checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.70", ] [[package]] @@ -3202,7 +3202,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.70", "wasm-bindgen-shared", ] @@ -3236,7 +3236,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.70", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -3475,7 +3475,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.70", ] [[package]] @@ -3495,7 +3495,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.70", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index e14ae6c6..6f93704a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ license = 'Apache-2.0' name = 'ever-cli' readme = 'README.md' repository = 'https://github.com/everx-labs/ever-cli' -version = '0.37.1' +version = '0.38.0' default-run = 'ever-cli' [dependencies] diff --git a/src/genaddr.rs b/src/genaddr.rs index 7640969a..a84399e4 100644 --- a/src/genaddr.rs +++ b/src/genaddr.rs @@ -14,7 +14,7 @@ use crate::config::Config; use crate::helpers::{create_client_local, read_keys, load_abi, calc_acc_address, load_abi_str}; use serde_json::json; use std::fs::OpenOptions; - +use std::ptr::eq; use crate::crypto::{gen_seed_phrase, generate_keypair_from_mnemonic}; use ton_client::utils::{convert_address, ParamsOfConvertAddress, AddressStringFormat}; @@ -146,10 +146,9 @@ fn update_contract_state(tvc_file: &str, pubkey: &[u8], data: Option, ab let mut state_init = OpenOptions::new().read(true).write(true).open(tvc_file) .map_err(|e| format!("unable to open contract file: {}", e))?; - let pubkey_object = pubkey.try_into() - .map_err(|e| format!("unable to load public key: {}", e))?; - let mut contract_image = if data_map_supported { + let pubkey_object = pubkey.try_into() + .map_err(|e| format!("unable to load public key: {}", e))?; ContractImage::from_state_init_and_key(&mut state_init, &pubkey_object) .map_err(|e| format!("unable to load contract image with key: {}", e))? } else { @@ -163,8 +162,13 @@ fn update_contract_state(tvc_file: &str, pubkey: &[u8], data: Option, ab .map_err(|e| format!("unable to update contract image data: {}", e))?; } } else { + let pk = if eq(pubkey, vec![0; 32].as_slice()) { + Some(hex::encode(pubkey)) + } else { + None + }; let js_init_data = crate::helpers::insert_pubkey_to_init_data( - Some(hex::encode(pubkey)), + pk, data.as_deref() )?; contract_image.update_data(false, js_init_data.as_str(), abi) diff --git a/src/helpers.rs b/src/helpers.rs index 515bb3dd..4cbc856e 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -1028,17 +1028,15 @@ pub fn decode_data(data: &str, param_name: &str) -> Result, String> { } pub fn insert_pubkey_to_init_data(pubkey: Option, opt_init_data: Option<&str>) -> Result { - let init_data = match opt_init_data { - Some(json) => json, - None => "{}" - }; + let init_data = opt_init_data.unwrap_or_else(|| "{}"); let mut js_init_data = serde_json::from_str(init_data) .map_err(|e| format!("Failed to decode initial data as json: {}", e))?; match &mut js_init_data { Value::Object(obj) => { - if obj.contains_key(&"_pubkey".to_string()) { - return Err("Public key was set via init data. Please, use command line options --genkey/--setkey to set public key.".to_owned()) + if obj.contains_key(&"_pubkey".to_string()) && pubkey.is_some() { + return Err("Public key was set via init data and via commad-line option --genkey/--setkey. \ +Please, use one way to set public key.".to_owned()) } if let Some(pk) = pubkey { let pubkey_str = format!("0x{}", pk);