From 554e3c6e184f343009b14feeb40884723c882df7 Mon Sep 17 00:00:00 2001 From: Stephen Heaps Date: Mon, 5 Feb 2024 10:20:55 -0500 Subject: [PATCH] Expose BraveWalletP3A to iOS via BraveWalletAPI --- ios/browser/api/brave_wallet/brave_wallet_api.h | 3 +++ ios/browser/api/brave_wallet/brave_wallet_api.mm | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/ios/browser/api/brave_wallet/brave_wallet_api.h b/ios/browser/api/brave_wallet/brave_wallet_api.h index 06641cb23014..0d5d0546346e 100644 --- a/ios/browser/api/brave_wallet/brave_wallet_api.h +++ b/ios/browser/api/brave_wallet/brave_wallet_api.h @@ -12,6 +12,7 @@ @protocol BraveWalletEthereumProvider; @protocol BraveWalletProviderDelegate; @protocol BraveWalletSolanaProvider; +@protocol BraveWalletBraveWalletP3A; typedef NS_ENUM(NSInteger, BraveWalletCoinType); @@ -43,6 +44,8 @@ OBJC_EXPORT - (NSDictionary*) providerScriptsForCoinType:(BraveWalletCoinType)coinType; +- (nullable id)walletP3A; + - (instancetype)init NS_UNAVAILABLE; @end diff --git a/ios/browser/api/brave_wallet/brave_wallet_api.mm b/ios/browser/api/brave_wallet/brave_wallet_api.mm index 14dd8576b3a2..fabcdd13d67d 100644 --- a/ios/browser/api/brave_wallet/brave_wallet_api.mm +++ b/ios/browser/api/brave_wallet/brave_wallet_api.mm @@ -7,6 +7,8 @@ #include "base/strings/sys_string_conversions.h" #include "brave/components/brave_wallet/browser/blockchain_registry.h" +#include "brave/components/brave_wallet/browser/brave_wallet_p3a.h" +#include "brave/components/brave_wallet/browser/brave_wallet_service.h" #include "brave/components/brave_wallet/browser/ethereum_provider_impl.h" #include "brave/components/brave_wallet/browser/solana_provider_impl.h" #include "brave/components/brave_wallet/resources/grit/brave_wallet_script_generated.h" @@ -203,4 +205,14 @@ - (NSString*)resourceForID:(int)resource_id { return scripts; } +- (nullable id)walletP3A { + auto* service = brave_wallet::BraveWalletServiceFactory::GetServiceForState( + _mainBrowserState); + if (!service) { + return nil; + } + return [[BraveWalletBraveWalletP3AMojoImpl alloc] + initWithBraveWalletP3A:service->GetBraveWalletP3A()->MakeRemote()]; +} + @end