cosmology-tech / telescope

A TypeScript Transpiler for Cosmos Protobufs ⚛️
https://cosmology.zone/products/telescope
Apache License 2.0
146 stars 43 forks source link

allow GlobalRegistry decode/encode to return types #687

Open pyramation opened 6 hours ago

pyramation commented 6 hours ago

From discord:

I'm no TS expert but is there a way for the GlobalRegistry to return concrete type instead of generic Object?

maybe we can solve using template style like Object<SomeThing> potentially could help? Or is this a non-issue and already something that can be done?

cc @Zetazzz

pyramation commented 5 hours ago

I'm not sure it's necessary because the encoders/decoders are typed:

https://github.com/osmosis-labs/osmojs/blob/72a55404a8d5cf4f14786016337b47e82d0e5338/packages/osmojs/src/cosmos/gov/v1beta1/tx.ts#L307

looking here I see the function is typed

fromAmino(object: MsgSubmitProposalAmino): MsgSubmitProposal {
    const message = createBaseMsgSubmitProposal();
    if (object.content !== undefined && object.content !== null) {
      message.content = GlobalDecoderRegistry.fromAminoMsg(object.content);
    }
    message.initialDeposit = object.initial_deposit?.map(e => Coin.fromAmino(e)) || [];
    if (object.proposer !== undefined && object.proposer !== null) {
      message.proposer = object.proposer;
    }
    return message;
  },

what is the issue here if we have MsgSubmitProposal