4

I'm following the guide in polkadot-js/typegen, the github source is shared. I am trying to follow along and decorate the api for my custom node-template called supersig-template

I have successfully created an output of the metadata:

curl -H "Content-Type: application/json" -d '{"id":"1", "jsonrpc":"2.0", "method": "state_getMetadata", "params":[]}' http://localhost:9933 > supersig-template.json

But I am not very clearly in the github source where I should be running yarn build. I try in the root of forking /docs repo. But I don't think that is the correct place.

Then I went into /docs/api/examples/promise/typegen separated it into its own repo, changed package json to include --endpoint ./supersig-template.json then ran yarn build and got this error:

typegen % yarn build
yarn run v1.22.19
$ yarn generate:defs && yarn generate:meta
$ ts-node --skip-project node_modules/.bin/polkadot-types-from-defs --package sample-polkadotjs-typegen/interfaces --input /src/interfaces --endpoint /Users/ramsey/decentration/typegen/supersig-template.json
Options:
  --help     Show help                                                 [boolean]
  --version  Show version number                                       [boolean]
  --input    The directory to use for the user definitions   [string] [required]
  --package  The package name & path to use for the user types
                                                             [string] [required]

Unknown argument: endpoint
error Command failed with exit code 1.

A few questions:

  • is typegen still up to date and something that can be used to decorate APIs?
  • has endpoint been removed as an argument?
  • am I going about thing the correct way to decorate the api?

Solution to "unknown endpoint" issue: Make sure to bump the version of both polkadot/api and polkadot/typegen to ^8.13.1 and it will yarn build successfully.

2
  • 1
    I've got these commands working with version 8.13.1 of polkadot dependencies.
    – forgetso
    Dec 5, 2022 at 11:14
  • 1
    thanks, the version was on 2.3.1 not 8.13.1, that resolved this issue. Jan 5, 2023 at 12:46

2 Answers 2

1

if you have added the rpc in the definitions.ts of your pallet like this they will not be automatically included or decorated because they are not automatically included in the ApiPromise and you are not passing them into the ApiPromise.create rpc option param.

The thing is that even if you extract them directly from the definitions.ts and add them to the connection like this it will still not work for some weird reason.

To fix this we maintain 2 separate sets of the RPC, one for the Typegeneration ( defined in the pallet/definitions.ts), and one for the connection, which is basically the same; just appended the PaletName to all RPC endpoints like this then include them like this

0

The cause is the version of @polkadot/api and @polkadot/typegen do not match. They should have the same version.... check your package.json file.

1

Your Answer

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

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