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

[iOS] Bitcoin account creation #22737

Merged
merged 6 commits into from
Apr 2, 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
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ extension WalletStore {
let txService = BraveWallet.TxServiceFactory.get(privateMode: privateMode),
let ethTxManagerProxy = BraveWallet.EthTxManagerProxyFactory.get(privateMode: privateMode),
let solTxManagerProxy = BraveWallet.SolanaTxManagerProxyFactory.get(privateMode: privateMode),
let walletP3A
let walletP3A,
let bitcoinWalletService = BraveWallet.BitcoinWalletServiceFactory.get(
privateMode: privateMode
)
else {
Logger.module.error("Failed to load wallet. One or more services were unavailable")
return nil
Expand All @@ -46,7 +49,8 @@ extension WalletStore {
ethTxManagerProxy: ethTxManagerProxy,
solTxManagerProxy: solTxManagerProxy,
ipfsApi: ipfsApi,
walletP3A: walletP3A
walletP3A: walletP3A,
bitcoinWalletService: bitcoinWalletService
)
}
}
Expand All @@ -67,7 +71,10 @@ extension CryptoStore {
let txService = BraveWallet.TxServiceFactory.get(privateMode: privateMode),
let ethTxManagerProxy = BraveWallet.EthTxManagerProxyFactory.get(privateMode: privateMode),
let solTxManagerProxy = BraveWallet.SolanaTxManagerProxyFactory.get(privateMode: privateMode),
let walletP3A
let walletP3A,
let bitcoinWalletService = BraveWallet.BitcoinWalletServiceFactory.get(
privateMode: privateMode
)
else {
Logger.module.error("Failed to load wallet. One or more services were unavailable")
return nil
Expand All @@ -83,7 +90,8 @@ extension CryptoStore {
ethTxManagerProxy: ethTxManagerProxy,
solTxManagerProxy: solTxManagerProxy,
ipfsApi: ipfsApi,
walletP3A: walletP3A
walletP3A: walletP3A,
bitcoinWalletService: bitcoinWalletService
)
}
}
Expand Down Expand Up @@ -240,7 +248,7 @@ extension Tab: BraveWalletProviderDelegate {
completion(.internal, nil)
return
}
case .fil, .btc:
case .fil, .btc, .zec:
// not supported
fallthrough
@unknown default:
Expand Down Expand Up @@ -348,7 +356,7 @@ extension Tab: BraveWalletProviderDelegate {
return !Preferences.Wallet.allowEthProviderAccess.value
case .sol:
return !Preferences.Wallet.allowSolProviderAccess.value
case .fil, .btc:
case .fil, .btc, .zec:
return true
@unknown default:
return true
Expand Down
15 changes: 10 additions & 5 deletions ios/brave-ios/Sources/BraveWallet/AddressView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@ struct AddressView<Content: View>: View {
var body: some View {
content()
.contextMenu {
Text(address.zwspOutput)
Button {
UIPasteboard.general.string = address
} label: {
Label(Strings.Wallet.copyAddressButtonTitle, braveSystemImage: "leo.copy.plain-text")
if !address.isEmpty {
Text(address.zwspOutput)
Button {
UIPasteboard.general.string = address
} label: {
Label(
Strings.Wallet.copyAddressButtonTitle,
braveSystemImage: "leo.copy.plain-text"
)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "btc-asset-icon 1@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private struct AccountListRowView: View {
AddressView(address: account.address) {
Button(action: didSelect) {
HStack {
AccountView(address: account.address, name: account.name)
AccountView(account: account)
checkmark
}
.contentShape(Rectangle())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,52 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

import BraveCore
import SwiftUI

/// Displays basic info around a single account
struct AccountView: View {
/// The full address, which will be truncated in the middle
var address: String
/// The seed to generate Blockie
var seed: String
/// The account name describing what the account is for
var name: String

init(account: BraveWallet.AccountInfo) {
self.address = account.address
self.seed = account.blockieSeed
self.name = account.name
}

init(
address: String,
seed: String,
name: String
) {
self.address = address
self.seed = seed
self.name = name
}

@ScaledMetric private var avatarSize = 40.0
private let maxAvatarSize: CGFloat = 80.0

var body: some View {
HStack {
Group {
Blockie(address: address)
Blockie(address: seed)
.frame(width: min(avatarSize, maxAvatarSize), height: min(avatarSize, maxAvatarSize))
}
VStack(alignment: .leading, spacing: 2) {
Text(name)
.font(.subheadline.weight(.semibold))
.foregroundColor(Color(.bravePrimary))
Text(address.truncatedAddress)
.font(.footnote)
.foregroundColor(Color(.braveLabel))
if !address.isEmpty {
Text(address.truncatedAddress)
.font(.footnote)
.foregroundColor(Color(.braveLabel))
}
}
.font(.caption)
Spacer()
Expand All @@ -43,6 +64,7 @@ struct AccountView_Previews: PreviewProvider {
static var previews: some View {
AccountView(
address: "0x0d8775f648430679a709e98d2b0cb6250d2887ef",
seed: "0x0d8775f648430679a709e98d2b0cb6250d2887ef",
name: "Account 1"
)
.previewLayout(.sizeThatFits)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ private struct AccountCardView: View {
private func topSectionContent(hidingButtons: Bool = true) -> some View {
HStack {
HStack(spacing: 8) {
Blockie(address: account.address)
Blockie(address: account.blockieSeed)
.frame(width: min(avatarSize, maxAvatarSize), height: min(avatarSize, maxAvatarSize))
VStack(alignment: .leading) {
AddressView(address: account.address) {
Expand All @@ -222,8 +222,10 @@ private struct AccountCardView: View {
Text(account.name)
.font(.headline.weight(.semibold))
.foregroundColor(Color(braveSystemName: .textPrimary))
Text(account.address.truncatedAddress)
.font(.footnote)
if !account.address.isEmpty {
Text(account.address.truncatedAddress)
.font(.footnote)
}
}
}
Text(account.accountSupportDisplayString)
Expand Down Expand Up @@ -268,10 +270,12 @@ private struct AccountCardView: View {
Label(Strings.Wallet.editButtonTitle, braveSystemImage: "leo.edit.pencil")
}
Divider()
Button {
action(.exportAccount)
} label: {
Label(Strings.Wallet.exportButtonTitle, braveSystemImage: "leo.key")
if account.coin != .btc {
Button {
action(.exportAccount)
} label: {
Label(Strings.Wallet.exportButtonTitle, braveSystemImage: "leo.key")
}
}
Button {
action(.depositToAccount)
Expand Down Expand Up @@ -347,7 +351,7 @@ private struct AccountCardView: View {
}

private var cardBackground: some View {
BlockieMaterial(address: account.address)
BlockieMaterial(address: account.blockieSeed)
.blur(radius: 25, opaque: true)
.opacity(0.3)
.clipShape(RoundedRectangle(cornerRadius: 8))
Expand Down
StephenHeaps marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ struct AccountActivityView: View {
} label: {
Label(Strings.Wallet.editButtonTitle, braveSystemImage: "leo.edit.pencil")
}
Button {
isPresentingExportAccount = true
} label: {
Label(Strings.Wallet.exportButtonTitle, braveSystemImage: "leo.key")
if store.account.coin != .btc {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe .zec here also?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I think now that handling also .zec is not what we need

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, you are right.

Button {
isPresentingExportAccount = true
} label: {
Label(Strings.Wallet.exportButtonTitle, braveSystemImage: "leo.key")
}
}
},
label: {
Expand Down Expand Up @@ -105,16 +107,18 @@ struct AccountActivityView: View {
private var headerSection: some View {
VStack(spacing: 0) {
VStack(spacing: 8) {
Blockie(address: store.account.address)
Blockie(address: store.account.blockieSeed)
.frame(width: 44, height: 44)
.clipShape(RoundedRectangle(cornerRadius: 4))
.accessibilityHidden(true)
VStack(spacing: 0) {
Text(store.account.name)
.font(.title2.weight(.semibold))
AddressView(address: store.account.address) {
Text(store.account.address.truncatedAddress)
.font(.caption)
if !store.account.address.isEmpty {
AddressView(address: store.account.address) {
Text(store.account.address.truncatedAddress)
.font(.caption)
}
}
}
}
Expand Down Expand Up @@ -186,7 +190,7 @@ struct AccountActivityView: View {
)
}
)
if store.account.coin != .fil {
if store.account.coin != .fil && store.account.coin != .btc {
Divider()
NavigationLink(
destination: {
Expand Down
Loading
Loading