-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move types related to providers to
evm-rpc-types
crate (#271
) Follow-up on #257 to move the following types to the `evm_rpc_types` crate: 1. `EthMainnetService` 2. `EthSepoliaService` 3. `HttpHeader` 4. `L2MainnetService` 5. `RpcApi` 6. `RpcConfig` 7. `RpcService` 8. `RpcServices` so that the public API of all methods in `main.rs` only use types from that crate as arguments.
- Loading branch information
1 parent
e2158f0
commit 27f43f0
Showing
12 changed files
with
636 additions
and
174 deletions.
There are no files selected for viewing
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,91 @@ | ||
pub use ic_cdk::api::management_canister::http_request::HttpHeader; | ||
|
||
use candid::{CandidType, Deserialize}; | ||
use serde::Serialize; | ||
|
||
#[derive(Clone, Debug, PartialEq, Eq, Default, CandidType, Deserialize)] | ||
pub struct RpcConfig { | ||
#[serde(rename = "responseSizeEstimate")] | ||
pub response_size_estimate: Option<u64>, | ||
} | ||
|
||
#[derive(Clone, CandidType, Deserialize)] | ||
pub enum RpcServices { | ||
Custom { | ||
#[serde(rename = "chainId")] | ||
chain_id: u64, | ||
services: Vec<RpcApi>, | ||
}, | ||
EthMainnet(Option<Vec<EthMainnetService>>), | ||
EthSepolia(Option<Vec<EthSepoliaService>>), | ||
ArbitrumOne(Option<Vec<L2MainnetService>>), | ||
BaseMainnet(Option<Vec<L2MainnetService>>), | ||
OptimismMainnet(Option<Vec<L2MainnetService>>), | ||
} | ||
|
||
#[derive(Clone, PartialEq, Eq, Ord, PartialOrd, Hash, Serialize, Deserialize, CandidType)] | ||
pub struct RpcApi { | ||
pub url: String, | ||
pub headers: Option<Vec<HttpHeader>>, | ||
} | ||
|
||
#[derive( | ||
Clone, Copy, Debug, PartialEq, Eq, Ord, PartialOrd, Hash, Serialize, Deserialize, CandidType, | ||
)] | ||
pub enum EthMainnetService { | ||
Alchemy, | ||
Ankr, | ||
BlockPi, | ||
PublicNode, | ||
Cloudflare, | ||
Llama, | ||
} | ||
|
||
#[derive( | ||
Clone, Copy, Debug, PartialEq, Eq, Ord, PartialOrd, Hash, Serialize, Deserialize, CandidType, | ||
)] | ||
pub enum EthSepoliaService { | ||
Alchemy, | ||
Ankr, | ||
BlockPi, | ||
PublicNode, | ||
Sepolia, | ||
} | ||
|
||
#[derive( | ||
Clone, Copy, Debug, PartialEq, Eq, Ord, PartialOrd, Hash, Serialize, Deserialize, CandidType, | ||
)] | ||
pub enum L2MainnetService { | ||
Alchemy, | ||
Ankr, | ||
BlockPi, | ||
PublicNode, | ||
Llama, | ||
} | ||
|
||
#[derive(Clone, PartialEq, Eq, Ord, PartialOrd, Hash, Serialize, Deserialize, CandidType)] | ||
pub enum RpcService { | ||
Chain(u64), | ||
Provider(u64), | ||
Custom(RpcApi), | ||
EthMainnet(EthMainnetService), | ||
EthSepolia(EthSepoliaService), | ||
ArbitrumOne(L2MainnetService), | ||
BaseMainnet(L2MainnetService), | ||
OptimismMainnet(L2MainnetService), | ||
} | ||
|
||
impl std::fmt::Debug for RpcService { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
match self { | ||
RpcService::Chain(chain_id) => write!(f, "Chain({})", chain_id), | ||
RpcService::Provider(provider_id) => write!(f, "Provider({})", provider_id), | ||
RpcService::Custom(_) => write!(f, "Custom(..)"), // Redact credentials | ||
RpcService::EthMainnet(service) => write!(f, "{:?}", service), | ||
RpcService::EthSepolia(service) => write!(f, "{:?}", service), | ||
RpcService::ArbitrumOne(service) | ||
| RpcService::BaseMainnet(service) | ||
| RpcService::OptimismMainnet(service) => write!(f, "{:?}", service), | ||
} | ||
} | ||
} |
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
Oops, something went wrong.