Skip to content

Commit

Permalink
Merge pull request #939 from everx-labs/IgorKoval/checks
Browse files Browse the repository at this point in the history
checks
  • Loading branch information
IgorKoval authored Jul 17, 2024
2 parents f169fc6 + 8514086 commit 88389a3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ license = 'Apache-2.0'
name = 'ever-cli'
readme = 'README.md'
repository = 'https://github.com/everx-labs/ever-cli'
version = '0.38.1'
version = '0.38.2'
default-run = 'ever-cli'

[dependencies]
Expand Down
10 changes: 6 additions & 4 deletions src/genaddr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ 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 ever_client::utils::{convert_address, ParamsOfConvertAddress, AddressStringFormat};

Expand All @@ -32,6 +31,9 @@ pub async fn generate_address(
.map_err(|e| format!("failed to read smart contract file: {}", e))?;

let abi = load_abi(abi_path, config).await?;
if !abi.abi().unwrap().data_map_supported() && !update_tvc {
return Err("Use command-line option --save for abi >= 2.4".to_string());
}

let phrase = if new_keys {
gen_seed_phrase()?
Expand Down Expand Up @@ -162,10 +164,10 @@ fn update_contract_state(tvc_file: &str, pubkey: &[u8], data: Option<String>, 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 {
let pk = if pubkey == vec![0; 32].as_slice() {
None
} else {
Some(hex::encode(pubkey))
};
let js_init_data = crate::helpers::insert_pubkey_to_init_data(
pk,
Expand Down
3 changes: 1 addition & 2 deletions src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ pub fn insert_pubkey_to_init_data(pubkey: Option<String>, opt_init_data: Option<
match &mut js_init_data {
Value::Object(obj) => {
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. \
return Err("Public key was set via init data and via command-line option --genkey/--setkey. \
Please, use one way to set public key.".to_owned())
}
if let Some(pk) = pubkey {
Expand All @@ -1045,6 +1045,5 @@ Please, use one way to set public key.".to_owned())
}
_ => panic!("js_init_data is not Value::Object")
}

Ok(js_init_data.to_string())
}

0 comments on commit 88389a3

Please sign in to comment.