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

Commit

Permalink
wip : deploy a contract, poc
Browse files Browse the repository at this point in the history
  • Loading branch information
Leon-azerty committed Jan 7, 2024
1 parent 623364f commit 2d77455
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 0 deletions.
9 changes: 9 additions & 0 deletions toolchains/solidity/core/Cargo.lock

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

14 changes: 14 additions & 0 deletions toolchains/solidity/core/crates/foundry-deploy/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "foundry-deploy"
version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true
exclude.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
osmium-libs-foundry-wrapper = { path = "../../../../../libs/foundry-wrapper" }
tower-lsp = "0.20.0"
tokio = { version = "1.34.0", features = ["full"] }
3 changes: 3 additions & 0 deletions toolchains/solidity/core/crates/foundry-deploy/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build:
cargo build
cp ../../target/debug/foundry-server ../../../extension/dist
53 changes: 53 additions & 0 deletions toolchains/solidity/core/crates/foundry-deploy/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
use std::process::Command;
use tower_lsp::{Client, LanguageServer};

#[derive(Debug)]
struct Backend {
client: Client,
}

impl<InitializeResult> LanguageServer for Backend {
fn initialize(&self, params: InitializeParams) -> Result<InitializeResult> {}

fn deploy_contract() {
//get infos thanks to the client
let contractName = "Test";
let rpc_url = "rpc_urlTest";
let key = "keyTest";

// Create a new instance of the command
let mut cmd = Command::new("forge");
// Add arguments to the command
cmd.arg("create");
cmd.arg("--rpc-url");
cmd.arg(rpc_url);
cmd.arg("--private-key");
cmd.arg(key);
cmd.arg("--verify");
cmd.arg(contractName);

// Execute the command and capture the result
let result = cmd.status();

// Handle the result
match result {
Ok(status) => {
if status.success() {
println!("Command executed successfully!");
} else {
println!("Command failed with exit code: {:?}", status.code());
}
}
Err(e) => {
println!("Error executing the command: {:?}", e);
}
}
}

fn shutdown(&self) -> Result<()> {
Ok(())
}
}

async fn main() {
}

0 comments on commit 2d77455

Please sign in to comment.