Skip to content

Commit

Permalink
Added Export JSON Keystore screens
Browse files Browse the repository at this point in the history
  • Loading branch information
eviltofu committed Dec 9, 2021
1 parent 25f4458 commit 0173716
Show file tree
Hide file tree
Showing 43 changed files with 1,605 additions and 78 deletions.
40 changes: 40 additions & 0 deletions AlphaWallet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
02220CFE273A9CDB006A09BF /* SaveCustomRpcViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02220CFD273A9CDA006A09BF /* SaveCustomRpcViewController.swift */; };
02220D00273A9DD6006A09BF /* SaveCustomRpcViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02220CFF273A9DD6006A09BF /* SaveCustomRpcViewModel.swift */; };
02220D02273A9E24006A09BF /* SaveCustomRpcView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02220D01273A9E23006A09BF /* SaveCustomRpcView.swift */; };
025F5D162760C73300B2A3BC /* ExportJsonKeystorePasswordViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 025F5D152760C73300B2A3BC /* ExportJsonKeystorePasswordViewModel.swift */; };
025F5D182760C74400B2A3BC /* ExportJsonKeystoreCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 025F5D172760C74400B2A3BC /* ExportJsonKeystoreCoordinator.swift */; };
025F5D1B2760C75800B2A3BC /* ExportJsonKeystorePasswordViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 025F5D192760C75800B2A3BC /* ExportJsonKeystorePasswordViewController.swift */; };
025F5D1C2760C75800B2A3BC /* ExportJsonKeystoreFileViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 025F5D1A2760C75800B2A3BC /* ExportJsonKeystoreFileViewController.swift */; };
025F5D1F2760C76A00B2A3BC /* ExportJsonKeystoreFileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 025F5D1D2760C76A00B2A3BC /* ExportJsonKeystoreFileView.swift */; };
025F5D202760C76A00B2A3BC /* ExportJsonKeystorePasswordView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 025F5D1E2760C76A00B2A3BC /* ExportJsonKeystorePasswordView.swift */; };
025F5D2F2760CDE600B2A3BC /* StringValidator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 025F5D2E2760CDE600B2A3BC /* StringValidator.swift */; };
025F5D3D2760CE9E00B2A3BC /* UIFactoryColors.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 025F5D3C2760CE9E00B2A3BC /* UIFactoryColors.xcassets */; };
0DF46B4002E13613F768E7AE /* Pods_AlphaWalletTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E36AB2DC7832A980726A4AB1 /* Pods_AlphaWalletTests.framework */; };
290B2B541F8F50030053C83E /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 290B2B561F8F50030053C83E /* Localizable.strings */; };
290B2B5F1F9177860053C83E /* UIImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 290B2B5E1F9177860053C83E /* UIImage.swift */; };
Expand Down Expand Up @@ -1037,6 +1045,14 @@
02220CFD273A9CDA006A09BF /* SaveCustomRpcViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SaveCustomRpcViewController.swift; sourceTree = "<group>"; };
02220CFF273A9DD6006A09BF /* SaveCustomRpcViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SaveCustomRpcViewModel.swift; sourceTree = "<group>"; };
02220D01273A9E23006A09BF /* SaveCustomRpcView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SaveCustomRpcView.swift; sourceTree = "<group>"; };
025F5D152760C73300B2A3BC /* ExportJsonKeystorePasswordViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExportJsonKeystorePasswordViewModel.swift; sourceTree = "<group>"; };
025F5D172760C74400B2A3BC /* ExportJsonKeystoreCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExportJsonKeystoreCoordinator.swift; sourceTree = "<group>"; };
025F5D192760C75800B2A3BC /* ExportJsonKeystorePasswordViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExportJsonKeystorePasswordViewController.swift; sourceTree = "<group>"; };
025F5D1A2760C75800B2A3BC /* ExportJsonKeystoreFileViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExportJsonKeystoreFileViewController.swift; sourceTree = "<group>"; };
025F5D1D2760C76A00B2A3BC /* ExportJsonKeystoreFileView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExportJsonKeystoreFileView.swift; sourceTree = "<group>"; };
025F5D1E2760C76A00B2A3BC /* ExportJsonKeystorePasswordView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExportJsonKeystorePasswordView.swift; sourceTree = "<group>"; };
025F5D2E2760CDE600B2A3BC /* StringValidator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StringValidator.swift; sourceTree = "<group>"; };
025F5D3C2760CE9E00B2A3BC /* UIFactoryColors.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = UIFactoryColors.xcassets; sourceTree = "<group>"; };
0B5A03D1E5E417FE79607D0F /* Pods_AlphaWallet.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_AlphaWallet.framework; sourceTree = BUILT_PRODUCTS_DIR; };
120A2B8C48180E93DBCCC2EE /* Pods-AlphaWalletUITests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AlphaWalletUITests.release.xcconfig"; path = "Pods/Target Support Files/Pods-AlphaWalletUITests/Pods-AlphaWalletUITests.release.xcconfig"; sourceTree = "<group>"; };
290B2B551F8F50030053C83E /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2067,6 +2083,14 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
025F5D3E2760CEA800B2A3BC /* UIFactory */ = {
isa = PBXGroup;
children = (
025F5D3C2760CE9E00B2A3BC /* UIFactoryColors.xcassets */,
);
path = UIFactory;
sourceTree = "<group>";
};
290B2B511F8F4F840053C83E /* Localization */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -2489,6 +2513,7 @@
5E7C72571AB0FECB26FEB1B1 /* ClearDappBrowserCacheCoordinator.swift */,
02220CFB273A9A02006A09BF /* SaveCustomRpcCoordinator.swift */,
5E7C757AEC6586F51EC75646 /* PingInfuraCoordinator.swift */,
025F5D172760C74400B2A3BC /* ExportJsonKeystoreCoordinator.swift */,
);
path = Coordinators;
sourceTree = "<group>";
Expand Down Expand Up @@ -2761,6 +2786,7 @@
87ED8FAE2488EA9C0005C69B /* SupportViewModel.swift */,
02220CFF273A9DD6006A09BF /* SaveCustomRpcViewModel.swift */,
5E7C73BF5CE15E6D7AFC3F0C /* ChooseSendPrivateTransactionsProviderViewModel.swift */,
025F5D152760C73300B2A3BC /* ExportJsonKeystorePasswordViewModel.swift */,
);
path = ViewModels;
sourceTree = "<group>";
Expand Down Expand Up @@ -3241,6 +3267,8 @@
87509A6126F8D67E00D3EE85 /* CollectUsersEmailViewController.swift */,
02220CFD273A9CDA006A09BF /* SaveCustomRpcViewController.swift */,
5E7C7177F1DDDDDDE020CB4D /* ChooseSendPrivateTransactionsProviderViewController.swift */,
025F5D1A2760C75800B2A3BC /* ExportJsonKeystoreFileViewController.swift */,
025F5D192760C75800B2A3BC /* ExportJsonKeystorePasswordViewController.swift */,
);
path = ViewControllers;
sourceTree = "<group>";
Expand Down Expand Up @@ -3945,6 +3973,8 @@
876C80CC2673940B00B16595 /* SwitchView.swift */,
02220D01273A9E23006A09BF /* SaveCustomRpcView.swift */,
5E7C73BFE30E0D43E97806EF /* SelectionTableViewCell.swift */,
025F5D1D2760C76A00B2A3BC /* ExportJsonKeystoreFileView.swift */,
025F5D1E2760C76A00B2A3BC /* ExportJsonKeystorePasswordView.swift */,
);
path = Views;
sourceTree = "<group>";
Expand Down Expand Up @@ -4870,6 +4900,7 @@
CCA4FE341FD427CA00749AE4 /* Helpers */ = {
isa = PBXGroup;
children = (
025F5D3E2760CEA800B2A3BC /* UIFactory */,
CCA4FE351FD4282400749AE4 /* DeviceChecker.swift */,
CCA4FE371FD428B300749AE4 /* JailbreakChecker.swift */,
5E7C77E1E6194F5A1DC8D645 /* ScreenChecker.swift */,
Expand All @@ -4881,6 +4912,7 @@
5E7C7B80946D854599838AD1 /* RemoteLogger.swift */,
5E7C77DBECDF831CD6C8FF71 /* Environment.swift */,
5F4D80A326A3F97B00BB1135 /* DeviceModel.swift */,
025F5D2E2760CDE600B2A3BC /* StringValidator.swift */,
);
path = Helpers;
sourceTree = "<group>";
Expand Down Expand Up @@ -5080,6 +5112,7 @@
C887C53A2057B703005ACF81 /* termsOfService.html in Resources */,
C876FF7D204A79D300B7D0EA /* SourceSansPro-Bold.otf in Resources */,
C880330D2054371500D73D6F /* [email protected] in Resources */,
025F5D3D2760CE9E00B2A3BC /* UIFactoryColors.xcassets in Resources */,
771AA966200D5F1900D25403 /* WordCollectionViewCell.xib in Resources */,
87B93B112726C59D00F6EA73 /* BrowserStorageSubscription.js in Resources */,
87B93B102726C59D00F6EA73 /* config.js in Resources */,
Expand Down Expand Up @@ -5471,6 +5504,7 @@
2996F14D1F6CA743005C33AE /* UIViewController.swift in Sources */,
2959961F1FAE759700DB66A8 /* RawTransaction.swift in Sources */,
87E2555824F52EBF00F025F7 /* GasSpeedTableViewCellViewModel.swift in Sources */,
025F5D202760C76A00B2A3BC /* ExportJsonKeystorePasswordView.swift in Sources */,
295B61D41FE7D5B500642E60 /* CurrencyFormatter.swift in Sources */,
296421991F70C1F900EB363B /* EmptyView.swift in Sources */,
771AA962200D5EC700D25403 /* PassphraseViewModel.swift in Sources */,
Expand Down Expand Up @@ -5612,6 +5646,7 @@
87BBF9972563DD7600FF4846 /* TransactionInProgressCoordinatorBridgeToPromise.swift in Sources */,
291F52A91F6B7BE100B369AB /* BlockNumber.swift in Sources */,
739533971FEFF5FD0084AFAB /* Currency.swift in Sources */,
025F5D1B2760C75800B2A3BC /* ExportJsonKeystorePasswordViewController.swift in Sources */,
298542F31FBD594D00CB5081 /* SettingsViewModel.swift in Sources */,
874D099025EE32EF00A58EF2 /* SignatureConfirmationDetailsViewModel.swift in Sources */,
CCA4FE381FD428B300749AE4 /* JailbreakChecker.swift in Sources */,
Expand Down Expand Up @@ -5798,6 +5833,7 @@
87D175EB24AEF8B5002130D2 /* UITableView.swift in Sources */,
76F1D7F08263A663C3A67926 /* GetIsERC721ContractCoordinator.swift in Sources */,
87BBF9872563DD7600FF4846 /* WalletConnectSessionDetailsViewModel.swift in Sources */,
025F5D162760C73300B2A3BC /* ExportJsonKeystorePasswordViewModel.swift in Sources */,
5E7C79DE8864702C51C0A7CC /* ResultResult.swift in Sources */,
87CDD49025F100AE0009B6AC /* Array.swift in Sources */,
87574A3025E7D41E00CAA0BB /* AnalyticsService.swift in Sources */,
Expand Down Expand Up @@ -5893,6 +5929,7 @@
76F1D5ECC391A932C96CAC13 /* GetENSOwnerCoordinator.swift in Sources */,
76F1D9BBB4ACAA00C8391172 /* GetENSInfoEncode.swift in Sources */,
8703F66726135B330082EE25 /* ChartHistory.swift in Sources */,
025F5D2F2760CDE600B2A3BC /* StringValidator.swift in Sources */,
76F1D5B10569F2351CA98A93 /* GasLimitConfiguration.swift in Sources */,
874DED1924C1BD2C006C8FCE /* SelectTokenViewModel.swift in Sources */,
5E7C7EB80D32A2F366E79140 /* SettingsHeaderView.swift in Sources */,
Expand Down Expand Up @@ -6033,6 +6070,7 @@
5E7C7777BDB574E021D2D6F1 /* LegacyFileBasedKeystore.swift in Sources */,
87713EB0264BAB2500B1B9CB /* TokenPagesContainerView.swift in Sources */,
5E7C73F6762376F5B2B4214D /* EtherKeystore.swift in Sources */,
025F5D1F2760C76A00B2A3BC /* ExportJsonKeystoreFileView.swift in Sources */,
5E7C7A9363A9DF11B233F9DC /* Keystore.swift in Sources */,
5E7C7B14B0D172F91D52F0BF /* EthereumSigner.swift in Sources */,
879F185926E7412D000602F2 /* Erc1155TokenInstanceViewModel.swift in Sources */,
Expand Down Expand Up @@ -6133,7 +6171,9 @@
5E7C7C5C350376B83D23154F /* MixpanelCoordinator.swift in Sources */,
5E7C769C85D1EBB44DEA5AC5 /* AnalyticsEventPropertyValue.swift in Sources */,
5E7C71EFB766F41D1BA5E1FB /* AnalyticsTypes.swift in Sources */,
025F5D1C2760C75800B2A3BC /* ExportJsonKeystoreFileViewController.swift in Sources */,
5E7C760168C99F9D50800DFD /* AnalyticsCoordinator.swift in Sources */,
025F5D182760C74400B2A3BC /* ExportJsonKeystoreCoordinator.swift in Sources */,
5E7C79BFFFB6A5FE833489C0 /* ActivitiesCoordinator.swift in Sources */,
5E7C783C2C5F4CFFC43AD63B /* EventSourceCoordinatorForActivities.swift in Sources */,
5E7C7F2284231870623C5605 /* TokenScriptCard.swift in Sources */,
Expand Down
20 changes: 0 additions & 20 deletions AlphaWallet/Assets.xcassets/dove.colorset/Contents.json

This file was deleted.

20 changes: 0 additions & 20 deletions AlphaWallet/Assets.xcassets/dusty.colorset/Contents.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"images" : [
{
"filename" : "iconsSettingsJson.pdf",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
Binary file not shown.
20 changes: 0 additions & 20 deletions AlphaWallet/Assets.xcassets/mine.colorset/Contents.json

This file was deleted.

76 changes: 76 additions & 0 deletions AlphaWallet/Core/Helpers/StringValidator.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
//
// StringValidator.swift
// AlphaWallet
//
// Created by Jerome Chan on 2/12/21.
//

import Foundation

typealias StringValidatorResult = Result<Void, StringValidator.Errors>

class StringValidator {
enum Errors: Error {
case list([StringValidator.Rule])
}

enum Rule {
case lengthLessThan(Int)
case lengthLessThanOrEqualTo(Int)
case lengthMoreThan(Int)
case lengthMoreThanOrEqualTo(Int)
case doesNotContain(CharacterSet)
case canOnlyContain(CharacterSet)

func validate(_ inputString: String) -> Bool {
switch self {
case .lengthLessThan(let length):
return inputString.count < length
case .lengthLessThanOrEqualTo(let length):
return inputString.count <= length
case .lengthMoreThan(let length):
return inputString.count > length
case .lengthMoreThanOrEqualTo(let length):
return inputString.count >= length
case .doesNotContain(let set):
return inputString.rangeOfCharacter(from: set) == nil
case .canOnlyContain(let set):
return inputString.rangeOfCharacter(from: set.inverted) == nil
}
}
}

private var rules: [StringValidator.Rule]

init() {
self.rules = []
}

init(rules: [StringValidator.Rule]) {
self.rules = rules
}

func validate(string inputString: String) -> StringValidatorResult {
let errors = rules.compactMap {
$0.validate(inputString) ? nil : $0
}
if errors.isEmpty {
return .success(())
}
return .failure(.list(errors))
}

func containsIllegalCharacters(string inputString: String) -> Bool {
guard case let Result.failure(StringValidator.Errors.list(errors)) = validate(string: inputString) else { return false }
let filteredErrors: [StringValidator.Rule] = errors.compactMap { error in
switch error {
case StringValidator.Rule.lengthLessThan, StringValidator.Rule.lengthLessThanOrEqualTo, StringValidator.Rule.lengthMoreThan, StringValidator.Rule.lengthMoreThanOrEqualTo:
return nil
default:
return error
}
}
return !filteredErrors.isEmpty
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x14",
"green" : "0x14",
"red" : "0x14"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.447",
"green" : "0.447",
"red" : "0.447"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.600",
"green" : "0.600",
"red" : "0.600"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading

0 comments on commit 0173716

Please sign in to comment.