Merge pull request #634 from alpha-wallet/remove-unnecessary-arg-in-xmlhandler-getName

Remove unnecessary func arg, simplifying code
pull/623/merge
James Sangalli 6 years ago committed by GitHub
commit 119666d80f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      AlphaWallet/AssetDefinition/XMLHandler.swift
  2. 5
      AlphaWallet/Settings/Types/Config.swift

@ -47,7 +47,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)
@ -57,7 +56,7 @@ private class PrivateXMLHandler {
return Token(
id: tokenBytes32,
index: index,
name: getName(lang: lang),
name: getName(),
values: values
)
}
@ -81,7 +80,8 @@ 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 {
if contractAddress.sameContract(as: Constants.ticketContractAddress) || contractAddress.sameContract(as: Constants.ticketContractAddressRopsten ) {
return "\(Constants.fifaWorldCup2018TokenNamePrefix) \(name)"
@ -138,7 +138,7 @@ private class PrivateXMLHandler {
}
}
func getLang() -> String {
private func getLang() -> String {
let lang = Locale.preferredLanguages[0]
if lang.hasPrefix("en") {
return "en"
@ -197,8 +197,8 @@ public class XMLHandler {
return privateXMLHandler.getFifaInfoForTicket(tokenId: tokenBytes32, index: index)
}
func getName(lang: String) -> String {
return privateXMLHandler.getName(lang: lang)
func getName() -> String {
return privateXMLHandler.getName()
}
/// Expected to return names like "cryptokitties", "tickets" that are specified in the asset definition. If absent, fallback to "tokens"

@ -133,8 +133,11 @@ struct Config {
func getContractLocalizedName(forContract contract: String) -> String? {
guard let contractAddress = Address(string: contract) else { return nil }
let xmlHandler = XMLHandler(contract: contract)
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 }
let lang = xmlHandler.getLang()
let name = xmlHandler.getName(lang: lang)
switch server {
case .main, .ropsten:
return name

Loading…
Cancel
Save