Skip to content

Commit

Permalink
chore: use custom http client with timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksuss committed Jul 17, 2023
1 parent 3858860 commit 748ac93
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion scripts/simple.sh
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ sleep 1
# Upgrading Aurora EVM to 2.9.0.
curl -sL $ENGINE_LAST_WASM_URL -o $ENGINE_WASM_PATH || error_exit
aurora-cli --engine $ENGINE_ACCOUNT stage-upgrade $ENGINE_WASM_PATH || error_exit
sleep 3
sleep 2
aurora-cli --engine $ENGINE_ACCOUNT deploy-upgrade || error_exit
sleep 1
version=$(aurora-cli --engine $ENGINE_ACCOUNT get-version || error_exit)
Expand Down
15 changes: 14 additions & 1 deletion src/client/near.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use crate::utils;

// The maximum amount of prepaid NEAR gas required for paying for a transaction.
const NEAR_GAS: u64 = 300_000_000_000_000;
const TIMEOUT: u64 = 20;

pub struct NearClient {
client: JsonRpcClient,
Expand All @@ -36,7 +37,19 @@ pub struct NearClient {

impl NearClient {
pub fn new<U: AsUrl>(url: U, engine_account_id: &str, signer_key_path: Option<String>) -> Self {
let client = JsonRpcClient::connect(url);
let mut headers = reqwest::header::HeaderMap::with_capacity(2);
headers.insert(
reqwest::header::CONTENT_TYPE,
reqwest::header::HeaderValue::from_static("application/json"),
);
let client = reqwest::Client::builder()
.timeout(std::time::Duration::from_secs(TIMEOUT))
.default_headers(headers)
.build()
.map(JsonRpcClient::with)
.expect("couldn't create json rpc client");
let client = client.connect(url);

Self {
client,
engine_account_id: engine_account_id.parse().unwrap(),
Expand Down

0 comments on commit 748ac93

Please sign in to comment.