Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Query for Transactions and unpack result into concrete types #136

Open
KyleMoser opened this issue Mar 26, 2022 · 1 comment
Open

Query for Transactions and unpack result into concrete types #136

KyleMoser opened this issue Mar 26, 2022 · 1 comment

Comments

@KyleMoser
Copy link

KyleMoser commented Mar 26, 2022

Hi, I am building on top of the Lens client/query library and am trying to add a type to search transactions (e.g. GetTxsEvent to start with).

It seems like the cosmos RPC library types, for example GetTxsEventResponse, do not automatically unpack their internal fields. For example, GetTxsEventResponse has internal Messages [] where each Message is the Any type. For my team's own use, we need to decode these Messages (among other fields in the GetTxsEventResponse).

My general thoughts on achieving this are:

  1. The Lens ChainClientConfig needs to register the Modules e.g.
ChainClientConfig{
	//...
	Modules:        client.ModuleBasics,
}
  1. Then call e.g. tx.UnpackInterfaces(codec.InterfaceRegistry)

The question is: is the Lens team interested in this functionality being added as a PR (after I build out the TX library a bit more) and does the approach I discussed above make sense or is something better that I did not see included in the Lens or cosmos-sdk library.

@jtieri
Copy link
Contributor

jtieri commented Apr 26, 2022

I know right now we have the AppModuleBasics hardcoded to be initialized at runtime when building the ChainClient codec.

lens/client/config.go

Lines 27 to 49 in adaed6e

var (
ModuleBasics = []module.AppModuleBasic{
auth.AppModuleBasic{},
authz.AppModuleBasic{},
bank.AppModuleBasic{},
capability.AppModuleBasic{},
// TODO: add osmosis governance proposal types here
// TODO: add other proposal types here
gov.NewAppModuleBasic(
paramsclient.ProposalHandler, distrclient.ProposalHandler, upgradeclient.ProposalHandler, upgradeclient.CancelProposalHandler,
),
crisis.AppModuleBasic{},
distribution.AppModuleBasic{},
feegrant.AppModuleBasic{},
mint.AppModuleBasic{},
params.AppModuleBasic{},
slashing.AppModuleBasic{},
staking.AppModuleBasic{},
upgrade.AppModuleBasic{},
transfer.AppModuleBasic{},
ibc.AppModuleBasic{},
}
)

I believe the goal is to be able to use dynamic gRPC queries in the future which would allow dynamic initialization of the Msg types for a specific chain. I could be a bit off on this though.

@jackzampolin any thoughts on this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants