diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f6fded86ef2..2a74296bd06 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,30 +63,6 @@ jobs: command: test args: --verbose --all-targets - - name: Check formatting (examples) - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --manifest-path examples/Cargo.toml --all --verbose -- --check - - - name: Check build (examples) - uses: actions-rs/cargo@v1 - with: - command: check - args: --manifest-path examples/Cargo.toml --verbose --all-targets - - - name: Check Clippy Lints (examples) - uses: actions-rs/cargo@v1 - with: - command: clippy - args: --manifest-path examples/Cargo.toml --verbose --all-targets - - - name: Run tests (examples) - uses: actions-rs/cargo@v1 - with: - command: test - args: --manifest-path examples/Cargo.toml --verbose --all-targets - publish: # Only do this job if publishing a release needs: build diff --git a/Cargo.lock b/Cargo.lock index e38f6df3500..28ebbbbe422 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -360,19 +360,23 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "axum" -version = "0.2.8" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f08f95a202e827209db1491047aa57c18c8adb4c5efcfcfd4a2da4838ee3a72" +checksum = "310a147401c66e79fc78636e4db63ac68cd6acb9ece056de806ea173a15bce32" dependencies = [ "async-trait", + "axum-core", "bitflags", "bytes 1.1.0", "futures-util", "http", "http-body", "hyper", + "matchit", + "memchr", + "mime", + "percent-encoding", "pin-project-lite", - "regex", "serde", "serde_json", "serde_urlencoded", @@ -385,6 +389,20 @@ dependencies = [ "tower-service", ] +[[package]] +name = "axum-core" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ca6c0b218388a7ed6a8d25e94f7dea5498daaa4fd8c711fb3ff166041b06fda" +dependencies = [ + "async-trait", + "bytes 1.1.0", + "futures-util", + "http", + "http-body", + "mime", +] + [[package]] name = "backtrace" version = "0.3.63" @@ -1217,6 +1235,7 @@ name = "fuel-core" version = "0.2.0" dependencies = [ "async-graphql", + "async-trait", "axum", "bincode", "chrono", @@ -1748,6 +1767,12 @@ dependencies = [ "log", ] +[[package]] +name = "http-range-header" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bfe8eed0a9285ef776bb792479ea3834e8b94e13d615c2f66d03dd50a435a29" + [[package]] name = "http-types" version = "2.12.0" @@ -2140,6 +2165,12 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" +[[package]] +name = "matchit" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58b6f41fdfbec185dd3dff58b51e323f5bc61692c0de38419a957b0dcfccca3c" + [[package]] name = "memchr" version = "2.4.1" @@ -3598,16 +3629,18 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.1.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f70061b0592867f0a60e67a6e699da5fe000c88a360a5b92ebdba9d73b2238c" +checksum = "03650267ad175b51c47d02ed9547fc7d4ba2c7e5cb76df0bed67edd1825ae297" dependencies = [ + "bitflags", "bytes 1.1.0", "futures-core", "futures-util", "http", "http-body", - "pin-project", + "http-range-header", + "pin-project-lite", "tower-layer", "tower-service", ] diff --git a/examples/.gitignore b/examples/.gitignore deleted file mode 100644 index 03314f77b5a..00000000000 --- a/examples/.gitignore +++ /dev/null @@ -1 +0,0 @@ -Cargo.lock diff --git a/examples/Cargo.toml b/examples/Cargo.toml deleted file mode 100644 index 43b97dbf6fa..00000000000 --- a/examples/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[workspace] -# Use the new resolver to prevent dev-deps and build-deps from enabling debugging or test features in production. -resolver = "2" -members = [ - "simple-wasm", -] - -[profile.release] -codegen-units = 1 -lto = "fat" -panic = "abort" diff --git a/examples/simple-wasm/.cargo/config b/examples/simple-wasm/.cargo/config deleted file mode 100644 index f4e8c002fc2..00000000000 --- a/examples/simple-wasm/.cargo/config +++ /dev/null @@ -1,2 +0,0 @@ -[build] -target = "wasm32-unknown-unknown" diff --git a/examples/simple-wasm/Cargo.toml b/examples/simple-wasm/Cargo.toml deleted file mode 100644 index 08b0baf32f2..00000000000 --- a/examples/simple-wasm/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] -name = "simple-wasm" -version = "0.0.0" -edition = "2021" -publish = false - -[lib] -crate-type = ['cdylib'] - -[dependencies] -fuel-indexer = { path = "../../fuel-indexer/lib" } -fuel-indexer-derive = { path = "../../fuel-indexer/derive" } -fuels-abigen-macro = "0.1" -fuels-core = { version = "0.1", features=["no-std"] } -serde = { version = "1.0.128", default-features = false, features = ["derive"] } diff --git a/examples/simple-wasm/README.md b/examples/simple-wasm/README.md deleted file mode 100644 index a5c143b0c4e..00000000000 --- a/examples/simple-wasm/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# WASM indexer - -A simple example of a wasm custom indexer - -## building - -cargo b --release - -## Running as a standalone - -cargo r --bin index-runner -- --wasm target/wasm32-wasi/release/simple_wasm.wasm diff --git a/examples/simple-wasm/contracts/my_struct.json b/examples/simple-wasm/contracts/my_struct.json deleted file mode 100644 index e4cf3a34a31..00000000000 --- a/examples/simple-wasm/contracts/my_struct.json +++ /dev/null @@ -1,41 +0,0 @@ -[ - { - "type":"contract", - "inputs":[ - { - "name":"SomeEvent", - "type":"struct SomeEvent", - "components": [ - { - "name": "id", - "type": "u64" - }, - { - "name": "account", - "type": "b256" - } - ] - }, - { - "name":"AnotherEvent", - "type":"struct AnotherEvent", - "components": [ - { - "name": "id", - "type": "u64" - }, - { - "name": "hash", - "type": "b256" - }, - { - "name": "bar", - "type": "bool" - } - ] - } - ], - "name":"takes_struct", - "outputs":[] - } -] diff --git a/examples/simple-wasm/manifest.yaml b/examples/simple-wasm/manifest.yaml deleted file mode 100644 index d323f47379f..00000000000 --- a/examples/simple-wasm/manifest.yaml +++ /dev/null @@ -1,14 +0,0 @@ ---- -namespace: test_namespace -graphql_schema: schema.graphql -wasm_module: simple_wasm.wasm -handlers: - - event: an_event_name - handler: function_one - - event: another_event_name - handler: function_two -test_events: - - trigger: an_event_name - payload: '{"id":78888,"account":[77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,11,22,77,77,77,77,77,77,7,0]}' - - trigger: another_event_name - payload: '{"id":78888,"hash":[55,44,22,77,77,77,0,77,77,77,0,0,77,77,77,77,77,77,77,77,77,77,11,22,77,77,77,77,77,77,7,0], "sub_event": {"id": 34, "account": [77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,0,0,1,7,1,0,7,7,3,2,3,3,1,0]}}' diff --git a/examples/simple-wasm/schema/schema.graphql b/examples/simple-wasm/schema/schema.graphql deleted file mode 100644 index e841876c299..00000000000 --- a/examples/simple-wasm/schema/schema.graphql +++ /dev/null @@ -1,20 +0,0 @@ -schema { - query: QueryRoot -} - -type QueryRoot { - thing1: Thing1 - thing2: Thing2 -} - -type Thing1 { - id: ID! - account: Address! -} - - -type Thing2 { - id: ID! - account: Address! @indexed - hash: Bytes32! @indexed -} diff --git a/examples/simple-wasm/src/lib.rs b/examples/simple-wasm/src/lib.rs deleted file mode 100644 index 084c4ad953f..00000000000 --- a/examples/simple-wasm/src/lib.rs +++ /dev/null @@ -1,33 +0,0 @@ -#![no_std] -extern crate alloc; -use fuel_indexer_derive::{graphql_schema, handler}; -use fuels_abigen_macro::wasm_abigen; - -graphql_schema!("test_namespace", "schema/schema.graphql"); -wasm_abigen!(no_name, "simple-wasm/contracts/my_struct.json"); - -#[handler] -fn function_one(event: SomeEvent) { - let SomeEvent { id, account } = event; - - let t1 = Thing1 { - id, - account: Address::from(account), - }; - t1.save(); -} - -#[handler] -fn function_two(event: AnotherEvent) { - let AnotherEvent { id, hash, .. } = event; - - let Thing1 { account, .. } = Thing1::load(id).expect("No object with that ID"); - - let t2 = Thing2 { - id, - account, - hash: Bytes32::from(hash), - }; - - t2.save(); -} diff --git a/fuel-core/Cargo.toml b/fuel-core/Cargo.toml index 06efb8a980a..a9900e60578 100644 --- a/fuel-core/Cargo.toml +++ b/fuel-core/Cargo.toml @@ -19,7 +19,8 @@ test = false [dependencies] async-graphql = { version = "=2.9", features = ["chrono", "chrono-tz"] } -axum = { version = "0.2" } +async-trait = "0.1" +axum = { version = "0.4.4" } bincode = "1.3" chrono = { version = "0.4", features = ["serde"] } derive_more = { version = "0.99" } @@ -46,7 +47,7 @@ strum = "0.21" strum_macros = "0.21" thiserror = "1.0.26" tokio = { version = "1.8", features = ["macros", "rt-multi-thread"] } -tower-http = { version = "0.1", features = ["set-header"] } +tower-http = { version = "0.2.1", features = ["set-header"] } tower-layer = "0.3" tracing = "0.1" tracing-subscriber = { version = "0.2", features = ["env-filter"] } diff --git a/fuel-core/src/service/graph_api.rs b/fuel-core/src/service/graph_api.rs index fb016b6cb60..41729355079 100644 --- a/fuel-core/src/service/graph_api.rs +++ b/fuel-core/src/service/graph_api.rs @@ -3,10 +3,9 @@ use crate::schema::{build_schema, dap, CoreSchema}; use crate::service::Config; use crate::tx_pool::TxPool; use async_graphql::{http::playground_source, http::GraphQLPlaygroundConfig, Request, Response}; +use axum::routing::{get, post}; use axum::{ - body::Body, extract::Extension, - handler::{get, post}, http::{ header::{ ACCESS_CONTROL_ALLOW_HEADERS, ACCESS_CONTROL_ALLOW_METHODS, ACCESS_CONTROL_ALLOW_ORIGIN, @@ -40,19 +39,18 @@ pub async fn start_server( .route("/graphql", post(graphql_handler).options(ok)) .route("/health", get(health)) .layer(AddExtensionLayer::new(schema)) - .layer(SetResponseHeaderLayer::<_, Body>::overriding( + .layer(SetResponseHeaderLayer::<_>::overriding( ACCESS_CONTROL_ALLOW_ORIGIN, HeaderValue::from_static("*"), )) - .layer(SetResponseHeaderLayer::<_, Body>::overriding( + .layer(SetResponseHeaderLayer::<_>::overriding( ACCESS_CONTROL_ALLOW_METHODS, HeaderValue::from_static("*"), )) - .layer(SetResponseHeaderLayer::<_, Body>::overriding( + .layer(SetResponseHeaderLayer::<_>::overriding( ACCESS_CONTROL_ALLOW_HEADERS, HeaderValue::from_static("*"), - )) - .boxed(); + )); let (tx, rx) = tokio::sync::oneshot::channel(); let listener = TcpListener::bind(&config.addr)?; diff --git a/fuel-indexer/derive/Cargo.toml b/fuel-indexer/derive/Cargo.toml index ff0d1d33e38..731814b566c 100644 --- a/fuel-indexer/derive/Cargo.toml +++ b/fuel-indexer/derive/Cargo.toml @@ -18,7 +18,7 @@ quote = "1.0" syn = { version = "1.0", features = ["full"] } [dev-dependencies] -fuels-core = { version = "0.1" } fuel-indexer = { path = "../lib" } +fuels-core = { version = "0.1" } serde = { version = "1.0", default-features = false, features = ["derive"] } trybuild = "1.0" diff --git a/fuel-indexer/indexer/Cargo.toml b/fuel-indexer/indexer/Cargo.toml index 9ba609b2eea..d44ff6935f5 100644 --- a/fuel-indexer/indexer/Cargo.toml +++ b/fuel-indexer/indexer/Cargo.toml @@ -24,8 +24,8 @@ wasmer-engine-universal = "2.0" [dev-dependencies] fuel-indexer = { path = "../lib" } fuel-tx = { version = "0.2", features = ["serde-types"] } -fuels-core = { version = "0.1" } fuel-types = { version = "0.1", features = ["serde-types"] } +fuels-core = { version = "0.1" } serde_yaml = "0.8.19" [features]