Last active
February 28, 2020 16:17
-
-
Save fortmarek/632ecee9a96921d948fdab65c9e3f67a to your computer and use it in GitHub Desktop.
Vote function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func vote(votes: [Candidate.ID: Int], contractAddress: String) { | |
#1 | |
guard let wallet = userRepository.state.value.wallet else { return } | |
let nonZeroVotes = votes.filter { $0.value != 0 } | |
#2 | |
tezosClient | |
.rateContract(at: contractAddress) | |
.vote(nonZeroVotes) | |
.callPublisher(from: wallet, amount: Tez(0)) | |
.handleEvents(receiveOutput: { [weak self] output in | |
print(output) | |
self?.addVotes(votes, for: contractAddress) | |
}, receiveCompletion: { completion in | |
print(completion) | |
}) | |
.startAndStore(in: &cancellables) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment