Skip to content

Commit

Permalink
happier
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmitry-lahoda committed Apr 14, 2024
1 parent 415a530 commit 3f34039
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions contracts/cosmwasm/executor/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,14 +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)?;
deps.api.debug(&format!("cvm::executor::execute::spawn::asset {:?}", reference));
let transfer_amount = match &reference.local {
AssetReference::Native { denom } => {
let coin = deps
.querier
.query_balance(env.contract.address.clone(), denom.clone())?;
deps.api.debug(&format!("cvm::executor::execute::spawn::filter {:?} {:?}", balance, coin));
deps.api.debug(&format!("cvm::executor::execute::spawn::filter {:?} {:?} {:?}", balance, coin, asset_id));
balance
.apply(coin.amount.into())
.map_err(|_| ContractError::ArithmeticError)
Expand Down
6 changes: 4 additions & 2 deletions contracts/cosmwasm/outpost/src/contract/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ pub(crate) fn handle_execute_program_privilleged(
if let Some(state::executors::ExecutorItem { address, .. }) = executor {
deps.api
.debug("cvm::outpost::execute:: reusing existing executor and adding funds");
// tbh it is SLOW to send and then execute, must be one message
let response = send_funds_to_executor(deps.as_ref(), address.clone(), assets)?;
let wasm_msg = wasm_execute(
address.clone(),
Expand All @@ -268,7 +269,7 @@ pub(crate) fn handle_execute_program_privilleged(
.unwrap_or(env.contract.address),
program,
},
vec![],
vec![], // funds now are send as separate message, which is bad
)?;
Ok(response
.add_event(make_event("route.execute").add_attribute("executor", address.into_string()))
Expand Down Expand Up @@ -327,7 +328,7 @@ fn send_funds_to_executor(
) -> Result {
let mut response = Response::new();
let executor_address = executor_address.into_string();
deps.api.debug(&format!("cvm::outpost:: sending funds {:?}", funds));
deps.api.debug(&format!("cvm::outpost::funds:: 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 {
Expand All @@ -344,6 +345,7 @@ fn send_funds_to_executor(
})?
} //cvm_route::asset::AssetReference::Erc20 { .. } => Err(ContractError::RuntimeUnsupportedOnNetwork)?,
};
deps.api.debug(&format!("cvm::outpost::funds::msg {:?}", msg));
response = response.add_message(msg);
}
Ok(response)
Expand Down
2 changes: 2 additions & 0 deletions crates/cvm-route/src/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ pub struct AssetItem {
pub asset_id: AssetId,
/// network id on which this asset id can be used locally
pub network_id: NetworkId,

/// TODO: make sure one cannot access local if it is bridged until bridged was unwrapped
pub local: AssetReference,
/// if asset was bridged, it would have way to identify bridge/source/channel
pub bridged: Option<BridgeAsset>,
Expand Down

0 comments on commit 3f34039

Please sign in to comment.