Skip to content

Commit 7cf94d5

Browse files
Adjust chain set, fix ws conn to gateway
1 parent 94df1d1 commit 7cf94d5

File tree

2 files changed

+20
-207
lines changed

2 files changed

+20
-207
lines changed

src/routes/relayer/types.rs

Lines changed: 4 additions & 183 deletions
Original file line numberDiff line numberDiff line change
@@ -32,119 +32,29 @@ impl From<PoktChains> for HeaderValue {
3232
pub enum PoktChains {
3333
#[cfg(any(test, feature = "dev"))]
3434
Anvil,
35-
Poly,
36-
ArbSepoliaTestnet,
35+
Base,
36+
Eth,
3737
ArbOne,
38-
ZksyncEra,
3938
Solana,
40-
Osmosis,
41-
Gnosis,
4239
Sui,
43-
Bera,
44-
Harmony,
45-
XrplEvmTestnet,
46-
Metis,
47-
Base,
48-
ZkLinkNova,
49-
Kaia,
50-
Op,
51-
Scroll,
52-
Taiko,
53-
Pocket,
54-
PocketBeta,
55-
OpSepoliaTestnet,
56-
// Fantom,
57-
Moonbeam,
58-
Ink,
59-
Evmos,
60-
BaseSepoliaTestnet,
61-
Sei,
62-
Kava,
63-
Oasys,
64-
Tron,
65-
Sonic,
66-
Near,
67-
AvaxDFK,
6840
Bsc,
69-
Polyzkevm,
70-
Linea,
71-
Celo,
72-
Fraxtal,
73-
Fuse,
74-
Avax,
75-
Iotex,
76-
Moonriver,
77-
Boba,
78-
EthSepoliaTestnet,
79-
Radix,
80-
Xrplevm,
81-
EthHoleskyTestnet,
82-
OpBNB,
83-
Blast,
84-
Mantle,
85-
Eth,
86-
TaikoHeklaTestnet,
87-
PolyAmoyTestnet,
41+
Poly,
42+
Op,
8843
}
8944

9045
impl fmt::Display for PoktChains {
9146
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
9247
match self {
9348
PoktChains::ArbOne => write!(f, "arb-one"),
94-
PoktChains::Avax => write!(f, "avax"),
95-
PoktChains::AvaxDFK => write!(f, "avax-dfk"),
9649
PoktChains::Base => write!(f, "base"),
97-
PoktChains::BaseSepoliaTestnet => write!(f, "base-sepolia-testnet"),
98-
PoktChains::Bera => write!(f, "bera"),
99-
PoktChains::Blast => write!(f, "blast"),
10050
PoktChains::Bsc => write!(f, "bsc"),
101-
PoktChains::Boba => write!(f, "boba"),
102-
PoktChains::Celo => write!(f, "celo"),
10351
PoktChains::Eth => write!(f, "eth"),
104-
PoktChains::EthHoleskyTestnet => write!(f, "eth-holesky-testnet"),
105-
PoktChains::EthSepoliaTestnet => write!(f, "eth-sepolia-testnet"),
106-
PoktChains::Evmos => write!(f, "evmos"),
107-
PoktChains::Fraxtal => write!(f, "fraxtal"),
108-
PoktChains::Fuse => write!(f, "fuse"),
109-
PoktChains::Gnosis => write!(f, "gnosis"),
110-
PoktChains::Harmony => write!(f, "harmony"),
111-
PoktChains::Iotex => write!(f, "iotex"),
112-
PoktChains::Kaia => write!(f, "kaia"),
113-
PoktChains::Kava => write!(f, "kava"),
114-
PoktChains::Metis => write!(f, "metis"),
115-
PoktChains::Moonbeam => write!(f, "moonbeam"),
116-
PoktChains::Moonriver => write!(f, "moonriver"),
117-
PoktChains::Near => write!(f, "near"),
118-
PoktChains::Oasys => write!(f, "oasys"),
119-
PoktChains::OpBNB => write!(f, "opbnb"),
12052
PoktChains::Op => write!(f, "op"),
121-
PoktChains::OpSepoliaTestnet => write!(f, "op-sepolia-testnet"),
122-
PoktChains::Osmosis => write!(f, "osmosis"),
123-
PoktChains::Pocket => write!(f, "pocket"),
124-
PoktChains::PocketBeta => write!(f, "pocket-beta"),
12553
PoktChains::Poly => write!(f, "poly"),
126-
PoktChains::PolyAmoyTestnet => write!(f, "poly-amoy-testnet"),
127-
PoktChains::Polyzkevm => write!(f, "poly-zkevm"),
128-
PoktChains::Radix => write!(f, "radix"),
129-
PoktChains::Scroll => write!(f, "scroll"),
13054
PoktChains::Solana => write!(f, "solana"),
13155
PoktChains::Sui => write!(f, "sui"),
132-
PoktChains::Taiko => write!(f, "taiko"),
133-
PoktChains::TaikoHeklaTestnet => write!(f, "taiko-hekla-testnet"),
134-
PoktChains::ZkLinkNova => write!(f, "zklink-nova"),
135-
PoktChains::ZksyncEra => write!(f, "zksync-era"),
13656
#[cfg(any(test, feature = "dev"))]
13757
PoktChains::Anvil => write!(f, "anvil"),
138-
PoktChains::XrplEvmTestnet => write!(f, "xrplevm-testnet"),
139-
// PoktChains::Fantom => write!(f, "fantom"),
140-
PoktChains::Ink => write!(f, "ink"),
141-
PoktChains::Sei => write!(f, "sei"),
142-
PoktChains::Tron => write!(f, "tron"),
143-
PoktChains::Sonic => write!(f, "sonic"),
144-
PoktChains::Linea => write!(f, "linea"),
145-
PoktChains::ArbSepoliaTestnet => write!(f, "arb-sepolia-testnet"),
146-
PoktChains::Xrplevm => write!(f, "xrplevm"),
147-
PoktChains::Mantle => write!(f, "mantle"),
14858
}
14959
}
15060
}
@@ -153,60 +63,15 @@ impl PoktChains {
15363
pub const fn id(&self) -> &'static str {
15464
match self {
15565
PoktChains::ArbOne => "arb-one",
156-
PoktChains::Avax => "avax",
157-
PoktChains::AvaxDFK => "avax-dfk",
15866
PoktChains::Base => "base",
159-
PoktChains::BaseSepoliaTestnet => "base-sepolia-testnet",
160-
PoktChains::Bera => "bera",
161-
PoktChains::Blast => "blast",
16267
PoktChains::Bsc => "bsc",
163-
PoktChains::Boba => "boba",
164-
PoktChains::Celo => "celo",
16568
PoktChains::Eth => "eth",
166-
PoktChains::EthHoleskyTestnet => "eth-holesky-testnet",
167-
PoktChains::EthSepoliaTestnet => "eth-sepolia-testnet",
168-
PoktChains::Evmos => "evmos",
169-
PoktChains::Fraxtal => "fraxtal",
170-
PoktChains::Fuse => "fuse",
171-
PoktChains::Gnosis => "gnosis",
172-
PoktChains::Harmony => "harmony",
173-
PoktChains::Iotex => "iotex",
174-
PoktChains::Kaia => "kaia",
175-
PoktChains::Kava => "kava",
176-
PoktChains::Metis => "metis",
177-
PoktChains::Moonbeam => "moonbeam",
178-
PoktChains::Moonriver => "moonriver",
179-
PoktChains::Near => "near",
180-
PoktChains::Oasys => "oasys",
181-
PoktChains::OpBNB => "opbnb",
18269
PoktChains::Op => "op",
183-
PoktChains::OpSepoliaTestnet => "op-sepolia-testnet",
184-
PoktChains::Osmosis => "osmosis",
185-
PoktChains::Pocket => "pocket",
186-
PoktChains::PocketBeta => "pocket-beta",
18770
PoktChains::Poly => "poly",
188-
PoktChains::PolyAmoyTestnet => "poly-amoy-testnet",
189-
PoktChains::Polyzkevm => "poly-zkevm",
190-
PoktChains::Radix => "radix",
191-
PoktChains::Scroll => "scroll",
19271
PoktChains::Solana => "solana",
19372
PoktChains::Sui => "sui",
194-
PoktChains::Taiko => "taiko",
195-
PoktChains::TaikoHeklaTestnet => "taiko-hekla-testnet",
196-
PoktChains::ZkLinkNova => "zklink-nova",
197-
PoktChains::ZksyncEra => "zksync-era",
19873
#[cfg(any(test, feature = "dev"))]
19974
PoktChains::Anvil => "anvil",
200-
PoktChains::XrplEvmTestnet => "xrplevm-testnet",
201-
// PoktChains::Fantom => "fantom",
202-
PoktChains::Ink => "ink",
203-
PoktChains::Sei => "sei",
204-
PoktChains::Tron => "tron",
205-
PoktChains::Sonic => "sonic",
206-
PoktChains::Linea => "linea",
207-
PoktChains::ArbSepoliaTestnet => "arb-sepolia-testnet",
208-
PoktChains::Xrplevm => "xrplevm",
209-
PoktChains::Mantle => "mantle",
21075
}
21176
}
21277
}
@@ -246,59 +111,15 @@ impl FromStr for PoktChains {
246111
fn from_str(value: &str) -> Result<Self, Self::Err> {
247112
match value.to_lowercase().as_ref() {
248113
"arb-one" => Ok(PoktChains::ArbOne),
249-
"avax" => Ok(PoktChains::Avax),
250-
"avax-dfk" => Ok(PoktChains::AvaxDFK),
251114
"base" => Ok(PoktChains::Base),
252-
"base-sepolia-testnet" => Ok(PoktChains::BaseSepoliaTestnet),
253-
"bera" => Ok(PoktChains::Bera),
254-
"blast" => Ok(PoktChains::Blast),
255115
"bsc" => Ok(PoktChains::Bsc),
256-
"boba" => Ok(PoktChains::Boba),
257-
"celo" => Ok(PoktChains::Celo),
258116
"eth" => Ok(PoktChains::Eth),
259-
"eth-holesky-testnet" => Ok(PoktChains::EthHoleskyTestnet),
260-
"eth-sepolia-testnet" => Ok(PoktChains::EthSepoliaTestnet),
261-
"evmos" => Ok(PoktChains::Evmos),
262-
"fraxtal" => Ok(PoktChains::Fraxtal),
263-
"fuse" => Ok(PoktChains::Fuse),
264-
"gnosis" => Ok(PoktChains::Gnosis),
265-
"harmony" => Ok(PoktChains::Harmony),
266-
"iotex" => Ok(PoktChains::Iotex),
267-
"kaia" => Ok(PoktChains::Kaia),
268-
"kava" => Ok(PoktChains::Kava),
269-
"metis" => Ok(PoktChains::Metis),
270-
"moonbeam" => Ok(PoktChains::Moonbeam),
271-
"moonriver" => Ok(PoktChains::Moonriver),
272-
"near" => Ok(PoktChains::Near),
273-
"oasys" => Ok(PoktChains::Oasys),
274-
"opbnb" => Ok(PoktChains::OpBNB),
275117
"op" => Ok(PoktChains::Op),
276-
"op-sepolia-testnet" => Ok(PoktChains::OpSepoliaTestnet),
277-
"osmosis" => Ok(PoktChains::Osmosis),
278-
"pocket" => Ok(PoktChains::Pocket),
279-
"pocket-beta" => Ok(PoktChains::PocketBeta),
280118
"poly" => Ok(PoktChains::Poly),
281-
"poly-amoy-testnet" => Ok(PoktChains::PolyAmoyTestnet),
282-
"poly-zkevm" => Ok(PoktChains::Polyzkevm),
283-
"radix" => Ok(PoktChains::Radix),
284-
"scroll" => Ok(PoktChains::Scroll),
285119
"solana" => Ok(PoktChains::Solana),
286120
"sui" => Ok(PoktChains::Sui),
287-
"taiko" => Ok(PoktChains::Taiko),
288-
"taiko-hekla-testnet" => Ok(PoktChains::TaikoHeklaTestnet),
289-
"zklink-nova" => Ok(PoktChains::ZkLinkNova),
290-
"zksync-era" => Ok(PoktChains::ZksyncEra),
291121
#[cfg(any(test, feature = "dev"))]
292122
"anvil" => Ok(PoktChains::Anvil),
293-
"xrplevm-testnet" => Ok(PoktChains::XrplEvmTestnet),
294-
// PoktChains::Fantom => "fantom",
295-
"ink" => Ok(PoktChains::Ink),
296-
"sei" => Ok(PoktChains::Sei),
297-
"tron" => Ok(PoktChains::Tron),
298-
"sonic" => Ok(PoktChains::Sonic),
299-
"linea" => Ok(PoktChains::Linea),
300-
"xrplevm" => Ok(PoktChains::Xrplevm),
301-
"mantle" => Ok(PoktChains::Mantle),
302123
_ => Err(RelayErrors::PoktChainIdParsingError),
303124
}
304125
}

src/routes/relayer/websockets.rs

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ use axum::response::IntoResponse;
66
use futures_util::stream::{SplitSink, SplitStream};
77
use futures_util::{SinkExt, StreamExt};
88
use http::StatusCode;
9+
use http::header::{CONNECTION, HOST, SEC_WEBSOCKET_KEY, SEC_WEBSOCKET_VERSION, UPGRADE};
10+
use openssl::base64;
911
// use http::header::{CONNECTION, HOST, SEC_WEBSOCKET_KEY, SEC_WEBSOCKET_VERSION, UPGRADE};
1012
// use openssl::base64;
1113
use rand::{RngCore, SeedableRng, rngs::StdRng};
@@ -85,30 +87,21 @@ pub async fn handle_ws_conn(
8587
let mut buf = [0u8; 16];
8688
let mut rng: StdRng = StdRng::from_rng(&mut rand::rng());
8789
rng.fill_bytes(&mut buf);
88-
// let sec_websocket_key = base64::encode_block(&buf);
89-
// = if cfg!(test) {
90-
// let request = http::Request::builder()
91-
// .uri("localhost:3070/v1")
92-
// .header("Target-Service-Id", path)
93-
// .header(SEC_WEBSOCKET_KEY, &sec_websocket_key)
94-
// .header(HOST, "localhost:3070")
95-
// .header(UPGRADE, "websocket")
96-
// .header(CONNECTION, "upgrade")
97-
// .header(SEC_WEBSOCKET_VERSION, 13)
98-
// .body(())
99-
// .unwrap();
100-
// connect_async_tls_with_config(request, None, false, None)
101-
// .await
102-
// .unwrap()
103-
// } else {
104-
// };
90+
let sec_websocket_key = base64::encode_block(&buf);
91+
let request = http::Request::builder()
92+
.uri("localhost:3070/v1")
93+
.header("Target-Service-Id", path)
94+
.header(SEC_WEBSOCKET_KEY, &sec_websocket_key)
95+
.header(HOST, "localhost:3070")
96+
.header(UPGRADE, "websocket")
97+
.header(CONNECTION, "upgrade")
98+
.header(SEC_WEBSOCKET_VERSION, 13)
99+
.body(())
100+
.unwrap();
105101

106-
let (node_socket, _res) = {
107-
let url = dotenvy::var("SEPOLIA_WS").unwrap();
108-
connect_async_tls_with_config(url, None, false, None)
109-
.await
110-
.unwrap()
111-
};
102+
let (node_socket, _res) = connect_async_tls_with_config(request, None, false, None)
103+
.await
104+
.unwrap();
112105

113106
let (mut node_tx, mut node_rv) = node_socket.split();
114107

@@ -126,7 +119,6 @@ pub async fn handle_ws_conn(
126119
user_tx.send(Message::Close(None)).await.unwrap();
127120
}
128121
Some(Ok(msg)) = node_rv.next() => {
129-
info!("{msg}");
130122
if let Some(m) = convert(msg) {
131123
match m {
132124
Message::Text(_) => {

0 commit comments

Comments
 (0)