-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
49 changed files
with
2,004 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
[package] | ||
description = "Madara client rpc service" | ||
name = "mc-gateway" | ||
authors.workspace = true | ||
edition.workspace = true | ||
license.workspace = true | ||
repository.workspace = true | ||
version.workspace = true | ||
homepage.workspace = true | ||
|
||
[package.metadata.docs.rs] | ||
targets = ["x86_64-unknown-linux-gnu"] | ||
|
||
[dependencies] | ||
|
||
# Deoxys | ||
mc-db = { workspace = true } | ||
mp-block = { workspace = true } | ||
mp-gateway = { workspace = true } | ||
mp-utils = { workspace = true } | ||
|
||
# Starknet | ||
starknet-core = { workspace = true } | ||
starknet-types-core = { workspace = true } | ||
|
||
# Other | ||
anyhow = { workspace = true } | ||
hyper = { workspace = true } | ||
log = { workspace = true } | ||
reqwest = { workspace = true } | ||
serde = { workspace = true, features = ["derive"] } | ||
serde_json = { workspace = true } | ||
thiserror = { workspace = true } | ||
tokio = { workspace = true } | ||
url = { workspace = true } | ||
|
||
[dev-dependencies] | ||
tokio = { workspace = true } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use std::collections::HashMap; | ||
|
||
use reqwest::Client; | ||
use url::Url; | ||
|
||
#[derive(Debug, Clone)] | ||
pub struct FeederClient { | ||
pub(crate) client: Client, | ||
pub(crate) gateway_url: Url, | ||
pub(crate) feeder_gateway_url: Url, | ||
pub(crate) headers: HashMap<String, String>, | ||
} | ||
|
||
impl FeederClient { | ||
pub fn new(gateway_url: Url, feeder_gateway_url: Url) -> Self { | ||
Self { client: Client::new(), gateway_url, feeder_gateway_url, headers: HashMap::new() } | ||
} | ||
|
||
pub fn new_with_headers(gateway_url: Url, feeder_gateway_url: Url, headers: &[(String, String)]) -> Self { | ||
let headers = headers.iter().cloned().collect(); | ||
Self { client: Client::new(), gateway_url, feeder_gateway_url, headers } | ||
} | ||
|
||
pub fn add_header(&mut self, key: &str, value: &str) { | ||
self.headers.insert(key.to_string(), value.to_string()); | ||
} | ||
|
||
pub fn remove_header(&mut self, key: &str) -> Option<String> { | ||
self.headers.remove(key) | ||
} | ||
|
||
pub fn starknet_alpha_mainnet() -> Self { | ||
Self::new( | ||
Url::parse("https://alpha-mainnet.starknet.io/gateway/").unwrap(), | ||
Url::parse("https://alpha-mainnet.starknet.io/feeder_gateway/").unwrap(), | ||
) | ||
} | ||
|
||
pub fn starknet_alpha_sepolia() -> Self { | ||
Self::new( | ||
Url::parse("https://alpha-sepolia.starknet.io/gateway/").unwrap(), | ||
Url::parse("https://alpha-sepolia.starknet.io/feeder_gateway/").unwrap(), | ||
) | ||
} | ||
} |
Oops, something went wrong.