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

Let Registry constructor argument override default types #994

Closed
webmaster128 opened this issue Jan 19, 2022 · 3 comments · Fixed by #1024
Closed

Let Registry constructor argument override default types #994

webmaster128 opened this issue Jan 19, 2022 · 3 comments · Fixed by #1024
Milestone

Comments

@webmaster128
Copy link
Member

With the addition systen, the constructor argument and the register method do the same and there is no way to get rid of Coin and MsgSend.

@webmaster128 webmaster128 added this to the 0.28.0 milestone Jan 19, 2022
@webmaster128
Copy link
Member Author

This requires adding Coin to defaultRegistryTypes.

@msteiner96
Copy link
Member

Just to be sure: You mean these two methods here?

  public constructor(customTypes: Iterable<[string, GeneratedType]> = []) {
    const { cosmosCoin, cosmosMsgSend } = defaultTypeUrls;
    this.types = new Map<string, GeneratedType>([
      [cosmosCoin, Coin],
      [cosmosMsgSend, MsgSend],
      ...customTypes,
    ]);
  }


  public register(typeUrl: string, type: GeneratedType): void {
    this.types.set(typeUrl, type);
  }

So the result should look like that?

public constructor(customTypes: Iterable<[string, GeneratedType]> = []) {
    this.types = new Map<string, GeneratedType>([
      ...customTypes,
    ]);
  }


  public register(typeUrl: string, type: GeneratedType): void {
    this.types.set(typeUrl, type);
  }

@webmaster128
Copy link
Member Author

webmaster128 commented Feb 1, 2022

The old types

      [cosmosCoin, Coin],
      [cosmosMsgSend, MsgSend],

could remain in the registry when no constructor argument is set. Then calling new Registry() is non-breaking and has Con and MsgSend as before. For this to happen we need to turn the default = [] to an optional. Once the constructor argument is set, it overrides the defaults instead of appending.

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

Successfully merging a pull request may close this issue.

2 participants