mirror of
https://github.com/serai-dex/serai.git
synced 2025-01-09 12:29:27 +00:00
Restore Foundry to a test dependency via direct usage of solc
This commit is contained in:
parent
7f1732c8c0
commit
a43815f101
7 changed files with 16 additions and 31 deletions
|
@ -54,11 +54,5 @@ runs:
|
||||||
components: ${{ inputs.rust-components }}
|
components: ${{ inputs.rust-components }}
|
||||||
targets: wasm32-unknown-unknown, riscv32imac-unknown-none-elf
|
targets: wasm32-unknown-unknown, riscv32imac-unknown-none-elf
|
||||||
|
|
||||||
- name: Install Foundry
|
|
||||||
uses: foundry-rs/foundry-toolchain@cb603ca0abb544f301eaed59ac0baf579aa6aecf
|
|
||||||
with:
|
|
||||||
version: nightly
|
|
||||||
cache: false
|
|
||||||
|
|
||||||
# - name: Cache Rust
|
# - name: Cache Rust
|
||||||
# uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43
|
# uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43
|
||||||
|
|
1
.github/actions/test-dependencies/action.yml
vendored
1
.github/actions/test-dependencies/action.yml
vendored
|
@ -29,6 +29,7 @@ runs:
|
||||||
uses: foundry-rs/foundry-toolchain@cb603ca0abb544f301eaed59ac0baf579aa6aecf
|
uses: foundry-rs/foundry-toolchain@cb603ca0abb544f301eaed59ac0baf579aa6aecf
|
||||||
with:
|
with:
|
||||||
version: nightly
|
version: nightly
|
||||||
|
cache: false
|
||||||
|
|
||||||
- name: Run a Monero Regtest Node
|
- name: Run a Monero Regtest Node
|
||||||
uses: ./.github/actions/monero
|
uses: ./.github/actions/monero
|
||||||
|
|
|
@ -1,7 +1,15 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("cargo:rerun-if-changed=contracts");
|
println!("cargo:rerun-if-changed=contracts");
|
||||||
println!("cargo:rerun-if-changed=artifacts");
|
println!("cargo:rerun-if-changed=artifacts");
|
||||||
println!("cargo:rerun-if-changed=foundry.toml");
|
|
||||||
|
|
||||||
assert!(std::process::Command::new("forge").args(["build"]).status().unwrap().success());
|
#[rustfmt::skip]
|
||||||
|
let args = [
|
||||||
|
"--base-path", ".",
|
||||||
|
"-o", "./artifacts", "--overwrite",
|
||||||
|
"--bin", "--abi",
|
||||||
|
"--optimize",
|
||||||
|
"./contracts/Schnorr.sol"
|
||||||
|
];
|
||||||
|
|
||||||
|
assert!(std::process::Command::new("solc").args(args).status().unwrap().success());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
[profile.default]
|
|
||||||
src = "contracts"
|
|
||||||
out = "artifacts"
|
|
||||||
|
|
||||||
optimizer = true
|
|
||||||
optimizer_runs = 20_000
|
|
|
@ -12,7 +12,7 @@ pub enum EthereumError {
|
||||||
VerificationError,
|
VerificationError,
|
||||||
}
|
}
|
||||||
|
|
||||||
abigen!(Schnorr, "./artifacts/Schnorr.sol/Schnorr.json");
|
abigen!(Schnorr, "./artifacts/Schnorr.abi");
|
||||||
|
|
||||||
pub async fn call_verify(
|
pub async fn call_verify(
|
||||||
contract: &Schnorr<Provider<Http>>,
|
contract: &Schnorr<Provider<Http>>,
|
||||||
|
|
|
@ -27,17 +27,6 @@ use ethereum_serai::{
|
||||||
contract::{Schnorr, call_verify},
|
contract::{Schnorr, call_verify},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(serde::Deserialize)]
|
|
||||||
struct Bytecode {
|
|
||||||
object: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(serde::Deserialize)]
|
|
||||||
struct Artifact {
|
|
||||||
abi: Option<Abi>,
|
|
||||||
bytecode: Bytecode,
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Replace with a contract deployment from an unknown account, so the environment solely has
|
// TODO: Replace with a contract deployment from an unknown account, so the environment solely has
|
||||||
// to fund the deployer, not create/pass a wallet
|
// to fund the deployer, not create/pass a wallet
|
||||||
pub async fn deploy_schnorr_verifier_contract(
|
pub async fn deploy_schnorr_verifier_contract(
|
||||||
|
@ -45,10 +34,9 @@ pub async fn deploy_schnorr_verifier_contract(
|
||||||
client: Arc<Provider<Http>>,
|
client: Arc<Provider<Http>>,
|
||||||
wallet: &k256::ecdsa::SigningKey,
|
wallet: &k256::ecdsa::SigningKey,
|
||||||
) -> eyre::Result<Schnorr<Provider<Http>>> {
|
) -> eyre::Result<Schnorr<Provider<Http>>> {
|
||||||
let path = "./artifacts/Schnorr.sol/Schnorr.json";
|
let abi: Abi = serde_json::from_reader(File::open("./artifacts/Schnorr.abi").unwrap()).unwrap();
|
||||||
let artifact: Artifact = serde_json::from_reader(File::open(path).unwrap()).unwrap();
|
|
||||||
let abi = artifact.abi.unwrap();
|
let hex_bin_buf = std::fs::read_to_string("./artifacts/Schnorr.bin").unwrap();
|
||||||
let hex_bin_buf = artifact.bytecode.object;
|
|
||||||
let hex_bin =
|
let hex_bin =
|
||||||
if let Some(stripped) = hex_bin_buf.strip_prefix("0x") { stripped } else { &hex_bin_buf };
|
if let Some(stripped) = hex_bin_buf.strip_prefix("0x") { stripped } else { &hex_bin_buf };
|
||||||
let bin = hex::decode(hex_bin).unwrap();
|
let bin = hex::decode(hex_bin).unwrap();
|
||||||
|
|
|
@ -48,7 +48,7 @@ svm install 0.8.16
|
||||||
svm use 0.8.16
|
svm use 0.8.16
|
||||||
```
|
```
|
||||||
|
|
||||||
### Install foundry and anvil
|
### Install foundry (for tests)
|
||||||
|
|
||||||
```
|
```
|
||||||
cargo install --git https://github.com/foundry-rs/foundry --profile local --locked forge cast chisel anvil
|
cargo install --git https://github.com/foundry-rs/foundry --profile local --locked forge cast chisel anvil
|
||||||
|
|
Loading…
Reference in a new issue