|
|
|
@ -114,7 +114,7 @@ class TokensDataStore { |
|
|
|
|
self.scheduledTimerForPricesUpdate() |
|
|
|
|
self.scheduledTimerForEthBalanceUpdate() |
|
|
|
|
|
|
|
|
|
updateERC875TokensToLocalizedName() |
|
|
|
|
fetchTokenNamesForNonFungibleTokensIfEmpty() |
|
|
|
|
} |
|
|
|
|
private func addEthToken() { |
|
|
|
|
//Check if we have previos values. |
|
|
|
@ -171,13 +171,7 @@ class TokensDataStore { |
|
|
|
|
completion: @escaping (ResultResult<String, AnyError>.t) -> Void) { |
|
|
|
|
let address = Address(string: addressString) |
|
|
|
|
getNameCoordinator.getName(for: address!) { (result) in |
|
|
|
|
let xmlName = XMLHandler(contract: address!.eip55String).getName() |
|
|
|
|
if xmlName == "N/A" { |
|
|
|
|
completion(result) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
let fullName = try! result.dematerialize().description + " " + xmlName |
|
|
|
|
completion(.success(fullName)) |
|
|
|
|
completion(result) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -527,12 +521,20 @@ class TokensDataStore { |
|
|
|
|
}, selector: #selector(Operation.main), userInfo: nil, repeats: true) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public func updateERC875TokensToLocalizedName() { |
|
|
|
|
public func fetchTokenNamesForNonFungibleTokensIfEmpty() { |
|
|
|
|
assetDefinitionStore.forEachContractWithXML { contract in |
|
|
|
|
if let localizedName = config.getContractLocalizedName(forContract: contract) { |
|
|
|
|
if let storedToken = enabledObject.first(where: { $0.contract.sameContract(as: contract) }) { |
|
|
|
|
//TODO multiple realm writes in a loop. Should we group them together? |
|
|
|
|
updateTokenName(token: storedToken, to: localizedName) |
|
|
|
|
let localizedName = XMLHandler(contract: contract).getName() |
|
|
|
|
if localizedName != "N/A" { |
|
|
|
|
if let storedToken = self.enabledObject.first(where: { $0.contract.sameContract(as: contract) }), storedToken.name.isEmpty { |
|
|
|
|
getContractName(for: contract) { result in |
|
|
|
|
switch result { |
|
|
|
|
case .success(let name): |
|
|
|
|
//TODO multiple realm writes in a loop. Should we group them together? |
|
|
|
|
self.updateTokenName(token: storedToken, to: name) |
|
|
|
|
case .failure: |
|
|
|
|
break |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|