Crate pallet_messages

Source
Expand description

Stores messages for IPFS and OnChain Schema payload locations

§Messages Pallet

Stores block-indexed data for a Schema using OnChain or IPFS payload location.

§Summary

messages stores metadata and message payload data for a set Schema. Message payloads are meant for streaming data, where when the message was sent is the focus. Discovery is via the MessagesInBlock on new blocks or requesting messages from a block. Retrieval is via a custom runtime API.

§Metadata vs Payload

Messages have both metadata and payloads. The payload should always match the data structure or the message is considered invalid. The metadata is the Block Number, Intent Id, and other data useful for discovering and organizing the payload information.

§Payload Options

  • IPFS: Storage of the CID and length of the file on IPFS
  • OnChain: Storage of the entire payload data, usually for sub-256 byte payloads

§Message Ordering

Messages are ordered by block number and IntentId, and within each block, they follow a specific order based on their transaction sequence within that block. This order is immutable.

§Actions

The Messages pallet provides for:

  • Adding messages for a given Intent
  • Enabling the retrieval of messages for a given Intent

§Interactions

§Extrinsics

Name/DescriptionCallerPaymentKey EventsRuntime Added
add_ipfs_message
Add a message to a Schema with an IPFS payload location
ProviderCapacity or TokensMessagesInBlock*1
add_onchain_message
Add a message to a Schema with an ON_CHAIN payload location
ProviderCapacity or TokensMessagesInBlock*1

* The MessagesInBlock may occur at most once per block and does not indicate which Intent(s) received messages.

See Rust Docs for more details.

§State Queries

NameDescriptionQueryRuntime Added
MessagesV3Suggested: Use custom runtime API instead of querying this storage directly.
Storage for the messages by Block Number, IntentId, and MessageIndex
messagesV3?
MessagesV2Removed in Runtime ??messagesV261
MessagesRemoved in Runtime 60messages1-60

See the Rust Docs for additional state queries and details.

§RPCs

Note: May be restricted based on node settings and configuration.

NameDescriptionCallNode Version
Get Messages by Schema Id (deprecated)Fetch paginated messages for a specific Schema Id in the given block range for a given Schema Id
Deprecated in v1.17.?. Use custom Runtime API get_messages_by_intent_id instead
getBySchemaIdv1.0.0+

See Rust Docs for more details.

§Runtime API

NameDescriptionCallAPI Version AddedRuntime Added
Get Schema by Id (deprecated)Retrieves the schema for the given Schema IdgetBySchemaId11
Get Messages by Schema and Block (deprecated)Retrieve the messages for a particular schema and block numbergetMessagesBySchemaAndBlock11
Get Messages by Intent and BlockRetrieve the messages for a particular intent and block range (paginated)getMessagesByIntentId2?

See Rust Docs for more details.

Re-exports§

pub use pallet::*;
pub use weights::*;

Modules§

migration
Storage migrations
pallet
The pallet module in each FRAME pallet hosts the most important items needed to construct this pallet.
weights
Autogenerated weights for pallet_messages

Structs§

Message
A single message type definition.

Traits§

MapToResponse
Trait for converting message storage to response type

Type Aliases§

MessageIndex
Index of message in the block
OffchainPayloadType
Payloads stored offchain contain a tuple of (bytes(the payload reference), payload length).