From 8b20e1190d0c4cc13bec9af0c5b6529415b9a83f Mon Sep 17 00:00:00 2001 From: Anirudha Bose Date: Wed, 30 Oct 2024 13:03:16 +0530 Subject: [PATCH] review(supermassive): use base::NoDestructor --- .../browser/brave_wallet_constants.cc | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/components/brave_wallet/browser/brave_wallet_constants.cc b/components/brave_wallet/browser/brave_wallet_constants.cc index 27b90685f7a2..de46375488f9 100644 --- a/components/brave_wallet/browser/brave_wallet_constants.cc +++ b/components/brave_wallet/browser/brave_wallet_constants.cc @@ -104,22 +104,23 @@ const base::flat_map& GetAnkrBlockchains() { std::optional GetZeroExAllowanceHolderAddress( const std::string& chain_id) { // key = chain_id, value = allowance_holder_contract_address - static std::map 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> + 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; }