question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Decentralize message type generation

See original GitHub issue

We want to support many different message type, some from the Cosmos SDK and some from custom blockchains that are not standardized. The user of CosmJS should have the most common message types ready to be used shipped with this library. But it should also be possible to add new message types from the caller code.

Some thoughts that might help getting there:

  1. Protojs allow dynamically adding .proto files: https://github.com/protobufjs/protobuf.js/blob/master/README.md#using-proto-files
  2. Maybe we can utilize JSON descriptors or reflection to dynamically add types
  3. The library @node-a-team/ts-amino uses decorators to add encoding information to TypeScript types as shown here: https://github.com/chainapsis/cosmosjs/blob/master/src/common/stdTx.ts. Maybe we can use decorators as well to start with a TypeScript class and annotate it with all the necessary runtime information, like:
@CosmosMessage("cosmos.bank.MsgSend") // adds this type to a registry using the string as the `type_url`
export class MsgSend {
  @Field.Bytes(1 /* protobuf field number goes here*/)
  public fromAddress: Uint8Array;

  @Field.Bytes(2, { fieldName: "to_address" /* runtime field name for protobuf; probably irrelevant since not encoded into the proto bytes*/  })
  public toAddress: Uint8Array;

  @Field.Repeated(3, { type: Type.Defined }) // don't know what this does but if it worked for Amino, it can probably be adapted
  public amount: Coin[];
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

0reactions
willclarktechcommented, Jun 23, 2020

Closed in #221

Read more comments on GitHub >

github_iconTop Results From Across the Web

Decentralized Messaging: Top 4 messaging apps - TrueConf
Matrix is an open protocol for decentralized, real-time communication. It can be used for text messaging, group chats, audio/video calls and bot ...
Read more >
Building A Decentralized Messaging with End-to-End ...
It explores industry standards for open messaging protocols that can be used to build a secured, decentralized and scalable messaging system ...
Read more >
The next big thing in messaging - Protocol
But decentralized messaging apps could be the kind of resilient, ... It's time to give Gen Z a seat at the table for...
Read more >
Introducing Origin Messaging: Decentralized, Secure, and ...
Origin Messaging requires a double opt-in key generation procedure for each participant in a conversation. This is not a frictionless onboarding experience, but ......
Read more >
I built a decentralized chat dapp // GUN web3 Tutorial - YouTube
Build a decentralized chat app using the GUN JavaScript library. Learn how to use web3 technology to create a peer-to-peer graph database ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found