Integrate Ethermine (TaiChi replacement) #3266

pull/3269/head
Vladyslav shepitko 3 years ago
parent 1eb2f95f40
commit cff0d192f8
  1. 1
      AlphaWallet/Analytics/Models/AnalyticsTypes.swift
  2. 21
      AlphaWallet/Assets.xcassets/iconsSettingsTaiChi.imageset/Contents.json
  3. 8
      AlphaWallet/Assets.xcassets/iconsSettingsTaiChi.imageset/icons-settings-taichi.svg
  4. 1
      AlphaWallet/Core/Features.swift
  5. 1
      AlphaWallet/Localization/en.lproj/Localizable.strings
  6. 1
      AlphaWallet/Localization/es.lproj/Localizable.strings
  7. 1
      AlphaWallet/Localization/ja.lproj/Localizable.strings
  8. 1
      AlphaWallet/Localization/ko.lproj/Localizable.strings
  9. 1
      AlphaWallet/Localization/zh-Hans.lproj/Localizable.strings
  10. 16
      AlphaWallet/Settings/Types/Config.swift
  11. 31
      AlphaWallet/Settings/ViewControllers/AdvancedSettingsViewController.swift
  12. 10
      AlphaWallet/Settings/ViewModels/AdvancedSettingsViewModel.swift
  13. 2
      AlphaWallet/Transactions/Coordinators/SingleChainTransactionEtherscanDataCoordinator.swift
  14. 17
      AlphaWallet/Transfer/Coordinators/SendTransactionCoordinator.swift
  15. 3
      AlphaWallet/Transfer/Coordinators/TransactionConfirmationCoordinator.swift

@ -72,6 +72,7 @@ enum Analytics {
case transactionType
case name
case messageType
case isPrivateNetworkEnabled
case type
case isAllFunds
case addCustomChainType

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "icons-settings-taichi.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40">
<g fill="none" fill-rule="evenodd">
<g>
<path fill="#2F2F2F" d="M20 40C8.954 40 0 31.046 0 20S8.954 0 20 0s20 8.954 20 20-8.954 20-20 20z"/>
<path fill="#FEFEFE" d="M20 20c-4.97 0-9 4.03-9 9 0 4.81 3.78 8.75 8.54 8.99C9.81 37.75 2 29.79 2 20S9.81 2.25 19.54 2.01c.15-.01.3-.01.46-.01.16 0 .31 0 .46.01C25.22 2.25 29 6.19 29 11c0 4.97-4.03 9-9 9z"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 498 B

@ -14,4 +14,5 @@ enum Features {
static let isPromptForEmailListSubscriptionEnabled = true
static let isAlertsEnabled = false
static let isErc1155Enabled = true
static let isUsingPrivateNetwork = false
}

@ -89,6 +89,7 @@
"settings.backupWallet.button.title" = "Back up this Wallet";
"settings.showSeedPhrase.button.title" = "Show Seed Phrase";
"settings.walletConnect.button.title" = "WalletConnect";
"settings.useEthermineNetwork.button.title" = "Use Ethermine for Ethereum";
"settings.language.useSystem.title" = "Use System Setting";
"settings.version.label.title" = "Version";
"settings.tokenScriptStandard.title" = "TokenScript Compatibility";

@ -89,6 +89,7 @@
"settings.backupWallet.button.title" = "Hacer una copia de seguridad de este monedero";
"settings.showSeedPhrase.button.title" = "Show Seed Phrase";
"settings.walletConnect.button.title" = "WalletConnect";
"settings.useEthermineNetwork.button.title" = "Use Ethermine for Ethereum";
"settings.language.useSystem.title" = "Usar la configuración del sistema";
"settings.version.label.title" = "Versión";
"settings.tokenScriptStandard.title" = "Compatibilidad de TokenScript";

@ -89,6 +89,7 @@
"settings.backupWallet.button.title" = "Back up this Wallet";
"settings.showSeedPhrase.button.title" = "Show Seed Phrase";
"settings.walletConnect.button.title" = "WalletConnect";
"settings.useEthermineNetwork.button.title" = "Use Ethermine for Ethereum";
"settings.language.useSystem.title" = "システム設定を使用";
"settings.version.label.title" = "バージョン";
"settings.tokenScriptStandard.title" = "TokenScript Compatibility";

@ -89,6 +89,7 @@
"settings.backupWallet.button.title" = "Back up this Wallet";
"settings.showSeedPhrase.button.title" = "Show Seed Phrase";
"settings.walletConnect.button.title" = "WalletConnect";
"settings.useEthermineNetwork.button.title" = "Use Ethermine for Ethereum";
"settings.language.useSystem.title" = "시스템 설정 사용";
"settings.version.label.title" = "버전";
"settings.tokenScriptStandard.title" = "TokenScript Compatibility";

@ -89,6 +89,7 @@
"settings.backupWallet.button.title" = "备份此钱包";
"settings.showSeedPhrase.button.title" = "Show Seed Phrase";
"settings.walletConnect.button.title" = "WalletConnect";
"settings.useEthermineNetwork.button.title" = "Use Ethermine for Ethereum";
"settings.language.useSystem.title" = "使用系统设置";
"settings.version.label.title" = "版本";
"settings.tokenScriptStandard.title" = "TokenScript 兼容性";

@ -153,12 +153,27 @@ struct Config {
static let lastFetchedAutoDetectedTransactedTokenErc721BlockNumber = "lastFetchedAutoDetectedTransactedTokenErc721BlockNumber"
static let lastFetchedAutoDetectedTransactedTokenNonErc20BlockNumber = "lastFetchedAutoDetectedTransactedTokenNonErc20BlockNumber"
static let walletNames = "walletNames"
static let usePrivateNetwork = "usePrivateNetworkKey"
static let customRpcServers = "customRpcServers"
static let homePageURL = "homePageURL"
}
let defaults: UserDefaults
var usePrivateNetwork: Bool {
get {
guard Features.isUsingPrivateNetwork else { return false }
return defaults.bool(forKey: Keys.usePrivateNetwork)
}
set {
guard Features.isUsingPrivateNetwork else { return }
defaults.set(newValue, forKey: Keys.usePrivateNetwork)
}
}
var enabledServers: [RPCServer] {
get {
if let chainIds = defaults.array(forKey: Keys.enabledServers) as? [Int] {
@ -234,6 +249,7 @@ struct Config {
let oneInch = URL(string: "https://api.1inch.exchange")!
let honeySwapTokens = URL(string: "https://tokens.honeyswap.org/")!
let rampAssets = URL(string: "https://api-instant.ramp.network")!
let privateRpcUrl = URL(string: "https://rpc.ethermine.org")
func anyEnabledServer() -> RPCServer {
let servers = enabledServers

@ -73,10 +73,33 @@ extension AdvancedSettingsViewController: UITableViewDataSource {
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let row = viewModel.rows[indexPath.row]
let cell: SettingTableViewCell = tableView.dequeueReusableCell(for: indexPath)
cell.configure(viewModel: .init(titleText: row.title, subTitleText: nil, icon: row.icon))
switch row {
case .analytics, .changeCurrency, .changeLanguage, .clearBrowserCache, .console, .tokenScript:
let cell: SettingTableViewCell = tableView.dequeueReusableCell(for: indexPath)
cell.configure(viewModel: .init(titleText: row.title, subTitleText: nil, icon: row.icon))
return cell
case .usePrivateNetwork:
let cell: SwitchTableViewCell = tableView.dequeueReusableCell(for: indexPath)
cell.configure(viewModel: .init(titleText: row.title, icon: row.icon, value: config.usePrivateNetwork))
cell.delegate = self
return cell
}
}
}
extension AdvancedSettingsViewController: SwitchTableViewCellDelegate {
return cell
func cell(_ cell: SwitchTableViewCell, switchStateChanged isOn: Bool) {
guard let indexPath = cell.indexPath else { return }
switch viewModel.rows[indexPath.row] {
case .analytics, .changeCurrency, .changeLanguage, .clearBrowserCache, .console, .tokenScript:
break
case .usePrivateNetwork:
config.usePrivateNetwork = isOn
}
}
}
@ -116,6 +139,8 @@ extension AdvancedSettingsViewController: UITableViewDelegate {
delegate?.advancedSettingsViewControllerChangeCurrencySelected(in: self)
case .analytics:
delegate?.advancedSettingsViewControllerAnalyticsSelected(in: self)
case .usePrivateNetwork:
break
}
}
}

@ -10,10 +10,11 @@ import UIKit
struct AdvancedSettingsViewModel {
var rows: [AdvancedSettingsRow] = {
let privateNerworkRow: [AdvancedSettingsRow] = Features.isUsingPrivateNetwork ? [.usePrivateNetwork] : []
if Features.isLanguageSwitcherDisabled {
return [.console, .clearBrowserCache, .tokenScript]
return [.console, .clearBrowserCache, .tokenScript] + privateNerworkRow
} else {
return [.console, .clearBrowserCache, .tokenScript, .changeLanguage]
return [.console, .clearBrowserCache, .tokenScript, .changeLanguage] + privateNerworkRow
}
}()
@ -29,6 +30,7 @@ enum AdvancedSettingsRow: CaseIterable {
case changeLanguage
case changeCurrency
case analytics
case usePrivateNetwork
var title: String {
switch self {
@ -44,6 +46,8 @@ enum AdvancedSettingsRow: CaseIterable {
return R.string.localizable.settingsChangeCurrencyTitle()
case .analytics:
return R.string.localizable.settingsAnalitycsTitle()
case .usePrivateNetwork:
return R.string.localizable.settingsUseEthermineNetworkButtonTitle()
}
}
@ -61,6 +65,8 @@ enum AdvancedSettingsRow: CaseIterable {
return R.image.settings_currency()!
case .analytics:
return R.image.settings_analytics()!
case .usePrivateNetwork:
return R.image.iconsSettingsTaiChi()!
}
}
}

@ -245,7 +245,7 @@ class SingleChainTransactionEtherscanDataCoordinator: SingleChainTransactionData
strongSelf.delete(transactions: [transaction])
}
}).cauterize()
//The transaction might not be posted to this node yet (ie. it doesn't even think that this transaction is pending). Especially common if we post a transaction to TaiChi and fetch pending status through Etherscan
//The transaction might not be posted to this node yet (ie. it doesn't even think that this transaction is pending). Especially common if we post a transaction to Ethermine and fetch pending status through Etherscan
case .responseNotFound, .errorObjectParseError, .unsupportedVersion, .unexpectedTypeObject, .missingBothResultAndError, .nonArrayResponse, .none:
break
}

@ -100,7 +100,22 @@ class SendTransactionCoordinator {
}
private var rpcURL: URL {
session.server.rpcURL
session.server.rpcURLReplaceMainWithPrivateNetworkIfNeeded(config: config)
}
}
fileprivate extension RPCServer {
func rpcURLReplaceMainWithPrivateNetworkIfNeeded(config: Config) -> URL {
switch self {
case .main where config.usePrivateNetwork:
if let url = config.privateRpcUrl {
return url
} else {
return rpcURL
}
case .xDai, .kovan, .ropsten, .rinkeby, .poa, .sokol, .classic, .callisto, .goerli, .artis_sigma1, .artis_tau1, .binance_smart_chain, .binance_smart_chain_testnet, .custom, .heco, .heco_testnet, .main, .fantom, .fantom_testnet, .avalanche, .avalanche_testnet, .polygon, .mumbai_testnet, .optimistic, .optimisticKovan, .cronosTestnet:
return self.rpcURL
}
}
}

@ -326,7 +326,8 @@ extension TransactionConfirmationCoordinator {
var analyticsProperties: [String: AnalyticsEventPropertyValue] = [
Analytics.Properties.speedType.rawValue: speedType.rawValue,
Analytics.Properties.chain.rawValue: server.chainID,
Analytics.Properties.transactionType.rawValue: transactionType.rawValue
Analytics.Properties.transactionType.rawValue: transactionType.rawValue,
Analytics.Properties.isPrivateNetworkEnabled.rawValue: configurator.session.config.usePrivateNetwork,
]
switch configuration {
case .sendFungiblesTransaction(_, _, _, amount: let amount, _):

Loading…
Cancel
Save