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

MOB-2090 - Fixing WC requests pull ups UI #592

Merged
merged 3 commits into from
Jun 28, 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 @@ -13,17 +13,17 @@ final class CoinRecordsService: CoinRecordsServiceProtocol {
[.init(ticker: "ETH",
version: nil,
expandedTicker: "crypto.ETH",
regexPattern: CoinRegexPattern.eth.regex,
regexPattern: CoinRegexPattern.ETH.regex,
isDeprecated: false),
.init(ticker: "MATIC",
version: nil,
expandedTicker: "crypto.MATIC",
regexPattern: CoinRegexPattern.eth.regex,
regexPattern: CoinRegexPattern.ETH.regex,
isDeprecated: false),
.init(ticker: "BTC",
version: nil,
expandedTicker: "crypto.BTC.address",
regexPattern: CoinRegexPattern.btc.regex,
regexPattern: CoinRegexPattern.BTC.regex,
isDeprecated: false)]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ final class UDWalletsService: UDWalletsServiceProtocol {

func createMPCWallet(ethAddress: HexAddress,
mpcMetadata: MPCWalletMetadata) throws -> UDWallet {
UDWallet.createMPC(address: ethAddress, mpcMetadata: mpcMetadata)
UDWallet.createMPC(address: ethAddress, aliasName: "Lite Wallet", mpcMetadata: mpcMetadata)
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ extension FB_UD_MPC {
return .init(accessToken: "", deviceId: "")
}

func startMessageSigning(accessToken: String, accountId: String, assetId: String, message: String, encoding: FB_UD_MPC.SignMessageEncoding) async throws -> FB_UD_MPC.OperationDetails {
func startMessageSigning(accessToken: String, accountId: String, assetId: String, message: String, signingType: FB_UD_MPC.MessageSigningType) async throws -> FB_UD_MPC.OperationDetails {
await Task.sleep(seconds: 0.5)
return .init(id: "", status: "", type: "")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ struct UDWallet: Codable, Hashable {
}

static func createMPC(address: String,
aliasName: String,
mpcMetadata: MPCWalletMetadata) -> UDWallet {
.init(address: address,
.init(aliasName: aliasName,
address: address,
type: .mpc,
mpcMetadata: mpcMetadata)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ import SwiftUI
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
Task {
let connectConfiguration = createConnectConfiguration()
let signConfiguration = createSignConfiguration()
let personalSignConfiguration = createSignConfiguration()
let signTypedDataConfiguration = createSignTypedDataConfiguration()
let paymentConfiguration = createPaymentConfiguration()
_ = try? await appContext.pullUpViewService.showWCRequestConfirmationPullUp(for: connectConfiguration,
_ = try? await appContext.pullUpViewService.showWCRequestConfirmationPullUp(for: signTypedDataConfiguration,
in: vc)
}
}
Expand All @@ -44,6 +45,34 @@ private func createSignMessageTransactionUIConfiguration() -> SignMessageTransac
.init(connectionConfig: createWalletConnectConfig(), signingMessage: "lakjsdasdjalsdjaslkdjalsdkj ald")
}

private func createSignTypedDataConfiguration() -> WCRequestUIConfiguration {
.signMessage(createSignTypedDataTxUIConfiguration())
}

private func createSignTypedDataTxUIConfiguration() -> SignMessageTransactionUIConfiguration {
let mes = """
{
"domain": {
"name": "Seaport",
"version": "1.6",
"chainId": "80002",
"verifyingContract": "0x0000000000000068f116a894984e2db1123eb395"
},
"primaryType": "OrderComponents",
"message": {
"orderType": "2",
"startTime": "1719566337",
"endTime": "1751102337",
"zoneHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"salt": "17103359048027891009",
"conduitKey": "0x0000000000000000000000000000000000000000000000000000000000000000",
"counter": "0"
}
}
"""
return .init(connectionConfig: createWalletConnectConfig(), signingMessage: mes)
}

private func createPaymentConfiguration() -> WCRequestUIConfiguration {
.payment(createSignPaymentTransactionUIConfiguration())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class BaseSignTransactionView: UIView, SelfNameable, NibInstantiateable {

let walletInfoStack = UIStackView(arrangedSubviews: [walletImageView, walletNameButton])
walletInfoStack.axis = .horizontal
walletInfoStack.spacing = -2
walletInfoStack.spacing = 8
walletInfoStack.alignment = .center

let walletLabel = UILabel()
Expand Down Expand Up @@ -149,7 +149,7 @@ extension BaseSignTransactionView {
walletImageView.isHidden = wallet.rrDomain == nil
}
}
walletNameButton?.setTitle(wallet.domainOrDisplayName, image: isSelectable ? .chevronDown : nil)
walletNameButton?.setTitle(wallet.domainOrDisplayName, image: nil)
walletNameButton?.setSelectorEnabled(isSelectable)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ final class ConnectServerRequestConfirmationView: BaseSignTransactionView {

private var networkSelectorButton: SelectorButton?
private var networkIndicator: UIImageView?
private var walletInfoStackView: UIStackView?
private var networkFullStackView: UIStackView?
private var bottomStackView: UIStackView?
private var supportedChains: [BlockchainType] = []
private var cancellables: Set<AnyCancellable> = []

Expand All @@ -40,9 +37,6 @@ extension ConnectServerRequestConfirmationView {
setNetworkFrom(appInfo: connectionConfig.appInfo)
setWith(appInfo: connectionConfig.appInfo)
setWithWallet(connectionConfig.wallet)
networkFullStackView?.isHidden = true
bottomStackView?.axis = .vertical
walletInfoStackView?.axis = .horizontal

let blockchainType = getChainFromAppInfo(connectionConfig.appInfo)
set(selectedChain: blockchainType)
Expand All @@ -57,55 +51,15 @@ private extension ConnectServerRequestConfirmationView {

func addWalletInfo() {
let walletStack = buildWalletInfoView()
walletStack.axis = .vertical
walletStack.alignment = .leading
walletStack.spacing = 6
self.walletInfoStackView = walletStack

let networkTitleLabel = UILabel()
networkTitleLabel.translatesAutoresizingMaskIntoConstraints = false
networkTitleLabel.setAttributedTextWith(text: String.Constants.network.localized(),
font: .currentFont(withSize: 14, weight: .medium),
textColor: .foregroundSecondary,
alignment: .right,
lineHeight: 20)

let networkSelectorButton = createNetworkSelectorButton()
self.networkSelectorButton = networkSelectorButton

let networkIndicator = createNetworkIndicator()
self.networkIndicator = networkIndicator

let networkIndicatorStack = UIStackView(arrangedSubviews: [networkIndicator, networkSelectorButton])
networkIndicatorStack.axis = .horizontal
networkIndicatorStack.alignment = .center
networkIndicatorStack.spacing = 8

let networkFullStack = UIStackView(arrangedSubviews: [networkTitleLabel, networkIndicatorStack])
networkFullStack.axis = .vertical
networkFullStack.alignment = .trailing
networkFullStack.spacing = 6
self.networkFullStackView = networkFullStack

let bottomStack = UIStackView(arrangedSubviews: [walletStack, networkFullStack])
bottomStack.spacing = 16
bottomStack.axis = .horizontal
walletStack.axis = .horizontal

let bottomStack = UIStackView(arrangedSubviews: [walletStack])
bottomStack.axis = .vertical
bottomStack.alignment = .center
bottomStack.distribution = .fillEqually
self.bottomStackView = bottomStack

contentStackView.addArrangedSubview(bottomStack)
}

func createNetworkSelectorButton() -> SelectorButton {
let networkSelectorButton = SelectorButton()
networkSelectorButton.customTitleEdgePadding = 0
networkSelectorButton.translatesAutoresizingMaskIntoConstraints = false
networkSelectorButton.heightAnchor.constraint(equalToConstant: 22).isActive = true

return networkSelectorButton
}

func set(selectedChain: BlockchainType) {
guard let networkSelectorButton = self.networkSelectorButton else { return }

Expand Down Expand Up @@ -137,16 +91,6 @@ private extension ConnectServerRequestConfirmationView {
networkIndicator?.image = UIImage.getNetworkLargeIcon(by: selectedChain)
}

func createNetworkIndicator() -> UIImageView {
let indicator = UIImageView()
indicator.translatesAutoresizingMaskIntoConstraints = false
indicator.tintColor = .foregroundWarning
indicator.heightAnchor.constraint(equalToConstant: 20).isActive = true
indicator.widthAnchor.constraint(equalTo: indicator.heightAnchor, multiplier: 1).isActive = true

return indicator
}

func didSelectBlockchainType(_ blockchainType: BlockchainType) {
logAnalytic(event: .didSelectChainNetwork,
parameters: [.chainNetwork: blockchainType.rawValue])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ private extension SignMessageRequestConfirmationView {
func addWalletInfo() {
let walletStackView = buildWalletInfoView()
walletStackView.axis = .horizontal
walletStackView.spacing = 16

let wrapStack = UIStackView(arrangedSubviews: [walletStackView])
wrapStack.axis = .vertical
Expand All @@ -57,7 +56,9 @@ private extension SignMessageRequestConfirmationView {
enum DisplayedMessageType {
static let lineHeight: CGFloat = 24
static let padding: CGFloat = 16
static let maxTextViewHeight: CGFloat = 176
static let maxTextViewHeight: CGFloat = {
deviceSize.isIPSE ? 220 : 320
}()
static let font: UIFont = .currentFont(withSize: 16, weight: .regular)

case simpleMessage(String)
Expand Down Expand Up @@ -96,7 +97,7 @@ enum DisplayedMessageType {
}

private func getTypedDataViewHeight() -> CGFloat {
return 300
return Self.maxTextViewHeight
}

private func prepareSimpleMessageView(signingMessage: String) -> UIView {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private extension PaymentTransactionRequestConfirmationView {
let walletStack = buildWalletInfoView()
walletStack.axis = .vertical
walletStack.alignment = .leading
walletStack.spacing = 6
walletStack.spacing = 16

let balanceLabel = UILabel()
balanceLabel.translatesAutoresizingMaskIntoConstraints = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ final class SelectorButton: BaseButton {
override func additionalSetup() {
titleLeftPadding = 0
titleRightPadding = 0
customImageEdgePadding = 0
}

}
Expand Down