There is 2 problems that keep us from doing it.
- Recursive datatypes are not available in the sophia language right now. This is planned to be implemented after the next hardfork but is a limiting factor right now in discovery of delegation chains, as delegations can be done with recursion and thus will be great to be represented by a recursive datatypes. There are possible workarounds, but they would be very costly in gas and amount of code.
- There is no
Chain.balance(height)
function in sophia, without this fetching stakes for past polls can’t be done in a trustless and reliable way within the smart contract. If we would have this feature in sophia it would be quite costly as well, as either all past account states would have to be persisted or will have to be recalculated for every call. - Some endpoints need lots of calls, as explained in a prior post. Imagine 1000 voters, having to check their balances would be 1000 requests to the node. Then voters may have delegations and delegations can be recursive, for each we will have to get balance at height to show a preliminary result.
Even if this would be possible to do without a backend it would lead to extensive load times when opening the aepp, in early testing over a minute for polls with > 50 participants.
All of these can easily be overcome by using a trustless backend server, that can be hosted and verified by anyone.