Exernal
Describe the feature you'd like
The output of stake-address-info should be flattened in order to make json parsing easier.
Dynamic field names like the stake address hex value require custom parsing in most languages.
Current:
$ cardano-cli shelley query stake-address-info --address $(cat bcsh_owner.staking.addr) --cardano-mode --testnet-magic 42
{
"e0bd6adc2c7528c379f2af60929e901b1e77d92c754f2e345456063e04": {
"delegation": "44e0cb4449c0adb0821cb34dc12ec44694d6e7936f6d11f8a146f91b",
"rewardAccountBalance": 0
}
}
Recommended:
$ cardano-cli shelley query stake-address-info --address $(cat bcsh_owner.staking.addr) --cardano-mode --testnet-magic 42
{
"address: "e0bd6adc2c7528c379f2af60929e901b1e77d92c754f2e345456063e04",
"delegation": "44e0cb4449c0adb0821cb34dc12ec44694d6e7936f6d11f8a146f91b",
"rewardAccountBalance": 0
}
Describe alternatives you've considered
Considered writing a custom parser, but it would be easier to just have you restructure the json on the node side.
@AndrewWestberg: With the query stake-address-info command, I've been intending to implement it such that users can query multiple stake addresses and get an output like this:
{
"stakeAddress0": {
"delegation": "stakePoolId0",
"rewardAccountBalance": 0
},
"stakeAddress1": {
"delegation": "stakePoolId1",
"rewardAccountBalance": 0
},
"stakeAddress2": {
"delegation": "stakePoolId2",
"rewardAccountBalance": 0
}
}
In that case, I think that it's useful to be able to get the information about a particular stake address by performing a lookup by key, e.g. obj['e0bd6adc2c7528c379f2af60929e901b1e77d92c754f2e345456063e04'].
If we were to go the route you've suggested, we'd instead return an array of stake address info objects and, in that case, one would need to iterate over the array in order to find the info for a particular stake address. To me, this seems a bit clunky to work with.
What are your thoughts?
@intricate I would prefer an array of stake addresses. Once we make the address itself a key, we have to do polymorphic parsing on the json side which is what is problematic.
[
{
"address: "<address_1>",
"delegation": "<delegation_1>",
"rewardAccountBalance": <balance_1>
},
{
"address: "<address_2>",
"delegation": "<delegation_2>",
"rewardAccountBalance": <balance_2>
},
{
"address: "<address_3>",
"delegation": "<delegation_3>",
"rewardAccountBalance": <balance_3>
}
]
@intricate After looking at it some more, it's not the end of the world to do it your way. I just have to parse the keys into a map at the top level. Feel free to either implement or just close. Developer's choice. ;)
Actually, after looking at it again and asking others for opinions, I think we should flatten it as you've suggested. Thanks.
@AndrewWestberg I think PR #1671 is what you want .
Most helpful comment
Actually, after looking at it again and asking others for opinions, I think we should flatten it as you've suggested. Thanks.