Skip to content
This repository has been archived by the owner on Jun 2, 2019. It is now read-only.

Commit

Permalink
Merge branch 'master' into feature/830-require-password-on-sending-tr…
Browse files Browse the repository at this point in the history
…ansactions

* master:
  Move reload into separate function
  Crash: Signing on watch address via browser #885
  fix crash when signing on watch address via browser #885 (#887)
  Update localized string and use R
  Move into separate function
  Update Analitics.swift (#882)
  Link "Settings → Telegram Group" should open channel according to user's locale (#879)
  Improve currentWalletDescriptionString
  Move Help center higher in order
  Version Bump
  • Loading branch information
taraspasichnyk committed Aug 6, 2018
2 parents ee2dc8a + c26d4cf commit b5c6cde
Show file tree
Hide file tree
Showing 26 changed files with 114 additions and 75 deletions.
8 changes: 6 additions & 2 deletions Trust.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@
A2B7ECAE2039001300828E7D /* ExportPrivateKeyViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A2B7ECAD2039001300828E7D /* ExportPrivateKeyViewController.swift */; };
A2E43B4E20802879001FAD3D /* UINavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A2E43B4D20802879001FAD3D /* UINavigationController.swift */; };
A2E895D020953404003D5303 /* QRGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = A2E895CF20953404003D5303 /* QRGenerator.swift */; };
ACE3F4EC211485F8003CB0A0 /* NSLocale.swift in Sources */ = {isa = PBXBuildFile; fileRef = ACE3F4EB211485F8003CB0A0 /* NSLocale.swift */; };
BB03A86D20416AF600649DA0 /* BalanceStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB03A86C20416AF600649DA0 /* BalanceStatus.swift */; };
BB03A8712042B01300649DA0 /* BalanceStatusTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB03A8702042B01300649DA0 /* BalanceStatusTests.swift */; };
BB1CC266203BA4440042E56C /* SendMaxAmountTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1CC265203BA4440042E56C /* SendMaxAmountTest.swift */; };
Expand Down Expand Up @@ -945,6 +946,7 @@
A2E895CF20953404003D5303 /* QRGenerator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QRGenerator.swift; sourceTree = "<group>"; };
A3B747245A27436E621E7E41 /* Pods-TrustUITests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TrustUITests.release.xcconfig"; path = "Pods/Target Support Files/Pods-TrustUITests/Pods-TrustUITests.release.xcconfig"; sourceTree = "<group>"; };
A48A17FC2CC895AF2BB871D0 /* Pods_TrustTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_TrustTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
ACE3F4EB211485F8003CB0A0 /* NSLocale.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSLocale.swift; sourceTree = "<group>"; };
B13A87D3BA5167741E5D0801 /* Pods-Trust.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Trust.release.xcconfig"; path = "Pods/Target Support Files/Pods-Trust/Pods-Trust.release.xcconfig"; sourceTree = "<group>"; };
BB03A86C20416AF600649DA0 /* BalanceStatus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BalanceStatus.swift; sourceTree = "<group>"; };
BB03A8702042B01300649DA0 /* BalanceStatusTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BalanceStatusTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1577,6 +1579,7 @@
77B64100209668FF00BEF3EB /* EtherNumberFormatter+Trust.swift */,
296FC5A520C2773B00B923EF /* UIScrollView.swift */,
771DC9D420F36555003E2CE2 /* UIBarButtonItem.swift */,
ACE3F4EB211485F8003CB0A0 /* NSLocale.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -3025,6 +3028,7 @@
297800521F71FDCF003185C1 /* FormAppearance.swift in Sources */,
77B3BF3C201908ED00EEC15A /* ConfirmCoordinator.swift in Sources */,
7704837020FFD2F700837735 /* TransactionsViewController.swift in Sources */,
ACE3F4EC211485F8003CB0A0 /* NSLocale.swift in Sources */,
2928500E2096A69E00EC5AFB /* AboutViewModel.swift in Sources */,
298542F91FBE9A0100CB5081 /* CryptoAddressValidator.swift in Sources */,
7778713C2086AD9900CF7303 /* BigInt.swift in Sources */,
Expand Down Expand Up @@ -3505,7 +3509,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 280;
CURRENT_PROJECT_VERSION = 281;
DEVELOPMENT_TEAM = 9873B38DWV;
ENABLE_BITCODE = YES;
GCC_WARN_UNUSED_LABEL = YES;
Expand Down Expand Up @@ -3533,7 +3537,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 280;
CURRENT_PROJECT_VERSION = 281;
DEVELOPMENT_TEAM = 9873B38DWV;
ENABLE_BITCODE = YES;
GCC_WARN_UNUSED_LABEL = YES;
Expand Down
2 changes: 1 addition & 1 deletion Trust/Browser/Coordinators/BrowserCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ extension BrowserCoordinator: BrowserViewControllerDelegate {
}

func didCall(action: DappAction, callbackID: Int) {
guard let account = session.account.currentAccount else {
guard let account = session.account.currentAccount, let _ = account.wallet else {
self.rootViewController.browserViewController.notifyFinish(callbackID: callbackID, value: .failure(DAppError.cancelled))
self.navigationController.topViewController?.displayError(error: InCoordinatorError.onlyWatchAccount)
return
Expand Down
2 changes: 1 addition & 1 deletion Trust/EtherClient/EtherKeystore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ class EtherKeystore: Keystore {

func signTransaction(_ transaction: SignTransaction) -> Result<Data, KeystoreError> {
let account = transaction.account
guard let password = getPassword(for: account.wallet!) else {
guard let wallet = account.wallet, let password = getPassword(for: wallet) else {
return .failure(.failedToSignTransaction)
}
let signer: Signer
Expand Down
12 changes: 12 additions & 0 deletions Trust/Extensions/NSLocale.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright DApps Platform Inc. All rights reserved.

import Foundation
import UIKit

extension NSLocale {
static var preferredLanguageCode: String? {
let langageRegion = NSLocale.preferredLanguages.first ?? ""
let languageComponents = NSLocale.components(fromLocaleIdentifier: langageRegion)
return languageComponents[NSLocale.Key.languageCode.rawValue]
}
}
4 changes: 2 additions & 2 deletions Trust/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.92.0</string>
<string>1.93.0</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
Expand All @@ -28,7 +28,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>280</string>
<string>281</string>
<key>Fabric</key>
<dict>
<key>APIKey</key>
Expand Down
1 change: 0 additions & 1 deletion Trust/Localization/de.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@
"import.wallet.watch.placeholder" = "%@ Adresse";
"settings.joinCommunity.label.title" = "Der Community beitreten";
"settings.support.title" = "Support";
"settings.helpCenter.title" = "Help Center";
"tokens.token.edit.navigation.title" = "Ein benutzerdefiniertes Token bearbeiten";
"wallet.section.hdWallet.title" = "HD Wallet";
"wallets.export.alertSheet.title" = "Privaten Schlüssel exportieren";
Expand Down
5 changes: 4 additions & 1 deletion Trust/Localization/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@
"import.wallet.watch.placeholder" = "%@ Address";
"settings.joinCommunity.label.title" = "Join Community";
"settings.support.title" = "Support";
"settings.helpCenter.title" = "Help Center";
"tokens.token.edit.navigation.title" = "Edit Custom Token";
"wallet.section.hdWallet.title" = "HD Wallet";
"wallets.export.alertSheet.title" = "Export Private Key";
Expand Down Expand Up @@ -286,3 +285,7 @@
"Network" = "Network";
"MultiCoinWallet" = "Multi-Coin Wallet";
"LearnMore" = "Learn More";
"settings.helpCenter.title" = "Help Center";
"DailyUsage" = "Daily Usage";
"DeferredDeepLinking" = "Deferred Deep Linking";
"CrashReports" = "Crash Reports";
3 changes: 2 additions & 1 deletion Trust/Localization/fr.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@
"import.wallet.watch.placeholder" = "%@ Adresse";
"settings.joinCommunity.label.title" = "Rejoindre la communauté";
"settings.support.title" = "Support";
"settings.helpCenter.title" = "Help Center";
"tokens.token.edit.navigation.title" = "Modifier le jeton personnalisé";
"wallet.section.hdWallet.title" = "Portefeuille HD";
"wallets.export.alertSheet.title" = "Exporter la clé privée";
Expand Down Expand Up @@ -283,3 +282,5 @@
"EnableTestNetworks" = "Activer les réseaux de test";
"Network" = "Réseau";
"MultiCoinWallet" = "Portefeuille multi-monnaies";
"LearnMore" = "En savoir plus";
"settings.helpCenter.title" = "Centre d'aide";
3 changes: 2 additions & 1 deletion Trust/Localization/ja.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@
"import.wallet.watch.placeholder" = "%@アドレス";
"settings.joinCommunity.label.title" = "コミュニティに参加する";
"settings.support.title" = "サポート";
"settings.helpCenter.title" = "Help Center";
"tokens.token.edit.navigation.title" = "カスタムトークンの編集";
"wallet.section.hdWallet.title" = "HDウォレット";
"wallets.export.alertSheet.title" = "秘密鍵のエクスポート";
Expand Down Expand Up @@ -283,3 +282,5 @@
"EnableTestNetworks" = "テストネットワークを有効にする";
"Network" = "ネットワーク";
"MultiCoinWallet" = "マルチコインウォレット";
"LearnMore" = "さらに詳しく知る";
"settings.helpCenter.title" = "ヘルプセンター";
5 changes: 4 additions & 1 deletion Trust/Localization/ru.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@
"import.wallet.watch.placeholder" = "%@ Адрес";
"settings.joinCommunity.label.title" = "Вступить в сообщество";
"settings.support.title" = "Поддержка";
"settings.helpCenter.title" = "Центр поддержки";
"tokens.token.edit.navigation.title" = "Редактировать токен пользователя";
"wallet.section.hdWallet.title" = "HD-кошелек";
"wallets.export.alertSheet.title" = "Экспортировать приватный ключ";
Expand Down Expand Up @@ -258,3 +257,7 @@
"Network" = "Сеть";
"MultiCoinWallet" = "Мульти-монетный кошелек";
"LearnMore" = "Подробнее";
"settings.helpCenter.title" = "Центр поддержки";
"DailyUsage" = "Ежедневное использование";
"DeferredDeepLinking" = "Deferred Deep Linking";
"CrashReports" = "Отчеты О Сбоях";
8 changes: 8 additions & 0 deletions Trust/Localization/uk.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@
"MainWallet" = "Основний Гаманець";
"Address" = "Адреса";
"CreatingWallet" = "Створення Гаманця";
"WalletImported" = "Гаманець імпортований";
"SelectCoin" = "Виберіть монету";
"ImportMainWallet" = "Імпортувати основний гаманець";
"TestNetworks" = "Тестові мережі";
"EnableTestNetworks" = "Увімкнути тестові мережі";
"Network" = "Мережа";
"LearnMore" = "Дізнатися більше";
"settings.helpCenter.title" = "Довідковий центр";
1 change: 0 additions & 1 deletion Trust/Localization/vi.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@
"import.wallet.watch.placeholder" = "Địa chỉ %@";
"settings.joinCommunity.label.title" = "Tham gia cộng đồng";
"settings.support.title" = "Hỗ trợ";
"settings.helpCenter.title" = "Help Center";
"tokens.token.edit.navigation.title" = "Thêm đồng tiền mã hóa tùy chỉnh.";
"wallet.section.hdWallet.title" = "Ví HD";
"wallets.export.alertSheet.title" = "Xuất khóa cá nhân";
Expand Down
1 change: 0 additions & 1 deletion Trust/Localization/zh-Hans.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@
"import.wallet.watch.placeholder" = "%@ 地址";
"settings.joinCommunity.label.title" = "加入社区";
"settings.support.title" = "支持我们";
"settings.helpCenter.title" = "Help Center";
"tokens.token.edit.navigation.title" = "编辑自定义通证";
"wallet.section.hdWallet.title" = "HD 钱包";
"wallets.export.alertSheet.title" = "导出私钥";
Expand Down
12 changes: 6 additions & 6 deletions Trust/Settings/Types/Analitics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ enum Analitics: String {

var title: String {
switch self {
case .answer: return "Daily usage"
case .branch: return "Deffered deep linking"
case .crashlytics: return "Crash reports"
case .answer: return R.string.localizable.dailyUsage()
case .branch: return R.string.localizable.deferredDeepLinking()
case .crashlytics: return R.string.localizable.crashReports()
}
}

var description: String {
switch self {
case .crashlytics:
return NSLocalizedString("settings.analitics.crashlytics.description", value: "Help Trust developers to improve its product and service by automatically sending crash reports.", comment: "")
return R.string.localizable.settingsAnaliticsCrashlyticsDescription()
case .branch:
return NSLocalizedString("settings.analitics.branch.description", value: "Help Trust improve user engagement by sharing deep links redirects.", comment: "")
return R.string.localizable.settingsAnaliticsBranchDescription()
case .answer:
return NSLocalizedString("settings.analitics.answer.description", value: "Help Trust improve user experience by sharing app daily diagnostic.", comment: "")
return R.string.localizable.settingsAnaliticsAnswerDescription()
}
}

Expand Down
4 changes: 3 additions & 1 deletion Trust/Settings/Types/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ public struct Constants {
// social
public static let website = "https://trustwalletapp.com"
public static let twitterUsername = "trustwalletapp"
public static let telegramUsername = "trustwallet"
public static let defaultTelegramUsername = "trustwallet"
public static let facebookUsername = "trustwalletapp"

public static var localizedTelegramUsernames = ["ru": "trustwallet_ru", "vi": "trustwallet_vn", "es": "trustwallet_es", "zh": "trustwallet_cn", "ja": "trustwallet_jp", "de": "trustwallet_de", "fr": "trustwallet_fr"]

// support
public static let supportEmail = "[email protected]"
public static let donationAddress = "0x9f8284ce2cf0c8ce10685f537b1fff418104a317"
Expand Down
11 changes: 0 additions & 11 deletions Trust/Settings/Types/RPCServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,6 @@ enum RPCServer {
return URL(string: urlString)!
}

var wssURL: URL {
let urlString: String = {
switch self {
case .main: return "wss://mainnet.infura.io/ws/llyrtzQ3YhkdESt2Fzrk"
case .poa: return "wss://poa.infura.io"
case .classic, .callisto, .gochain: return "wss://localhost"
}
}()
return URL(string: urlString)!
}

var remoteURL: URL {
let urlString: String = {
switch self {
Expand Down
9 changes: 7 additions & 2 deletions Trust/Settings/Types/ServiceProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ enum URLServiceProvider {
case .twitter:
return URL(string: "twitter://user?screen_name=\(Constants.twitterUsername)")!
case .telegram:
return URL(string: "tg://resolve?domain=\(Constants.telegramUsername)")
return URL(string: "tg://resolve?domain=\(preferredTelegramUsername())")
case .facebook:
return URL(string: "fb://profile?id=\(Constants.facebookUsername)")
case .discord: return nil
Expand All @@ -58,7 +58,7 @@ enum URLServiceProvider {
case .twitter:
return "https://twitter.com/\(Constants.twitterUsername)"
case .telegram:
return "https://telegram.me/\(Constants.telegramUsername)"
return "https://telegram.me/\(preferredTelegramUsername())"
case .facebook:
return "https://www.facebook.com/\(Constants.facebookUsername)"
case .discord:
Expand Down Expand Up @@ -92,4 +92,9 @@ enum URLServiceProvider {
case .dappsOpenSea: return nil
}
}

private func preferredTelegramUsername() -> String {
let languageCode = NSLocale.preferredLanguageCode ?? ""
return Constants.localizedTelegramUsernames[languageCode] ?? Constants.defaultTelegramUsername
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,30 @@ final class BrowserConfigurationViewController: FormViewController {
guard let `self` = self else { return }
$0.title = self.viewModel.clearBrowserCacheTitle
}.onCellSelection { [weak self] _, _ in
guard let `self` = self else { return }
self.confirm(
title: self.viewModel.clearBrowserCacheConfirmTitle,
message: self.viewModel.clearBrowserCacheConfirmMessage,
okTitle: R.string.localizable.delete(),
okStyle: .destructive,
completion: { [weak self] result in
guard let `self` = self else { return }
switch result {
case .success:
self.delegate?.didPressDeleteCache(in: self)
case .failure: break
}
})
self?.confirmClear()
}.cellUpdate { cell, _ in
cell.textLabel?.textAlignment = .left
cell.textLabel?.textColor = .black
}
}

private func confirmClear() {
confirm(
title: viewModel.clearBrowserCacheConfirmTitle,
message: viewModel.clearBrowserCacheConfirmMessage,
okTitle: R.string.localizable.delete(),
okStyle: .destructive,
completion: { [weak self] result in
guard let `self` = self else { return }
switch result {
case .success:
self.delegate?.didPressDeleteCache(in: self)
case .failure: break
}
}
)
}

required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
Expand Down
21 changes: 12 additions & 9 deletions Trust/Settings/ViewControllers/SettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,24 +153,27 @@ final class SettingsViewController: FormViewController, Coordinator {
<<< linkProvider(type: .discord)

+++ Section()

<<< AppFormAppearance.button { button in
button.title = R.string.localizable.shareWithFriends()
button.cell.imageView?.image = R.image.settings_colorful_share()
}.onCellSelection { [unowned self] cell, _ in
self.helpUsCoordinator.presentSharing(in: self, from: cell.contentView)
}
<<< linkProvider(type: .helpCenter)

+++ Section()
<<< aboutRow()
<<< shareWithFriendsRow()

+++ Section()
<<< linkProvider(type: .helpCenter)
<<< aboutRow()

+++ Section()
<<< developersRow()
}

private func shareWithFriendsRow() -> ButtonRow {
return AppFormAppearance.button { button in
button.title = R.string.localizable.shareWithFriends()
button.cell.imageView?.image = R.image.settings_colorful_share()
}.onCellSelection { [unowned self] cell, _ in
self.helpUsCoordinator.presentSharing(in: self, from: cell.contentView)
}
}

private func walletsRow(for wallet: WalletInfo) -> ButtonRow {
let viewModel = WalletInfoViewModel(wallet: wallet)
return AppFormAppearance.button { row in
Expand Down
15 changes: 9 additions & 6 deletions Trust/Tokens/ViewControllers/NewTokenViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -171,18 +171,21 @@ final class NewTokenViewController: FormViewController {
firstly {
viewModel.info(for: contract)
}.done { [weak self] token in
self?.nameRow?.value = token.name
self?.decimalsRow?.value = token.decimals.description
self?.symbolRow?.value = token.symbol
self?.nameRow?.reload()
self?.decimalsRow?.reload()
self?.symbolRow?.reload()
self?.reloadFields(with: token)
}.ensure { [weak self] in
self?.hideLoading()
}.catch {_ in
//We could not find any info about this contract.This error is already logged in crashlytics.
}
}

private func reloadFields(with token: TokenObject) {
self.nameRow?.value = token.name
self.decimalsRow?.value = token.decimals.description
self.symbolRow?.value = token.symbol
self.nameRow?.reload()
self.decimalsRow?.reload()
self.symbolRow?.reload()
}

required init?(coder aDecoder: NSCoder) {
Expand Down
Loading

0 comments on commit b5c6cde

Please sign in to comment.