mirror of
https://github.com/fluencelabs/aquavm
synced 2024-12-04 15:20:16 +00:00
first prototype
This commit is contained in:
parent
0bba055ad5
commit
aee41603e8
50
Cargo.lock
generated
50
Cargo.lock
generated
@ -6,6 +6,9 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"fluence",
|
||||
"log",
|
||||
"serde",
|
||||
"serde-lexpr",
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -16,7 +19,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
||||
|
||||
[[package]]
|
||||
name = "fluence"
|
||||
version = "0.2.6"
|
||||
version = "0.2.7"
|
||||
dependencies = [
|
||||
"fluence-sdk-macro",
|
||||
"fluence-sdk-main",
|
||||
@ -24,14 +27,14 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "fluence-sdk-macro"
|
||||
version = "0.2.6"
|
||||
version = "0.2.7"
|
||||
dependencies = [
|
||||
"fluence-sdk-wit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fluence-sdk-main"
|
||||
version = "0.2.6"
|
||||
version = "0.2.7"
|
||||
dependencies = [
|
||||
"fluence-sdk-macro",
|
||||
"log",
|
||||
@ -40,7 +43,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "fluence-sdk-wit"
|
||||
version = "0.2.6"
|
||||
version = "0.2.7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -67,6 +70,29 @@ version = "0.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6"
|
||||
|
||||
[[package]]
|
||||
name = "lexpr"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d6b5eeb1dcf1c6a1fad8c1a88c4cc01618db83810c55cc64c1f86d73688fbfdc"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"lexpr-macros",
|
||||
"proc-macro-hack",
|
||||
"ryu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lexpr-macros"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cd627fb38e19c00d8d068618259205f7a91c91aeade5c15bc35dbca037bb1c35"
|
||||
dependencies = [
|
||||
"proc-macro-hack",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.77"
|
||||
@ -88,6 +114,12 @@ version = "0.2.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c36fa947111f5c62a733b652544dd0016a43ce89619538a8ef92724a6f501a20"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-hack"
|
||||
version = "0.5.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "99c605b9a0adc77b7211c6b1f722dcb613d68d66859a44f3d485a6da332b0598"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.21"
|
||||
@ -162,6 +194,16 @@ dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde-lexpr"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "143e5e658ac3a7374bdf285b9355cab74dd144293b86c9be27eab39452239d41"
|
||||
dependencies = [
|
||||
"lexpr",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.116"
|
||||
|
@ -10,4 +10,7 @@ path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
fluence = { path = "/Users/mike/dev/work/fluence/wasm/rust-sdk", features = ["logger"] }
|
||||
serde = "1.0.116"
|
||||
serde_derive = "1.0.116"
|
||||
serde-lexpr = "0.1.1"
|
||||
log = "0.4.11"
|
||||
|
25
src/instructions/call.rs
Normal file
25
src/instructions/call.rs
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2020 Fluence Labs Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
use serde_derive::{Serialize, Deserialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
|
||||
pub(crate) struct Call {
|
||||
pub peer_part: (String, Option<String>),
|
||||
pub fn_part: (Option<String>, String),
|
||||
pub args: String,
|
||||
pub result_name: String,
|
||||
}
|
28
src/instructions/mod.rs
Normal file
28
src/instructions/mod.rs
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2020 Fluence Labs Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mod call;
|
||||
|
||||
use serde_derive::{Serialize, Deserialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub(crate) enum Instruction {
|
||||
Null,
|
||||
Call(call::Call),
|
||||
Par(Box<Instruction>, Box<Instruction>),
|
||||
Seq(Box<Instruction>, Box<Instruction>),
|
||||
}
|
19
src/lib.rs
Normal file
19
src/lib.rs
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright 2020 Fluence Labs Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mod stepper_outcome;
|
||||
|
||||
pub use stepper_outcome::StepperOutcome;
|
25
src/main.rs
25
src/main.rs
@ -14,23 +14,21 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
mod air;
|
||||
mod instructions;
|
||||
mod stepper_outcome;
|
||||
|
||||
use instructions::Instruction;
|
||||
use stepper_outcome::StepperOutcome;
|
||||
|
||||
use fluence::fce;
|
||||
use log::info;
|
||||
|
||||
pub fn main() {
|
||||
fluence::WasmLogger::init_with_level(log::Level::Info).unwrap();
|
||||
}
|
||||
|
||||
#[fce]
|
||||
pub struct StepperOutcome {
|
||||
pub data: String,
|
||||
pub next_peer_pks: Vec<String>,
|
||||
}
|
||||
|
||||
#[fce]
|
||||
pub fn invoke(init_user_id: String, aqua: String, data: String) -> StepperOutcome {
|
||||
info!(
|
||||
log::info!(
|
||||
"stepper invoked with user_id = {}, aqua = {:?}, data = {:?}",
|
||||
init_user_id, aqua, data
|
||||
);
|
||||
@ -40,5 +38,16 @@ pub fn invoke(init_user_id: String, aqua: String, data: String) -> StepperOutcom
|
||||
next_peer_pks: vec![init_user_id],
|
||||
};
|
||||
|
||||
let parsed_aqua: Vec<Instruction> = match serde_lexpr::from_str(&aqua) {
|
||||
Ok(parsed) => parsed,
|
||||
Err(e) => {
|
||||
log::error!("supplied aqua script can't be parsed: {:?}", e);
|
||||
|
||||
return outcome;
|
||||
}
|
||||
};
|
||||
|
||||
log::info!("parsed_aqua: {:?}", parsed_aqua);
|
||||
|
||||
outcome
|
||||
}
|
||||
|
23
src/stepper_outcome.rs
Normal file
23
src/stepper_outcome.rs
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2020 Fluence Labs Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
use fluence::fce;
|
||||
|
||||
#[fce]
|
||||
pub struct StepperOutcome {
|
||||
pub data: String,
|
||||
pub next_peer_pks: Vec<String>,
|
||||
}
|
Loading…
Reference in New Issue
Block a user