Skip to content

Commit

Permalink
Fix NearRPCClient
Browse files Browse the repository at this point in the history
  • Loading branch information
karim-en committed Mar 11, 2024
1 parent c89e605 commit 5bfa947
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion eth2near/contract_wrapper/src/near_rpc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ use std::error::Error;
pub struct NearRPCClient {
endpoint_url: String,
client: Client,
api_key: String,
}

impl NearRPCClient {
pub fn new(endpoint_url: &str) -> Self {
pub fn new(endpoint_url: &str, api_key: &Option<String>) -> Self {
Self {
endpoint_url: endpoint_url.to_string(),
client: reqwest::blocking::Client::new(),
api_key: api_key.clone().unwrap_or_default(),
}
}

Expand All @@ -30,6 +32,7 @@ impl NearRPCClient {
let res = self
.client
.post(&self.endpoint_url)
.header("x-api-key", self.api_key.clone())
.json(&json_value)
.send()?
.text()?;
Expand All @@ -50,6 +53,7 @@ impl NearRPCClient {
let res = self
.client
.post(&self.endpoint_url)
.header("x-api-key", self.api_key.clone())
.json(&json_value)
.send()?
.text()?;
Expand Down
2 changes: 1 addition & 1 deletion eth2near/eth2near-block-relay-rs/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl Config {
}

fn check_account_id(&self) {
let near_rpc_client = NearRPCClient::new(&self.near_endpoint);
let near_rpc_client = NearRPCClient::new(&self.near_endpoint, &self.near_endpoint_api_key);

// check `signer_account_id`
let _signer_account_id: near_sdk::AccountId = self
Expand Down
2 changes: 1 addition & 1 deletion eth2near/eth2near-block-relay-rs/src/eth2near_relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl Eth2NearRelay {
beacon_rpc_client,
eth1_rpc_client: Eth1RPCClient::new(&config.eth1_endpoint),
eth_client_contract: eth_contract,
near_rpc_client: NearRPCClient::new(&config.near_endpoint),
near_rpc_client: NearRPCClient::new(&config.near_endpoint, &config.near_endpoint_api_key),
headers_batch_size: config.headers_batch_size as u64,
ethereum_network: config.ethereum_network.to_string(),
interval_between_light_client_updates_submission_in_epochs: config
Expand Down

0 comments on commit 5bfa947

Please sign in to comment.