Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom metadata storage #450

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft

Conversation

vatsa287
Copy link
Member

This is a draft implementation of having a custom metadata of MaxMetaPairLength in asset, but in general this can be replicated across the chain.
One of the current use-case would be to store created_at: UTC of old_chain_block after migration so apps can access this value instead of newly created block time.

How it is implemented?

  • For demonstration have made this to asset specific.
  • Create a storage named AssetMeta to store metadata of storage. It allows to custom k:v of MaxMetaPairLength currently set to 5, where the identifier of the asset is the first key, and second key is a custom type.
  • When lookup'ed on using the identifier we get a list of all the k:v of the pallet metadata, but when used with a custom key it produces a result with the custom value.

Ex:

  • Create a metapairs on the SDK, with string type k:v which has custom keys and values attached to the identifier of the asset.
    const metaPairs: [string, string][] = [
      ["key1", "value1"],
      ["key2", "value2"],
      ["key3", "value3"],
      ["key4", "value4"],
      ["key5", "value5"],
    ];

    const tx = api.tx.asset.issue(
      assetEntry.entry,
      assetEntry.digest,
      authorizationId,
      metaPairs
    )
  • Chain-state after execution with all k:v seen,
Screenshot 2024-05-13 at 3 06 54 PM
  • Chain-state after execution with a particular key query,
Screenshot 2024-05-13 at 3 07 13 PM

Signed-off-by: Shreevatsa N <[email protected]>
@vatsa287
Copy link
Member Author

@vatsa287 vatsa287 marked this pull request as draft May 23, 2024 04:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant