1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//! A set of traits and utilities that provide a common interface for interacting with the Gadget SDK.
//!
//! Usually, when you need access to the SDK, you will need to pass the Context to your jobs/functions. In your code, you will create a struct that encapsulates all the things that you would need from outside world from your job.
//! for example, if you need to interact with the network, you will need to have a network client in your struct. If you need to interact with the database storage, you will need to have a db client in your struct. And so on.
//!
//! This module provides a set of traits that you can implement for your struct to make it a context-aware struct by adding new functionalities to it.
//!
//! # Example
//!
//! ```rust,no_run
//! use gadget_context_derive::TangleClientContext;
//! use gadget_sdk::config::StdGadgetConfiguration;
//! use gadget_sdk::contexts::KeystoreContext;
//! use gadget_sdk::event_listener::tangle::jobs::{
//! services_post_processor, services_pre_processor,
//! };
//! use gadget_sdk::event_listener::tangle::TangleEventListener;
//! use gadget_sdk::job;
//! use gadget_sdk::tangle_subxt::tangle_testnet_runtime::api::services::events::JobCalled;
//!
//! // This your struct that encapsulates all the things you need from outside world.
//! // By deriving KeystoreContext, you can now access the keystore client from your struct.
//! #[derive(Clone, Debug, KeystoreContext, TangleClientContext)]
//! struct MyContext {
//! foo: String,
//! bar: u64,
//! #[config]
//! sdk_config: StdGadgetConfiguration,
//! #[call_id]
//! call_id: Option<u64>,
//! }
//!
//! #[job(
//! id = 0,
//! params(who),
//! result(_),
//! event_listener(
//! listener = TangleEventListener<MyContext, JobCalled>,
//! pre_processor = services_pre_processor,
//! post_processor = services_post_processor,
//! )
//! )]
//! async fn my_job(who: String, ctx: MyContext) -> Result<String, std::convert::Infallible> {
//! // Access the keystore client from the context.
//! let keystore = ctx.keystore();
//! // Do something with the keystore client.
//! // ...
//! Ok(format!("Hello, {}!", who))
//! }
//! ```
// derives
pub use *;
pub use BigInt;
// A macro that takes an arbitrary mod, like "eigenlayer", then writes that as well as a line saying "pub use eigenlayer::*;" to the file.
// This way, we can easily add new modules to the SDK without having to manually import each time
create_module_derive!;
create_module_derive!;
create_module_derive!;
create_module_derive!;
create_module_derive!;
create_module_derive!;
create_module_derive!;