mirror of
https://github.com/fluencelabs/examples
synced 2025-04-25 10:42:16 +00:00
update to marine, marine-test, bump versions
This commit is contained in:
parent
7f33ee4b4f
commit
0f1425c650
Binary file not shown.
Binary file not shown.
@ -1,27 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
set -o errexit -o nounset -o pipefail
|
||||
|
||||
# This script builds all subprojects and puts all created Wasm modules in one dir
|
||||
# cd sqlite
|
||||
# cargo update
|
||||
# fce build --release
|
||||
# cd ..
|
||||
cd curl_adapter
|
||||
cargo update --aggressive
|
||||
marine build --release
|
||||
|
||||
cd ../facade
|
||||
cargo update --aggressive
|
||||
marine build --release
|
||||
cd ..
|
||||
|
||||
mkdir -p artifacts
|
||||
rm -f artifacts/*.wasm
|
||||
|
||||
cd curl_adapter
|
||||
cargo update
|
||||
fce build --release
|
||||
cd ..
|
||||
|
||||
cd facade
|
||||
cargo update
|
||||
fce build --release
|
||||
cd ..
|
||||
|
||||
rm -f artifacts/*
|
||||
cp curl_adapter/target/wasm32-wasi/release/curl_adapter.wasm artifacts/
|
||||
cp facade/target/wasm32-wasi/release/facade.wasm artifacts/
|
||||
# cp sqlite/target/wasm32-wasi/release/sqlite_test.wasm artifacts/
|
||||
# wget https://github.com/fluencelabs/sqlite/releases/download/v0.9.0_w/sqlite3.wasm
|
||||
# mv sqlite3.wasm artifacts/
|
||||
|
104
web3-examples/web3-examples/curl_adapter/Cargo.lock
generated
104
web3-examples/web3-examples/curl_adapter/Cargo.lock
generated
@ -33,67 +33,34 @@ dependencies = [
|
||||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fce-timestamp-macro"
|
||||
version = "0.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3c59a6302902583b2c84e87de9d72b949da4396a369baf0aaa49e97021600bb0"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"quote",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fluence"
|
||||
version = "0.6.2"
|
||||
version = "0.6.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b731bd4a69a3945186f2ff96ff753908939c8a2debd60e1f0e8edb6a28757f8"
|
||||
checksum = "88b09e1cd11a51ba4d169db347d009fe41ece2714eef4d5df720343733a1d5a6"
|
||||
dependencies = [
|
||||
"fce-timestamp-macro",
|
||||
"fluence-sdk-macro",
|
||||
"fluence-sdk-main",
|
||||
"marine-macro",
|
||||
"marine-timestamp-macro",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fluence-sdk-macro"
|
||||
version = "0.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cb43d2f51f1becb70e2125ef8ca9759597900f95cc22ce7dca981a7d6ccd7dde"
|
||||
dependencies = [
|
||||
"fluence-sdk-wit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fluence-sdk-main"
|
||||
version = "0.6.1"
|
||||
version = "0.6.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a78910d85e3cdcb9c2baf56144f20a99925c67ac445d4156220c005bfd2f9604"
|
||||
checksum = "68d93cde99e1494e11755a39b93863333397245c9959c774fe3bebd9e4143879"
|
||||
dependencies = [
|
||||
"fluence-sdk-macro",
|
||||
"log",
|
||||
"marine-macro",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fluence-sdk-wit"
|
||||
version = "0.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eab3ed39703b72e0e52bce9e1760746c73f65a5694c8da4dec751d3bfdec15b8"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"syn",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.2"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8"
|
||||
checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
@ -108,9 +75,9 @@ checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.84"
|
||||
version = "0.2.97"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1cca32fa0182e8c0989459524dc356b8f2b5c10f1b9eb521b7d182c03cf8c5ff"
|
||||
checksum = "12b8adadd720df158f4d70dfe7ccc6adb0472d7c55ca83445f6a5ab3e36f8fb6"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
@ -121,6 +88,39 @@ dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "marine-macro"
|
||||
version = "0.6.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f63d927851847cc3dd9e3bd0f10bdeb313859d4822d5b5f650d9d34d461ed419"
|
||||
dependencies = [
|
||||
"marine-macro-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "marine-macro-impl"
|
||||
version = "0.6.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fb504be4a90e229ab453c7369cc8a9063acec819f3397802eea719cd0a232be1"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"syn",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "marine-timestamp-macro"
|
||||
version = "0.6.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5994c7db5567d21609f2a2e5a40d9d4564f86c17ca35b2d77007152619b9d7fc"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"quote",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-integer"
|
||||
version = "0.1.44"
|
||||
@ -142,9 +142,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.24"
|
||||
version = "1.0.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71"
|
||||
checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038"
|
||||
dependencies = [
|
||||
"unicode-xid",
|
||||
]
|
||||
@ -186,9 +186,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.61"
|
||||
version = "1.0.64"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4fceb2595057b6891a4ee808f70054bd2d12f0e97f1cbb78689b59f676df325a"
|
||||
checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"ryu",
|
||||
@ -197,9 +197,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.67"
|
||||
version = "1.0.73"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6498a9efc342871f91cc2d0d694c674368b4ceb40f62b65a7a08c3792935e702"
|
||||
checksum = "f71489ff30030d2ae598524f61326b902466f72a0fb1a8564c001cc63425bcc7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -219,9 +219,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
|
||||
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
|
||||
|
||||
[[package]]
|
||||
name = "uuid"
|
||||
|
@ -10,5 +10,5 @@ path = "src/main.rs"
|
||||
name = "curl_adapter"
|
||||
|
||||
[dependencies]
|
||||
fluence = { version = "=0.6.2", features = ["logger"]}
|
||||
fluence = { version = "=0.6.9", features = ["logger"]}
|
||||
log = "0.4.8"
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
#![allow(improper_ctypes)]
|
||||
|
||||
use fluence::fce;
|
||||
use fluence::marine;
|
||||
use fluence::module_manifest;
|
||||
use fluence::MountedBinaryResult;
|
||||
use fluence::WasmLoggerBuilder;
|
||||
@ -27,33 +27,15 @@ fn main() {
|
||||
WasmLoggerBuilder::new().build().unwrap();
|
||||
}
|
||||
|
||||
#[fce]
|
||||
#[marine]
|
||||
pub fn curl_request(curl_cmd: Vec<String>) -> MountedBinaryResult {
|
||||
let response = curl(curl_cmd);
|
||||
response
|
||||
}
|
||||
|
||||
// mounted_binaries are available to import like this:
|
||||
#[fce]
|
||||
#[marine]
|
||||
#[link(wasm_import_module = "host")]
|
||||
extern "C" {
|
||||
pub fn curl(cmd: Vec<String>) -> MountedBinaryResult;
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn curl_test() {
|
||||
let args = r#"-X POST --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x1b4", true],"id":1}'"#;
|
||||
let url = "https://kovan.infura.io/v3//0cc023286cae4ab886598ecd14e256fd";
|
||||
|
||||
let cmd = format!("{} {}", args, url);
|
||||
println!("cmd: {}", cmd);
|
||||
|
||||
let res = curl_request(vec![cmd]);
|
||||
println!("res: {}", res);
|
||||
assert!(true);
|
||||
}
|
||||
}
|
||||
|
138
web3-examples/web3-examples/facade/Cargo.lock
generated
138
web3-examples/web3-examples/facade/Cargo.lock
generated
@ -2,9 +2,9 @@
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "arrayvec"
|
||||
version = "0.5.2"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
|
||||
checksum = "be4dc07131ffa69b8072d35f5007352af944213cde02545e2103680baed38fcd"
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
@ -14,9 +14,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
|
||||
|
||||
[[package]]
|
||||
name = "bitvec"
|
||||
version = "0.20.1"
|
||||
version = "0.20.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f5011ffc90248764d7005b0e10c7294f5aa1bd87d9dd7248f4ad475b347c294d"
|
||||
checksum = "7774144344a4faa177370406a7ff5f1da24303817368584c6206c8303eb07848"
|
||||
dependencies = [
|
||||
"funty",
|
||||
"radium",
|
||||
@ -32,9 +32,9 @@ checksum = "65c1bf4a04a88c54f589125563643d773f3254b5c38571395e2b591c693bbc81"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.4.2"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b"
|
||||
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
|
||||
|
||||
[[package]]
|
||||
name = "bytes"
|
||||
@ -103,21 +103,12 @@ dependencies = [
|
||||
"fluence",
|
||||
"hex",
|
||||
"log",
|
||||
"marine-sqlite-connector",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tiny-keccak",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fce-timestamp-macro"
|
||||
version = "0.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3c59a6302902583b2c84e87de9d72b949da4396a369baf0aaa49e97021600bb0"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"quote",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fixed-hash"
|
||||
version = "0.7.0"
|
||||
@ -132,50 +123,27 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "fluence"
|
||||
version = "0.6.2"
|
||||
version = "0.6.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b731bd4a69a3945186f2ff96ff753908939c8a2debd60e1f0e8edb6a28757f8"
|
||||
checksum = "88b09e1cd11a51ba4d169db347d009fe41ece2714eef4d5df720343733a1d5a6"
|
||||
dependencies = [
|
||||
"fce-timestamp-macro",
|
||||
"fluence-sdk-macro",
|
||||
"fluence-sdk-main",
|
||||
"marine-macro",
|
||||
"marine-timestamp-macro",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fluence-sdk-macro"
|
||||
version = "0.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cb43d2f51f1becb70e2125ef8ca9759597900f95cc22ce7dca981a7d6ccd7dde"
|
||||
dependencies = [
|
||||
"fluence-sdk-wit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fluence-sdk-main"
|
||||
version = "0.6.1"
|
||||
version = "0.6.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a78910d85e3cdcb9c2baf56144f20a99925c67ac445d4156220c005bfd2f9604"
|
||||
checksum = "68d93cde99e1494e11755a39b93863333397245c9959c774fe3bebd9e4143879"
|
||||
dependencies = [
|
||||
"fluence-sdk-macro",
|
||||
"log",
|
||||
"marine-macro",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fluence-sdk-wit"
|
||||
version = "0.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eab3ed39703b72e0e52bce9e1760746c73f65a5694c8da4dec751d3bfdec15b8"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"syn",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "funty"
|
||||
version = "1.1.0"
|
||||
@ -184,9 +152,9 @@ checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7"
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.2"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8"
|
||||
checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
@ -234,9 +202,9 @@ checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.84"
|
||||
version = "0.2.97"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1cca32fa0182e8c0989459524dc356b8f2b5c10f1b9eb521b7d182c03cf8c5ff"
|
||||
checksum = "12b8adadd720df158f4d70dfe7ccc6adb0472d7c55ca83445f6a5ab3e36f8fb6"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
@ -247,6 +215,48 @@ dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "marine-macro"
|
||||
version = "0.6.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f63d927851847cc3dd9e3bd0f10bdeb313859d4822d5b5f650d9d34d461ed419"
|
||||
dependencies = [
|
||||
"marine-macro-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "marine-macro-impl"
|
||||
version = "0.6.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fb504be4a90e229ab453c7369cc8a9063acec819f3397802eea719cd0a232be1"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"syn",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "marine-sqlite-connector"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6ffc3801a49d91595f2b8a80b4fbef21b15ea84bc69624ba84052a37b3b5b1a5"
|
||||
dependencies = [
|
||||
"fluence",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "marine-timestamp-macro"
|
||||
version = "0.6.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5994c7db5567d21609f2a2e5a40d9d4564f86c17ca35b2d77007152619b9d7fc"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"quote",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-integer"
|
||||
version = "0.1.44"
|
||||
@ -268,9 +278,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "parity-scale-codec"
|
||||
version = "2.0.0"
|
||||
version = "2.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "75c823fdae1bb5ff5708ee61a62697e6296175dc671710876871c853f48592b3"
|
||||
checksum = "e0f518afaa5a47d0d6386229b0a6e01e86427291d643aa4cabb4992219f504f8"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"bitvec",
|
||||
@ -299,9 +309,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.24"
|
||||
version = "1.0.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71"
|
||||
checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038"
|
||||
dependencies = [
|
||||
"unicode-xid",
|
||||
]
|
||||
@ -334,9 +344,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.3.0"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d"
|
||||
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core",
|
||||
@ -344,9 +354,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.6.1"
|
||||
version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c026d7df8b298d90ccbbc5190bd04d85e159eaf5576caeacf8741da93ccbd2e5"
|
||||
checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
]
|
||||
@ -412,9 +422,9 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.67"
|
||||
version = "1.0.73"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6498a9efc342871f91cc2d0d694c674368b4ceb40f62b65a7a08c3792935e702"
|
||||
checksum = "f71489ff30030d2ae598524f61326b902466f72a0fb1a8564c001cc63425bcc7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -423,9 +433,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tap"
|
||||
version = "1.0.0"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "36474e732d1affd3a6ed582781b3683df3d0563714c59c39591e8ff707cf078e"
|
||||
checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
@ -461,9 +471,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
|
||||
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
|
||||
|
||||
[[package]]
|
||||
name = "uuid"
|
||||
|
@ -14,9 +14,10 @@ path = "src/main.rs"
|
||||
[dependencies]
|
||||
serde = {version = "1.0.118", features = ["derive"] }
|
||||
serde_json = "1.0.64"
|
||||
fluence = { version = "=0.6.2", features = ["logger"]}
|
||||
fluence = { version = "=0.6.9", features = ["logger"]}
|
||||
log = "0.4.8"
|
||||
chrono = "0.4.19"
|
||||
ethereum-types = "0.11.0"
|
||||
hex = "0.4.3"
|
||||
tiny-keccak = {version = "2.0.2", features = ["keccak", "sha3"]}
|
||||
marine-sqlite-connector = "0.4.1"
|
@ -13,21 +13,25 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use serde_json;
|
||||
use fluence::marine;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use fluence::fce;
|
||||
use serde_json;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
struct DataProcResponse {
|
||||
result: f64,
|
||||
outliers: Vec<f64>,
|
||||
error: String
|
||||
error: String,
|
||||
}
|
||||
|
||||
#[fce]
|
||||
pub fn sum_data(data:Vec<String>) -> String {
|
||||
#[marine]
|
||||
pub fn sum_data(data: Vec<String>) -> String {
|
||||
if data.len() < 1 {
|
||||
let result = DataProcResponse {result: -1.0, outliers: [].to_vec(), error: "No data provided".to_string()};
|
||||
let result = DataProcResponse {
|
||||
result: -1.0,
|
||||
outliers: [].to_vec(),
|
||||
error: "No data provided".to_string(),
|
||||
};
|
||||
return serde_json::to_string(&result).unwrap();
|
||||
}
|
||||
|
||||
@ -36,7 +40,7 @@ pub fn sum_data(data:Vec<String>) -> String {
|
||||
.map(|o| serde_json::from_str(o).unwrap())
|
||||
.collect();
|
||||
|
||||
let mut data:Vec<u128> = objs
|
||||
let mut data: Vec<u128> = objs
|
||||
.iter()
|
||||
.map(|o| {
|
||||
u128::from_str_radix(
|
||||
@ -47,17 +51,24 @@ pub fn sum_data(data:Vec<String>) -> String {
|
||||
})
|
||||
.collect();
|
||||
|
||||
let sum:f64 = data.iter().map(|x| *x as f64).sum();
|
||||
let result = DataProcResponse {result: sum, outliers: [].to_vec(), error: "".to_string()};
|
||||
let sum: f64 = data.iter().map(|x| *x as f64).sum();
|
||||
let result = DataProcResponse {
|
||||
result: sum,
|
||||
outliers: [].to_vec(),
|
||||
error: "".to_string(),
|
||||
};
|
||||
println!("{:?}", result);
|
||||
serde_json::to_string(&result).unwrap()
|
||||
}
|
||||
|
||||
#[fce]
|
||||
pub fn drop_outliers_and_average(data:Vec<String>) -> String {
|
||||
|
||||
#[marine]
|
||||
pub fn drop_outliers_and_average(data: Vec<String>) -> String {
|
||||
if data.len() < 1 {
|
||||
let result = DataProcResponse {result: -1.0, outliers: [].to_vec(), error: "No data provided".to_string()};
|
||||
let result = DataProcResponse {
|
||||
result: -1.0,
|
||||
outliers: [].to_vec(),
|
||||
error: "No data provided".to_string(),
|
||||
};
|
||||
return serde_json::to_string(&result).unwrap();
|
||||
}
|
||||
|
||||
@ -77,27 +88,31 @@ pub fn drop_outliers_and_average(data:Vec<String>) -> String {
|
||||
})
|
||||
.collect();
|
||||
data.sort();
|
||||
|
||||
let mut low_high: Vec<f64> = Vec::new();
|
||||
if data.len() > 3 {
|
||||
// low_high.push([data.remove(0) as f64);
|
||||
// low_high.push(data.remove(data.last()) as f64);
|
||||
low_high.extend(&[data.remove(0) as f64, data.remove(data.len() - 1) as f64]);
|
||||
}
|
||||
|
||||
let avg: f64 = (data.iter().sum::<u128>() as f64 / data.len() as f64);
|
||||
|
||||
let result = DataProcResponse {result: avg, outliers: low_high, error: "".to_string()};
|
||||
let result = DataProcResponse {
|
||||
result: avg,
|
||||
outliers: low_high,
|
||||
error: "".to_string(),
|
||||
};
|
||||
|
||||
serde_json::to_string(&result).unwrap()
|
||||
|
||||
}
|
||||
|
||||
#[fce]
|
||||
pub fn simple_average(data:Vec<String>) -> String {
|
||||
|
||||
#[marine]
|
||||
pub fn simple_average(data: Vec<String>) -> String {
|
||||
if data.len() < 1 {
|
||||
let result = DataProcResponse {result: -1.0, outliers: [].to_vec(), error: "No data provided".to_string()};
|
||||
let result = DataProcResponse {
|
||||
result: -1.0,
|
||||
outliers: [].to_vec(),
|
||||
error: "No data provided".to_string(),
|
||||
};
|
||||
return serde_json::to_string(&result).unwrap();
|
||||
}
|
||||
|
||||
@ -116,18 +131,19 @@ pub fn simple_average(data:Vec<String>) -> String {
|
||||
.unwrap()
|
||||
})
|
||||
.collect();
|
||||
|
||||
let avg: f64 = (data.iter().sum::<u128>() as f64 / data.len() as f64);
|
||||
|
||||
let result = DataProcResponse {result: avg, outliers: [].to_vec(), error: "".to_string()};
|
||||
let result = DataProcResponse {
|
||||
result: avg,
|
||||
outliers: [].to_vec(),
|
||||
error: "".to_string(),
|
||||
};
|
||||
|
||||
serde_json::to_string(&result).unwrap()
|
||||
|
||||
}
|
||||
|
||||
#[fce]
|
||||
#[marine]
|
||||
pub fn test_drop_outliers_and_average() {
|
||||
|
||||
let data: Vec<String> = vec![
|
||||
r#"{"result": "0x64"}"#.to_string(),
|
||||
r#"{"result": "0x6E"}"#.to_string(),
|
||||
@ -145,7 +161,6 @@ pub fn test_drop_outliers_and_average() {
|
||||
let result = drop_outliers_and_average(data);
|
||||
println!("{:?}", result);
|
||||
|
||||
|
||||
let data: Vec<String> = vec![
|
||||
r#"{"result": "0x64"}"#.to_string(),
|
||||
r#"{"result": "0x6E"}"#.to_string(),
|
||||
@ -155,9 +170,8 @@ pub fn test_drop_outliers_and_average() {
|
||||
println!("{:?}", result);
|
||||
}
|
||||
|
||||
#[fce]
|
||||
#[marine]
|
||||
pub fn test_simple_average() {
|
||||
|
||||
let data: Vec<String> = vec![
|
||||
r#"{"result": "0x64"}"#.to_string(),
|
||||
r#"{"result": "0x6E"}"#.to_string(),
|
||||
@ -175,7 +189,6 @@ pub fn test_simple_average() {
|
||||
let result = simple_average(data);
|
||||
println!("{:?}", result);
|
||||
|
||||
|
||||
let data: Vec<String> = vec![
|
||||
r#"{"result": "0x64"}"#.to_string(),
|
||||
r#"{"result": "0x6E"}"#.to_string(),
|
||||
@ -183,6 +196,4 @@ pub fn test_simple_average() {
|
||||
|
||||
let result = simple_average(data);
|
||||
println!("{:?}", result);
|
||||
|
||||
|
||||
}
|
||||
|
@ -13,14 +13,12 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use serde_json;
|
||||
use fluence::marine;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use fluence::fce;
|
||||
use serde_json;
|
||||
|
||||
|
||||
#[fce]
|
||||
#[marine]
|
||||
pub fn test_drop_outliers_and_average() {
|
||||
|
||||
let data: Vec<String> = vec![
|
||||
r#"{"result": "0x64"}"#.to_string(),
|
||||
r#"{"result": "0x6E"}"#.to_string(),
|
||||
@ -38,7 +36,6 @@ pub fn test_drop_outliers_and_average() {
|
||||
let result = drop_outliers_and_average(data);
|
||||
println!("{:?}", result);
|
||||
|
||||
|
||||
let data: Vec<String> = vec![
|
||||
r#"{"result": "0x64"}"#.to_string(),
|
||||
r#"{"result": "0x6E"}"#.to_string(),
|
||||
@ -48,9 +45,8 @@ pub fn test_drop_outliers_and_average() {
|
||||
println!("{:?}", result);
|
||||
}
|
||||
|
||||
#[fce]
|
||||
#[marine]
|
||||
pub fn test_simple_average() {
|
||||
|
||||
let data: Vec<String> = vec![
|
||||
r#"{"result": "0x64"}"#.to_string(),
|
||||
r#"{"result": "0x6E"}"#.to_string(),
|
||||
@ -68,7 +64,6 @@ pub fn test_simple_average() {
|
||||
let result = simple_average(data);
|
||||
println!("{:?}", result);
|
||||
|
||||
|
||||
let data: Vec<String> = vec![
|
||||
r#"{"result": "0x64"}"#.to_string(),
|
||||
r#"{"result": "0x6E"}"#.to_string(),
|
||||
@ -76,6 +71,4 @@ pub fn test_simple_average() {
|
||||
|
||||
let result = simple_average(data);
|
||||
println!("{:?}", result);
|
||||
|
||||
|
||||
}
|
||||
|
@ -19,13 +19,13 @@ use crate::eth_utils::{check_response_string, get_nonce, BLOCK_NUMBER_TAGS};
|
||||
use crate::fce_results::JsonRpcResult;
|
||||
use crate::jsonrpc_helpers::{batch, Request};
|
||||
use chrono::Utc;
|
||||
use fluence::fce;
|
||||
use fluence::marine;
|
||||
use serde::{Deserialize, Deserializer, Serialize};
|
||||
use serde_json;
|
||||
use serde_json::Value;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
|
||||
#[fce]
|
||||
#[marine]
|
||||
pub fn eth_get_balance(url: String, account: String, block_number: String) -> JsonRpcResult {
|
||||
let method = String::from("eth_getBalance");
|
||||
let id = get_nonce();
|
||||
@ -47,7 +47,7 @@ pub fn eth_get_balance(url: String, account: String, block_number: String) -> Js
|
||||
check_response_string(response, &id)
|
||||
}
|
||||
|
||||
#[fce]
|
||||
#[marine]
|
||||
pub fn eth_get_block_height(url: String) -> JsonRpcResult {
|
||||
let method = "eth_blockNumber".to_string();
|
||||
let params: Vec<String> = Vec::new();
|
||||
@ -59,7 +59,7 @@ pub fn eth_get_block_height(url: String) -> JsonRpcResult {
|
||||
check_response_string(response, &id)
|
||||
}
|
||||
|
||||
#[fce]
|
||||
#[marine]
|
||||
pub fn eth_get_tx_by_hash(url: String, tx_hash: String) -> String {
|
||||
let method: String = String::from("eth_getTransactionByHash");
|
||||
let params: Vec<String> = vec![tx_hash];
|
||||
@ -113,7 +113,7 @@ struct GetTxResponse {
|
||||
result: Option<TxSerde>,
|
||||
}
|
||||
|
||||
#[fce]
|
||||
#[marine]
|
||||
pub struct Tx {
|
||||
pub blockHash: String,
|
||||
pub blockNumber: String,
|
||||
@ -146,7 +146,7 @@ impl From<TxSerde> for Tx {
|
||||
}
|
||||
}
|
||||
|
||||
#[fce]
|
||||
#[marine]
|
||||
pub fn eth_get_txs_by_hashes(url: String, tx_hashes: Vec<String>) -> Vec<Tx> {
|
||||
let method: String = String::from("eth_getTransactionByHash");
|
||||
let params: Vec<_> = tx_hashes.into_iter().map(|h| vec![h]).collect();
|
||||
|
@ -18,9 +18,9 @@ use crate::eth_calls::{eth_get_balance, eth_get_tx_by_hash};
|
||||
use crate::eth_filters::{get_filter_changes, new_pending_tx_filter, uninstall_filter};
|
||||
use crate::eth_utils::wei_to_eth;
|
||||
use crate::fce_results::TestResult;
|
||||
use fluence::fce;
|
||||
use fluence::marine;
|
||||
|
||||
#[fce]
|
||||
#[marine]
|
||||
fn test_eth_get_balance_good(url: String) -> TestResult {
|
||||
let burn_address = String::from("0x0000000000000000000000000000000000000000");
|
||||
let block_height = String::from("latest");
|
||||
@ -41,7 +41,7 @@ fn test_eth_get_balance_good(url: String) -> TestResult {
|
||||
TestResult::from(Result::from(Err(err_msg)))
|
||||
}
|
||||
|
||||
#[fce]
|
||||
#[marine]
|
||||
fn test_eth_get_balance_bad(url: String) -> TestResult {
|
||||
let burn_address = String::from("0x0000000000000000000000000000000000000000");
|
||||
let block_height = String::from("latest");
|
||||
@ -62,7 +62,7 @@ fn test_eth_get_balance_bad(url: String) -> TestResult {
|
||||
TestResult::from(Result::from(Err(err_msg)))
|
||||
}
|
||||
|
||||
#[fce]
|
||||
#[marine]
|
||||
fn test_eth_get_tx_by_hash(url: String, tx_hash: String) {
|
||||
let res: String = eth_get_tx_by_hash(url, tx_hash.clone());
|
||||
let obj: serde_json::Value = serde_json::from_str(&res).unwrap();
|
||||
|
@ -18,11 +18,11 @@ use crate::eth_calls::{eth_get_balance, eth_get_tx_by_hash};
|
||||
use crate::eth_filters::{get_filter_changes, new_pending_tx_filter, uninstall_filter};
|
||||
use crate::eth_utils::wei_to_eth;
|
||||
use crate::fce_results::TestResult;
|
||||
use fluence::fce;
|
||||
use fluence::marine;
|
||||
use serde_json;
|
||||
use serde_json::Value;
|
||||
|
||||
#[fce]
|
||||
#[marine]
|
||||
fn test_filters(url: String) -> TestResult {
|
||||
let pending_filter_id = new_pending_tx_filter(url.clone());
|
||||
let result = get_filter_changes(url.clone(), pending_filter_id.clone());
|
||||
@ -35,7 +35,7 @@ fn test_filters(url: String) -> TestResult {
|
||||
TestResult::from(Result::from(Err(String::from(err_msg))))
|
||||
}
|
||||
|
||||
#[fce]
|
||||
#[marine]
|
||||
pub fn test_pending_with_null_filter(url: String) -> String {
|
||||
let mut matches: Vec<(String, String, String, String)> = Vec::new();
|
||||
let pending_filter_id = new_pending_tx_filter(url.clone());
|
||||
|
@ -19,14 +19,14 @@ use crate::eth_utils::{check_response_string, get_nonce};
|
||||
use crate::fce_results::JsonRpcResult;
|
||||
use crate::jsonrpc_helpers::Request;
|
||||
use crate::jsonrpc_helpers::JSON_RPC;
|
||||
use fluence::fce;
|
||||
use fluence::marine;
|
||||
use serde_json::Value;
|
||||
|
||||
/// see:
|
||||
/// https://eth.wiki/json-rpc/API#eth_uninstallfilter
|
||||
/// https://docs.alchemyapi.io/alchemy/documentation/alchemy-api-reference/json-rpc#eth_uninstallfilter
|
||||
/// https://infura.io/docs/ethereum/json-rpc/eth-uninstallFilter
|
||||
#[fce]
|
||||
#[marine]
|
||||
pub fn uninstall_filter(url: String, filter_id: String) -> bool {
|
||||
let method = String::from("eth_uninstallFilter");
|
||||
let params: Vec<String> = vec![filter_id];
|
||||
@ -53,7 +53,7 @@ pub fn uninstall_filter(url: String, filter_id: String) -> bool {
|
||||
// https://eth.wiki/json-rpc/API#eth_newpendingtransactionfilter
|
||||
// https://infura.io/docs/ethereum/wss/eth_newPendingTransactionFilter
|
||||
// https://docs.alchemyapi.io/alchemy/documentation/alchemy-api-reference/json-rpc#eth_getfilterchanges
|
||||
#[fce]
|
||||
#[marine]
|
||||
pub fn new_pending_tx_filter(url: String) -> String {
|
||||
let method: String;
|
||||
let mut params: Vec<String> = Vec::new();
|
||||
@ -83,7 +83,7 @@ pub fn new_pending_tx_filter(url: String) -> String {
|
||||
// https://eth.wiki/json-rpc/API#eth_getfilterchanges
|
||||
// https://infura.io/docs/ethereum/json-rpc/eth-getFilterChanges
|
||||
// https://docs.alchemyapi.io/alchemy/documentation/alchemy-api-reference/json-rpc#eth_getfilterchanges
|
||||
#[fce]
|
||||
#[marine]
|
||||
pub fn get_filter_changes(url: String, filter_id: String) -> String {
|
||||
let method = String::from("eth_getFilterChanges");
|
||||
let params: Vec<String> = vec![filter_id];
|
||||
@ -96,7 +96,7 @@ pub fn get_filter_changes(url: String, filter_id: String) -> String {
|
||||
response
|
||||
}
|
||||
|
||||
#[fce]
|
||||
#[marine]
|
||||
pub fn get_filter_changes_list(url: String, filter_id: String) -> Vec<String> {
|
||||
let method = String::from("eth_getFilterChanges");
|
||||
let params: Vec<String> = vec![filter_id];
|
||||
@ -131,7 +131,7 @@ pub fn get_filter_changes_list(url: String, filter_id: String) -> Vec<String> {
|
||||
}
|
||||
}
|
||||
|
||||
#[fce]
|
||||
#[marine]
|
||||
pub fn get_filter_changes_without_null(url: String, filter_id: String, limit: String) -> Vec<Tx> {
|
||||
let tx_hashes = get_filter_changes_list(url.clone(), filter_id.clone());
|
||||
let limit: usize = limit.parse().unwrap_or(5000);
|
||||
|
@ -13,10 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use fluence::fce;
|
||||
use fluence::marine;
|
||||
use tiny_keccak::{Hasher, Keccak};
|
||||
|
||||
#[fce]
|
||||
#[marine]
|
||||
pub fn eth_hash_method_id(input: Vec<u8>) -> Vec<u8> {
|
||||
let mut output = [0u8; 32];
|
||||
let mut keccak = Keccak::v256();
|
||||
@ -26,7 +26,7 @@ pub fn eth_hash_method_id(input: Vec<u8>) -> Vec<u8> {
|
||||
output.to_vec()
|
||||
}
|
||||
|
||||
#[fce]
|
||||
#[marine]
|
||||
pub fn test_eth_hash_method_id() -> String {
|
||||
use hex::encode;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
use fluence::fce;
|
||||
use fluence::marine;
|
||||
|
||||
#[fce]
|
||||
#[marine]
|
||||
pub fn eth_type_test() {
|
||||
use ethereum_types::{H160, H256, U256, U512};
|
||||
use serde_json as ser;
|
||||
|
@ -16,10 +16,10 @@
|
||||
|
||||
use crate::jsonrpc_helpers::JSON_RPC;
|
||||
use crate::Result;
|
||||
use fluence::fce;
|
||||
use fluence::marine;
|
||||
use serde_json::Value;
|
||||
|
||||
#[fce]
|
||||
#[marine]
|
||||
#[derive(Debug)]
|
||||
pub struct JsonRpcResult {
|
||||
pub jsonrpc: String,
|
||||
@ -59,7 +59,7 @@ impl From<Result<String>> for JsonRpcResult {
|
||||
}
|
||||
}
|
||||
|
||||
#[fce]
|
||||
#[marine]
|
||||
#[derive(Debug)]
|
||||
pub struct TestResult {
|
||||
pub test_passed: bool,
|
||||
|
@ -22,7 +22,7 @@
|
||||
unused_mut
|
||||
)]
|
||||
|
||||
use fluence::fce;
|
||||
use fluence::marine;
|
||||
use fluence::module_manifest;
|
||||
use fluence::MountedBinaryResult;
|
||||
use fluence::WasmLoggerBuilder;
|
||||
@ -45,7 +45,7 @@ pub fn main() {
|
||||
WasmLoggerBuilder::new().build().ok();
|
||||
}
|
||||
|
||||
#[fce]
|
||||
#[marine]
|
||||
#[link(wasm_import_module = "curl_adapter")]
|
||||
extern "C" {
|
||||
pub fn curl_request(url: Vec<String>) -> MountedBinaryResult;
|
||||
|
Loading…
x
Reference in New Issue
Block a user