Skip to content

Commit

Permalink
review(supermassive): separate function for 0x headers
Browse files Browse the repository at this point in the history
  • Loading branch information
onyb committed Oct 30, 2024
1 parent a6df80c commit 21ac0e1
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions components/brave_wallet/browser/swap_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,13 @@ GURL AppendJupiterQuoteParams(const GURL& swap_url,
return url;
}

base::flat_map<std::string, std::string> GetHeaders(bool is_zero_ex = false) {
base::flat_map<std::string, std::string> headers = {
{kBraveServicesKeyHeader, BUILDFLAG(BRAVE_SERVICES_KEY)}};
if (is_zero_ex) {
headers[kZeroExAPIVersionHeader] = kZeroExAPIVersion;
}
base::flat_map<std::string, std::string> GetHeaders() {
return {{kBraveServicesKeyHeader, BUILDFLAG(BRAVE_SERVICES_KEY)}};
}

base::flat_map<std::string, std::string> GetHeadersForZeroEx() {
auto headers = GetHeaders();
headers[kZeroExAPIVersionHeader] = kZeroExAPIVersion;
return headers;
}

Expand Down Expand Up @@ -381,8 +382,9 @@ void SwapService::GetQuote(mojom::SwapQuoteParamsPtr params,

api_request_helper_.Request(net::HttpRequestHeaders::kGetMethod,
GetZeroExQuoteURL(*params, fee_param), "", "",
std::move(internal_callback), GetHeaders(true),
{}, std::move(conversion_callback));
std::move(internal_callback),
GetHeadersForZeroEx(), {},
std::move(conversion_callback));

return;
}
Expand Down Expand Up @@ -556,7 +558,7 @@ void SwapService::GetTransaction(mojom::SwapTransactionParamsUnionPtr params,
net::HttpRequestHeaders::kGetMethod,
GetZeroExTransactionURL(*params->get_zero_ex_transaction_params(),
swap_fee->fee_param),
"", "", std::move(internal_callback), GetHeaders(true), {},
"", "", std::move(internal_callback), GetHeadersForZeroEx(), {},
std::move(conversion_callback));

return;
Expand Down

0 comments on commit 21ac0e1

Please sign in to comment.