Skip to content

Commit

Permalink
fix: don't egress empty all_batch calls (#4102)
Browse files Browse the repository at this point in the history
  • Loading branch information
dandanlen authored Oct 12, 2023
1 parent 0887c9a commit 6320a79
Showing 1 changed file with 26 additions and 19 deletions.
45 changes: 26 additions & 19 deletions state-chain/chains/src/eth/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,25 +225,32 @@ where
return Err(AllBatchError::Other)
}
}
Ok(Self::AllBatch(EvmTransactionBuilder::new_unsigned(
E::replay_protection(E::contract_address(EthereumContract::Vault)),
all_batch::AllBatch::new(
fetch_deploy_params,
fetch_only_params,
transfer_params
.into_iter()
.map(|TransferAssetParams { asset, to, amount }| {
E::token_address(asset)
.map(|address| EncodableTransferAssetParams {
to,
amount,
asset: address,
})
.ok_or(AllBatchError::Other)
})
.collect::<Result<Vec<_>, _>>()?,
),
)))
if fetch_only_params.is_empty() &&
fetch_deploy_params.is_empty() &&
transfer_params.is_empty()
{
Err(AllBatchError::NotRequired)
} else {
Ok(Self::AllBatch(EvmTransactionBuilder::new_unsigned(
E::replay_protection(E::contract_address(EthereumContract::Vault)),
all_batch::AllBatch::new(
fetch_deploy_params,
fetch_only_params,
transfer_params
.into_iter()
.map(|TransferAssetParams { asset, to, amount }| {
E::token_address(asset)
.map(|address| EncodableTransferAssetParams {
to,
amount,
asset: address,
})
.ok_or(AllBatchError::Other)
})
.collect::<Result<Vec<_>, _>>()?,
),
)))
}
}
}

Expand Down

0 comments on commit 6320a79

Please sign in to comment.