Skip to content

Commit

Permalink
Code refactoring as follow up to recent BlockchainType changes (#610)
Browse files Browse the repository at this point in the history
* Select recepient when send crypto refactoring

* Cleaning

* Cleaning

* Add flags to measure type-checking performance

* Fixing preview target

* Add animation to mpc wallet card

* Cleaning
  • Loading branch information
Oleg-Pecheneg authored Jul 18, 2024
1 parent 5ae4d1e commit e757c3c
Show file tree
Hide file tree
Showing 38 changed files with 889 additions and 838 deletions.
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: BlockchainType.Ethereum.regexPattern,
isDeprecated: false),
.init(ticker: "MATIC",
version: nil,
expandedTicker: "crypto.MATIC",
regexPattern: CoinRegexPattern.ETH.regex,
regexPattern: BlockchainType.Matic.regexPattern,
isDeprecated: false),
.init(ticker: "BTC",
version: nil,
expandedTicker: "crypto.BTC.address",
regexPattern: CoinRegexPattern.BTC.regex,
regexPattern: BlockchainType.Bitcoin.regexPattern,
isDeprecated: false)]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public struct Debugger {
case Messaging = "MS"
case Debug = "DEBUG"
case NFT = "NFT"
case mpc = "MPC"
}

enum DebugTopicsSet {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ struct DomainItem: DomainEntity {

func doesRequirePayment() -> Bool {
switch self.getBlockchainType() {
case .Ethereum, .Base: return true
case .Matic: return false
case .Ethereum: return true

case .Matic, .Base, .Bitcoin, .Solana:
return false
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct UDWallet: Codable, Hashable {
}

static func == (lhs: UDWallet, rhs: UDWallet) -> Bool {
let resultEth = (lhs.address == rhs.address) && lhs.address != nil
let resultEth = (lhs.address == rhs.address)
return resultEth
}

Expand Down
21 changes: 9 additions & 12 deletions unstoppable-ios-app/domains-manager-ios.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@
C6011AB628F4022300342666 /* DomainProfileCryptoSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6011AB528F4022300342666 /* DomainProfileCryptoSection.swift */; };
C6011ABD28F4045000342666 /* DomainProfileTopInfoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6011ABB28F4045000342666 /* DomainProfileTopInfoCell.swift */; };
C6011AC128F4045000342666 /* DomainProfileTopInfoCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = C6011ABC28F4045000342666 /* DomainProfileTopInfoCell.xib */; };
C60319922C29775E00A77109 /* CoinRegexPattern.swift in Sources */ = {isa = PBXBuildFile; fileRef = C60319912C29775E00A77109 /* CoinRegexPattern.swift */; };
C60319932C29775E00A77109 /* CoinRegexPattern.swift in Sources */ = {isa = PBXBuildFile; fileRef = C60319912C29775E00A77109 /* CoinRegexPattern.swift */; };
C60319952C2B0ED100A77109 /* FB_UD_MPC_MessageSigningType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C60319942C2B0ED100A77109 /* FB_UD_MPC_MessageSigningType.swift */; };
C60319962C2B0ED100A77109 /* FB_UD_MPC_MessageSigningType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C60319942C2B0ED100A77109 /* FB_UD_MPC_MessageSigningType.swift */; };
C60319982C2C1F7400A77109 /* BlockchainType+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C60319972C2C1F7400A77109 /* BlockchainType+Extension.swift */; };
Expand Down Expand Up @@ -468,7 +466,6 @@
C61C333A2B90CE6600BD11F5 /* MessagingChatUserDisplayInfoImageLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = C61C33392B90CE6600BD11F5 /* MessagingChatUserDisplayInfoImageLoader.swift */; };
C61C333B2B90CE6600BD11F5 /* MessagingChatUserDisplayInfoImageLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = C61C33392B90CE6600BD11F5 /* MessagingChatUserDisplayInfoImageLoader.swift */; };
C61C50002820E39600D1110A /* PullUpSelectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C61C4FFF2820E39600D1110A /* PullUpSelectionView.swift */; };
C61C50052820FC5E00D1110A /* UISearchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = C61C50042820FC5E00D1110A /* UISearchBar.swift */; };
C61DB0FE2B95872500CDA243 /* PublicProfileLargeTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C61DB0FD2B95872500CDA243 /* PublicProfileLargeTextView.swift */; };
C61DB0FF2B95872900CDA243 /* PublicProfileLargeTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C61DB0FD2B95872500CDA243 /* PublicProfileLargeTextView.swift */; };
C61DB1052B95879200CDA243 /* PublicProfilePrimaryLargeTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C61DB1042B95879200CDA243 /* PublicProfilePrimaryLargeTextView.swift */; };
Expand Down Expand Up @@ -757,6 +754,8 @@
C63F1D0928AF31D5000A5C12 /* AnalyticsServiceEnvironment.swift in Sources */ = {isa = PBXBuildFile; fileRef = C63F1D0428AF31D5000A5C12 /* AnalyticsServiceEnvironment.swift */; };
C63F1D0D28AF31D5000A5C12 /* AnalyticsServiceProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = C63F1D0528AF31D5000A5C12 /* AnalyticsServiceProtocol.swift */; };
C63F1D1128AF31D5000A5C12 /* AnalyticsService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C63F1D0628AF31D5000A5C12 /* AnalyticsService.swift */; };
C640D6122C48087C006B21C3 /* AnimatedMPCWalletGridMask.swift in Sources */ = {isa = PBXBuildFile; fileRef = C640D6112C48087C006B21C3 /* AnimatedMPCWalletGridMask.swift */; };
C640D6132C48087C006B21C3 /* AnimatedMPCWalletGridMask.swift in Sources */ = {isa = PBXBuildFile; fileRef = C640D6112C48087C006B21C3 /* AnimatedMPCWalletGridMask.swift */; };
C640F3552C06FC66009EB0F9 /* MPCWalletPasswordValidator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C640F3542C06FC66009EB0F9 /* MPCWalletPasswordValidator.swift */; };
C640F3562C06FC66009EB0F9 /* MPCWalletPasswordValidator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C640F3542C06FC66009EB0F9 /* MPCWalletPasswordValidator.swift */; };
C640F3582C06FCB6009EB0F9 /* MPCWalletPasswordValidatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C640F3572C06FCB6009EB0F9 /* MPCWalletPasswordValidatorTests.swift */; };
Expand Down Expand Up @@ -2328,7 +2327,6 @@
C6D647542B1EDBAE00D724AC /* WalletInfoBadgeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6ECBF8A28D2D20900E94309 /* WalletInfoBadgeView.swift */; };
C6D647552B1EDBAE00D724AC /* WalletInfoBadgeView.xib in Resources */ = {isa = PBXBuildFile; fileRef = C6ECBF8F28D2D20D00E94309 /* WalletInfoBadgeView.xib */; };
C6D647562B1EDBF800D724AC /* UserProfileAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = C666E0FB29CD594F0003DECB /* UserProfileAction.swift */; };
C6D647572B1EDC1600D724AC /* UISearchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = C61C50042820FC5E00D1110A /* UISearchBar.swift */; };
C6D647582B1EDC1C00D724AC /* CollectionTextHeaderReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C68953912834CD280046CBA3 /* CollectionTextHeaderReusableView.swift */; };
C6D647592B1EDC2E00D724AC /* TertiaryButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6668945281151F6002062B4 /* TertiaryButton.swift */; };
C6D6475B2B1EDCED00D724AC /* PreviewDomainProfileInfoStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6D6475A2B1EDCED00D724AC /* PreviewDomainProfileInfoStorage.swift */; };
Expand Down Expand Up @@ -2790,7 +2788,6 @@
C6011AB528F4022300342666 /* DomainProfileCryptoSection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DomainProfileCryptoSection.swift; sourceTree = "<group>"; };
C6011ABB28F4045000342666 /* DomainProfileTopInfoCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DomainProfileTopInfoCell.swift; sourceTree = "<group>"; };
C6011ABC28F4045000342666 /* DomainProfileTopInfoCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = DomainProfileTopInfoCell.xib; sourceTree = "<group>"; };
C60319912C29775E00A77109 /* CoinRegexPattern.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoinRegexPattern.swift; sourceTree = "<group>"; };
C60319942C2B0ED100A77109 /* FB_UD_MPC_MessageSigningType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FB_UD_MPC_MessageSigningType.swift; sourceTree = "<group>"; };
C60319972C2C1F7400A77109 /* BlockchainType+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BlockchainType+Extension.swift"; sourceTree = "<group>"; };
C603A53528522C0D003962E3 /* IgnoreFailureArrayElement+PropertyWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "IgnoreFailureArrayElement+PropertyWrapper.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3008,7 +3005,6 @@
C61C332C2B906DCE00BD11F5 /* MockEntitiesFabric+Explore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MockEntitiesFabric+Explore.swift"; sourceTree = "<group>"; };
C61C33392B90CE6600BD11F5 /* MessagingChatUserDisplayInfoImageLoader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessagingChatUserDisplayInfoImageLoader.swift; sourceTree = "<group>"; };
C61C4FFF2820E39600D1110A /* PullUpSelectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PullUpSelectionView.swift; sourceTree = "<group>"; };
C61C50042820FC5E00D1110A /* UISearchBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UISearchBar.swift; sourceTree = "<group>"; };
C61DB0FD2B95872500CDA243 /* PublicProfileLargeTextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublicProfileLargeTextView.swift; sourceTree = "<group>"; };
C61DB1042B95879200CDA243 /* PublicProfilePrimaryLargeTextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublicProfilePrimaryLargeTextView.swift; sourceTree = "<group>"; };
C61DB1072B9587B600CDA243 /* PublicProfileSecondaryLargeTextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublicProfileSecondaryLargeTextView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3236,6 +3232,7 @@
C63F1D0428AF31D5000A5C12 /* AnalyticsServiceEnvironment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnalyticsServiceEnvironment.swift; sourceTree = "<group>"; };
C63F1D0528AF31D5000A5C12 /* AnalyticsServiceProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnalyticsServiceProtocol.swift; sourceTree = "<group>"; };
C63F1D0628AF31D5000A5C12 /* AnalyticsService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnalyticsService.swift; sourceTree = "<group>"; };
C640D6112C48087C006B21C3 /* AnimatedMPCWalletGridMask.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnimatedMPCWalletGridMask.swift; sourceTree = "<group>"; };
C640F3542C06FC66009EB0F9 /* MPCWalletPasswordValidator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MPCWalletPasswordValidator.swift; sourceTree = "<group>"; };
C640F3572C06FCB6009EB0F9 /* MPCWalletPasswordValidatorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MPCWalletPasswordValidatorTests.swift; sourceTree = "<group>"; };
C640F35B2C070718009EB0F9 /* MPCOnboardingPurchaseTakeoverRecoveryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MPCOnboardingPurchaseTakeoverRecoveryViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -5360,7 +5357,6 @@
C628E36227FDDAA00044E408 /* UILabel.swift */,
C6098319282B707B00546392 /* UINavigationController.swift */,
C6E0415A295053DC0080F8E3 /* UIScrollView.swift */,
C61C50042820FC5E00D1110A /* UISearchBar.swift */,
C6456F142800212000A517D5 /* UIStackView.swift */,
C628E34E27FDB2A30044E408 /* UITableView.swift */,
C6D6E53F28193851008C66BB /* UITableViewCell.swift */,
Expand Down Expand Up @@ -7097,6 +7093,7 @@
C640F36B2C071266009EB0F9 /* MPCWalletTakeoverState.swift */,
C640F36E2C0712A8009EB0F9 /* MPCWalletTakeoverError.swift */,
C68F15752BD769830049BFA2 /* MPCWalletStateCardView.swift */,
C640D6112C48087C006B21C3 /* AnimatedMPCWalletGridMask.swift */,
C640F3542C06FC66009EB0F9 /* MPCWalletPasswordValidator.swift */,
C66556682BF70B9900F0BD7A /* UDAuth */,
C66556722BF70F6400F0BD7A /* Checkout */,
Expand Down Expand Up @@ -7553,7 +7550,6 @@
C61DB10D2B95925C00CDA243 /* BalanceStringFormatter.swift */,
C63B1F332A4595D000B1D7D1 /* Base64DataTransformer.swift */,
C6EECE962833A3E400978ED5 /* CoinRecord.swift */,
C60319912C29775E00A77109 /* CoinRegexPattern.swift */,
C6C9DEAD2834BD9300BAC36F /* CopyWalletAddressPullUpHandler.swift */,
C6D5DABB2836021300379C38 /* CryptoRecord.swift */,
C68017852886730300524712 /* CurrencyImageLoader.swift */,
Expand Down Expand Up @@ -9426,7 +9422,6 @@
C64939FC2B637DDB00457363 /* ReverseResolutionSelectionView.swift in Sources */,
C69F99412A9F1478004B1958 /* DomainProfileBadgeDisplayInfo.swift in Sources */,
C69F99242A9F1264004B1958 /* ClearListBackground.swift in Sources */,
C60319922C29775E00A77109 /* CoinRegexPattern.swift in Sources */,
C6456F0B27FF299800A517D5 /* UIView.swift in Sources */,
C6FFBADE2B833C3600CB442D /* ChatListChatRowView.swift in Sources */,
C6D3B9D92A6ECC9C0091B279 /* XMTPEntitiesTransformer.swift in Sources */,
Expand Down Expand Up @@ -9729,6 +9724,7 @@
C6FFBAE12B834EF700CB442D /* HomeChatNavigationDestination.swift in Sources */,
C688C1A12B8490F700BD233A /* ChatRequestsListViewModel.swift in Sources */,
C68BA7592BBD10AF00FF524C /* WalletTransactionTypeIndicatorView.swift in Sources */,
C640D6122C48087C006B21C3 /* AnimatedMPCWalletGridMask.swift in Sources */,
C6C9DEAE2834BD9300BAC36F /* CopyWalletAddressPullUpHandler.swift in Sources */,
C623967C2A288A8A00363F60 /* MessagingChatMessageDisplayType.swift in Sources */,
C6C57C3D2869C0890093FD8C /* UDDomainSharingWatchCardView.swift in Sources */,
Expand Down Expand Up @@ -9931,7 +9927,6 @@
C65272662A15DEB9001A084C /* KeyboardService.swift in Sources */,
C6A2D51E284DBDF000327C47 /* QRScannerSightView.swift in Sources */,
C69F99272A9F1264004B1958 /* AvatarStyleClipped.swift in Sources */,
C61C50052820FC5E00D1110A /* UISearchBar.swift in Sources */,
C628E36827FDDB230044E408 /* UIButton.swift in Sources */,
C696989A2ACBCE640000738C /* PushMessagingWebSocketsService.swift in Sources */,
C63F1D0D28AF31D5000A5C12 /* AnalyticsServiceProtocol.swift in Sources */,
Expand Down Expand Up @@ -10845,6 +10840,7 @@
C6D646342B1DC43D00D724AC /* TextTertiaryButton.swift in Sources */,
C61808322B19ADF10032E543 /* PreviewCoreAppCoordinator.swift in Sources */,
C6B2E2002B96C51B00CEA1F9 /* MessagingChatMessageUnsupportedTypeDisplayInfo.swift in Sources */,
C640D6132C48087C006B21C3 /* AnimatedMPCWalletGridMask.swift in Sources */,
C6D645AA2B1DBB3800D724AC /* UICollectionViewLayout.swift in Sources */,
C6C8F9372B2183D100A9834D /* DomainImageDetailsViewPresenter.swift in Sources */,
C6D6470D2B1ED7D000D724AC /* MessagingChatMessageDisplayInfo.swift in Sources */,
Expand Down Expand Up @@ -10974,7 +10970,6 @@
C6102FC82B6A339A0098AF75 /* HomeWebAccountView.swift in Sources */,
C6B761E02BB3D78F00773943 /* SerializedWalletTransaction.swift in Sources */,
C6BF6BDD2B8F11CC006CC2BD /* TaskWithDeadline.swift in Sources */,
C60319932C29775E00A77109 /* CoinRegexPattern.swift in Sources */,
C6534A922BBFBA10008EEBB5 /* HomeExploreFollowersSectionView.swift in Sources */,
C61807BE2B19A0CB0032E543 /* Extension-String+Preview.swift in Sources */,
C621A4402BB10EFD00CB5CB9 /* QRScannerPreviewView.swift in Sources */,
Expand Down Expand Up @@ -11095,7 +11090,6 @@
C6D647A62B1F189B00D724AC /* PurchaseSearchDomainsViewController.swift in Sources */,
C630C7372BD781E900AC1662 /* OnboardingAddWalletViewController.swift in Sources */,
C6D645C62B1DBD3900D724AC /* CNavigationBarContentView.swift in Sources */,
C6D647572B1EDC1600D724AC /* UISearchBar.swift in Sources */,
C68F156E2BD659740049BFA2 /* MPCActivateWalletEnterView.swift in Sources */,
C6D647A72B1F18AE00D724AC /* HappyEndViewController.swift in Sources */,
C61808722B19BC150032E543 /* Color.swift in Sources */,
Expand Down Expand Up @@ -11537,6 +11531,7 @@
);
MARKETING_VERSION = 5.3.5;
MERGED_BINARY_TYPE = automatic;
OTHER_SWIFT_FLAGS = "-Xfrontend -warn-long-expression-type-checking=50 -Xfrontend -warn-long-function-bodies=50";
PRODUCT_BUNDLE_IDENTIFIER = com.unstoppabledomains.manager;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
Expand Down Expand Up @@ -11571,6 +11566,7 @@
);
MARKETING_VERSION = 5.3.5;
MERGED_BINARY_TYPE = automatic;
OTHER_SWIFT_FLAGS = "-Xfrontend -warn-long-expression-type-checking=50 -Xfrontend -warn-long-function-bodies=50";
PRODUCT_BUNDLE_IDENTIFIER = com.unstoppabledomains.manager;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -11747,6 +11743,7 @@
);
MARKETING_VERSION = 5.3.5;
MERGED_BINARY_TYPE = automatic;
OTHER_SWIFT_FLAGS = "-Xfrontend -warn-long-expression-type-checking=50 -Xfrontend -warn-long-function-bodies=50";
PRODUCT_BUNDLE_IDENTIFIER = com.unstoppabledomains.manager;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct CoinRecord: Hashable, Comparable, CustomStringConvertible, Codable {
self.ticker = ticker
self.version = version
self.expandedTicker = expandedTicker
self.regexPattern = regexPattern ?? CoinRegexPattern.ETH.regex
self.regexPattern = regexPattern ?? BlockchainType.Ethereum.regexPattern
if let version = version {
self.isPrimaryChain = CoinRecord.primaryChainsMap[ticker] == version
} else {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public struct Debugger {
case Messaging = "MS"
case Debug = "DEBUG"
case NFT = "NFT"
case mpc = "MPC"
}

enum DebugTopicsSet {
Expand All @@ -60,7 +61,7 @@ public struct Debugger {
case .debugUI:
return [.Error, .Navigation, .UI, .Images, .Debug]
case .debugNetwork:
return [.Network, .WebSockets, .Error, .Debug]
return [.Network, .WebSockets, .Error, .Debug, .mpc]
case .custom(let topics):
return topics
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ extension MockEntitiesFabric {

static func mockReceiver() -> SendCryptoAsset.AssetReceiver {
.init(walletAddress: Wallet.mockEntities()[1].address,
regexPattern: .ETH)
network: .Ethereum)
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ extension BlockchainType {
resolveChain(env: env).id
}


var chainIcon: UIImage {
switch self {
case .Ethereum:
Expand All @@ -174,3 +173,27 @@ extension BlockchainType {
}
}
}

extension BlockchainType {
var isEVMNetwork: Bool {
switch self {
case .Ethereum, .Matic, .Base: true
case .Bitcoin: false
case .Solana: false
}
}

var regexPattern: String {
switch self {
case .Ethereum, .Matic, .Base: "^0x[a-fA-F0-9]{40}$"
case .Bitcoin: "^bc1[ac-hj-np-z02-9]{6,87}$|^[13][a-km-zA-HJ-NP-Z1-9]{25,39}$"
case .Solana: "^[1-9A-HJ-NP-Za-km-z]{32,44}$"
}
}

func isStringMatchingRegex(_ string: String) -> Bool {
let predicate = NSPredicate(format: "SELF MATCHES %@", regexPattern)

return predicate.evaluate(with: string)
}
}
Loading

0 comments on commit e757c3c

Please sign in to comment.