diff --git a/eth2near/contract_wrapper/src/near_rpc_client.rs b/eth2near/contract_wrapper/src/near_rpc_client.rs index 6fd4f2e8..f767d879 100644 --- a/eth2near/contract_wrapper/src/near_rpc_client.rs +++ b/eth2near/contract_wrapper/src/near_rpc_client.rs @@ -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) -> Self { Self { endpoint_url: endpoint_url.to_string(), client: reqwest::blocking::Client::new(), + api_key: api_key.clone().unwrap_or_default(), } } @@ -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()?; @@ -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()?; diff --git a/eth2near/eth2near-block-relay-rs/src/config.rs b/eth2near/eth2near-block-relay-rs/src/config.rs index ef6c89a2..3910f480 100644 --- a/eth2near/eth2near-block-relay-rs/src/config.rs +++ b/eth2near/eth2near-block-relay-rs/src/config.rs @@ -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 diff --git a/eth2near/eth2near-block-relay-rs/src/eth2near_relay.rs b/eth2near/eth2near-block-relay-rs/src/eth2near_relay.rs index c30f622d..ac73587b 100644 --- a/eth2near/eth2near-block-relay-rs/src/eth2near_relay.rs +++ b/eth2near/eth2near-block-relay-rs/src/eth2near_relay.rs @@ -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