Skip to content

Commit

Permalink
Merge pull request #56 from popshootjapan/resubmit/1.2.1
Browse files Browse the repository at this point in the history
Resubmit/1.2.1
  • Loading branch information
yuzushioh authored Aug 2, 2018
2 parents 6d98be1 + 0d683f7 commit b6cf348
Show file tree
Hide file tree
Showing 15 changed files with 70 additions and 71 deletions.
12 changes: 6 additions & 6 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
github "D-Technologies/EthereumKit" "6034dc9b466fae773c30d522640fa002b0c6a650"
github "Quick/Nimble" "v7.1.2"
github "Quick/Quick" "v1.3.0"
github "D-Technologies/EthereumKit" "ecde51527ca5dd57f3c5bf7dafd73cd5e66fe94f"
github "Quick/Nimble" "v7.1.3"
github "Quick/Quick" "v1.3.1"
github "ReactiveX/RxSwift" "4.2.0"
github "SVProgressHUD/SVProgressHUD" "2.2.5"
github "Swinject/Swinject" "2.4.1"
github "antitypical/Result" "3.2.4"
github "ishkawa/APIKit" "3.2.1"
github "antitypical/Result" "4.0.0"
github "ishkawa/APIKit" "4.0.0"
github "kishikawakatsumi/KeychainAccess" "v3.1.1"
github "krzyzanowskim/CryptoSwift" "0.10.0"
github "pinterest/PINCache" "2.3"
github "realm/realm-cocoa" "v3.7.2"
github "realm/realm-cocoa" "v3.7.5"
github "yuzushioh/CryptoEthereumSwift" "1.0.1"
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
source "https://rubygems.org"

gem 'cocoapods', '1.5.0'
gem 'fastlane', '2.93.1'
gem 'fastlane', '2.100.1'

40 changes: 20 additions & 20 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,19 @@ GEM
declarative-option (0.1.0)
domain_name (0.5.20180417)
unf (>= 0.0.5, < 1.0.0)
dotenv (2.4.0)
dotenv (2.5.0)
emoji_regex (0.1.1)
escape (0.0.4)
excon (0.62.0)
faraday (0.15.0)
faraday (0.15.2)
multipart-post (>= 1.2, < 3)
faraday-cookie_jar (0.0.6)
faraday (>= 0.7.4)
http-cookie (~> 1.0.0)
faraday_middleware (0.12.2)
faraday (>= 0.7.4, < 1.0)
fastimage (2.1.1)
fastlane (2.93.1)
fastimage (2.1.3)
fastlane (2.100.1)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.3, < 3.0.0)
babosa (>= 1.0.2, < 2.0.0)
Expand All @@ -81,7 +81,7 @@ GEM
faraday_middleware (~> 0.9)
fastimage (>= 2.1.0, < 3.0.0)
gh_inspector (>= 1.1.2, < 2.0.0)
google-api-client (>= 0.13.1, < 0.14.0)
google-api-client (>= 0.21.2, < 0.22.0)
highline (>= 1.7.2, < 2.0.0)
json (< 3.0.0)
mini_magick (~> 4.5.1)
Expand All @@ -90,7 +90,7 @@ GEM
multipart-post (~> 2.0.0)
plist (>= 3.1.0, < 4.0.0)
public_suffix (~> 2.0.0)
rubyzip (>= 1.1.0, < 2.0.0)
rubyzip (>= 1.2.1, < 2.0.0)
security (= 0.1.3)
simctl (~> 1.6.3)
slack-notifier (>= 2.0.0, < 3.0.0)
Expand All @@ -100,14 +100,14 @@ GEM
tty-spinner (>= 0.8.0, < 1.0.0)
word_wrap (~> 1.0.0)
xcodeproj (>= 1.5.7, < 2.0.0)
xcpretty (>= 0.2.4, < 1.0.0)
xcpretty (~> 0.2.8)
xcpretty-travis-formatter (>= 0.0.3)
fourflusher (2.0.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
google-api-client (0.13.6)
google-api-client (0.21.2)
addressable (~> 2.5, >= 2.5.1)
googleauth (~> 0.5)
googleauth (>= 0.5, < 0.7.0)
httpclient (>= 2.8.1, < 3.0)
mime-types (~> 3.0)
representable (~> 3.0)
Expand Down Expand Up @@ -142,9 +142,9 @@ GEM
multi_json (1.13.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
nanaimo (0.2.5)
nanaimo (0.2.6)
nap (1.1.0)
naturally (2.1.0)
naturally (2.2.0)
netrc (0.11.0)
os (0.9.6)
plist (3.4.0)
Expand All @@ -153,7 +153,7 @@ GEM
declarative (< 0.1.0)
declarative-option (< 0.2.0)
uber (< 0.2.0)
retriable (3.1.1)
retriable (3.1.2)
rouge (2.0.7)
ruby-macho (1.1.0)
rubyzip (1.2.1)
Expand All @@ -163,16 +163,16 @@ GEM
faraday (~> 0.9)
jwt (>= 1.5, < 3.0)
multi_json (~> 1.10)
simctl (1.6.4)
simctl (1.6.5)
CFPropertyList
naturally
slack-notifier (2.3.2)
terminal-notifier (1.8.0)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
thread_safe (0.3.6)
tty-cursor (0.5.0)
tty-screen (0.6.4)
tty-cursor (0.6.0)
tty-screen (0.6.5)
tty-spinner (0.8.0)
tty-cursor (>= 0.5.0)
tzinfo (1.2.5)
Expand All @@ -181,14 +181,14 @@ GEM
unf (0.1.4)
unf_ext
unf_ext (0.0.7.5)
unicode-display_width (1.3.2)
unicode-display_width (1.4.0)
word_wrap (1.0.0)
xcodeproj (1.5.7)
xcodeproj (1.5.9)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.2)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.2.4)
nanaimo (~> 0.2.5)
xcpretty (0.2.8)
rouge (~> 2.0.7)
xcpretty-travis-formatter (1.0.0)
Expand All @@ -199,7 +199,7 @@ PLATFORMS

DEPENDENCIES
cocoapods (= 1.5.0)
fastlane (= 2.93.1)
fastlane (= 2.100.1)

BUNDLED WITH
1.16.1
1.16.2
12 changes: 6 additions & 6 deletions Wei.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1792,7 +1792,7 @@
CODE_SIGN_ENTITLEMENTS = Wei/Wei.entitlements;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 11;
CURRENT_PROJECT_VERSION = 14;
DEVELOPMENT_TEAM = JUG749AXCX;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -1821,7 +1821,7 @@
BUNDLE_LOADER = "$(TEST_HOST)";
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 11;
CURRENT_PROJECT_VERSION = 14;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/iOS",
Expand Down Expand Up @@ -1960,7 +1960,7 @@
BUNDLE_DISPLAY_SUFFIX = "-D";
CODE_SIGN_ENTITLEMENTS = Wei/Wei.entitlements;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 11;
CURRENT_PROJECT_VERSION = 14;
DEVELOPMENT_TEAM = JUG749AXCX;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -1990,7 +1990,7 @@
CODE_SIGN_ENTITLEMENTS = Wei/Wei.entitlements;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 11;
CURRENT_PROJECT_VERSION = 14;
DEVELOPMENT_TEAM = JUG749AXCX;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -2019,7 +2019,7 @@
BUNDLE_LOADER = "$(TEST_HOST)";
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 11;
CURRENT_PROJECT_VERSION = 14;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/iOS",
Expand All @@ -2044,7 +2044,7 @@
BUNDLE_LOADER = "$(TEST_HOST)";
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 11;
CURRENT_PROJECT_VERSION = 14;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/iOS",
Expand Down
1 change: 1 addition & 0 deletions Wei/DI/ViewModelAssembly.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ final class ViewModelAssembly: Assembly {
container.register(CreateWalletViewModel.self) { resolver in
return CreateWalletViewModel(dependency: (
resolver.resolve(ApplicationStoreProtocol.self)!,
resolver.resolve(WalletManagerProtocol.self)!,
resolver.resolve(MnemonicManagerProtocol.self)!,
resolver.resolve(RegistrationRepositoryProtocol.self)!,
resolver.resolve(DeviceCheckerProtocol.self)!
Expand Down
2 changes: 1 addition & 1 deletion Wei/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>11</string>
<string>14</string>
<key>Fabric</key>
<dict>
<key>APIKey</key>
Expand Down
2 changes: 1 addition & 1 deletion Wei/Model/AppStatus.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ struct AppStatus: Decodable {
enum CodingKeys: String, CodingKey {
case isUnderMaintenance = "maintenance_ongoing"
case forceUpdates = "need_update"
case needsAgreeTerms = "need_terms_agrement"
case needsAgreeTerms = "need_terms_agreement"
}
}
2 changes: 1 addition & 1 deletion Wei/Model/RegistrationService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ final class RegistrationService {
struct Response: Decodable {}

var path: String {
return "agrement_version"
return "agreement_version"
}

var method: HTTPMethod {
Expand Down
20 changes: 16 additions & 4 deletions Wei/Utility/WalletManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,26 @@ final class WalletManager: WalletManagerProtocol, Injectable {
)

init(dependency: Dependency) {
let applicationStore = dependency
var applicationStore = dependency

guard let seed = applicationStore.seed else {
fatalError("Store seed before instantiating Wallet")
let seed: Data
if let storedSeed = applicationStore.seed {
seed = Data(hex: storedSeed)
} else {
let mnemonic = Mnemonic.create()

do {
seed = try Mnemonic.createSeed(mnemonic: mnemonic)
} catch let error {
fatalError("failed to generate seed, error: \(error.localizedDescription)")
}

applicationStore.mnemonic = mnemonic.joined(separator: " ")
applicationStore.seed = seed.toHexString()
}

do {
wallet = try Wallet(seed: Data(hex: seed), network: applicationStore.network, debugPrints: Environment.current.debugPrints)
wallet = try Wallet(seed: seed, network: applicationStore.network, debugPrints: Environment.current.debugPrints)
} catch let error {
fatalError("Failed to instantiate Wallet: \(error.localizedDescription)")
}
Expand Down
36 changes: 11 additions & 25 deletions Wei/View/CreateWallet/CreateWalletViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,20 @@ final class CreateWalletViewModel: InjectableViewModel {

typealias Dependency = (
ApplicationStoreProtocol,
WalletManagerProtocol,
MnemonicManagerProtocol,
RegistrationRepositoryProtocol,
DeviceCheckerProtocol
)

private var applicationStore: ApplicationStoreProtocol
private let walletManager: WalletManagerProtocol
private let mnemonicManager: MnemonicManagerProtocol
private let registrationRepository: RegistrationRepositoryProtocol
private let deviceChecker: DeviceCheckerProtocol

init(dependency: Dependency) {
(applicationStore, mnemonicManager, registrationRepository, deviceChecker) = dependency
(applicationStore, walletManager, mnemonicManager, registrationRepository, deviceChecker) = dependency
}

struct Input {
Expand All @@ -49,35 +51,19 @@ final class CreateWalletViewModel: InjectableViewModel {
return Driver.empty()
}

// When the wallet generation succeeds and api registration fails, there will be the case
// that user has a seed but not registered propery. so do not double-generate wallet seed
// to prevent it.
if weakSelf.applicationStore.seed == nil {
let mnemonic = weakSelf.mnemonicManager.create()
let seed: String
do {
seed = try weakSelf.mnemonicManager.createSeed(mnemonic: mnemonic).toHexString()
} catch let error {
return Driver.just(Action.failed(error))
}
weakSelf.applicationStore.mnemonic = mnemonic.joined(separator: " ")
weakSelf.applicationStore.seed = seed
}

// NOTE: To register user's address, you need the instance of wallet,
// but because the seed is generated right before here, you can't inject
// the instance to the ViewModel.
let wallet = Container.shared.resolve(WalletManagerProtocol.self)!

let signUpCompleted: Observable<String>
if weakSelf.applicationStore.accessToken == nil {
if let accessToken = weakSelf.applicationStore.accessToken {
signUpCompleted = Observable.just(accessToken)
} else {
signUpCompleted = weakSelf.deviceChecker.deviceToken.flatMap { deviceToken -> Observable<String> in
return weakSelf.registrationRepository
.signUp(address: wallet.address(), sign: try wallet.sign(message: "Welcome to Wei wallet!"), token: deviceToken)
.signUp(
address: weakSelf.walletManager.address(),
sign: try weakSelf.walletManager.sign(message: "Welcome to Wei wallet!"),
token: deviceToken
)
.asObservable()
}
} else {
signUpCompleted = Observable.just(weakSelf.applicationStore.accessToken!)
}

let source = signUpCompleted
Expand Down
2 changes: 1 addition & 1 deletion Wei/View/Root/RootViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ final class RootViewModel: InjectableViewModel {
// the seed or access token. This case will happen if seed is saved in the keychain
// from other apps developed by us.
let presentCreateWalletViewController = input.viewDidAppear
.filter { applicationStore.seed == nil || applicationStore.accessToken == nil }
.filter { applicationStore.accessToken == nil }

return Output(
showHomeViewController: showHomeViewController,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<attributedString key="attributedText">
<fragment>
<string key="content">いつもWei Walletをご利用いただきありがとうございます。
サービスの安定的な提供のため、2018年7月12日にWeiWalletの</string>
サービスの安定的な提供のため、WeiWalletの</string>
<attributes>
<font key="NSFont" size="13" name="HiraginoSans-W3"/>
<paragraphStyle key="NSParagraphStyle" alignment="left" lineBreakMode="wordWrapping" baseWritingDirection="natural" tighteningFactorForTruncation="0.0"/>
Expand Down
4 changes: 2 additions & 2 deletions Wei/ja.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
"Transaction.Sent" = "送金済み";

// MARK: - Send View Pager
"Page.QRCode" = "QRコードを撮影";
"Page.QRCode" = "QRを読み取る";
"Page.CopyAddress" = "アドレスコピー";

// MARK: - SelectAddressByQR
"SelectAddress.Warning.Text" = "相手のQRコードを撮影するか、\nアドレスを入力してください";
"SelectAddress.Warning.Text" = "相手のQRコードを読み取るか、\nアドレスを入力してください";

// MARK: - Suggest Backup
"SuggestBackup.Message" = "バックアップを取ることであなたの保有しているイーサリアムは復元することができます";
Expand Down
2 changes: 1 addition & 1 deletion WeiTests/Helper/Fixture/GetAppStatus.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"maintenance_ongoing": false,
"need_update": false,
"need_terms_agrement": false
"need_terms_agreement": false
}
2 changes: 1 addition & 1 deletion WeiTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<key>CFBundleShortVersionString</key>
<string>1.2.1</string>
<key>CFBundleVersion</key>
<string>11</string>
<string>14</string>
</dict>
</plist>

0 comments on commit b6cf348

Please sign in to comment.