Skip to content

Commit

Permalink
review(supermassive): use base::NoDestructor
Browse files Browse the repository at this point in the history
  • Loading branch information
onyb committed Oct 30, 2024
1 parent dcf4616 commit 8b20e11
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions components/brave_wallet/browser/brave_wallet_constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,23 @@ const base::flat_map<std::string, std::string>& GetAnkrBlockchains() {
std::optional<std::string> GetZeroExAllowanceHolderAddress(
const std::string& chain_id) {
// key = chain_id, value = allowance_holder_contract_address
static std::map<std::string, std::string> allowance_holder_addresses = {
{mojom::kMainnetChainId, kZeroExAllowanceHolderCancun},
{mojom::kArbitrumMainnetChainId, kZeroExAllowanceHolderCancun},
{mojom::kAvalancheMainnetChainId, kZeroExAllowanceHolderShanghai},
{mojom::kBaseMainnetChainId, kZeroExAllowanceHolderCancun},
{mojom::kBlastMainnetChainId, kZeroExAllowanceHolderCancun},
{mojom::kBnbSmartChainMainnetChainId, kZeroExAllowanceHolderCancun},
{mojom::kLineaChainId, kZeroExAllowanceHolderLondon},
{mojom::kOptimismMainnetChainId, kZeroExAllowanceHolderCancun},
{mojom::kPolygonMainnetChainId, kZeroExAllowanceHolderCancun},
{mojom::kScrollChainId, kZeroExAllowanceHolderShanghai}};
static base::NoDestructor<std::map<std::string, std::string>>
allowance_holder_addresses(
{{mojom::kMainnetChainId, kZeroExAllowanceHolderCancun},
{mojom::kArbitrumMainnetChainId, kZeroExAllowanceHolderCancun},
{mojom::kAvalancheMainnetChainId, kZeroExAllowanceHolderShanghai},
{mojom::kBaseMainnetChainId, kZeroExAllowanceHolderCancun},
{mojom::kBlastMainnetChainId, kZeroExAllowanceHolderCancun},
{mojom::kBnbSmartChainMainnetChainId, kZeroExAllowanceHolderCancun},
{mojom::kLineaChainId, kZeroExAllowanceHolderLondon},
{mojom::kOptimismMainnetChainId, kZeroExAllowanceHolderCancun},
{mojom::kPolygonMainnetChainId, kZeroExAllowanceHolderCancun},
{mojom::kScrollChainId, kZeroExAllowanceHolderShanghai}});

auto allowance_holder_address_pair =
allowance_holder_addresses.find(chain_id.c_str());
allowance_holder_addresses->find(chain_id.c_str());

if (allowance_holder_address_pair == allowance_holder_addresses.end()) {
if (allowance_holder_address_pair == allowance_holder_addresses->end()) {
// not found
return std::nullopt;
}
Expand Down

0 comments on commit 8b20e11

Please sign in to comment.