Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Figure out how to use proto.Any registry #393

Closed
ethanfrey opened this issue Aug 17, 2020 · 7 comments
Closed

Figure out how to use proto.Any registry #393

ethanfrey opened this issue Aug 17, 2020 · 7 comments

Comments

@ethanfrey
Copy link
Contributor

See cosmos/cosmos-sdk#6722

We need to:

  1. Figure out how to set up an registry of type names <-> classes lookup (I think some of this is done with decorators)
  2. See if this endpoint let's us properly decode the Any items.
@willclarktech
Copy link
Contributor

@webmaster128 I believe this is already done. Is there anything else that's needed for this issue?

@ethanfrey
Copy link
Contributor Author

@willclarktech Simon is off today. If you link me to the usage of the code, I can confirm if it is done or ask any follow up questions.

This is about parsing something that comes wrapped in Any - allowing us to no longer hard-code BaseAccount when parsing the proto.Any that stores an account. You can link me to that parse code and I can give feedback there.

@ethanfrey
Copy link
Contributor Author

Ah, I see the #354 issue on the above. I would not close this issue until that works with a general solution.
(You can solve that issue with a much simpler solution than a general registry)

@willclarktech
Copy link
Contributor

@ethanfrey
Copy link
Contributor Author

Interesting.

So, this allows us to use a registry to explicitly encode some fields with an any type (to proto.Any) and later decode that proto.Any into the original type: https://github.com/cosmos/cosmjs/blob/master/packages/proto-signing/src/magic.spec.ts#L62-L70

So the Registry object is required for all proto.Any encoding/decoding, but not needed when we encode/decoded concrete types without proto.Any. Correct? (The SDK also has a semi-global registry of all types to handle Any encoding/decoding).

@ethanfrey
Copy link
Contributor Author

I think we can close this as well. Thanks for linking me the solution

@willclarktech
Copy link
Contributor

willclarktech commented Oct 21, 2020

So the Registry object is required for all proto.Any encoding/decoding, but not needed when we encode/decoded concrete types without proto.Any. Correct?

@ethanfrey Yep!

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

No branches or pull requests

2 participants