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

fix(create): concat bytecode and constructor call to match old ethabi behavior #6134

Merged
merged 2 commits into from
Oct 27, 2023
Merged
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
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