From f30c73b365d04f2b025a346e7e54a80775e0b2bb Mon Sep 17 00:00:00 2001 From: Hwee-Boon Yar Date: Sat, 25 Aug 2018 23:40:25 +0800 Subject: [PATCH] Remove unnecessary func arg, simplifying code --- AlphaWallet/AssetDefinition/XMLHandler.swift | 16 ++++++---------- AlphaWallet/Settings/Types/Config.swift | 3 +-- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/AlphaWallet/AssetDefinition/XMLHandler.swift b/AlphaWallet/AssetDefinition/XMLHandler.swift index feaee3814..88b4f95f2 100644 --- a/AlphaWallet/AssetDefinition/XMLHandler.swift +++ b/AlphaWallet/AssetDefinition/XMLHandler.swift @@ -38,7 +38,6 @@ private class PrivateXMLHandler { func getFifaInfoForTicket(tokenId tokenBytes32: BigUInt, index: UInt16) -> Token { guard tokenBytes32 != 0 else { return .empty } - let lang = getLang() var values = [String: AssetAttributeValue]() for (name, attribute) in fields { let value = attribute.extract(from: tokenBytes32) @@ -48,7 +47,7 @@ private class PrivateXMLHandler { return Token( id: tokenBytes32, index: index, - name: getName(lang: lang), + name: getName(), values: values ) } @@ -72,14 +71,15 @@ private class PrivateXMLHandler { return fields } - func getName(lang: String) -> String { + func getName() -> String { + let lang = getLang() if let name = contract?["name"].getElementWithLangAttribute(equals: lang)?.text { return name } return "N/A" } - func getLang() -> String { + private func getLang() -> String { let lang = Locale.preferredLanguages[0] if lang.hasPrefix("en") { return "en" @@ -138,12 +138,8 @@ public class XMLHandler { return privateXMLHandler.getFifaInfoForTicket(tokenId: tokenBytes32, index: index) } - func getName(lang: String) -> String { - return privateXMLHandler.getName(lang: lang) - } - - func getLang() -> String { - return privateXMLHandler.getLang() + func getName() -> String { + return privateXMLHandler.getName() } func getIssuer() -> String { diff --git a/AlphaWallet/Settings/Types/Config.swift b/AlphaWallet/Settings/Types/Config.swift index 04b3f7a22..84e15b677 100644 --- a/AlphaWallet/Settings/Types/Config.swift +++ b/AlphaWallet/Settings/Types/Config.swift @@ -143,8 +143,7 @@ struct Config { func createDefaultTicketToken(forContract contract: String) -> ERCToken? { guard let contractAddress = Address(string: contract) else { return nil } let xmlHandler = XMLHandler(contract: contract) - let lang = xmlHandler.getLang() - let name = xmlHandler.getName(lang: lang) + let name = xmlHandler.getName() //TODO get symbol from RPC node, but this doesn't provide much benefit as it is a hardcoded //placeholder anyway //GetSymbolCoordinator(web3: Web3Swift()).getSymbol(for: contractAddress) { result in }