Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eth misc fixes #327

Merged
merged 4 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,12 +305,11 @@ impl InnerApp {
) -> Result<()> {
#[cfg(feature = "ethereum")]
{
crate::bitcoin::exempt_from_fee()?;

// TODO: fee

let signer = self.signer()?;
let coins = self.bitcoin.accounts.withdraw(signer, amount)?;
let mut coins = self.bitcoin.accounts.withdraw(signer, amount)?;

let fee = coins.take(20_000_000)?;
self.bitcoin.give_rewards(fee)?;

let dest = Dest::EthAccount {
network,
Expand Down Expand Up @@ -511,6 +510,7 @@ impl InnerApp {

match sender {
Identity::NativeAccount { address } => {
log::debug!("Returning funds to NativeAccount sender");
self.bitcoin.accounts.deposit(address, coins)?;
}
#[cfg(feature = "ethereum")]
Expand All @@ -519,10 +519,17 @@ impl InnerApp {
connection,
address,
} => {
self.ethereum
let res = self
.ethereum
.network_mut(network)?
.connection_mut(connection.into())?
.transfer(address.into(), coins)?;
.transfer(address.into(), coins);
if let Err(e) = res {
log::debug!("Error returning funds to EthAccount sender: {:?}", e);
// TODO: place funds in rewards pool?
} else {
log::debug!("Returning funds to EthAccount sender");
}
}
_ => {}
}
Expand Down
9 changes: 7 additions & 2 deletions src/ethereum/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,12 @@ impl Connection {

/// Processes an adjustment to the emergency disbursal balances received
/// from the remote bridge contract deployment.
///
/// NOTE: as of this version, the emergency disbursal balances are not yet
/// being used by the Bitcoin state machine. When it is integrated, the
/// total balances will be checked against the actual amount of funds
/// bridged to the contract and all emergency disbursal balances will be
/// ignored if the total exceeds the actual balance.
pub fn adjust_emergency_disbursal_balance(
&mut self,
script: Adapter<Script>,
Expand Down Expand Up @@ -1003,8 +1009,7 @@ pub fn logic_call_args(
maxGas: alloy_core::primitives::U256::from(max_gas),
payload: alloy_core::primitives::Bytes::from(data.to_vec()),
timeOut: alloy_core::primitives::U256::from(u64::MAX),
invalidationId: alloy_core::primitives::FixedBytes::from(uint256(nonce_id)), /* TODO: set
* in msg */
invalidationId: alloy_core::primitives::FixedBytes::from(uint256(nonce_id)),
invalidationNonce: alloy_core::primitives::U256::from(1),
}
}
Expand Down
Loading