Skip to content
This repository has been archived by the owner on Aug 28, 2023. It is now read-only.

Commit

Permalink
Merge pull request #835 from gnosis/backmerge-3.19.1
Browse files Browse the repository at this point in the history
Backmerge release 3.19.1
  • Loading branch information
fmrsabino authored Mar 21, 2022
2 parents 541dd3f + 43ddd2e commit c3396ab
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "safe-client-gateway"
version = "3.19.0"
version = "3.19.1"
authors = ["jpalvarezl <[email protected]>", "rmeissner <[email protected]>", "fmrsabino <[email protected]>"]
edition = "2018"

Expand Down
12 changes: 4 additions & 8 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@ pub fn webhook_token() -> String {
env::var("WEBHOOK_TOKEN").expect("WEBHOOK_TOKEN missing in env")
}

pub fn transaction_service_auth_token() -> String {
let token = env::var("TRANSACTION_SERVICE_AUTH_TOKEN").unwrap_or_else(|_| {
log::warn!("TRANSACTION_SERVICE_AUTH_TOKEN missing in env");
String::new()
});
format!("Token {}", token)
}

pub fn scheme() -> String {
env_with_default("SCHEME", "https".into())
}
Expand Down Expand Up @@ -169,6 +161,10 @@ pub fn redis_scan_count() -> usize {
env_with_default("REDIS_SCAN_COUNT", 300)
}

pub fn token_cache_size_count() -> usize {
env_with_default("TOKEN_CACHE_SIZE_COUNT", 20000)
}

pub fn feature_flag_nested_decoding() -> bool {
env_with_default("FEATURE_FLAG_NESTED_DECODING", true)
}
Expand Down
5 changes: 5 additions & 0 deletions src/config/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ fn build_usize_test_cases() -> Vec<USizeEnvValue> {
env_key: String::from("TX_QUEUED_CACHE_DURATION"),
generator: Box::new(super::tx_queued_cache_duration),
},
USizeEnvValue {
expected_default: super::token_cache_size_count(),
env_key: String::from("TOKEN_CACHE_SIZE_COUNT"),
generator: Box::new(super::token_cache_size_count),
},
]
}

Expand Down
5 changes: 3 additions & 2 deletions src/providers/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::config::{
contract_info_request_timeout, default_request_timeout, long_error_duration,
request_cache_duration, safe_app_info_request_timeout, safe_app_manifest_cache_duration,
safe_info_cache_duration, safe_info_request_timeout, short_error_duration,
token_info_cache_duration, token_info_request_timeout,
token_cache_size_count, token_info_cache_duration, token_info_request_timeout,
};
use crate::providers::address_info::ContractInfo;
use crate::utils::context::RequestContext;
Expand Down Expand Up @@ -260,7 +260,8 @@ impl DefaultInfoProvider<'_> {
}

async fn populate_token_cache(&self) -> ApiResult<()> {
let url = core_uri!(self, "/v1/tokens/?limit=10000")?;
let token_cache_size_count = token_cache_size_count();
let url = core_uri!(self, "/v1/tokens/?limit={}", token_cache_size_count)?;
let request = {
let mut request = Request::new(url);
request.timeout(Duration::from_millis(token_info_request_timeout()));
Expand Down
6 changes: 3 additions & 3 deletions src/providers/tests/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ async fn default_info_provider_token_info() {
});

let mut token_request = Request::new(String::from(
"https://safe-transaction.rinkeby.staging.gnosisdev.com/api/v1/tokens/?limit=10000",
"https://safe-transaction.rinkeby.staging.gnosisdev.com/api/v1/tokens/?limit=20000",
));
token_request.timeout(Duration::from_millis(token_info_request_timeout()));
let page_tokens: Page<TokenInfo> = Page {
Expand Down Expand Up @@ -281,7 +281,7 @@ async fn default_info_provider_token_info_request_failure() {
});

let mut token_request = Request::new(String::from(
"https://safe-transaction.rinkeby.staging.gnosisdev.com/api/v1/tokens/?limit=10000",
"https://safe-transaction.rinkeby.staging.gnosisdev.com/api/v1/tokens/?limit=20000",
));
token_request.timeout(Duration::from_millis(token_info_request_timeout()));

Expand Down Expand Up @@ -334,7 +334,7 @@ async fn default_info_provider_token_info_not_found_in_cache() {
});

let mut token_request = Request::new(String::from(
"https://safe-transaction.rinkeby.staging.gnosisdev.com/api/v1/tokens/?limit=10000",
"https://safe-transaction.rinkeby.staging.gnosisdev.com/api/v1/tokens/?limit=20000",
));
token_request.timeout(Duration::from_millis(token_info_request_timeout()));
let page_tokens: Page<TokenInfo> = Page {
Expand Down
5 changes: 1 addition & 4 deletions src/routes/safes/handlers/safes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ use crate::cache::cache_operations::RequestCached;
use crate::common::models::backend::transactions::{MultisigTransaction, Transaction};
use crate::common::models::backend::transfers::Transfer;
use crate::common::models::page::{Page, SafeList};
use crate::config::{
owners_for_safes_cache_duration, transaction_request_timeout, transaction_service_auth_token,
};
use crate::config::{owners_for_safes_cache_duration, transaction_request_timeout};
use crate::providers::info::{DefaultInfoProvider, InfoProvider};
use crate::routes::safes::models::{SafeLastChanges, SafeState};
use crate::utils::context::RequestContext;
Expand Down Expand Up @@ -153,7 +151,6 @@ pub async fn get_owners_for_safe(
let url = core_uri!(info_provider, "/v1/owners/{}/safes/", owner_address)?;
let body = RequestCached::new_from_context(url, context)
.cache_duration(owners_for_safes_cache_duration())
.add_header(("Authorization", &transaction_service_auth_token()))
.execute()
.await?;

Expand Down
6 changes: 0 additions & 6 deletions src/routes/safes/tests/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,6 @@ async fn get_owners() {
"https://safe-transaction.rinkeby.staging.gnosisdev.com/api/v1/owners/{}/safes/",
&safe_address
));
let auth_token = "some_other_random_token";
env::set_var("TRANSACTION_SERVICE_AUTH_TOKEN", &auth_token);
safe_request.add_header(("Authorization", &format!("Token {}", &auth_token)));
mock_http_client
.expect_get()
.times(1)
Expand Down Expand Up @@ -325,9 +322,6 @@ async fn get_owners_not_found() {
"https://safe-transaction.rinkeby.staging.gnosisdev.com/api/v1/owners/{}/safes/",
&safe_address
));
let auth_token = "some_other_random_token";
env::set_var("TRANSACTION_SERVICE_AUTH_TOKEN", &auth_token);
safe_request.add_header(("Authorization", &format!("Token {}", &auth_token)));
mock_http_client
.expect_get()
.times(1)
Expand Down
2 changes: 1 addition & 1 deletion src/routes/transactions/tests/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async fn post_confirmation_success() {

// Transfer TokenInfo
let mut token_request = Request::new(String::from(
"https://safe-transaction.rinkeby.staging.gnosisdev.com/api/v1/tokens/?limit=10000",
"https://safe-transaction.rinkeby.staging.gnosisdev.com/api/v1/tokens/?limit=20000",
));
token_request.timeout(Duration::from_millis(token_info_request_timeout()));
let page_tokens: Page<TokenInfo> = Page {
Expand Down

0 comments on commit c3396ab

Please sign in to comment.