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-2092 - Fixed copies and domain resolution #597

Merged
merged 3 commits into from
Jul 4, 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 @@ -253,6 +253,10 @@ extension NetworkService: DomainProfileNetworkServiceProtocol {
func getTrendingDomains() async throws -> SerializedRankingDomainsResponse {
MockEntitiesFabric.Explore.createTrendingProfiles()
}

func fetchReverseResolution(for address: HexAddress) async throws -> DomainName? {
"oleg.x"
}
}

// MARK: - WalletTransactionsNetworkServiceProtocol
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ struct DomainProfileDisplayInfo: Hashable {
}
}

var pfpInfo: DomainPFPInfo {
DomainPFPInfo(domainName: domainName,
pfpURL: pfpURL?.absoluteString,
imageType: imageType)
}

}

extension DomainProfileDisplayInfo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ extension SemiSupportedBlockchainType {
.bitcoinIcon
case .Solana:
.solanaIcon
case .Base:
.baseIcon
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,16 @@ enum BlockchainType: String, CaseIterable, Codable, Hashable {
enum SemiSupportedBlockchainType: String, CaseIterable, Codable, Hashable {
case Bitcoin = "BTC"
case Solana = "SOL"
case Base = "BASE"

var fullName: String {
switch self {
case .Bitcoin:
return "Bitcoin"
case .Solana:
return "Solana"
case .Base:
return "Base"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ extension String {
static let viewInBrowser = "VIEW_IN_BROWSER"
static let tokens = "TOKENS"
static let collectibles = "COLLECTIBLES"
static let collectible = "COLLECTIBLE"
static let receive = "RECEIVE"
static let profile = "PROFILE"
static let more = "MORE"
Expand Down Expand Up @@ -1196,6 +1197,7 @@ extension String {
static let noRecordsToSendCryptoPullUpTitle = "NO_RECORDS_TO_SEND_CRYPTO_PULL_UP_TITLE"
static let noRecordsToSendCryptoMessage = "NO_RECORDS_TO_SEND_CRYPTO_MESSAGE"
static let sentSuccessfully = "SENT_SUCCESSFULLY"
static let receivedSuccessfully = "RECEIVED_SUCCESSFULLY"

// Import MPC
static let importMPCWalletTitle = "IMPORT_MPC_WALLET_TITLE"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ extension UIImage {
static let warningIcon = UIImage(named: "warningIcon")!
static let ethereumIcon = UIImage(named: "ethereumIcon")!
static let polygonIcon = UIImage(named: "polygonIcon")!
static let baseIcon = UIImage(named: "baseIcon")!
static let externalWalletIndicator = UIImage(named: "externalWalletIndicator")!
static let cloudIcon = UIImage(named: "cloudIcon")!
static let checkCircleWhite = UIImage(named: "checkCircleWhite")!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,7 @@ private extension WalletTransactionDisplayInfoListItemView {
if transaction.isDomainNFT {
nftTxValueViewWith(name: String.Constants.domain.localized())
} else {
nftTxValueViewWith(name: "NFT")

nftTxValueViewWith(name: String.Constants.collectible.localized())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ extension DomainProfilesService: DomainProfilesServiceProtocol {
try? storage.retrieveProfileFor(domainName: domainName)
}

func fetchResolvedDomainProfileDisplayInfo(for walletAddress: HexAddress) async throws -> DomainProfileDisplayInfo {
let domainName = try await networkService.fetchReverseResolution(for: walletAddress)
guard let domainName else {
throw DomainProfilesServiceError.noDomainForWalletAddress
}
return try await fetchDomainProfileDisplayInfo(for: domainName)
}

func fetchDomainProfileDisplayInfo(for domainName: DomainName) async throws -> DomainProfileDisplayInfo {
let serializedProfile = try await getSerializedPublicDomainProfile(for: domainName)
let profile = DomainProfileDisplayInfo(serializedProfile: serializedProfile)
Expand Down Expand Up @@ -259,6 +267,7 @@ private extension DomainProfilesService {
extension DomainProfilesService {
enum DomainProfilesServiceError: String, LocalizedError {
case noDomainForSocialDetails
case noDomainForWalletAddress

public var errorDescription: String? {
return rawValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ protocol DomainProfilesServiceProtocol {

func getCachedDomainProfileDisplayInfo(for domainName: String) -> DomainProfileDisplayInfo?
func fetchDomainProfileDisplayInfo(for domainName: DomainName) async throws -> DomainProfileDisplayInfo
func fetchResolvedDomainProfileDisplayInfo(for walletAddress: HexAddress) async throws -> DomainProfileDisplayInfo
func getCachedAndRefreshDomainProfileStream(for domainName: DomainName) -> AsyncThrowingStream<DomainProfileDisplayInfo, Error>
@discardableResult
func updateUserDomainProfile(for domain: DomainDisplayInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ protocol DomainProfileNetworkServiceProtocol {

func getProfileSuggestions(for domainName: DomainName) async throws -> SerializedDomainProfileSuggestionsResponse
func getTrendingDomains() async throws -> SerializedRankingDomainsResponse
func fetchReverseResolution(for address: HexAddress) async throws -> DomainName?
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "baseIcon.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "original"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "solanaIcon.pdf",
"filename" : "solanaIcon.svg",
"idiom" : "universal"
}
],
Expand Down
Binary file not shown.
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 @@ -160,6 +160,7 @@
"VIEW_IN_BROWSER" = "View in browser";
"TOKENS" = "Tokens";
"COLLECTIBLES" = "Collectibles";
"COLLECTIBLE" = "Collectible";
"RECEIVE" = "Receive";
"PROFILE" = "Profile";
"MORE" = "More";
Expand Down Expand Up @@ -1091,6 +1092,7 @@ More tabs are coming in the next updates.";
"NO_RECORDS_TO_SEND_CRYPTO_PULL_UP_TITLE" = "%@ hasn't added an address for the crypto you wish to send";
"NO_RECORDS_TO_SEND_CRYPTO_MESSAGE" = "To prevent loss of funds we restrict sending of crypto if an address hasn't been added to the domain by it's owner. Kindly inform the domain owner so you can send them funds.";
"SENT_SUCCESSFULLY" = "Sent successfully";
"RECEIVED_SUCCESSFULLY" = "Received successfully";

// Import MPC
"IMPORT_MPC_WALLET_TITLE" = "Import %@";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private extension TransactionDetailsPullUpView {
@ViewBuilder
func titleViews() -> some View {
VStack(spacing: 8) {
Text(String.Constants.sentSuccessfully.localized())
Text(title)
.textAttributes(color: .foregroundDefault, fontSize: 22, fontWeight: .bold)
HStack {
Text(tx.time, style: .date)
Expand All @@ -70,6 +70,15 @@ private extension TransactionDetailsPullUpView {
}
}

var title: String {
switch tx.type {
case .tokenDeposit, .nftDeposit:
String.Constants.receivedSuccessfully.localized()
case .tokenWithdrawal, .nftWithdrawal:
String.Constants.sentSuccessfully.localized()
}
}

@ViewBuilder
func txVisualisationsView() -> some View {
ZStack {
Expand Down Expand Up @@ -185,7 +194,7 @@ private extension TransactionDetailsPullUpView {
if tx.isDomainNFT {
String.Constants.domain.localized()
} else {
"NFT"
String.Constants.collectible.localized()
}
}
}
Expand Down Expand Up @@ -216,9 +225,11 @@ private extension TransactionDetailsPullUpView {
struct TxReceiverVisualisationView: View {

@Environment(\.imageLoadingService) var imageLoadingService
@Environment(\.domainProfilesService) var domainProfilesService

let tx: WalletTransactionDisplayInfo
@State private var icon: UIImage?
@State private var profile: DomainProfileDisplayInfo?

var body: some View {
BaseVisualisationView(title: title,
Expand Down Expand Up @@ -246,7 +257,7 @@ private extension TransactionDetailsPullUpView {

var subtitle: String {
if receiverDomainName == nil {
return "Recepient"
return String.Constants.recipient.localized()
}
return tx.to.address.walletAddressTruncated
}
Expand All @@ -268,24 +279,23 @@ private extension TransactionDetailsPullUpView {
}

private var receiverDomainName: String? {
if let domainName = tx.to.domainName {
return domainName
if let profile {
return profile.domainName
}
return nil
}

private func loadIcon() {
Task {
if let receiverDomainName {
icon = await imageLoadingService.loadImage(from: .domainNameInitials(receiverDomainName,
if let profile = try? await domainProfilesService.fetchResolvedDomainProfileDisplayInfo(for: tx.to.address) {
self.profile = profile
icon = await imageLoadingService.loadImage(from: .domainNameInitials(profile.domainName,
size: .default),
downsampleDescription: .mid)

if let pfp = await imageLoadingService.loadImage(from: .walletDomain(tx.to.address),
downsampleDescription: .mid) {
icon = pfp
}
icon = await imageLoadingService.loadImage(from: .domainPFPSource(profile.pfpInfo.source),
downsampleDescription: .mid)
}

}
}
}
Expand Down