Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose BraveWalletP3A to iOS via BraveWalletAPI (uplift to 1.63.x) #21910

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading