Skip to content
This repository has been archived by the owner on Apr 28, 2022. It is now read-only.

Commit

Permalink
Upgrade ethcontract version
Browse files Browse the repository at this point in the history
  • Loading branch information
vkgnosis committed Jul 14, 2021
1 parent 322ed42 commit cf58c1b
Show file tree
Hide file tree
Showing 9 changed files with 158 additions and 133 deletions.
16 changes: 8 additions & 8 deletions Cargo.lock

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

8 changes: 4 additions & 4 deletions contracts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ bin = [
]

[dependencies]
ethcontract = { version = "0.12.2", default-features = false, features = ["http"] }
ethcontract = { version = "0.13.1", default-features = false, features = ["http"] }
serde = "1.0"

# [bin-dependencies]
anyhow = { version = "1.0", optional = true }
env_logger = { version = "0.8", optional = true }
ethcontract-generate = { version = "0.12.2", optional = true}
ethcontract-generate = { version = "0.13.1", optional = true}
filetime = { version = "0.2.14", optional = true }
log = { version = "0.4", optional = true }
serde_json = { version = "1.0", optional = true }
tokio = { version = "1.8", optional = true, features = ["macros", "rt-multi-thread", "time"] }

[build-dependencies]
ethcontract-generate = "0.12.2"
ethcontract = { version = "0.12.2", default-features = false, features = ["http"] }
ethcontract = { version = "0.13.1", default-features = false, features = ["http"] }
ethcontract-generate = "0.13.1"
maplit = "1.0"
190 changes: 108 additions & 82 deletions contracts/build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use ethcontract::common::DeploymentInformation;
use ethcontract_generate::{Address, Builder};
use ethcontract::{
common::{contract::Network, DeploymentInformation},
Address,
};
use ethcontract_generate::{loaders::TruffleLoader, ContractBuilder};
use std::{env, fs, path::Path};

#[path = "src/paths.rs"]
Expand All @@ -17,55 +20,67 @@ fn main() {

generate_contract_with_config("BalancerV2Vault", |builder| {
builder
.with_contract_mod_override(Some("balancer_v2_vault"))
.add_deployment(
1,
addr("0xBA12222222228d8Ba445958a75a0704d566BF2C8"),
Some(tx(
"0x28c44bb10d469cbd42accf97bd00b73eabbace138e9d44593e851231fbed1cb7",
)),
.contract_mod_override("balancer_v2_vault")
.add_network(
"1",
Network {
address: addr("0xBA12222222228d8Ba445958a75a0704d566BF2C8"),
deployment_information: Some(tx(
"0x28c44bb10d469cbd42accf97bd00b73eabbace138e9d44593e851231fbed1cb7",
)),
},
)
.add_deployment(
4,
addr("0xBA12222222228d8Ba445958a75a0704d566BF2C8"),
// <https://rinkeby.etherscan.io/tx/0x5fe65a242760f7f32b582dc402a081791d57ea561474617fcd0e763c995cfec7>
Some(DeploymentInformation::BlockNumber(8441702)),
.add_network(
"4",
Network {
address: addr("0xBA12222222228d8Ba445958a75a0704d566BF2C8"),
// <https://rinkeby.etherscan.io/tx/0x5fe65a242760f7f32b582dc402a081791d57ea561474617fcd0e763c995cfec7>
deployment_information: Some(DeploymentInformation::BlockNumber(8441702)),
},
)
});
generate_contract_with_config("BalancerV2WeightedPoolFactory", |builder| {
builder
.with_contract_mod_override(Some("balancer_v2_weighted_pool_factory"))
.add_deployment(
1,
addr("0x8E9aa87E45e92bad84D5F8DD1bff34Fb92637dE9"),
Some(tx(
"0x0f9bb3624c185b4e107eaf9176170d2dc9cb1c48d0f070ed18416864b3202792",
)),
.contract_mod_override("balancer_v2_weighted_pool_factory")
.add_network(
"1",
Network {
address: addr("0x8E9aa87E45e92bad84D5F8DD1bff34Fb92637dE9"),
deployment_information: Some(tx(
"0x0f9bb3624c185b4e107eaf9176170d2dc9cb1c48d0f070ed18416864b3202792",
)),
},
)
.add_deployment(
4,
addr("0x8E9aa87E45e92bad84D5F8DD1bff34Fb92637dE9"),
Some(tx(
"0xae8c45c1d40756d0eb312723a2993341e379ea6d8bef4adfae2709345939f8eb",
)),
.add_network(
"4",
Network {
address: addr("0x8E9aa87E45e92bad84D5F8DD1bff34Fb92637dE9"),
deployment_information: Some(tx(
"0xae8c45c1d40756d0eb312723a2993341e379ea6d8bef4adfae2709345939f8eb",
)),
},
)
});
generate_contract_with_config("BalancerV2WeightedPool2TokensFactory", |builder| {
builder
.with_contract_mod_override(Some("balancer_v2_weighted_pool_2_tokens_factory"))
.add_deployment(
1,
addr("0xa5bf2ddf098bb0ef6d120c98217dd6b141c74ee0"),
Some(tx(
"0xf40c05058422d730b7035c254f8b765722935a5d3003ac37b13a61860adbaf08",
)),
.contract_mod_override("balancer_v2_weighted_pool_2_tokens_factory")
.add_network(
"1",
Network {
address: addr("0xa5bf2ddf098bb0ef6d120c98217dd6b141c74ee0"),
deployment_information: Some(tx(
"0xf40c05058422d730b7035c254f8b765722935a5d3003ac37b13a61860adbaf08",
)),
},
)
.add_deployment(
4,
addr("0xa5bf2ddf098bb0ef6d120c98217dd6b141c74ee0"),
Some(tx(
"0xbe28062b575c2743b3b4525c3a175b9acad36695c15dba1c69af5f3fc3ceca37",
)),
.add_network(
"4",
Network {
address: addr("0xa5bf2ddf098bb0ef6d120c98217dd6b141c74ee0"),
deployment_information: Some(tx(
"be28062b575c2743b3b4525c3a175b9acad36695c15dba1c69af5f3fc3ceca37",
)),
},
)
});
generate_contract("BalancerV2WeightedPool");
Expand All @@ -74,86 +89,97 @@ fn main() {
generate_contract("GPv2AllowListAuthentication");
generate_contract_with_config("GPv2Settlement", |builder| {
builder
.with_contract_mod_override(Some("gpv2_settlement"))
.add_deployment(
1,
addr("0x3328f5f2cEcAF00a2443082B657CedEAf70bfAEf"),
Some(tx(
"0x34b7f9a340e663df934fcc662b3ec5fcd7cd0c93d3c46f8ce612e94fff803909",
)),
.contract_mod_override("gpv2_settlement")
.add_network(
"1",
Network {
address: addr("0x3328f5f2cEcAF00a2443082B657CedEAf70bfAEf"),
deployment_information: Some(tx(
"34b7f9a340e663df934fcc662b3ec5fcd7cd0c93d3c46f8ce612e94fff803909",
)),
},
)
.add_deployment(
4,
addr("0x3328f5f2cEcAF00a2443082B657CedEAf70bfAEf"),
Some(tx(
"0x52badda922fd91052e6682d125daa59dea3ce5c57add5a9d362bec2d6ccfd2b1",
)),
.add_network(
"4",
Network {
address: addr("0x3328f5f2cEcAF00a2443082B657CedEAf70bfAEf"),
deployment_information: Some(tx(
"52badda922fd91052e6682d125daa59dea3ce5c57add5a9d362bec2d6ccfd2b1",
)),
},
)
.add_deployment(
100,
addr("0x3328f5f2cEcAF00a2443082B657CedEAf70bfAEf"),
Some(tx(
"0x95bbefbca7162435eeb71bac6960aae4d7112abce87a51ad3952d7b7af0279e3",
)),
.add_network(
"100",
Network {
address: addr("0x3328f5f2cEcAF00a2443082B657CedEAf70bfAEf"),
deployment_information: Some(tx(
"95bbefbca7162435eeb71bac6960aae4d7112abce87a51ad3952d7b7af0279e3",
)),
},
)
});
generate_contract("IUniswapLikeRouter");
generate_contract("IUniswapLikePair");
generate_contract_with_config("SushiswapV2Router02", |builder| {
builder
.add_deployment_str(1, "0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F")
.add_deployment_str(4, "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506")
.add_deployment_str(100, "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506")
.add_network_str("1", "0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F")
.add_network_str("4", "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506")
.add_network_str("100", "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506")
});
generate_contract_with_config("SushiswapV2Factory", |builder| {
builder
.add_deployment_str(1, "0xC0AEe478e3658e2610c5F7A4A2E1777cE9e4f2Ac")
.add_deployment_str(4, "0xc35DADB65012eC5796536bD9864eD8773aBc74C4")
.add_deployment_str(100, "0xc35DADB65012eC5796536bD9864eD8773aBc74C4")
.add_network_str("1", "0xC0AEe478e3658e2610c5F7A4A2E1777cE9e4f2Ac")
.add_network_str("4", "0xc35DADB65012eC5796536bD9864eD8773aBc74C4")
.add_network_str("100", "0xc35DADB65012eC5796536bD9864eD8773aBc74C4")
});
generate_contract_with_config("UniswapV2Router02", |builder| {
builder
.add_deployment_str(1, "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D")
.add_deployment_str(4, "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D")
.add_deployment_str(100, "0x1C232F01118CB8B424793ae03F870aa7D0ac7f77")
.add_network_str("1", "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D")
.add_network_str("4", "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D")
.add_network_str("100", "0x1C232F01118CB8B424793ae03F870aa7D0ac7f77")
});
generate_contract_with_config("UniswapV2Factory", |builder| {
builder
.add_deployment_str(1, "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f")
.add_deployment_str(4, "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f")
.add_deployment_str(100, "0xA818b4F111Ccac7AA31D0BCc0806d64F2E0737D7")
.add_network_str("1", "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f")
.add_network_str("4", "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f")
.add_network_str("100", "0xA818b4F111Ccac7AA31D0BCc0806d64F2E0737D7")
});
generate_contract_with_config("WETH9", |builder| {
builder
.add_deployment_str(1, "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2")
.add_deployment_str(4, "0xc778417E063141139Fce010982780140Aa0cD5Ab")
.add_deployment_str(100, "0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d")
.add_network_str("1", "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2")
.add_network_str("4", "0xc778417E063141139Fce010982780140Aa0cD5Ab")
.add_network_str("100", "0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d")
});
}

fn generate_contract(name: &str) {
generate_contract_with_config(name, |builder| builder)
}

fn generate_contract_with_config(name: &str, config: impl FnOnce(Builder) -> Builder) {
let artifact = paths::contract_artifacts_dir()
fn generate_contract_with_config(
name: &str,
config: impl FnOnce(ContractBuilder) -> ContractBuilder,
) {
let path = paths::contract_artifacts_dir()
.join(name)
.with_extension("json");
let contract = TruffleLoader::new()
.name(name)
.load_contract_from_file(&path)
.unwrap();
let address_file = paths::contract_address_file(name);
let dest = env::var("OUT_DIR").unwrap();

println!("cargo:rerun-if-changed={}", artifact.display());
let mut builder = Builder::new(artifact)
.with_contract_name_override(Some(name))
.with_visibility_modifier(Some("pub"));
println!("cargo:rerun-if-changed={}", path.display());
let mut builder = ContractBuilder::new().visibility_modifier("pub");

if let Ok(address) = fs::read_to_string(&address_file) {
println!("cargo:rerun-if-changed={}", address_file.display());
builder = builder.add_deployment_str(5777, address.trim());
builder = builder.add_network_str("5777", address.trim());
}

config(builder)
.generate()
.generate(&contract)
.unwrap()
.write_to_file(Path::new(&dest).join(format!("{}.rs", name)))
.unwrap();
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/bin/vendor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl VendorContext<'_> {
fn github(&self, name: &str, path: &str) -> Result<&Self> {
self.vendor_source(
name,
Source::http(format!("https://raw.githubusercontent.com/{}", path))?,
Source::http(&format!("https://raw.githubusercontent.com/{}", path))?,
)
}

Expand Down
2 changes: 1 addition & 1 deletion e2e/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ harness = false
[dev-dependencies]
contracts = { path = "../contracts" }
criterion = "0.3"
ethcontract = { version = "0.12.2", default-features = false }
ethcontract = { version = "0.13.1", default-features = false }
hex-literal = "0.3"
lazy_static = "1.4"
maplit = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion orderbook/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ bigdecimal = "0.2"
chrono = { version = "0.4", default-features = false, features = ["clock"] }
contracts = { path = "../contracts" }
either = "1.0"
ethcontract = { version = "0.12.2", default-features = false }
ethcontract = { version = "0.13.1", default-features = false }
futures = "0.3.15"
gas-estimation = { git = "https://github.com/gnosis/gp-gas-estimation.git", tag = "v0.2.0", features = ["web3_"] }
hex = { version = "0.4", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async-trait = "0.1"
atty = "0.2"
contracts = { path = "../contracts" }
derivative = "2.2"
ethcontract = { version = "0.12.2", default-features = false }
ethcontract = { version = "0.13.1", default-features = false }
futures = "0.3"
gas-estimation = { git = "https://github.com/gnosis/gp-gas-estimation.git", tag = "v0.2.0", features = ["web3_"] }
hex = { version = "0.4", default-features = false }
Expand Down
Loading

0 comments on commit cf58c1b

Please sign in to comment.