3

There's upcoming features coming to pallet uniques. They are now merged to master of substrate repo but not yet released. We would like to be prepared for it on Singular marketplace but not 100% sure how to generate types to work on the UI with it. I can generate custom chain types, and import it as api-augument, this will decorate tx, query, rpc calls but the return types (definitions/interfaces) are un-decorated then (returns typles and codecs instead of the actual types). Any advice on this?

The features I am talking about for the reference: https://github.com/paritytech/substrate/commit/9dad17f77b8a56ccf0d289ae410ee1e61d9b12a1

when I add this to custom node and then generate chain types from it and replace my augmentation with it I get the new methods like buyItem but return types of all uniques methods are under-decorated

2 Answers 2

2

There are 2 parts to the TS interfaces -

  • those that ship in Substrate, Polkadot & Kusama
  • those that ship in other chains

For the first batch, the API tracks the latest Substrate/Kusama/Polkadot metadata on a weekly basis, which means that the TS definitions for any of these on master is at most outdated by a week. (This obviously means that the developer would need to follow API updates, e.g. the weekly releases ship with the latest generated TS interfaces)

For the second type (which would also include non-merged PRs on the above repos), you would need to generate your own definitions and augment that.

Looking at your specific question and the specific PR and dates, the relevant TS definitions has been available since the 8.13.1 API release.

The metadata update went in here eg. for the ItemPriceSet enum entry as added above.

The short version: types are decorated from metadata at-runtime, for updated at-development Substrate TS definitions, ensure you track the API releases.

1
  • 1
    Thank you, that what I was looking for. I was on 8.12.1 and I assumed you only update interfaces when runtime is released and not from master. But if you get them from master then this is perfect.
    – Yuri
    Jul 21, 2022 at 10:32
0

Probably there are some tricks related to getting the types working with the TypeScript type generation:

https://polkadot.js.org/docs/api/examples/promise/typegen

However, you will not be able to call and test these new extrinsics with just the new types.

Instead I suggest you run a test network with the latest version of Substrate, which should give you access to the latest pallet and all the new APIs, calls, and types.

You can test against this, and then have confidence that your UI is ready when the upgrade happens on the main network.

Additionally, you can add simple checks like:

if api.tx.uniques.set_price { /* then show ui for set price */ }

This will automatically feature gate your UI to only show elements which a runtime supports the new calls for.

2
  • 1
    We already have our own node with latest pallet unique and all new methods available. The issue is specifically regarding typescript type generation, I can only successfully generate/decorate half of it (rpc, query, tx calls, but not return interfaces themselves)
    – Yuri
    Jul 20, 2022 at 11:03
  • Sorry, I am not sure I know how to solve that.
    – Shawn Tabrizi
    Jul 21, 2022 at 8:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.