Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

feat(solc): add support for library linking #656

Merged
merged 9 commits into from
Dec 8, 2021
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

- Return cached artifacts from project `compile` when the cache only contains
some files
- Add support for library linking and make `Bytecode`'s `object` filed an `enum BytecodeObject`
[#656](https://github.com/gakonst/ethers-rs/pull/656).

### 0.6.0

Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ethers-contract/src/factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl<M: Middleware> Deployer<M> {
/// let client = std::sync::Arc::new(client);
///
/// // create a factory which will be used to deploy instances of the contract
/// let factory = ContractFactory::new(contract.abi.unwrap().clone(), contract.bin.unwrap().clone(), client);
/// let factory = ContractFactory::new(contract.abi.unwrap().clone(), contract.bytecode().unwrap().clone(), client);
///
/// // The deployer created by the `deploy` call exposes a builder which gets consumed
/// // by the async `send` call
Expand Down
2 changes: 1 addition & 1 deletion ethers-contract/tests/abigen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ async fn can_handle_underscore_functions() {
let compiled = compiled.get(path, contract).unwrap();
let factory = ethers_contract::ContractFactory::new(
compiled.abi.unwrap().clone(),
compiled.bin.unwrap().clone(),
compiled.bytecode().unwrap().clone(),
client.clone(),
);
let addr = factory.deploy("hi".to_string()).unwrap().legacy().send().await.unwrap().address();
Expand Down
3 changes: 2 additions & 1 deletion ethers-contract/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ pub fn compile_contract(name: &str, filename: &str) -> (Abi, Bytes) {
let path = format!("./tests/solidity-contracts/{}", filename);
let compiled = Solc::default().compile_source(&path).unwrap();
let contract = compiled.get(&path, name).expect("could not find contract");
(contract.abi.unwrap().clone(), contract.bin.unwrap().clone())
let (abi, bin, _) = contract.into_parts_or_default();
(abi, bin)
}

/// connects the private key to http://localhost:8545
Expand Down
3 changes: 2 additions & 1 deletion ethers-middleware/tests/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ async fn deploy_and_call_contract() {
let path = format!("./tests/solidity-contracts/{}", path);
let compiled = Solc::default().compile_source(&path).unwrap();
let contract = compiled.get(&path, name).expect("could not find contract");
(contract.abi.unwrap().clone(), contract.bin.unwrap().clone())
let (abi, bin, _) = contract.into_parts_or_default();
(abi, bin)
}

let (abi, bytecode) = compile_contract("SimpleStorage.sol", "SimpleStorage");
Expand Down
3 changes: 2 additions & 1 deletion ethers-middleware/tests/transformer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ fn compile_contract(path: &str, name: &str) -> (Abi, Bytes) {
let path = format!("./tests/solidity-contracts/{}", path);
let compiled = Solc::default().compile_source(&path).unwrap();
let contract = compiled.get(&path, name).expect("could not find contract");
(contract.abi.unwrap().clone(), contract.bin.unwrap().clone())
let (abi, bin, _) = contract.into_parts_or_default();
(abi, bin)
}

#[tokio::test]
Expand Down
1 change: 1 addition & 0 deletions ethers-solc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ svm = { package = "svm-rs", version = "0.2.0", optional = true }
glob = "0.3.0"
tracing = "0.1.29"
num_cpus = "1.13.0"
tiny-keccak = { version = "2.0.2", default-features = false }

[target.'cfg(not(any(target_arch = "x86", target_arch = "x86_64")))'.dependencies]
sha2 = { version = "0.9.8", default-features = false }
Expand Down
4 changes: 0 additions & 4 deletions ethers-solc/benches/compile_many.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ fn load_compiler_inputs() -> Vec<CompilerInput> {
.take(5)
{
let file = file.unwrap();
if file.path().to_string_lossy().as_ref().ends_with("20.json") {
// TODO needs support for parsing library placeholders first
continue
}
let input = std::fs::read_to_string(file.path()).unwrap();
let input: CompilerInput = serde_json::from_str(&input).unwrap();
inputs.push(input);
Expand Down
Loading