Rename bool variable/label to be more idiomatic

pull/2849/head
Hwee-Boon Yar 3 years ago
parent b34809f2ed
commit ea298dcc19
  1. 2
      AlphaWallet/TokenScriptClient/Coordinators/EventSourceCoordinator.swift
  2. 12
      AlphaWallet/Tokens/Helpers/TokenAdaptor.swift

@ -32,7 +32,7 @@ class EventSourceCoordinator {
var fetchPromises = [Promise<Void>]() var fetchPromises = [Promise<Void>]()
for each in xmlHandler.attributesWithEventSource { for each in xmlHandler.attributesWithEventSource {
guard let eventOrigin = each.eventOrigin else { continue } guard let eventOrigin = each.eventOrigin else { continue }
let tokenHolders = TokenAdaptor(token: token, assetDefinitionStore: assetDefinitionStore, eventsDataStore: eventsDataStore).getTokenHolders(forWallet: wallet, sourceFromEvents: false) let tokenHolders = TokenAdaptor(token: token, assetDefinitionStore: assetDefinitionStore, eventsDataStore: eventsDataStore).getTokenHolders(forWallet: wallet, isSourcedFromEvents: false)
for eachTokenHolder in tokenHolders { for eachTokenHolder in tokenHolders {
guard let tokenId = eachTokenHolder.tokenIds.first else { continue } guard let tokenId = eachTokenHolder.tokenIds.first else { continue }

@ -21,7 +21,7 @@ class TokenAdaptor {
} }
//`sourceFromEvents`: We'll usually source from events if available, except when we are actually using this func to create the filter to fetch the events //`sourceFromEvents`: We'll usually source from events if available, except when we are actually using this func to create the filter to fetch the events
public func getTokenHolders(forWallet account: Wallet, sourceFromEvents: Bool = true) -> [TokenHolder] { public func getTokenHolders(forWallet account: Wallet, isSourcedFromEvents: Bool = true) -> [TokenHolder] {
switch token.type { switch token.type {
case .nativeCryptocurrency, .erc20, .erc875, .erc721ForTickets: case .nativeCryptocurrency, .erc20, .erc875, .erc721ForTickets:
return getNotSupportedByNonFungibleJsonTokenHolders(forWallet: account) return getNotSupportedByNonFungibleJsonTokenHolders(forWallet: account)
@ -29,7 +29,7 @@ class TokenAdaptor {
let tokenType = NonFungibleFromJsonSupportedTokenHandling(token: token) let tokenType = NonFungibleFromJsonSupportedTokenHandling(token: token)
switch tokenType { switch tokenType {
case .supported: case .supported:
return getSupportedByNonFungibleJsonTokenHolders(forWallet: account, sourceFromEvents: sourceFromEvents) return getSupportedByNonFungibleJsonTokenHolders(forWallet: account, isSourcedFromEvents: isSourcedFromEvents)
case .notSupported: case .notSupported:
return getNotSupportedByNonFungibleJsonTokenHolders(forWallet: account) return getNotSupportedByNonFungibleJsonTokenHolders(forWallet: account)
} }
@ -66,12 +66,12 @@ class TokenAdaptor {
} }
} }
private func getSupportedByNonFungibleJsonTokenHolders(forWallet account: Wallet, sourceFromEvents: Bool) -> [TokenHolder] { private func getSupportedByNonFungibleJsonTokenHolders(forWallet account: Wallet, isSourcedFromEvents: Bool) -> [TokenHolder] {
let balance = token.balance let balance = token.balance
var tokens = [Token]() var tokens = [Token]()
for item in balance { for item in balance {
let jsonString = item.balance let jsonString = item.balance
if let token = getTokenForNonFungible(forJSONString: jsonString, inWallet: account, server: self.token.server, sourceFromEvents: sourceFromEvents) { if let token = getTokenForNonFungible(forJSONString: jsonString, inWallet: account, server: self.token.server, isSourcedFromEvents: isSourcedFromEvents) {
tokens.append(token) tokens.append(token)
} }
} }
@ -157,12 +157,12 @@ class TokenAdaptor {
XMLHandler(token: token, assetDefinitionStore: assetDefinitionStore).getToken(name: name, symbol: symbol, fromTokenIdOrEvent: tokenIdOrEvent, index: index, inWallet: account, server: server, tokenType: token.type) XMLHandler(token: token, assetDefinitionStore: assetDefinitionStore).getToken(name: name, symbol: symbol, fromTokenIdOrEvent: tokenIdOrEvent, index: index, inWallet: account, server: server, tokenType: token.type)
} }
private func getTokenForNonFungible(forJSONString jsonString: String, inWallet account: Wallet, server: RPCServer, sourceFromEvents: Bool) -> Token? { private func getTokenForNonFungible(forJSONString jsonString: String, inWallet account: Wallet, server: RPCServer, isSourcedFromEvents: Bool) -> Token? {
guard let data = jsonString.data(using: .utf8), let nonFungible = nonFungible(fromJsonData: data) else { return nil } guard let data = jsonString.data(using: .utf8), let nonFungible = nonFungible(fromJsonData: data) else { return nil }
let xmlHandler = XMLHandler(token: token, assetDefinitionStore: assetDefinitionStore) let xmlHandler = XMLHandler(token: token, assetDefinitionStore: assetDefinitionStore)
let event: EventInstance? let event: EventInstance?
if sourceFromEvents, let attributeWithEventSource = xmlHandler.attributesWithEventSource.first, let eventFilter = attributeWithEventSource.eventOrigin?.eventFilter, let eventName = attributeWithEventSource.eventOrigin?.eventName, let eventContract = attributeWithEventSource.eventOrigin?.contract { if isSourcedFromEvents, let attributeWithEventSource = xmlHandler.attributesWithEventSource.first, let eventFilter = attributeWithEventSource.eventOrigin?.eventFilter, let eventName = attributeWithEventSource.eventOrigin?.eventName, let eventContract = attributeWithEventSource.eventOrigin?.contract {
let filterName = eventFilter.name let filterName = eventFilter.name
let filterValue: String let filterValue: String
if let implicitAttribute = EventSourceCoordinator.convertToImplicitAttribute(string: eventFilter.value) { if let implicitAttribute = EventSourceCoordinator.convertToImplicitAttribute(string: eventFilter.value) {

Loading…
Cancel
Save