Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

How do you create type registry JSON files? #94

Closed
khssnv opened this issue Dec 10, 2022 · 2 comments
Closed

How do you create type registry JSON files? #94

khssnv opened this issue Dec 10, 2022 · 2 comments

Comments

@khssnv
Copy link

khssnv commented Dec 10, 2022

Hi there 👋

There are type registry JSON files in a type_registry directory. It seems like very few of them are provided by projects developers. Could you reveal how you create these JSONs? It could help to contribute to the project. Thanks!

@arjanz
Copy link
Member

arjanz commented Dec 12, 2022

There is some history for those type registry files. Since Substrate introduced MetadataV14, it contains an embedded type registry with all types used in the calls and storage functions. Before that, types were just mere strings how they were named in the RUST code of the runtime. So back then there was a need to manually administer a type registry to describe the type decomposition in primitives.

For networks like Kusama those registries were already maintained by PolkadotJS (example), so I could gratefully re-use those.

But for other networks that don't provide an own registry file, you basically have to analyse the RUST source and create a type registry manually:

Crust example: https://github.com/crustio/crust/blob/d2de3d018c9367cec98411d56fdb0836cffb75cd/cstrml/benefits/src/lib.rs#L138

Type registry:

But later on they upgrade to MetadataV14, so there was no more need for the manually type registry. (See comment: polkascan/py-substrate-interface#251 (comment))

TL;DR: Probably you don't need to create/maintain a type registry file, unless the Substrate runtime still utilises MetadataV13 or lower (check substrate.get_metadata() and substrate.implements_scaleinfo()).

@khssnv
Copy link
Author

khssnv commented Dec 13, 2022

Got it, thank you for sharing 👍

@khssnv khssnv closed this as completed Dec 13, 2022
@polkascan polkascan locked and limited conversation to collaborators Jan 3, 2023
@arjanz arjanz converted this issue into discussion #96 Jan 3, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants