-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Run code during finalize_block instead of through FFI * Remove FFI code, move contract and utils to new crate * Undo more changes * Declare addresses in contracts crate * Rename contracts to ain-contracts * Fix clippy errors * Remove extra new line, update gitignore * Undo old changes * Remove unwraps * Add test header * Refactor to use `get_contract_storage` * Make `basic` optional in `apply` * Rename to `pkg_install_solc` * Fix make.sh, remove redundant clone * Compile multiple contracts * Add DST20 support * Only deploy DST20 of DATs * Use executor state for bridge, add more tests * Add tests, fix empty balance bridge issue Bridge issue pending PR #2221 * Refactor rest of DST20 tests * Add 0 balance test * Fix lints * Use SOLC_PATH, fix build, add more tests * Add check for same token ID * Move BridgeTx into SystemTx * Validate DST20 code during transferdomain * Check for address usage before deployment * Add feature flag for transferdomain * Feature flag every edges * Trigger actions * Remove unused attributes --------- Co-authored-by: Prasanna Loganathar <[email protected]> Co-authored-by: jouzo <[email protected]> Co-authored-by: Jouzo <[email protected]>
- Loading branch information
1 parent
ca8b35e
commit e9daefb
Showing
23 changed files
with
1,396 additions
and
126 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,54 @@ | ||
use anyhow::anyhow; | ||
use ethers_solc::{Project, ProjectPathsConfig}; | ||
use ethers_solc::{Project, ProjectPathsConfig, Solc}; | ||
use std::env; | ||
use std::fs; | ||
use std::path::PathBuf; | ||
|
||
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
// compile solidity project | ||
// configure `root` as our project root | ||
let root = PathBuf::from("counter_contract"); | ||
if !root.exists() { | ||
return Err("Project root {root:?} does not exists!".into()); | ||
} | ||
let contracts = vec![("counter_contract", "Counter"), ("dst20", "DST20")]; | ||
|
||
let paths = ProjectPathsConfig::builder() | ||
.root(&root) | ||
.sources(&root) | ||
.build()?; | ||
|
||
let project = Project::builder() | ||
.paths(paths) | ||
.set_auto_detect(true) | ||
.no_artifacts() | ||
.build()?; | ||
let output = project.compile().unwrap(); | ||
let artifacts = output.into_artifacts(); | ||
|
||
for (id, artifact) in artifacts { | ||
if id.name == "Counter" { | ||
let abi = artifact.abi.ok_or_else(|| anyhow!("ABI not found"))?; | ||
let bytecode = artifact.deployed_bytecode.expect("No bytecode found"); | ||
|
||
fs::create_dir_all("counter_contract/output/")?; | ||
fs::write( | ||
PathBuf::from("counter_contract/output/bytecode.json"), | ||
serde_json::to_string(&bytecode).unwrap().as_bytes(), | ||
)?; | ||
fs::write( | ||
PathBuf::from("counter_contract/output/abi.json"), | ||
serde_json::to_string(&abi).unwrap().as_bytes(), | ||
)?; | ||
for (file_path, contract_name) in contracts { | ||
let solc = Solc::new(env::var("SOLC_PATH")?); | ||
let root = PathBuf::from(file_path); | ||
if !root.exists() { | ||
return Err("Project root {root:?} does not exists!".into()); | ||
} | ||
} | ||
|
||
project.rerun_if_sources_changed(); | ||
let paths = ProjectPathsConfig::builder() | ||
.root(&root) | ||
.sources(&root) | ||
.build()?; | ||
|
||
let project = Project::builder() | ||
.solc(solc) | ||
.paths(paths) | ||
.set_auto_detect(true) | ||
.no_artifacts() | ||
.build()?; | ||
let output = project.compile().unwrap(); | ||
let artifacts = output.into_artifacts(); | ||
|
||
for (id, artifact) in artifacts { | ||
if id.name == contract_name { | ||
let abi = artifact.abi.ok_or_else(|| anyhow!("ABI not found"))?; | ||
let bytecode = artifact.deployed_bytecode.expect("No bytecode found"); | ||
|
||
fs::create_dir_all(format!("{file_path}/output/"))?; | ||
fs::write( | ||
PathBuf::from(format!("{file_path}/output/bytecode.json")), | ||
serde_json::to_string(&bytecode).unwrap().as_bytes(), | ||
)?; | ||
fs::write( | ||
PathBuf::from(format!("{file_path}/output/abi.json")), | ||
serde_json::to_string(&abi).unwrap().as_bytes(), | ||
)?; | ||
} | ||
} | ||
|
||
project.rerun_if_sources_changed(); | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,4 @@ pragma solidity >=0.8.2 <0.9.0; | |
*/ | ||
contract Counter { | ||
uint256 public number; | ||
} | ||
} |
Oops, something went wrong.