Skip to content

Commit

Permalink
Merge pull request #327 from nomic-io/eth-misc
Browse files Browse the repository at this point in the history
Eth misc fixes
  • Loading branch information
mappum authored Oct 28, 2024
2 parents b1afd08 + 2f2e0c1 commit da29cf7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
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

0 comments on commit da29cf7

Please sign in to comment.