Skip to content

Commit

Permalink
logs about amouns
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmitry-lahoda committed Apr 14, 2024
1 parent 98bf922 commit 415a530
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
7 changes: 5 additions & 2 deletions contracts/cosmwasm/executor/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,12 +393,14 @@ pub fn execute_spawn(
let mut response = Response::default();
response = response.add_event(events::CvmExecutorInstructionSpawning::new(network_id));
for (asset_id, balance) in assets.0 {

let reference = outpost_address.get_asset_by_id(deps.querier, asset_id)?;
let transfer_amount = match &reference.local {
AssetReference::Native { denom } => {
let coin = deps
.querier
.query_balance(env.contract.address.clone(), denom.clone())?;
.querier
.query_balance(env.contract.address.clone(), denom.clone())?;
deps.api.debug(&format!("cvm::executor::execute::spawn::filter {:?} {:?}", balance, coin));
balance
.apply(coin.amount.into())
.map_err(|_| ContractError::ArithmeticError)
Expand All @@ -411,6 +413,7 @@ pub fn execute_spawn(
),
// AssetReference::Erc20 { .. } => Err(ContractError::AssetUnsupportedOnThisNetwork)?,
}?;
deps.api.debug(&format!("cvm::executor::execute::spawn::transfer_amount {:?}", transfer_amount));

if !transfer_amount.is_zero() {
let asset_id: u128 = asset_id.into();
Expand Down
17 changes: 6 additions & 11 deletions contracts/cosmwasm/outpost/src/contract/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ use crate::{
};

use cosmwasm_std::{
entry_point, wasm_execute, Addr, BankMsg, Coin, CosmosMsg, Deps, DepsMut, Env, MessageInfo,
Response, StdError,
ensure, ensure_eq, entry_point, wasm_execute, Addr, BankMsg, Coin, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Response, StdError
};
use cvm_route::asset::{AssetReference, NetworkAssetItem};
use cw20::{Cw20Contract, Cw20ExecuteMsg};
Expand Down Expand Up @@ -288,7 +287,7 @@ pub(crate) fn handle_execute_program_privilleged(
// Err(ContractError::BadlyConfiguredRouteBecauseThisChainCanSendOnlyFromCosmwasm)?
// }
};
deps.api.debug("instantiating executor");
deps.api.debug("cvm::outpost:: instantiating executor");
let this = msg::Outpost::new(env.contract.address);

let executor_instantiate_submsg = crate::executor::instantiate(
Expand All @@ -300,7 +299,7 @@ pub(crate) fn handle_execute_program_privilleged(
)?;

// Secondly, call itself again with the same parameters, so that this functions goes
// into `Ok` state and properly executes the executor
// into `Ok` state and properly executes the executor
let execute_program = cvm_runtime::outpost::BridgeExecuteProgramMsg {
salt: executor_origin.salt,
program,
Expand Down Expand Up @@ -328,13 +327,9 @@ fn send_funds_to_executor(
) -> Result {
let mut response = Response::new();
let executor_address = executor_address.into_string();
for (asset_id, amount) in funds.0 {
// Ignore zero amounts
if amount == 0 {
continue;
}
deps.api.debug("cvm::outpost:: sending funds");

deps.api.debug(&format!("cvm::outpost:: sending funds {:?}", funds));
for (asset_id, amount) in funds.0 {
ensure!(amount >= <_>::default(), ContractError::DoNotAddFundsInsteadOfSendingZero);
let msg = match assets::get_asset_by_id(deps, asset_id)?.local {
cvm_route::asset::AssetReference::Native { denom } => BankMsg::Send {
to_address: executor_address.clone(),
Expand Down
2 changes: 2 additions & 0 deletions contracts/cosmwasm/outpost/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ pub enum ContractError {
ArithmeticOverflow,
#[error("Not enough funds to cover the operation.")]
InsufficientFunds,
#[error("Do not add funds instead of sending zero.")]
DoNotAddFundsInsteadOfSendingZero,
#[error("Program funds denom mapping to host not found for asset_id {0} native = {1}")]
ProgramFundsDenomMappingToHostNotFound(AssetId, String),
#[error("Program amount not equal to host amount")]
Expand Down

0 comments on commit 415a530

Please sign in to comment.