Skip to content

Commit

Permalink
Expose BraveWalletP3A to iOS via BraveWalletAPI (uplift to 1.63.x) (#…
Browse files Browse the repository at this point in the history
…21910)

Uplift of #21903 (squashed) to beta

Co-authored-by: brave-builds <[email protected]>
  • Loading branch information
brave-builds and brave-builds authored Feb 6, 2024
1 parent 73dc726 commit a78382e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ios/browser/api/brave_wallet/brave_wallet_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
@protocol BraveWalletEthereumProvider;
@protocol BraveWalletProviderDelegate;
@protocol BraveWalletSolanaProvider;
@protocol BraveWalletBraveWalletP3A;

typedef NS_ENUM(NSInteger, BraveWalletCoinType);

Expand Down Expand Up @@ -43,6 +44,8 @@ OBJC_EXPORT
- (NSDictionary<BraveWalletProviderScriptKey, NSString*>*)
providerScriptsForCoinType:(BraveWalletCoinType)coinType;

- (nullable id<BraveWalletBraveWalletP3A>)walletP3A;

- (instancetype)init NS_UNAVAILABLE;

@end
Expand Down
12 changes: 12 additions & 0 deletions ios/browser/api/brave_wallet/brave_wallet_api.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -203,4 +205,14 @@ - (NSString*)resourceForID:(int)resource_id {
return scripts;
}

- (nullable id<BraveWalletBraveWalletP3A>)walletP3A {
auto* service = brave_wallet::BraveWalletServiceFactory::GetServiceForState(
_mainBrowserState);
if (!service) {
return nil;
}
return [[BraveWalletBraveWalletP3AMojoImpl alloc]
initWithBraveWalletP3A:service->GetBraveWalletP3A()->MakeRemote()];
}

@end

0 comments on commit a78382e

Please sign in to comment.