Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add Tenderly RPCs #301

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions SUPPORTED_CHAINS.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ Chain name with associated `chainId` query param to use.
- Base Goerli (`eip155:84531`)
- Zora (`eip155:7777777`)
- Zora Goerli (`eip155:999`)
- Boba Ethereum (`eip155:288`)
- Boba BNB (`eip155:56288`)
- Boba BNB Testnet (`eip155:9728`)

## WebSocket RPC

Expand All @@ -41,7 +44,14 @@ WebSocket RPC is not recommended for production use, and may be removed in the f
- Optimism Goerli (`eip155:420`)
- Arbitrum (`eip155:42161`)
- Arbitrum Goerli (`eip155:421613`)
- Polygon (`eip155:137`)
- Polygon Mumbai (`eip155:80001`)
- Aurora (`eip155:1313161554`)
- Aurora Testnet (`eip155:1313161555`)
- Base (`eip155:8453`)
- Base Goerli (`eip155:84531`)
- Zora (`eip155:7777777`)
- Zora Goerli (`eip155:999`)
- Boba Ethereum (`eip155:288`)
- Boba BNB (`eip155:56288`)
- Boba BNB Testnet (`eip155:9728`)
2 changes: 2 additions & 0 deletions src/env/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ mod omnia;
mod pokt;
mod publicnode;
mod server;
mod tenderly;
mod zksync;
mod zora;

Expand All @@ -28,6 +29,7 @@ pub use {
pokt::*,
publicnode::*,
server::*,
tenderly::*,
zksync::*,
zora::*,
};
Expand Down
180 changes: 180 additions & 0 deletions src/env/tenderly.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
use {
super::ProviderConfig,
crate::providers::{Priority, Weight},
std::collections::HashMap,
};

#[derive(Debug)]
pub struct TenderlyConfig {
pub supported_chains: HashMap<String, (String, Weight)>,
pub supported_ws_chains: HashMap<String, (String, Weight)>,
}

impl Default for TenderlyConfig {
fn default() -> Self {
Self {
supported_chains: default_supported_chains(),
supported_ws_chains: default_ws_supported_chains(),
}
}
}

impl ProviderConfig for TenderlyConfig {
fn supported_chains(self) -> HashMap<String, (String, Weight)> {
self.supported_chains
}

fn supported_ws_chains(self) -> HashMap<String, (String, Weight)> {
self.supported_ws_chains
}

fn provider_kind(&self) -> crate::providers::ProviderKind {
crate::providers::ProviderKind::Tenderly
}
}

fn default_supported_chains() -> HashMap<String, (String, Weight)> {
// Keep in-sync with SUPPORTED_CHAINS.md

HashMap::from([
// Ethereum Mainnet
(
"eip155:1".into(),
("mainnet".into(), Weight::new(Priority::Low).unwrap()),
),
// Ethereum Görli
(
"eip155:5".into(),
("goerli".into(), Weight::new(Priority::Low).unwrap()),
),
// Ethereum Sepolia
(
"eip155:11155111".into(),
("sepolia".into(), Weight::new(Priority::Low).unwrap()),
),
// Optimism Mainnet
(
"eip155:10".into(),
("optimism".into(), Weight::new(Priority::Low).unwrap()),
),
// Optimism Görli
(
"eip155:420".into(),
(
"optimism-goerli".into(),
Weight::new(Priority::Low).unwrap(),
),
),
// Polygon Mainnet
(
"eip155:137".into(),
("polygon".into(), Weight::new(Priority::Low).unwrap()),
),
// Polygon Mumbai
(
"eip155:80001".into(),
("polygon-mumbai".into(), Weight::new(Priority::Low).unwrap()),
),
// Base Mainnet
(
"eip155:8453".into(),
("base".into(), Weight::new(Priority::Low).unwrap()),
),
// Base Görli
(
"eip155:84531".into(),
("base-goerli".into(), Weight::new(Priority::Low).unwrap()),
),
// Boba Ethereum Mainnet
(
"eip155:288".into(),
("boba-ethereum".into(), Weight::new(Priority::Low).unwrap()),
),
// Boba BNB Mainnet
(
"eip155:56288".into(),
("boba-bnb".into(), Weight::new(Priority::Low).unwrap()),
),
// Boba BNB Testnet
(
"eip155:9728".into(),
(
"boba-bnb-testnet".into(),
Weight::new(Priority::Low).unwrap(),
),
),
])
}

fn default_ws_supported_chains() -> HashMap<String, (String, Weight)> {
// Keep in-sync with SUPPORTED_CHAINS.md

HashMap::from([
// Ethereum Mainnet
(
"eip155:1".into(),
("mainnet".into(), Weight::new(Priority::Low).unwrap()),
),
// Ethereum Görli
(
"eip155:5".into(),
("goerli".into(), Weight::new(Priority::Low).unwrap()),
),
// Ethereum Sepolia
(
"eip155:11155111".into(),
("sepolia".into(), Weight::new(Priority::Low).unwrap()),
),
// Optimism Mainnet
(
"eip155:10".into(),
("optimism".into(), Weight::new(Priority::Low).unwrap()),
),
// Optimism Görli
(
"eip155:420".into(),
(
"optimism-goerli".into(),
Weight::new(Priority::Low).unwrap(),
),
),
// Polygon Mainnet
(
"eip155:137".into(),
("polygon".into(), Weight::new(Priority::Low).unwrap()),
),
// Polygon Mumbai
(
"eip155:80001".into(),
("polygon-mumbai".into(), Weight::new(Priority::Low).unwrap()),
),
// Base Mainnet
(
"eip155:8453".into(),
("base".into(), Weight::new(Priority::Low).unwrap()),
),
// Base Görli
(
"eip155:84531".into(),
("base-goerli".into(), Weight::new(Priority::Low).unwrap()),
),
// Boba Ethereum Mainnet
(
"eip155:288".into(),
("boba-ethereum".into(), Weight::new(Priority::Low).unwrap()),
),
// Boba BNB Mainnet
(
"eip155:56288".into(),
("boba-bnb".into(), Weight::new(Priority::Low).unwrap()),
),
// Boba BNB Testnet
(
"eip155:9728".into(),
(
"boba-bnb-testnet".into(),
Weight::new(Priority::Low).unwrap(),
),
),
])
}
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use {
OmniatechConfig,
PoktConfig,
PublicnodeConfig,
TenderlyConfig,
ZKSyncConfig,
ZoraConfig,
},
Expand All @@ -34,6 +35,8 @@ use {
PoktProvider,
ProviderRepository,
PublicnodeProvider,
TenderlyProvider,
TenderlyWsProvider,
ZKSyncProvider,
ZoraProvider,
ZoraWsProvider,
Expand Down Expand Up @@ -246,10 +249,13 @@ fn init_providers() -> ProviderRepository {
providers
.add_provider::<InfuraProvider, InfuraConfig>(InfuraConfig::new(infura_project_id.clone()));
providers.add_provider::<ZoraProvider, ZoraConfig>(ZoraConfig::default());
providers.add_provider::<TenderlyProvider, TenderlyConfig>(TenderlyConfig::default());

// WebSocket Providers
providers
.add_ws_provider::<InfuraWsProvider, InfuraConfig>(InfuraConfig::new(infura_project_id));
providers.add_ws_provider::<ZoraWsProvider, ZoraConfig>(ZoraConfig::default());
providers.add_ws_provider::<TenderlyWsProvider, TenderlyConfig>(TenderlyConfig::default());

providers
}
5 changes: 5 additions & 0 deletions src/providers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ mod infura;
mod omnia;
mod pokt;
mod publicnode;
mod tenderly;
mod weights;
mod zerion;
mod zksync;
Expand All @@ -37,6 +38,7 @@ pub use {
omnia::OmniatechProvider,
pokt::PoktProvider,
publicnode::PublicnodeProvider,
tenderly::{TenderlyProvider, TenderlyWsProvider},
zksync::ZKSyncProvider,
zora::{ZoraProvider, ZoraWsProvider},
};
Expand Down Expand Up @@ -227,6 +229,7 @@ pub enum ProviderKind {
Binance,
ZKSync,
Publicnode,
Tenderly,
Omniatech,
Base,
Zora,
Expand All @@ -240,6 +243,7 @@ impl Display for ProviderKind {
ProviderKind::Binance => "Binance",
ProviderKind::ZKSync => "zkSync",
ProviderKind::Publicnode => "Publicnode",
ProviderKind::Tenderly => "Tenderly",
ProviderKind::Omniatech => "Omniatech",
ProviderKind::Base => "Base",
ProviderKind::Zora => "Zora",
Expand All @@ -255,6 +259,7 @@ impl ProviderKind {
"Binance" => Some(Self::Binance),
"zkSync" => Some(Self::ZKSync),
"Publicnode" => Some(Self::Publicnode),
"Tenderly" => Some(Self::Tenderly),
"Omniatech" => Some(Self::Omniatech),
"Base" => Some(Self::Base),
"Zora" => Some(Self::Zora),
Expand Down
Loading