cosmjs icon indicating copy to clipboard operation
cosmjs copied to clipboard

Duplication code

Open happylolonly opened this issue 1 year ago • 3 comments

Hi, why need such funcs? https://github.com/cosmos/cosmjs/blob/v0.32.0/packages/stargate/src/stargateclient.ts#L333

It is not possible to just use them from inherited modules, than make public?

In our project our devs made same, and code looks duplicated https://github.com/cybercongress/soft3.js/blob/main/src/cyberclient.ts#L430

Or you can do: public getAllBalances = this.forceGetQueryClient().bank.allBalances; it will be shorter, and keep types correct.

What do you think?

happylolonly avatar Dec 12 '23 19:12 happylolonly

Ideally I would want something like this. (or better inherit from that module's extension such https://github.com/cybercongress/soft3.js/blob/main/src/queries/bandwidth.ts#L26 )

image

happylolonly avatar Dec 12 '23 19:12 happylolonly

What if make queryClient public, than private? It will alow to use all methods from extensions

https://github.com/cosmos/cosmjs/blob/v0.32.0/packages/stargate/src/stargateclient.ts#L200

happylolonly avatar Dec 12 '23 19:12 happylolonly

The whole idea of those wrapper functions does not scale and needs to be abandoned at some point, for both queries and messages/transactions. This was already touched briefly in https://github.com/cosmos/cosmjs/issues/1440. There is an experimental generic Client class that comes without them shown in https://github.com/cosmos/cosmjs/pull/1486. So yeah, it was a good idea when this API was originally designed but we can't keep up with the amount of functionality and at the same time using the protobuf API directly got more convenient.

webmaster128 avatar Dec 12 '23 21:12 webmaster128