Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[BUG] Hello world blueprint does not compile. #390

Closed
shekohex opened this issue Oct 24, 2024 · 0 comments · Fixed by #391
Closed

[BUG] Hello world blueprint does not compile. #390

shekohex opened this issue Oct 24, 2024 · 0 comments · Fixed by #391
Assignees
Labels
bug 🪲 Something isn't working

Comments

@shekohex
Copy link
Contributor

Here is my blueprint:

use gadget_sdk as sdk;
use gadget_sdk::tangle_subxt::tangle_testnet_runtime::api;
use std::convert::Infallible;

use api::services::events::JobCalled;
use sdk::event_listener::tangle::TangleEventListener;

#[derive(Clone)]
pub struct ServiceContext {
    pub config: sdk::config::StdGadgetConfiguration,
}

/// Returns "Hello World!" if `who` is `None`, otherwise returns "Hello, {who}!"
#[sdk::job(id = 0, params(who), result(_), event_listener(listener = TangleEventListener::<JobCalled, ServiceContext>))]
pub fn say_hello(who: Option<String>, context: ServiceContext) -> Result<String, Infallible> {
    match who {
        Some(who) => Ok(format!("Hello, {who}!")),
        None => Ok("Hello World!".to_string()),
    }
}

And When I try to compile it, I get this error:

error[E0271]: expected `{async block@src/lib.rs:14:1: 14:121}` to be a future that resolves to `Result<TangleJobEvent<OnlineClient<PolkadotConfig>>, Error>`, but it resolves to `Result<TangleEvent<JobCalled, ServiceContext>, _>`
   --> src/lib.rs:14:1
    |
14  | #[sdk::job(id = 0, params(who), result(_), event_listener(listener = TangleEventListener::<JobCalled, ServiceContext>))]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Result<TangleJobEvent<...>, ...>`, found `Result<TangleEvent<JobCalled, ...>, ...>`
    |
    = note: expected enum `Result<TangleJobEvent<OnlineClient<PolkadotConfig>>, gadget_sdk::Error>`
               found enum `Result<gadget_sdk::event_listener::tangle::TangleEvent<gadget_sdk::tangle_subxt::tangle_testnet_runtime::api::services::events::JobCalled, ServiceContext>, _>`
note: required by a bound in `EventFlowWrapper::<Ctx, Event, PreProcessOut, JobOutput>::new`
   --> /home/shady/.cargo/registry/src/index.crates.io-6f17d22bba15001f/gadget-sdk-0.2.1/src/event_listener/executor.rs:129:24
    |
120 |     pub fn new<T, Pre, PreFut, Job, JobFut, Post, PostFut>(
    |            --- required by a bound in this associated function
...
129 |         PreFut: Future<Output = Result<PreProcessOut, crate::Error>> + Send + 'static,
    |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `EventFlowWrapper::<Ctx, Event, PreProcessOut, JobOutput>::new`
    = note: this error originates in the attribute macro `sdk::job` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0271`.
error: could not compile `hello-blueprint` (lib) due to 1 previous error

My Cargo.toml deps

[dependencies]
tracing = "0.1"
async-trait = "0.1"
color-eyre = "0.6"
structopt = "0.3.26"
tokio = { version = "1.39", default-features = false, features = ["full"] }
tracing-subscriber = { version = "0.3", features = ["parking_lot", "env-filter"] }

[dependencies.gadget-sdk]
version = "0.2.1"
default-features = false
features = ["std", "getrandom"]

[build-dependencies]
blueprint-metadata = "0.1.5"

This seems to be something related to the recent PRs #363 #359

@shekohex shekohex added the bug 🪲 Something isn't working label Oct 24, 2024
@github-project-automation github-project-automation bot moved this to Not Started 🕧 in Webb Universe Oct 24, 2024
@github-project-automation github-project-automation bot moved this from Not Started 🕧 to Completed ✅ in Webb Universe Oct 24, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug 🪲 Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants