paritytech / polkadot-launch

Simple CLI tool to launch a local Polkadot test network
MIT License
459 stars 93 forks source link

Support custom Polkadot JS types on the parachain side #97

Open JoshOrndorff opened 3 years ago

JoshOrndorff commented 3 years ago

Currently the launch config has a key called types. This allows the user to insert custom types that are needed on the relay chain side. This is useful and necessary because if launch can't communicate with the relay chain, it can't submit transactions.

There is currently no corresponding support for the Parachains. I recommend we move the current types field into the relaychain section, and add a similar types field to each parachain.

It's actually not clear to me when or why launch needs to communicate with the parachains, but I think it must because I'm getting an error about how Polkadot JS can't construct the RoundIndex type, and indeed that is a custom type on Monbeam.

2021-05-11 13:20:31        API/INIT: Error: createType(RoundIndex):: Cannot construct unknown type RoundIndex
    at createTypeUnsafe (/home/joshy/polkadot-launch/node_modules/@polkadot/types/create/createType.cjs:66:11)
    at createType (/home/joshy/polkadot-launch/node_modules/@polkadot/types/create/createType.cjs:78:10)
    at TypeRegistry.createType (/home/joshy/polkadot-launch/node_modules/@polkadot/types/create/registry.cjs:306:39)
    at extendHeadMeta (/home/joshy/polkadot-launch/node_modules/@polkadot/metadata/decorate/storage/createFunction.cjs:144:53)
    at extendPrefixedMap (/home/joshy/polkadot-launch/node_modules/@polkadot/metadata/decorate/storage/createFunction.cjs:169:23)
    at createFunction (/home/joshy/polkadot-launch/node_modules/@polkadot/metadata/decorate/storage/createFunction.cjs:192:5)
    at /home/joshy/polkadot-launch/node_modules/@polkadot/metadata/decorate/storage/index.cjs:40:91
    at Array.reduce (<anonymous>)
    at /home/joshy/polkadot-launch/node_modules/@polkadot/metadata/decorate/storage/index.cjs:38:39
    at Array.reduce (<anonymous>)
ArseniiPetrovich commented 3 years ago

Workaround: Open Polkadot.JS app. Navigate to "Settings" => "Developer" and paste the following snippet there:

{
  "RoundIndex": "u32"
}
ArseniiPetrovich commented 3 years ago

@JoshOrndorff May I ask you why if I run the local node of Moonbeam and point PolkadotJS to it - it works awesome, and if I run a custom network using PolkadotLaunch - it doesn't work at all. And what is more interesting - how do I make it work properly? Any ideas on when do I get these custom types Polkadot.JS needs?

JoshOrndorff commented 3 years ago

I haven't had this problem in a while. I guess it either it got fixed or was caused by a mistake I was making locally. If you are trying to launch a local moonbeam network, you could get support in our discord.

ArseniiPetrovich commented 3 years ago

@JoshOrndorff tried to reach you via the Element chat, but sure, let me try discord instead :)

ArseniiPetrovich commented 3 years ago

Just got an update from the team via discord. There is a method now that will let you export the required custom types: https://github.com/PureStake/moonbeam/pull/838