-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
55 changed files
with
31,171 additions
and
23,422 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[workspace] | ||
members = ["app", "crates"] | ||
members = ["app", "crates/bindings"] | ||
resolver = "2" | ||
|
||
[workspace.dependencies] | ||
foundry-contracts = { path = "crates" } | ||
foundry-contracts = { path = "crates/bindings" } |
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,8 +1,28 @@ | ||
pflow-rs | ||
-------- | ||
# Status | ||
|
||
Early Concept | ||
|
||
Discover and interact with pflow-xyz contracts using this contract explorer. | ||
|
||
## Status | ||
web api | ||
------- | ||
|
||
Early Concept | ||
``` | ||
pflow --daemon | ||
``` | ||
|
||
Run a seqeuncer node to aggregate event logs. | ||
|
||
|
||
cli | ||
--- | ||
|
||
FIXME - need to target | ||
|
||
``` | ||
pflow --try '[{ "action": "foo", "seq": 0, "scalar" },...{ "action": "foo", "seq": 0, "scalar" }]' | ||
``` | ||
|
||
And, execute generalized intent based workflows. |
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
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 |
---|---|---|
|
@@ -6,4 +6,8 @@ clippy: | |
|
||
.PHONY: test | ||
test: | ||
cargo test --all | ||
cargo test --all | ||
|
||
.PHONY: run | ||
run: | ||
cargo run --bin pflow |
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use serde_json::Value; | ||
use std::str::FromStr; | ||
use std::fmt; | ||
|
||
#[derive(Debug, serde::Serialize, serde::Deserialize, Clone)] | ||
pub struct Action { | ||
action: String, | ||
scalar: i64, | ||
#[serde(default)] | ||
seq: Option<i64>, | ||
} | ||
|
||
impl Default for Action { | ||
fn default() -> Self { | ||
Action { | ||
action: "noop".to_string(), | ||
scalar: 1, | ||
seq: Some(0), | ||
} | ||
} | ||
} | ||
|
||
impl FromStr for Action { | ||
type Err = String; | ||
|
||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
let action = serde_json::from_str(s); | ||
match action { | ||
Ok(a) => Ok(a), | ||
Err(e) => Err(e.to_string()), | ||
} | ||
} | ||
} | ||
|
||
impl fmt::Display for Action { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
write!(f, "{}", serde_json::to_string(self).unwrap()) | ||
} | ||
} | ||
|
||
pub fn run_command(action: Action) -> Value { | ||
let result = match action.action.as_str() { | ||
_ => -1, | ||
}; | ||
|
||
serde_json::json!({"result": result}) | ||
} |
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,3 +1,4 @@ | ||
|
||
pub mod server; | ||
pub mod storage; | ||
pub mod command; | ||
pub mod models; |
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,32 +1,52 @@ | ||
use std::error::Error; | ||
use clap::Parser; | ||
use clap::{Parser}; | ||
use tokio::task; | ||
use pflow_cli::server::app; | ||
use pflow_cli::command::{run_command, Action}; | ||
|
||
#[derive(Debug, Parser)] | ||
struct Config { | ||
#[clap(short = 'p', long, default_value = "3000")] | ||
port: u16, | ||
|
||
#[clap(short = 'd', long, default_value = "false")] | ||
daemon: bool, | ||
|
||
#[clap(short = 'v', long, default_value = "false")] | ||
verbose: bool, | ||
|
||
#[clap(value_parser)] | ||
input: Option<Action>, | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), Box<dyn Error>> { | ||
let config = Config::parse(); | ||
let addr = std::net::SocketAddr::from(([127, 0, 0, 1], config.port)); | ||
println!("Listening on {}", addr); | ||
|
||
let browser_task = task::spawn(async { | ||
if webbrowser::open("http://localhost:3000").is_ok() { | ||
println!("Browser opened successfully"); | ||
if config.daemon { | ||
println!("Listening on {}", addr); | ||
let browser_task = task::spawn(async { | ||
if webbrowser::open("http://localhost:3000").is_ok() { | ||
println!("Browser opened successfully"); | ||
} else { | ||
println!("Failed to open browser"); | ||
} | ||
}); | ||
|
||
axum_server::bind(addr) | ||
.serve(app().into_make_service()) | ||
.await?; | ||
|
||
browser_task.await?; | ||
} else { | ||
if config.input.is_none() { | ||
println!("No input provided"); | ||
} else { | ||
println!("Failed to open browser"); | ||
run_command(config.input.expect("No input provided")); | ||
} | ||
}); | ||
|
||
axum_server::bind(addr) | ||
.serve(app().into_make_service()) | ||
.await?; | ||
return Ok(()); | ||
} | ||
|
||
browser_task.await?; | ||
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use lazy_static::lazy_static; | ||
use pflow_metamodel::*; | ||
|
||
/// Expected CID needs to be updated if the model definition changes | ||
fn check_for_update(cid: &str, model: &Model) { | ||
let zblob = model.net.to_zblob(); | ||
assert_eq!(cid, zblob.ipfs_cid, "[MODIFIED] {}\n[pflow] https://pflow.dev?z={:}\n",zblob.ipfs_cid, zblob.base64_zipped); | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! pflow_model { | ||
($name:ident, $oid_name:ident, $expected_cid:expr, $($dsl:tt)*) => { | ||
lazy_static! { | ||
pub static ref $name: Model = { | ||
let model = pflow_dsl! { | ||
$($dsl)* | ||
}; | ||
check_for_update($expected_cid, &model); | ||
model | ||
}; | ||
|
||
pub static ref $oid_name: String = $expected_cid.to_string(); | ||
} | ||
}; | ||
} | ||
|
||
/// Declare the model and its OID outside of the test module | ||
/// Expected CID needs to be updated if the model changes | ||
pflow_model!(TEST_MODEL, | ||
TEST_CID, "zb2rhnJobUyvbfHB3yrFDZ3Z4KDhJRSNtrpeU272zri2LYfDT", | ||
declare "petriNet" | ||
cell "place0", 0, 3, [100, 180] | ||
func "txn0", "default", [20, 100] | ||
func "txn1", "default", [180, 100] | ||
func "txn2", "default", [20, 260] | ||
func "txn3", "default", [180, 260] | ||
arrow "txn0", "place0", 1 | ||
arrow "place0", "txn1", 3 | ||
guard "txn2", "place0", 3 | ||
guard "place0", "txn3", 1 | ||
); | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn test_pflow_dsl() { | ||
check_for_update(&**TEST_CID, &TEST_MODEL); | ||
} | ||
|
||
} |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.