Remove build warnings

pull/2195/head
Hwee-Boon Yar 4 years ago
parent 577a3c41d5
commit 28ad948ae4
  1. 4
      AlphaWallet/Activities/Coordinators/ActivitiesCoordinator.swift
  2. 2
      AlphaWallet/Activities/ViewModels/ActivitiesViewModel.swift
  3. 2
      AlphaWallet/Activities/ViewModels/DefaultActivityCellViewModel.swift
  4. 2
      AlphaWallet/Activities/ViewModels/DefaultActivityViewModel.swift
  5. 1
      AlphaWallet/InCoordinator.swift
  6. 2
      AlphaWallet/Settings/Types/Config.swift
  7. 3
      AlphaWallet/Settings/ViewControllers/SettingsViewController.swift
  8. 2
      AlphaWallet/TokenScriptClient/Models/AssetAttribute.swift
  9. 10
      AlphaWallet/TokenScriptClient/Models/TokenScriptFilterParser.swift
  10. 6
      AlphaWallet/TokenScriptClient/Models/XMLHandler.swift
  11. 2
      AlphaWallet/Tokens/Coordinators/GetContractInteractions.swift
  12. 2
      AlphaWallet/Transactions/Coordinators/SingleChainTransactionEtherscanDataCoordinator.swift
  13. 2
      AlphaWallet/Transactions/ViewModels/TransactionsViewModel.swift
  14. 2
      AlphaWallet/UI/ButtonsBar.swift

@ -121,7 +121,7 @@ class ActivitiesCoordinator: Coordinator {
return (contract: eachContract, server: eachServer, xmlHandler: xmlHandler) return (contract: eachContract, server: eachServer, xmlHandler: xmlHandler)
} }
let contractsAndCardsOptional: [[(tokenContract: AlphaWallet.Address, server: RPCServer, card: TokenScriptCard, interpolatedFilter: String)]] = contractServerXmlHandlers.flatMap { eachContract, eachServer, xmlHandler in let contractsAndCardsOptional: [[(tokenContract: AlphaWallet.Address, server: RPCServer, card: TokenScriptCard, interpolatedFilter: String)]] = contractServerXmlHandlers.compactMap { eachContract, eachServer, xmlHandler in
var contractAndCard: [(tokenContract: AlphaWallet.Address, server: RPCServer, card: TokenScriptCard, interpolatedFilter: String)] = .init() var contractAndCard: [(tokenContract: AlphaWallet.Address, server: RPCServer, card: TokenScriptCard, interpolatedFilter: String)] = .init()
for card in xmlHandler.activityCards { for card in xmlHandler.activityCards {
let (filterName, filterValue) = card.eventOrigin.eventFilter let (filterName, filterValue) = card.eventOrigin.eventFilter
@ -367,7 +367,7 @@ extension ActivitiesCoordinator: TransactionDataCoordinatorDelegate {
case .success(let items): case .success(let items):
transactions = items transactions = items
reloadViewController() reloadViewController()
case .failure(let error): case .failure:
break break
} }
} }

@ -14,7 +14,7 @@ struct ActivitiesViewModel {
var newItems: [String: NSMutableArray] = [:] var newItems: [String: NSMutableArray] = [:]
for each in activities { for each in activities {
let date = formatter.string(from: each.date) let date = formatter.string(from: each.date)
var currentItems = newItems[date] ?? .init() let currentItems = newItems[date] ?? .init()
currentItems.add(each) currentItems.add(each)
newItems[date] = currentItems newItems[date] = currentItems
} }

@ -116,7 +116,7 @@ struct DefaultActivityCellViewModel {
case .erc20Sent, .erc20Received, .erc20OwnerApproved, .erc20ApprovalObtained, .nativeCryptoSent, .nativeCryptoReceived: case .erc20Sent, .erc20Received, .erc20OwnerApproved, .erc20ApprovalObtained, .nativeCryptoSent, .nativeCryptoReceived:
if let value = cardAttributes["amount"]?.uintValue { if let value = cardAttributes["amount"]?.uintValue {
let formatter = EtherNumberFormatter.short let formatter = EtherNumberFormatter.short
let value = formatter.string(from: BigInt(value) ?? BigInt(), decimals: activity.tokenObject.decimals) let value = formatter.string(from: BigInt(value))
return "\(sign)\(value) \(activity.tokenObject.symbol)" return "\(sign)\(value) \(activity.tokenObject.symbol)"
} else { } else {
return "" return ""

@ -43,7 +43,7 @@ struct DefaultActivityViewModel {
case .erc20Sent, .erc20Received, .erc20OwnerApproved, .erc20ApprovalObtained, .nativeCryptoSent, .nativeCryptoReceived: case .erc20Sent, .erc20Received, .erc20OwnerApproved, .erc20ApprovalObtained, .nativeCryptoSent, .nativeCryptoReceived:
if let value = cardAttributes["amount"]?.uintValue { if let value = cardAttributes["amount"]?.uintValue {
let formatter = EtherNumberFormatter.short let formatter = EtherNumberFormatter.short
let value = formatter.string(from: BigInt(value) ?? BigInt(), decimals: activity.tokenObject.decimals) let value = formatter.string(from: BigInt(value))
return "\(sign)\(value) \(activity.tokenObject.symbol)" return "\(sign)\(value) \(activity.tokenObject.symbol)"
} else { } else {
return "" return ""

@ -420,7 +420,6 @@ class InCoordinator: NSObject, Coordinator {
} }
private func createActivityCoordinator() -> ActivitiesCoordinator { private func createActivityCoordinator() -> ActivitiesCoordinator {
let realm = self.realm(forAccount: wallet)
let coordinator = ActivitiesCoordinator( let coordinator = ActivitiesCoordinator(
config: config, config: config,
sessions: walletSessions, sessions: walletSessions,

@ -199,7 +199,7 @@ extension Config {
} }
func saveWalletName(_ walletName: String, forAddress address: AlphaWallet.Address) { func saveWalletName(_ walletName: String, forAddress address: AlphaWallet.Address) {
var walletName = walletName.trimmed let walletName = walletName.trimmed
guard !walletName.isEmpty else { return } guard !walletName.isEmpty else { return }
var names = walletNames var names = walletNames
names[address] = walletName names[address] = walletName

@ -119,9 +119,6 @@ class SettingsViewController: UIViewController {
icon: row.icon) icon: row.icon)
) )
let serverToResolveEns = RPCServer.main
let address = account.address
firstly { firstly {
GetWalletNameCoordinator(config: config).getName(forAddress: account.address) GetWalletNameCoordinator(config: config).getName(forAddress: account.address)
}.done { [weak self] name in }.done { [weak self] name in

@ -112,7 +112,7 @@ struct AssetAttribute {
} else { } else {
originFound = nil originFound = nil
} }
case .some(.function), .some(.userEntry), .some(.userEntry), .some(.tokenId), .none: case .some(.function), .some(.userEntry), .some(.tokenId), .none:
originFound = possibleOrigin originFound = possibleOrigin
} }
} }

@ -194,19 +194,13 @@ struct TokenScriptFilterParser {
var buffer: [Character] = [] var buffer: [Character] = []
var escapeBuffer: [Character]? = nil var escapeBuffer: [Character]? = nil
var wasPreviousEscapedCharacter = false var wasPreviousEscapedCharacter = false
for (i, c) in expression.enumerated() { for (_, c) in expression.enumerated() {
let next: String?
if i + 1 < expression.count {
next = expression[i + 1]
} else {
next = nil
}
let previous = buffer.last.flatMap { String($0) } let previous = buffer.last.flatMap { String($0) }
if c == escape && escapeBuffer == nil { if c == escape && escapeBuffer == nil {
//start new escape //start new escape
escapeBuffer = .init() escapeBuffer = .init()
continue continue
} else if c == escape, var eb = escapeBuffer { } else if c == escape, let eb = escapeBuffer {
if escapeBuffer.isEmpty { if escapeBuffer.isEmpty {
//Invalid escape sequence with double backward slash (\\) //Invalid escape sequence with double backward slash (\\)
if !buffer.isEmpty { if !buffer.isEmpty {

@ -309,7 +309,7 @@ private class PrivateXMLHandler {
let (xml, hasValidTokenScriptFile) = PrivateXMLHandler.storeXmlAccordingToTokenScriptStatus(xmlString: xmlString, tokenScriptStatus: tokenScriptStatus) let (xml, hasValidTokenScriptFile) = PrivateXMLHandler.storeXmlAccordingToTokenScriptStatus(xmlString: xmlString, tokenScriptStatus: tokenScriptStatus)
self.xml = xml self.xml = xml
self.hasValidTokenScriptFile = hasValidTokenScriptFile self.hasValidTokenScriptFile = hasValidTokenScriptFile
if isBase ?? false { if isBase {
self.server = .any self.server = .any
} else { } else {
self.server = PrivateXMLHandler.extractServer(fromXML: xml, xmlContext: xmlContext, matchingContract: contract).flatMap { .server($0) } self.server = PrivateXMLHandler.extractServer(fromXML: xml, xmlContext: xmlContext, matchingContract: contract).flatMap { .server($0) }
@ -680,7 +680,7 @@ public class XMLHandler {
} }
var tokenViewIconifiedHtml: (html: String, style: String) { var tokenViewIconifiedHtml: (html: String, style: String) {
let (html: html, style: style) = privateXMLHandler.tokenViewIconifiedHtml let (html: html, style: _) = privateXMLHandler.tokenViewIconifiedHtml
if let baseXMLHandler = baseXMLHandler { if let baseXMLHandler = baseXMLHandler {
if html.isEmpty { if html.isEmpty {
return baseXMLHandler.tokenViewIconifiedHtml return baseXMLHandler.tokenViewIconifiedHtml
@ -693,7 +693,7 @@ public class XMLHandler {
} }
var tokenViewHtml: (html: String, style: String) { var tokenViewHtml: (html: String, style: String) {
let (html: html, style: style) = privateXMLHandler.tokenViewHtml let (html: html, style: _) = privateXMLHandler.tokenViewHtml
if let baseXMLHandler = baseXMLHandler { if let baseXMLHandler = baseXMLHandler {
if html.isEmpty { if html.isEmpty {
return baseXMLHandler.tokenViewHtml return baseXMLHandler.tokenViewHtml

@ -10,7 +10,7 @@ import SwiftyJSON
class GetContractInteractions { class GetContractInteractions {
func getErc20Interactions(contractAddress: AlphaWallet.Address? = nil, address: AlphaWallet.Address, server: RPCServer, startBlock: Int? = nil, completion: @escaping ([Transaction]) -> Void) { func getErc20Interactions(contractAddress: AlphaWallet.Address? = nil, address: AlphaWallet.Address, server: RPCServer, startBlock: Int? = nil, completion: @escaping ([Transaction]) -> Void) {
guard var etherscanURL = server.etherscanAPIURLForERC20TxList(for: address, startBlock: startBlock) else { return } guard let etherscanURL = server.etherscanAPIURLForERC20TxList(for: address, startBlock: startBlock) else { return }
Alamofire.request(etherscanURL).validate().responseJSON { response in Alamofire.request(etherscanURL).validate().responseJSON { response in
switch response.result { switch response.result {
case .success(let value): case .success(let value):

@ -84,7 +84,7 @@ class SingleChainTransactionEtherscanDataCoordinator: SingleChainTransactionData
server: session.server, server: session.server,
startBlock: startBlock startBlock: startBlock
) { result in ) { result in
if let maxBlockNumber = result.map { $0.blockNumber }.max() { if let maxBlockNumber = result.map({ $0.blockNumber }).max() {
Config.setLastFetchedErc20InteractionBlockNumber(maxBlockNumber, server: self.session.server, wallet: wallet) Config.setLastFetchedErc20InteractionBlockNumber(maxBlockNumber, server: self.session.server, wallet: wallet)
} }
self.update(items: result) self.update(items: result)

@ -14,7 +14,7 @@ struct TransactionsViewModel {
var newItems: [String: NSMutableArray] = [:] var newItems: [String: NSMutableArray] = [:]
for transaction in transactions { for transaction in transactions {
let date = formatter.string(from: transaction.date) let date = formatter.string(from: transaction.date)
var currentItems = newItems[date] ?? .init() let currentItems = newItems[date] ?? .init()
currentItems.add(transaction) currentItems.add(transaction)
newItems[date] = currentItems newItems[date] = currentItems
} }

@ -142,7 +142,7 @@ class ButtonsBarBackgroundView: UIView {
} }
} }
@objc class ButtonsBar: UIView { class ButtonsBar: UIView {
static let buttonsHeight = CGFloat(ScreenChecker().isNarrowScreen ? 38 : 48) static let buttonsHeight = CGFloat(ScreenChecker().isNarrowScreen ? 38 : 48)
//A gap so it doesn't stick to the bottom of devices without a bottom safe area //A gap so it doesn't stick to the bottom of devices without a bottom safe area
static let marginAtBottomScreen = CGFloat(3) static let marginAtBottomScreen = CGFloat(3)

Loading…
Cancel
Save