diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..f5dbe239 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.idea/ +/target +.repl_history diff --git a/.repl_history b/.repl_history new file mode 100644 index 00000000..5487528c --- /dev/null +++ b/.repl_history @@ -0,0 +1,4 @@ +#V2 +interface +call aquamarine invoke ["asd", ["a", "b"]] +call aquamarine invoke ["asd", "a"] diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 00000000..d89e379f --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,228 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "aquamarine" +version = "0.1.0" +dependencies = [ + "fluence", + "log", +] + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "fluence" +version = "0.2.4" +source = "git+https://github.com/fluencelabs/rust-sdk#75f4baaa905255b240d191880aeeed3e7ec1ad4f" +dependencies = [ + "fluence-sdk-macro", + "fluence-sdk-main", + "safe-transmute", +] + +[[package]] +name = "fluence-sdk-macro" +version = "0.2.4" +source = "git+https://github.com/fluencelabs/rust-sdk#75f4baaa905255b240d191880aeeed3e7ec1ad4f" +dependencies = [ + "fluence-sdk-wit", +] + +[[package]] +name = "fluence-sdk-main" +version = "0.2.4" +source = "git+https://github.com/fluencelabs/rust-sdk#75f4baaa905255b240d191880aeeed3e7ec1ad4f" +dependencies = [ + "fluence-sdk-macro", + "log", + "serde", +] + +[[package]] +name = "fluence-sdk-wit" +version = "0.2.4" +source = "git+https://github.com/fluencelabs/rust-sdk#75f4baaa905255b240d191880aeeed3e7ec1ad4f" +dependencies = [ + "proc-macro2", + "quote", + "serde", + "serde_json", + "syn", + "uuid", +] + +[[package]] +name = "getrandom" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "itoa" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" + +[[package]] +name = "libc" +version = "0.2.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f96b10ec2560088a8e76961b00d47107b3a625fecb76dedb29ee7ccbf98235" + +[[package]] +name = "log" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c36fa947111f5c62a733b652544dd0016a43ce89619538a8ef92724a6f501a20" + +[[package]] +name = "proc-macro2" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36e28516df94f3dd551a587da5357459d9b36d945a7c37c3557928c1c2ff2a2c" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom", + "libc", + "rand_chacha", + "rand_core", + "rand_hc", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core", +] + +[[package]] +name = "ryu" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" + +[[package]] +name = "safe-transmute" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50b8b2cd387f744f69469aaed197954ba4c0ecdb31e02edf99b023e0df11178a" + +[[package]] +name = "serde" +version = "1.0.116" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96fe57af81d28386a513cbc6858332abc6117cfdb5999647c6444b8f43a370a5" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.116" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f630a6370fd8e457873b4bd2ffdae75408bc291ba72be773772a4c2a065d9ae8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "164eacbdb13512ec2745fb09d51fd5b22b0d65ed294a1dcf7285a360c80a675c" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "syn" +version = "1.0.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6690e3e9f692504b941dc6c3b188fd28df054f7fb8469ab40680df52fdcc842b" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "unicode-xid" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" + +[[package]] +name = "uuid" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fde2f6a4bea1d6e007c4ad38c6839fa71cbb63b6dbf5b595aa38dc9b1093c11" +dependencies = [ + "rand", +] + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 00000000..ef82ae20 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "aquamarine" +version = "0.1.0" +authors = ["Fluence Labs"] +edition = "2018" + +[[bin]] +name = "aquamarine" +path = "src/main.rs" + +[dependencies] +fluence = { git = "https://github.com/fluencelabs/rust-sdk", features = ["logger"] } +log = "0.4.11" diff --git a/Config.toml b/Config.toml new file mode 100644 index 00000000..935deda1 --- /dev/null +++ b/Config.toml @@ -0,0 +1,6 @@ +modules_dir = "artifacts/" + +[[module]] + name = "aquamarine" + mem_pages_count = 100 + logger_enabled = true diff --git a/artifacts/aquamarine.wasm b/artifacts/aquamarine.wasm new file mode 100755 index 00000000..d4611fb4 Binary files /dev/null and b/artifacts/aquamarine.wasm differ diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 00000000..9e57a1a4 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,40 @@ +/* + * 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; +use log::info; + +pub fn main() { + fluence::WasmLogger::init_with_level(log::Level::Info).unwrap(); +} + +#[fce] +pub struct StepperOutcome { + pub aqua: String, + pub next_peer_pks: Vec, +} + +#[fce] +pub fn invoke(init_user_id: String, aqua: String) -> StepperOutcome { + info!("stepper invoked with user_id = {}, aqua = {:?}", init_user_id, aqua); + + let outcome = StepperOutcome { + aqua, + next_peer_pks: vec![init_user_id] + }; + + outcome +}