Skip to content

Commit

Permalink
fix(create): concat bytecode and constructor call to match old etha…
Browse files Browse the repository at this point in the history
…bi behavior (#6134)

* fix: concat bytecode and constructor call to match old ethabi behavior

* fmt/clippy
  • Loading branch information
Evalir authored Oct 27, 2023
1 parent 93f64c7 commit aa257c2
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions crates/forge/bin/cmd/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,20 +534,24 @@ where
let data: Bytes = match (self.abi.constructor(), params.is_empty()) {
(None, false) => return Err(ContractError::ConstructorError),
(None, true) => self.bytecode.clone(),
(Some(constructor), _) => constructor
.abi_encode_input(&params)
.map_err(|f| ContractError::DetokenizationError(InvalidOutputType(f.to_string())))?
.into(),
(Some(constructor), _) => {
let input: Bytes = constructor
.abi_encode_input(&params)
.map_err(|f| {
ContractError::DetokenizationError(InvalidOutputType(f.to_string()))
})?
.into();
// Concatenate the bytecode and abi-encoded constructor call.
self.bytecode.iter().copied().chain(input).collect()
}
};

// create the tx object. Since we're deploying a contract, `to` is `None`
// We default to EIP-1559 transactions, but the sender can convert it back
// to a legacy one
#[cfg(feature = "legacy")]
let tx = TransactionRequest { to: None, data: Some(data), ..Default::default() };
#[cfg(not(feature = "legacy"))]
// We default to EIP1559 transactions, but the sender can convert it back
// to a legacy one.
let tx =
Eip1559TransactionRequest { to: None, data: Some(data.0.into()), ..Default::default() };

let tx = tx.into();

Ok(Deployer {
Expand Down

0 comments on commit aa257c2

Please sign in to comment.