Skip to content

Commit

Permalink
shorter
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmitry-lahoda committed Apr 14, 2024
1 parent 8df78cd commit 5c4d0ad
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions contracts/cosmwasm/outpost/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ pub enum ContractError {
NotImplemented,
#[error("{0}")]
IbcIdentifier(IdentifierError),
#[error("{0}")]
SaltLimitReached(String),
#[error("Network config")]
NetworkConfig,
#[error("Unknown target network")]
Expand Down
10 changes: 7 additions & 3 deletions contracts/cosmwasm/outpost/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
state::{self, network::load_this},
};
use cosmwasm_std::{
to_json_binary, Deps, DepsMut, Reply, Response, StdError, StdResult, SubMsg, WasmMsg,
ensure, to_json_binary, Deps, DepsMut, Reply, Response, StdError, StdResult, SubMsg, WasmMsg
};

use cvm_runtime::{executor::CvmExecutorInstantiated, CallOrigin, ExecutorOrigin};
Expand Down Expand Up @@ -53,6 +53,11 @@ pub fn instantiate(
executor_origin: &ExecutorOrigin,
salt: Vec<u8>,
) -> Result<SubMsg, ContractError> {
let salt = to_json_binary(&salt)?;
ensure!(
salt.len() <= 64,
ContractError::SaltLimitReached(salt.to_string())
);
let next_executor_id: u128 = state::executors::EXECUTORS_COUNT
.load(deps.storage)
.unwrap_or_default()
Expand All @@ -68,8 +73,7 @@ pub fn instantiate(
funds: vec![],
// and label has some unknown limits (including usage of special characters)
label: format!("cvm_executor_{}", &next_executor_id),
// salt limit is 64 characters
salt: to_json_binary(&salt)?,
salt,
};
let executor_instantiate_submessage =
SubMsg::reply_on_success(instantiate_msg, ReplyId::InstantiateExecutor.into());
Expand Down
2 changes: 1 addition & 1 deletion mantis/node/src/mantis/cosmos/cvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ pub fn calculate_salt(
base.extend(pair.b.as_bytes().to_vec());
let mut hasher = Sha224::default();
hasher.update(base);
hasher.finalize().into_iter().take(48).collect()
hasher.finalize().into_iter().take(16).collect()
}

0 comments on commit 5c4d0ad

Please sign in to comment.