Background:
The Polkadot App's frontend allows us to call claimer.lookup
link without any options. This returns a list of APNs and the associated accounts.
The substrate-frontend-template that we have been building off of requires that we include an option, which does not allow us to get all APNs and accounts. As a workaround we have tried to make a direct RPC call, but we cannot figure out how to decode the response.
I believe the response is SCALE encoded. Below is a blog post discussing some of the intricacies of doing this: https://www.shawntabrizi.com/substrate/querying-substrate-storage-via-rpc/
For the specifics of what we are currently trying you can look in this file:
https://github.com/Greenetwork/BLX_frontend_new/blob/maprefresh/src/MapRefresh.js#L21
The response to getKeysPaged
call is being decoded by the Polkadot frontend, but I haven't found a way to decode it in our https://github.com/Greenetwork/BLX_frontend_new
example response from chain:
[
"0x2df95c7f7f0d67daa549602785d7beae891ad457bf4da54990fa84a2acb148a20cf935632272b1131281c8c417ea1d513500000000000000000000000000000000000000000000000000000000000000",
"0x2df95c7f7f0d67daa549602785d7beae891ad457bf4da54990fa84a2acb148a21640c3ff7716f6e3d046d710919caccb3434343735380000000000000000000000000000000000000000000000000000",
"0x2df95c7f7f0d67daa549602785d7beae891ad457bf4da54990fa84a2acb148a229bde7c5407d4c0e698d76543e46e51c3334353039383600000000000000000000000000000000000000000000000000"
]
decoded result in Polkadot js apps frontend
[
[
[
0x3500000000000000000000000000000000000000000000000000000000000000
],
5Ec3KvnQdwYfLDgZB6JujjatVkHKbzMPQP5YojDAmia8YBuQ
],
[
[
0x3434343735380000000000000000000000000000000000000000000000000000
],
5EE6fRKB1Drd8cZAVHGuZJHpmQr7bV66Mz2VaXEPJCnJSChw
],
[
[
0x3334353039383600000000000000000000000000000000000000000000000000
],
5Ew5ExAtUSBEMw96ZMMvS5TsyR7RQfwuve6zpebVYJQDetYZ
]
]
example front-end-template response that needs to be decoded:
After further reading of https://www.shawntabrizi.com/substrate/transparent-keys-in-substrate/
the RPC response:
0x2df95c7f7f0d67daa549602785d7beae891ad457bf4da54990fa84a2acb148a2a0e98c1569443b450c93febfe626c7683331373035330000000000000000000000000000000000000000000000000000
---------------------- storage prefix key ------------------------+++++++ blake2 128 hash ++++++++------------------------ account id ----------------------------
But our account id
is of type Address32 so we need to do one more lookup and feed account id back into claimer.lookup