Skip to content

@joystream/types - api.tx, api.query and api.consts augmentation #1165

@Lezek123

Description

@Lezek123

The works introdcued in #1124 (mainly defsFromTypes.ts script) and #1158 (exposing more types in the registry) opened the door for taking the full advantage of @polkadot/typegen tool without the need for immediate migration to this solution.

There are now only a few changes required to create augmented api interfaces for api.tx, api.query and api.consts (that could temporarly be an alternative for the current usage of @joystream/types, since full migration of Pioneer and other projects to this solution could take some time).

Changes required:

  • Expose a few more missing types in the registry (mostly versioned-store related)
  • A few minor tweaks in @joystream/types and defsFromTypes.ts script (ie. @polkadot/typegen will not accept BTreeSet so we need to convert it to Vec when running defsFromTypes.ts script. There are also some issues with struct fields like values, since they have the same name as base Struct fields/methods etc.)
  • Create a subdirectory in @joystream/types for the new, auto-generated types (with the structure matching: https://github.com/polkadot-js/api/tree/master/docs/examples/promise/90_typegen) in such a way that they can co-exist with current types and api.createType augmentation.
  • Add&Adjust the scripts to easily generate/update types and api augmentation files in one step based on current state of @joystream/types and the runtime (currently that would require a few manual steps, like running print:typedef into a file, copying the defs etc.).

Metadata

Metadata

Assignees

Labels

estimate-9hTime estimation for issues in a project - 9h

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions