Custom modules: CLI queries with --height flag doesn't return contextualised data
RaulBernal opened this issue · 1 comments
I created a new "applicant" for custom module "plasticcredit" at height 124115
https://empowerchain.exploreme.pro/transaction/E6B45B722D0368D22E32356355B1939A07CF8B94D2BCD0629D7FF60E49FD9B5A
I modify that "applicant id" at block 124153
https://empowerchain.exploreme.pro/transaction/45613A1896AEEFA76D131E33721416B924F65750C402A9D9D3E18A898E23B7F2
The error is that the --height
flag is ignored and the context is not taken into account in the CLI query function.
Therefore, it does not return an error if you ask for an "applicant" before the creation block.
empowerd query plasticcredit applicant 9 --height 1
applicant:
admin: empower153hxvnx24h07aptul43fsuyeq7kgt2erlugswu
description: New description
id: "9"
name: Raul2
The initial value it had (before being modified) is not shown either.
It should show "Raul" as name and "Just by messing around..." as description
empowerd query plasticcredit applicant 9 --height 124116
applicant:
admin: empower153hxvnx24h07aptul43fsuyeq7kgt2erlugswu
description: New description
id: "9"
name: Raul2
As result, always displaying the last value, so that no "history" can be built on an "applicant" and how it has changed over time.
I think the bug is at function CmdQueryApplicant()
at /x/plasticcredit/client/cli/query.go#L122
You should change at line 128:
clientCtx := client.GetClientContextFromCmd(cmd)
by
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
It seems that all custom modules are affected:
https://github.com/search?q=repo%3AEmpowerPlastic%2Fempowerchain%20GetClientContextFromCmd&type=code