diff --git a/AlphaWallet/TokenScriptClient/Coordinators/EventSourceCoordinator.swift b/AlphaWallet/TokenScriptClient/Coordinators/EventSourceCoordinator.swift index 98f6fbaba..09e7de7bf 100644 --- a/AlphaWallet/TokenScriptClient/Coordinators/EventSourceCoordinator.swift +++ b/AlphaWallet/TokenScriptClient/Coordinators/EventSourceCoordinator.swift @@ -32,7 +32,7 @@ class EventSourceCoordinator { var fetchPromises = [Promise]() for each in xmlHandler.attributesWithEventSource { 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 { guard let tokenId = eachTokenHolder.tokenIds.first else { continue } diff --git a/AlphaWallet/Tokens/Helpers/TokenAdaptor.swift b/AlphaWallet/Tokens/Helpers/TokenAdaptor.swift index d1a3aa020..a8b3ca619 100644 --- a/AlphaWallet/Tokens/Helpers/TokenAdaptor.swift +++ b/AlphaWallet/Tokens/Helpers/TokenAdaptor.swift @@ -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 - public func getTokenHolders(forWallet account: Wallet, sourceFromEvents: Bool = true) -> [TokenHolder] { + public func getTokenHolders(forWallet account: Wallet, isSourcedFromEvents: Bool = true) -> [TokenHolder] { switch token.type { case .nativeCryptocurrency, .erc20, .erc875, .erc721ForTickets: return getNotSupportedByNonFungibleJsonTokenHolders(forWallet: account) @@ -29,7 +29,7 @@ class TokenAdaptor { let tokenType = NonFungibleFromJsonSupportedTokenHandling(token: token) switch tokenType { case .supported: - return getSupportedByNonFungibleJsonTokenHolders(forWallet: account, sourceFromEvents: sourceFromEvents) + return getSupportedByNonFungibleJsonTokenHolders(forWallet: account, isSourcedFromEvents: isSourcedFromEvents) case .notSupported: 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 var tokens = [Token]() for item in 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) } } @@ -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) } - 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 } let xmlHandler = XMLHandler(token: token, assetDefinitionStore: assetDefinitionStore) 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 filterValue: String if let implicitAttribute = EventSourceCoordinator.convertToImplicitAttribute(string: eventFilter.value) {