Skip to content

Commit 28dba08

Browse files
committed
add tenderly provider and tests from #301
1 parent b8ebcf4 commit 28dba08

File tree

11 files changed

+465
-38
lines changed

11 files changed

+465
-38
lines changed

SUPPORTED_CHAINS.md

+10
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ Chain name with associated `chainId` query param to use.
2929
- Base Goerli (`eip155:84531`)
3030
- Zora (`eip155:7777777`)
3131
- Zora Goerli (`eip155:999`)
32+
- Boba Ethereum (`eip155:288`)
33+
- Boba BNB (`eip155:56288`)
34+
- Boba BNB Testnet (`eip155:9728`)
3235

3336
## WebSocket RPC
3437

@@ -41,7 +44,14 @@ WebSocket RPC is not recommended for production use, and may be removed in the f
4144
- Optimism Goerli (`eip155:420`)
4245
- Arbitrum (`eip155:42161`)
4346
- Arbitrum Goerli (`eip155:421613`)
47+
- Polygon (`eip155:137`)
48+
- Polygon Mumbai (`eip155:80001`)
4449
- Aurora (`eip155:1313161554`)
4550
- Aurora Testnet (`eip155:1313161555`)
51+
- Base (`eip155:8453`)
52+
- Base Goerli (`eip155:84531`)
4653
- Zora (`eip155:7777777`)
4754
- Zora Goerli (`eip155:999`)
55+
- Boba Ethereum (`eip155:288`)
56+
- Boba BNB (`eip155:56288`)
57+
- Boba BNB Testnet (`eip155:9728`)

src/env/mod.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,13 @@ mod omnia;
1717
mod pokt;
1818
mod publicnode;
1919
mod server;
20+
mod tenderly;
2021
mod zksync;
2122
mod zora;
2223

2324
pub use {
24-
base::*,
25-
binance::*,
26-
infura::*,
27-
omnia::*,
28-
pokt::*,
29-
publicnode::*,
30-
server::*,
31-
zksync::*,
32-
zora::*,
25+
base::*, binance::*, infura::*, omnia::*, pokt::*, publicnode::*, server::*, tenderly::*,
26+
zksync::*, zora::*,
3327
};
3428

3529
#[derive(Debug, Clone, PartialEq, Eq, Hash)]

src/env/tenderly.rs

+180
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
use {
2+
super::ProviderConfig,
3+
crate::providers::{Priority, Weight},
4+
std::collections::HashMap,
5+
};
6+
7+
#[derive(Debug)]
8+
pub struct TenderlyConfig {
9+
pub supported_chains: HashMap<String, (String, Weight)>,
10+
pub supported_ws_chains: HashMap<String, (String, Weight)>,
11+
}
12+
13+
impl Default for TenderlyConfig {
14+
fn default() -> Self {
15+
Self {
16+
supported_chains: default_supported_chains(),
17+
supported_ws_chains: default_ws_supported_chains(),
18+
}
19+
}
20+
}
21+
22+
impl ProviderConfig for TenderlyConfig {
23+
fn supported_chains(self) -> HashMap<String, (String, Weight)> {
24+
self.supported_chains
25+
}
26+
27+
fn supported_ws_chains(self) -> HashMap<String, (String, Weight)> {
28+
self.supported_ws_chains
29+
}
30+
31+
fn provider_kind(&self) -> crate::providers::ProviderKind {
32+
crate::providers::ProviderKind::Tenderly
33+
}
34+
}
35+
36+
fn default_supported_chains() -> HashMap<String, (String, Weight)> {
37+
// Keep in-sync with SUPPORTED_CHAINS.md
38+
39+
HashMap::from([
40+
// Ethereum Mainnet
41+
(
42+
"eip155:1".into(),
43+
("mainnet".into(), Weight::new(Priority::Low).unwrap()),
44+
),
45+
// Ethereum Görli
46+
(
47+
"eip155:5".into(),
48+
("goerli".into(), Weight::new(Priority::Low).unwrap()),
49+
),
50+
// Ethereum Sepolia
51+
(
52+
"eip155:11155111".into(),
53+
("sepolia".into(), Weight::new(Priority::Low).unwrap()),
54+
),
55+
// Optimism Mainnet
56+
(
57+
"eip155:10".into(),
58+
("optimism".into(), Weight::new(Priority::Low).unwrap()),
59+
),
60+
// Optimism Görli
61+
(
62+
"eip155:420".into(),
63+
(
64+
"optimism-goerli".into(),
65+
Weight::new(Priority::Low).unwrap(),
66+
),
67+
),
68+
// Polygon Mainnet
69+
(
70+
"eip155:137".into(),
71+
("polygon".into(), Weight::new(Priority::Low).unwrap()),
72+
),
73+
// Polygon Mumbai
74+
(
75+
"eip155:80001".into(),
76+
("polygon-mumbai".into(), Weight::new(Priority::Low).unwrap()),
77+
),
78+
// Base Mainnet
79+
(
80+
"eip155:8453".into(),
81+
("base".into(), Weight::new(Priority::Low).unwrap()),
82+
),
83+
// Base Görli
84+
(
85+
"eip155:84531".into(),
86+
("base-goerli".into(), Weight::new(Priority::Low).unwrap()),
87+
),
88+
// Boba Ethereum Mainnet
89+
(
90+
"eip155:288".into(),
91+
("boba-ethereum".into(), Weight::new(Priority::Low).unwrap()),
92+
),
93+
// Boba BNB Mainnet
94+
(
95+
"eip155:56288".into(),
96+
("boba-bnb".into(), Weight::new(Priority::Low).unwrap()),
97+
),
98+
// Boba BNB Testnet
99+
(
100+
"eip155:9728".into(),
101+
(
102+
"boba-bnb-testnet".into(),
103+
Weight::new(Priority::Low).unwrap(),
104+
),
105+
),
106+
])
107+
}
108+
109+
fn default_ws_supported_chains() -> HashMap<String, (String, Weight)> {
110+
// Keep in-sync with SUPPORTED_CHAINS.md
111+
112+
HashMap::from([
113+
// Ethereum Mainnet
114+
(
115+
"eip155:1".into(),
116+
("mainnet".into(), Weight::new(Priority::Low).unwrap()),
117+
),
118+
// Ethereum Görli
119+
(
120+
"eip155:5".into(),
121+
("goerli".into(), Weight::new(Priority::Low).unwrap()),
122+
),
123+
// Ethereum Sepolia
124+
(
125+
"eip155:11155111".into(),
126+
("sepolia".into(), Weight::new(Priority::Low).unwrap()),
127+
),
128+
// Optimism Mainnet
129+
(
130+
"eip155:10".into(),
131+
("optimism".into(), Weight::new(Priority::Low).unwrap()),
132+
),
133+
// Optimism Görli
134+
(
135+
"eip155:420".into(),
136+
(
137+
"optimism-goerli".into(),
138+
Weight::new(Priority::Low).unwrap(),
139+
),
140+
),
141+
// Polygon Mainnet
142+
(
143+
"eip155:137".into(),
144+
("polygon".into(), Weight::new(Priority::Low).unwrap()),
145+
),
146+
// Polygon Mumbai
147+
(
148+
"eip155:80001".into(),
149+
("polygon-mumbai".into(), Weight::new(Priority::Low).unwrap()),
150+
),
151+
// Base Mainnet
152+
(
153+
"eip155:8453".into(),
154+
("base".into(), Weight::new(Priority::Low).unwrap()),
155+
),
156+
// Base Görli
157+
(
158+
"eip155:84531".into(),
159+
("base-goerli".into(), Weight::new(Priority::Low).unwrap()),
160+
),
161+
// Boba Ethereum Mainnet
162+
(
163+
"eip155:288".into(),
164+
("boba-ethereum".into(), Weight::new(Priority::Low).unwrap()),
165+
),
166+
// Boba BNB Mainnet
167+
(
168+
"eip155:56288".into(),
169+
("boba-bnb".into(), Weight::new(Priority::Low).unwrap()),
170+
),
171+
// Boba BNB Testnet
172+
(
173+
"eip155:9728".into(),
174+
(
175+
"boba-bnb-testnet".into(),
176+
Weight::new(Priority::Low).unwrap(),
177+
),
178+
),
179+
])
180+
}

src/lib.rs

+7-19
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,16 @@ use {
1313
Router,
1414
},
1515
env::{
16-
BaseConfig,
17-
BinanceConfig,
18-
InfuraConfig,
19-
OmniatechConfig,
20-
PoktConfig,
21-
PublicnodeConfig,
22-
ZKSyncConfig,
23-
ZoraConfig,
16+
BaseConfig, BinanceConfig, InfuraConfig, OmniatechConfig, PoktConfig, PublicnodeConfig,
17+
TenderlyConfig, ZKSyncConfig, ZoraConfig,
2418
},
2519
error::RpcResult,
2620
http::Request,
2721
hyper::{header::HeaderName, http, Body},
2822
providers::{
29-
BaseProvider,
30-
BinanceProvider,
31-
InfuraProvider,
32-
InfuraWsProvider,
33-
OmniatechProvider,
34-
PoktProvider,
35-
ProviderRepository,
36-
PublicnodeProvider,
37-
ZKSyncProvider,
38-
ZoraProvider,
39-
ZoraWsProvider,
23+
BaseProvider, BinanceProvider, InfuraProvider, InfuraWsProvider, OmniatechProvider,
24+
PoktProvider, ProviderRepository, PublicnodeProvider, TenderlyProvider, TenderlyWsProvider,
25+
ZKSyncProvider, ZoraProvider, ZoraWsProvider,
4026
},
4127
std::{
4228
net::{IpAddr, Ipv4Addr, SocketAddr},
@@ -246,10 +232,12 @@ fn init_providers() -> ProviderRepository {
246232
providers
247233
.add_provider::<InfuraProvider, InfuraConfig>(InfuraConfig::new(infura_project_id.clone()));
248234
providers.add_provider::<ZoraProvider, ZoraConfig>(ZoraConfig::default());
235+
providers.add_provider::<TenderlyProvider, TenderlyConfig>(TenderlyConfig::default());
249236

250237
providers
251238
.add_ws_provider::<InfuraWsProvider, InfuraConfig>(InfuraConfig::new(infura_project_id));
252239
providers.add_ws_provider::<ZoraWsProvider, ZoraConfig>(ZoraConfig::default());
240+
providers.add_ws_provider::<TenderlyWsProvider, TenderlyConfig>(TenderlyConfig::default());
253241

254242
providers
255243
}

src/providers/mod.rs

+19-10
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ mod infura;
2020
mod omnia;
2121
mod pokt;
2222
mod publicnode;
23+
mod tenderly;
2324
mod weights;
2425
mod zerion;
2526
mod zksync;
@@ -37,6 +38,7 @@ pub use {
3738
omnia::OmniatechProvider,
3839
pokt::PoktProvider,
3940
publicnode::PublicnodeProvider,
41+
tenderly::{TenderlyProvider, TenderlyWsProvider},
4042
zksync::ZKSyncProvider,
4143
zora::{ZoraProvider, ZoraWsProvider},
4244
};
@@ -227,23 +229,29 @@ pub enum ProviderKind {
227229
Binance,
228230
ZKSync,
229231
Publicnode,
232+
Tenderly,
230233
Omniatech,
231234
Base,
232235
Zora,
233236
}
234237

235238
impl Display for ProviderKind {
236239
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
237-
write!(f, "{}", match self {
238-
ProviderKind::Infura => "Infura",
239-
ProviderKind::Pokt => "Pokt",
240-
ProviderKind::Binance => "Binance",
241-
ProviderKind::ZKSync => "zkSync",
242-
ProviderKind::Publicnode => "Publicnode",
243-
ProviderKind::Omniatech => "Omniatech",
244-
ProviderKind::Base => "Base",
245-
ProviderKind::Zora => "Zora",
246-
})
240+
write!(
241+
f,
242+
"{}",
243+
match self {
244+
ProviderKind::Infura => "Infura",
245+
ProviderKind::Pokt => "Pokt",
246+
ProviderKind::Binance => "Binance",
247+
ProviderKind::ZKSync => "zkSync",
248+
ProviderKind::Publicnode => "Publicnode",
249+
ProviderKind::Tenderly => "Tenderly",
250+
ProviderKind::Omniatech => "Omniatech",
251+
ProviderKind::Base => "Base",
252+
ProviderKind::Zora => "Zora",
253+
}
254+
)
247255
}
248256
}
249257

@@ -255,6 +263,7 @@ impl ProviderKind {
255263
"Binance" => Some(Self::Binance),
256264
"zkSync" => Some(Self::ZKSync),
257265
"Publicnode" => Some(Self::Publicnode),
266+
"Tenderly" => Some(Self::Tenderly),
258267
"Omniatech" => Some(Self::Omniatech),
259268
"Base" => Some(Self::Base),
260269
"Zora" => Some(Self::Zora),

0 commit comments

Comments
 (0)