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

Feat/will hacky #482

Merged
Prev Previous commit
Next Next commit
clippy + fmt
  • Loading branch information
0xJepsen committed Sep 7, 2023
commit 09bc3ebf07eff11190b6b6631998afc62f9bd5b5
155 changes: 49 additions & 106 deletions arbiter-core/src/middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,63 +345,6 @@ impl Middleware for RevmMiddleware {

let outcome = self.provider().as_ref().outcome_receiver.recv()??;

// match revm_result.outcome {
// TransactionOutcome::Success(execution_result) => {
// let Success { logs, output, .. } = unpack_execution_result(execution_result)?;
// let block_number = revm_result.block_number;

// match output {
// Output::Create(_, address) => {
// let tx_receipt = TransactionReceipt {
// block_hash: None,
// block_number: Some(block_number),
// contract_address: Some(recast_address(address.unwrap())),
// ..Default::default()
// };

// // TODO: Create the actual tx_hash
// // TODO: I'm not sure we need to set the confirmations.
// let mut pending_tx =
// PendingTransaction::new(ethers::types::H256::zero(), self.provider())
// .interval(Duration::ZERO)
// .confirmations(0);

// let state_ptr: *mut PendingTxState =
// &mut pending_tx as *mut _ as *mut PendingTxState;

// // Modify the value (this assumes you have access to the enum variants)
// unsafe {
// *state_ptr = PendingTxState::CheckingReceipt(Some(tx_receipt));
// }

// Ok(pending_tx)
// }
// Output::Call(_) => {
// let block_number = revm_result.block_number;
// let tx_receipt = TransactionReceipt {
// block_hash: None,
// block_number: Some(block_number),
// logs,
// ..Default::default()
// };

// // TODO: Create the actual tx_hash
// // TODO: I'm not sure we need to set the confirmations.
// let mut pending_tx =
// PendingTransaction::new(ethers::types::H256::zero(), self.provider())
// .interval(Duration::ZERO)
// .confirmations(0);

// let state_ptr: *mut PendingTxState =
// &mut pending_tx as *mut _ as *mut PendingTxState;

// // Modify the value (this assumes you have access to the enum variants)
// unsafe {
// *state_ptr = PendingTxState::CheckingReceipt(Some(tx_receipt));
// }

// Ok(pending_tx)
// }
if let Outcome::TransactionCompleted(execution_result, block_number) = outcome {
let Success {
_reason: _,
Expand All @@ -412,59 +355,59 @@ impl Middleware for RevmMiddleware {
} = unpack_execution_result(execution_result)?;

match output {
Output::Create(_, address) => {
// TODO: Add other reciept fields
let tx_receipt = TransactionReceipt {
block_hash: None,
block_number: Some(block_number),
contract_address: Some(recast_address(address.unwrap())),
logs,
..Default::default()
};

// TODO: Create the actual tx_hash
// TODO: I'm not sure we need to set the confirmations.
let mut pending_tx =
PendingTransaction::new(ethers::types::H256::zero(), self.provider())
.interval(Duration::ZERO)
.confirmations(0);

let state_ptr: *mut PendingTxState =
&mut pending_tx as *mut _ as *mut PendingTxState;

// Modify the value (this assumes you have access to the enum variants)
unsafe {
*state_ptr = PendingTxState::CheckingReceipt(Some(tx_receipt));
}
Output::Create(_, address) => {
// TODO: Add other reciept fields
let tx_receipt = TransactionReceipt {
block_hash: None,
block_number: Some(block_number),
contract_address: Some(recast_address(address.unwrap())),
logs,
..Default::default()
};

// TODO: Create the actual tx_hash
// TODO: I'm not sure we need to set the confirmations.
let mut pending_tx =
PendingTransaction::new(ethers::types::H256::zero(), self.provider())
.interval(Duration::ZERO)
.confirmations(0);

let state_ptr: *mut PendingTxState =
&mut pending_tx as *mut _ as *mut PendingTxState;

// Modify the value (this assumes you have access to the enum variants)
unsafe {
*state_ptr = PendingTxState::CheckingReceipt(Some(tx_receipt));
}

Ok(pending_tx)
Ok(pending_tx)
}
Output::Call(_) => {
// TODO: Add other reciept fields
let tx_receipt = TransactionReceipt {
block_hash: None,
block_number: Some(block_number),
logs,
..Default::default()
};

// TODO: Create the actual tx_hash
// TODO: I'm not sure we need to set the confirmations.
let mut pending_tx =
PendingTransaction::new(ethers::types::H256::zero(), self.provider())
.interval(Duration::ZERO)
.confirmations(0);

let state_ptr: *mut PendingTxState =
&mut pending_tx as *mut _ as *mut PendingTxState;

// Modify the value (this assumes you have access to the enum variants)
unsafe {
*state_ptr = PendingTxState::CheckingReceipt(Some(tx_receipt));
}
// TODO: Add other reciept fields
let tx_receipt = TransactionReceipt {
block_hash: None,
block_number: Some(block_number),
logs,
..Default::default()
};

// TODO: Create the actual tx_hash
// TODO: I'm not sure we need to set the confirmations.
let mut pending_tx =
PendingTransaction::new(ethers::types::H256::zero(), self.provider())
.interval(Duration::ZERO)
.confirmations(0);

let state_ptr: *mut PendingTxState =
&mut pending_tx as *mut _ as *mut PendingTxState;

// Modify the value (this assumes you have access to the enum variants)
unsafe {
*state_ptr = PendingTxState::CheckingReceipt(Some(tx_receipt));
}

Ok(pending_tx)
},
Ok(pending_tx)
}
}
} else {
panic!("This should never happen!")
Expand Down