Add balances to squid accounts

I started a developer documentation (Duniter | Developer guide) to explain these kind of things, but I have less time (Je ne suis plus à plein temps!), so it’s moving slowly.

To get the free balance, you have to use storage.system.account and not storage.balances.account. This does not account for unclaimed UDs.

It is the goal to be able to get balance from indexer (#11) but that’s not an easy task. So for now, it makes sense to ask directly to Duniter and compute unclaimed UDs.

Because it is not done yet. And it is not done yet because it is not easy. From indexer point of view, to get the balance, you have to handle for every kind of balance change event or directly listen on storage. And if you want to have unclaimed UDs you have to update as many accounts as there are identities at every new UD.

This “unclaimed UD” optimization was necessary (Duniter side) and discussed here:

If only all “newbies” were developing a full Duniter client :joy_cat:

Due to the nature of blockchain, we have to keep things quite minimal, especially what we want to happen at a high rate (money transfers). That’s the very reason of the UD optimization.

Yes it is. The indexer role is to make app development as easy as possible and to counterbalance the “minimalistic” nature of blockchain by providing as rich features as affordable. See #36 for indexer optimizations.

read more on pallet balances

For people who want to read more:

You have a bit more info on the events in the doc https://paritytech.github.io/polkadot-sdk/master/pallet_balances/pallet/enum.Event.html.

If you want examples:

> https://squid.gdev.coinduf.eu/v1/graphql
query Events($name: String!) {
  event(where: {name: {_eq: $name}}, limit: 1) {
    id
  }
}
{"name": "Endowed"}

And replace name by the event you want to test.

TODO check why UniversalDividend.UdsClaimed does not come with Balances.Issued but Balances.Deposit.

I’ll have a look at your MR !27. I hope to see unclaimed UD indexing ^^.

3 Likes