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

Remove FixedDepositAnchor contract, update contracts, and update ethers-rs #75

Merged
merged 4 commits into from
Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
1,657 changes: 1,077 additions & 580 deletions Cargo.lock

Large diffs are not rendered by default.

11 changes: 4 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ members = [".", "proposals"]

[package]
name = "webb"
version = "0.4.4"
version = "0.5.0"
edition = "2021"
authors = ["Webb Developers"]
license = "GPL-3.0"
Expand All @@ -24,11 +24,8 @@ async-trait = "0.1"
rand = { version = "0.8", default-features = false, features = ["getrandom"] }
thiserror = "1.0.26"
hex = { version = "0.4", default-features = false }

# EVM crates.
ethers = { version = "0.6.0", default-features = false, optional = true, features = ["legacy", "rustls"] }
# Used by ethers (but we need it to be vendored with the lib).
openssl = { version = "0.10", features = ["vendored"], optional = true }
ethers = { version = "0.17.0", default-features = false, optional = true, features = ["legacy", "rustls", "abigen"] }
serde = { version = "1", default-features = false, features = ["derive"] }
serde_json = { version = "1", optional = true }

Expand All @@ -40,7 +37,7 @@ sp-keyring = "6.0.0"
[build-dependencies]
serde_json = "1"
tempfile = "3.2"
ethers = { version = "0.6.0", default-features = false, optional = true, features = ["legacy"] }
ethers = { version = "0.17.0", default-features = false, optional = true, features = ["legacy", "abigen"] }
syn = { version = "1.0.80", optional = true }
scale = { package = "parity-scale-codec", version = "3", default-features = false, optional = true }
frame-metadata = { version = "15.0.0", optional = true, features = ["v14", "std"] }
Expand All @@ -50,7 +47,7 @@ subxt-codegen = { version = "0.22.0", optional = true }
default = ["substrate-runtime", "evm-runtime"]
# Main features.
substrate-runtime = ["subxt", "scale", "scale-info"]
evm-runtime = ["ethers", "serde_json", "openssl"]
evm-runtime = ["ethers", "serde_json"]
# Tests
integration-tests = []
# Build
Expand Down
31 changes: 11 additions & 20 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@ use std::error::Error;

#[cfg(feature = "generate-contracts")]
mod evm {
use std::io::Write;

use ethers::contract::Abigen;
use tempfile::NamedTempFile;

use super::*;
use ethers::contract::Abigen;

fn parse_and_write_abigen(
path: &str,
Expand All @@ -17,12 +13,7 @@ mod evm {
println!("cargo:rerun-if-changed=./{}", path);
println!("cargo:rerun-if-changed=./{}", out);

let contract_file = std::fs::read_to_string(path)?;
let raw: serde_json::Value = serde_json::from_str(&contract_file)?;
let abi = serde_json::to_vec(&raw["abi"])?;
let mut abi_file = NamedTempFile::new()?;
abi_file.write_all(&abi)?;
Abigen::new(contract_name, abi_file.path().to_string_lossy())?
Abigen::new(contract_name, path)?
.add_event_derive("serde::Serialize")
.add_event_derive("serde::Deserialize")
.rustfmt(false) // don't use rustfmt for now.
Expand All @@ -39,14 +30,6 @@ mod evm {
)
}

pub fn build_protocol_solidity_anchor() -> Result<(), Box<dyn Error>> {
parse_and_write_abigen(
"contracts/protocol-solidity/FixedDepositAnchor.json",
"src/evm/contract/protocol_solidity/fixed_deposit_anchor.rs",
"FixedDepositAnchorContract",
)
}

pub fn build_protocol_solidity_vanchor() -> Result<(), Box<dyn Error>> {
parse_and_write_abigen(
"contracts/protocol-solidity/VAnchor.json",
Expand Down Expand Up @@ -91,6 +74,14 @@ mod evm {
)
}

pub fn build_protocol_solidity_token_wrapper() -> Result<(), Box<dyn Error>>
{
parse_and_write_abigen(
"contracts/protocol-solidity/TokenWrapper.json",
"src/evm/contract/protocol_solidity/token_wrapper.rs",
"TokenWrapperContract",
)
}
pub fn build_protocol_solidity_treasury() -> Result<(), Box<dyn Error>> {
parse_and_write_abigen(
"contracts/protocol-solidity/Treasury.json",
Expand Down Expand Up @@ -191,11 +182,11 @@ fn main() -> Result<(), Box<dyn Error>> {
#[cfg(feature = "generate-contracts")]
{
evm::build_protocol_solidity_anchor_base()?;
evm::build_protocol_solidity_anchor()?;
evm::build_protocol_solidity_vanchor()?;
evm::build_protocol_solidity_anchor_proxy()?;
evm::build_protocol_solidity_anchor_handler()?;
evm::build_protocol_solidity_signature_bridge()?;
evm::build_protocol_solidity_token_wrapper()?;
evm::build_protocol_solidity_governed_token_wrapper()?;
evm::build_protocol_solidity_token_wrapper_handler()?;
evm::build_protocol_solidity_treasury()?;
Expand Down
23 changes: 2 additions & 21 deletions contracts/protocol-solidity/AnchorHandler.json

Large diffs are not rendered by default.

Loading