Decentralize message type generation
See original GitHub issueWe 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:
- Protojs allow dynamically adding .proto files: https://github.com/protobufjs/protobuf.js/blob/master/README.md#using-proto-files
- Maybe we can utilize JSON descriptors or reflection to dynamically add types
- 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:
- Created 3 years ago
- Comments:6 (6 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Good table of tradeoffs here: https://github.com/protobufjs/protobuf.js/blob/7bacfc8/README.md#reflection-vs-static-code
Closed in #221