2

In polkadot-js has provided for developer to define custom types in the pallet, so that polkadot-ui can understand those types (it means can use some underlying API polkadot-js). These types are defined using the json format. This is example

{
  "TransactionInput": {
    "parent_output": "Hash",
    "signature": "Signature"
  },
  "TransactionOutput": {
    "value": "u128",
    "pubkey": "Hash",
    "sale": "u32"
  },
  "Transaction": {
    "inputs": "Vec<TransactionInput>",
    "outputs": "Vec<TransactionOutput>"
  }
}

I see that in substrate-node-template/scripts has aggregrate_types.js file that generate types.json. I dont know how to generate it automaticly or I should write by hand. Example that, in my pallet that i have defined enum RoleID and struct Role. But in UI it doesn't understand what RoleID is. Can you explain more clearly? I believe that it can be related to define types.json. enter image description here https://github.com/polkadot-js/apps/blob/master/packages/page-settings/src/md/basics.md#developer

aggregrate_types.json: enter image description here

Thanks!!!

CocDap
  • 180
  • 4
  • I don't see the `aggregrate_types.js` you mention [here](https://github.com/paritytech/substrate/tree/master/bin/node-template/scripts) - can you point that out? – Nuke Jul 22 '21 at 16:57
  • Thanks for reply!!! aggregrate_types.js that i mention in susbtrate-node-template. Yeah when i check in github they delete this file. But in some previous commit, they have – CocDap Jul 22 '21 at 17:19
  • @NukeManDan The aggregate_type.js script can be found here: https://github.com/substrate-developer-hub/recipes/search?q=filename%3Aaggregate_types.js – btwiuse Aug 08 '21 at 09:18

2 Answers2

1

Presently, generating this by hand is the best way following the docs here. There are not clean ways to automatically generate this to my knowlage, but soon you will not need to worry about at all it once this PR lands in Substrate!

Nuke
  • 1,032
  • 7
  • 13
0

Thanks to https://github.com/paritytech/substrate/pull/8615, you don't have to manually write types.json anymore.

Make sure the metadata version of your node is v14 or higher. Otherwise you need to upgrade your substrate version to make it automagically work for you.

btwiuse
  • 2,585
  • 1
  • 23
  • 31