Merge branch 'master' into with-rise-time-patch

pull/505/head
James Sangalli 6 years ago committed by GitHub
commit 911cd8fd6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      AlphaWallet/InCoordinator.swift
  2. 10
      AlphaWallet/Tokens/Coordinators/TokensCoordinator.swift
  3. 6
      AlphaWallet/Tokens/Types/TokensDataStore.swift

@ -572,7 +572,7 @@ extension InCoordinator: TokensCoordinatorDelegate {
func addImported(contract: String) {
let tokensCoordinator = coordinators.first { $0 is TokensCoordinator } as? TokensCoordinator
tokensCoordinator?.addToken(for: contract)
tokensCoordinator?.addImportedToken(for: contract)
}
}

@ -139,12 +139,20 @@ class TokensCoordinator: Coordinator {
}
}
func addToken(for contract: String) {
//Adding a token may fail if we lose connectivity while fetching the contract details (e.g. name and balance). So we remove the contract from the hidden list (if it was there) so that the app has the chance to add it automatically upon auto detection at startup
func addImportedToken(for contract: String) {
delete(hiddenContract: contract)
addToken(for: contract) {
self.tokensViewController.fetch()
}
}
private func delete(hiddenContract contract: String) {
guard let hiddenContract = storage.hiddenContracts.first(where: { $0.contract.sameContract(as: contract) }) else { return }
//TODO we need to make sure it's all uppercase?
storage.delete(hiddenContracts: [hiddenContract])
}
func newTokenViewController() -> NewTokenViewController {
let controller = NewTokenViewController()
controller.delegate = self

@ -322,6 +322,12 @@ class TokensDataStore {
}
}
func delete(hiddenContracts: [HiddenContract]) {
realm.beginWrite()
realm.delete(hiddenContracts)
try! realm.commitWrite()
}
enum TokenUpdate {
case value(BigInt)
case isDisabled(Bool)

Loading…
Cancel
Save