SimplyStaking / polkadot_api_server

API Server in JavaScript for Querying Polkadot Nodes
Apache License 2.0
32 stars 15 forks source link

The request does not work #3

Closed ponchik69 closed 4 years ago

ponchik69 commented 4 years ago

The request /api/query/staking/stakers return this: {"error":"TypeError: api.query.staking.stakers is not a function"} I suppose that api.query.staking.stakers in function getStakingStakers must be api.query.staking.nominators, but I'm not so sure.

So I canceled my PR.

DanielMagro97 commented 4 years ago

Hi Vladmir,\ thanks for opening an issue about this, we are aware of it and will be pushing a release soon. The replacement of api.query.staking.stakers is now api.query.staking.erasStakers. This takes the websocket of a node the API is connected to, the account id being queried, and optionally the era index (if unspecified will use the active era index) as parameters. The total, own and value fields are sometimes returned as decimal, and other times as hex, depending on the magnitude of the value, so it's important to detect and decode accordingly.

.../api/query/staking/erasStakers?websocket=ws://1.2.3.4:9944&account_id=F4LocUbsPrcC8xVap4wiTgDakzn3xFyXneuYDHRaHxnb6dH
{
    "result": {
        "total": "0x0000000000000000005ed57263f01574",
        "own": 130989253937,
        "others": [
            {
                "who": "DixnRtQUuQeuFkh5nyTvd8BDhuKsd4fpgnkkrFtety7BR3o",
                "value": 3776686589013
            },
            {
                "who": "EMdZSpRK9J79QhPHhxX9Lw1CEPjh48FTvrJHVswmcRf36sa",
                "value": "0x0000000000000000005ed1e4904eabee"
            }
        ]
    }
}