3

I've been trying to follow the documentation for generating types for @polkadot/api https://polkadot.js.org/docs/api/examples/promise/typegen/. However the generated files seem to be missing many types, revealed by tsc:

Error: src/interfaces/augment-api-consts.ts(87,22): error TS2304: Cannot find name 'SpWeightsWeightV2Weight'.
Error: src/interfaces/augment-api-consts.ts(115,20): error TS2304: Cannot find name 'FrameSystemLimitsBlockLength'.
Error: src/interfaces/augment-api-consts.ts(119,21): error TS2304: Cannot find name 'FrameSystemLimitsBlockWeights'.
Error: src/interfaces/augment-api-consts.ts(123,17): error TS2304: Cannot find name 'SpWeightsRuntimeDbWeight'.
Error: src/interfaces/augment-api-consts.ts(135,16): error TS2304: Cannot find name 'SpVersionRuntimeVersion'.
Error: src/interfaces/augment-api-events.ts(44,121): error TS2304: Cannot find name 'FrameSupportTokensMiscBalanceStatus'.
Error: src/interfaces/augment-api-events.ts(44,230): error TS2304: Cannot find name 'FrameSupportTokensMiscBalanceStatus'.
Error: src/interfaces/augment-api-events.ts(70,52): error TS2304: Cannot find name 'SpRuntimeDispatchError'.
Error: src/interfaces/augment-api-events.ts(74,56): error TS2304: Cannot find name 'SpRuntimeDispatchError'.
Error: src/interfaces/augment-api-events.ts(84,74): error TS2304: Cannot find name 'SpFinalityGrandpaAppPublic'.
Error: src/interfaces/augment-api-events.ts(84,139): error TS2304: Cannot find name 'SpFinalityGrandpaAppPublic'.
Error: src/interfaces/augment-api-events.ts(197,64): error TS2304: Cannot find name 'PalletProcessValidationBinaryExpressionTreeBooleanExpressionSymbol'.
Error: src/interfaces/augment-api-events.ts(216,113): error TS2304: Cannot find name 'SpRuntimeDispatchError'.
Error: src/interfaces/augment-api-events.ts(216,210): error TS2304: Cannot find name 'SpRuntimeDispatchError'.
Error: src/interfaces/augment-api-events.ts(256,64): error TS2304: Cannot find name 'SpRuntimeDispatchError'.
Error: src/interfaces/augment-api-events.ts(256,117): error TS2304: Cannot find name 'SpRuntimeDispatchError'.
Error: src/interfaces/augment-api-events.ts(260,69): error TS2304: Cannot find name 'SpRuntimeDispatchError'.
Error: src/interfaces/augment-api-events.ts(260,122): error TS2304: Cannot find name 'SpRuntimeDispatchError'.
Error: src/interfaces/augment-api-events.ts(274,64): error TS2304: Cannot find name 'SpRuntimeDispatchError'.
Error: src/interfaces/augment-api-events.ts(274,102): error TS2304: Cannot find name 'FrameSupportDispatchDispatchInfo'.
Error: src/interfaces/augment-api-events.ts(274,154): error TS2304: Cannot find name 'SpRuntimeDispatchError'.
Error: src/interfaces/augment-api-events.ts(274,192): error TS2304: Cannot find name 'FrameSupportDispatchDispatchInfo'.
Error: src/interfaces/augment-api-events.ts(278,64): error TS2304: Cannot find name 'FrameSupportDispatchDispatchInfo'.
Error: src/interfaces/augment-api-events.ts(278,115): error TS2304: Cannot find name 'FrameSupportDispatchDispatchInfo'.
Error: src/interfaces/augment-api-events.ts(312,83): error TS2304: Cannot find name 'SpRuntimeDispatchError'.
Error: src/interfaces/augment-api-events.ts(312,152): error TS2304: Cannot find name 'SpRuntimeDispatchError'.
Error: src/interfaces/augment-api-events.ts(316,89): error TS2304: Cannot find name 'SpRuntimeDispatchError'.
Error: src/interfaces/augment-api-events.ts(316,158): error TS2304: Cannot find name 'SpRuntimeDispatchError'.
Error: src/interfaces/augment-api-query.ts(24,65): error TS2304: Cannot find name 'SpConsensusAuraSr25519AppSr25519Public'.
Error: src/interfaces/augment-api-query.ts(63,95): error TS2304: Cannot find name 'PalletBalancesAccountData'.
Error: src/interfaces/augment-api-query.ts(72,97): error TS2304: Cannot find name 'PalletBalancesBalanceLock'.
Error: src/interfaces/augment-api-query.ts(76,100): error TS2304: Cannot find name 'PalletBalancesReserveData'.
Error: src/interfaces/augment-api-query.ts(99,70): error TS2304: Cannot find name 'PalletGrandpaStoredPendingChange'.
Error: src/interfaces/augment-api-query.ts(120,55): error TS2304: Cannot find name 'PalletGrandpaStoredState'.
Error: src/interfaces/augment-api-query.ts(174,97): error TS2304: Cannot find name 'PalletPreimageRequestStatus'.
Error: src/interfaces/augment-api-query.ts(184,131): error TS2304: Cannot find name 'PalletProcessValidationProcess'.
Error: src/interfaces/augment-api-query.ts(207,100): error TS2304: Cannot find name 'PalletSchedulerScheduled'.
Error: src/interfaces/augment-api-query.ts(226,101): error TS2304: Cannot find name 'PalletSimpleNftToken'.
Error: src/interfaces/augment-api-query.ts(246,95): error TS2304: Cannot find name 'FrameSystemAccountInfo'.
Error: src/interfaces/augment-api-query.ts(258,61): error TS2304: Cannot find name 'FrameSupportDispatchPerDispatchClassWeight'.
Error: src/interfaces/augment-api-query.ts(262,56): error TS2304: Cannot find name 'SpRuntimeDigest'.
Error: src/interfaces/augment-api-query.ts(276,60): error TS2304: Cannot find name 'FrameSystemEventRecord'.
Error: src/interfaces/augment-api-query.ts(293,71): error TS2304: Cannot find name 'FrameSystemPhase'.
Error: src/interfaces/augment-api-query.ts(305,75): error TS2304: Cannot find name 'FrameSystemLastRuntimeUpgradeInfo'.
Error: src/interfaces/augment-api-query.ts(352,94): error TS2304: Cannot find name 'PalletCollectiveVotes'.
Error: src/interfaces/augment-api-tx.ts(144,106): error TS2304: Cannot find name 'SpWeightsWeightV2Weight'.
Error: src/interfaces/augment-api-tx.ts(144,231): error TS2304: Cannot find name 'SpWeightsWeightV2Weight'.
Error: src/interfaces/augment-api-tx.ts(172,68): error TS2304: Cannot find name 'SpFinalityGrandpaEquivocationProof'.
Error: src/interfaces/augment-api-tx.ts(172,179): error TS2304: Cannot find name 'SpCoreVoid'.
Error: src/interfaces/augment-api-tx.ts(172,233): error TS2304: Cannot find name 'SpFinalityGrandpaEquivocationProof'.
Error: src/interfaces/augment-api-tx.ts(172,269): error TS2304: Cannot find name 'SpCoreVoid'.
Error: src/interfaces/augment-api-tx.ts(184,76): error TS2304: Cannot find name 'SpFinalityGrandpaEquivocationProof'.
Error: src/interfaces/augment-api-tx.ts(184,187): error TS2304: Cannot find name 'SpCoreVoid'.
Error: src/interfaces/augment-api-tx.ts(184,241): error TS2304: Cannot find name 'SpFinalityGrandpaEquivocationProof'.
Error: src/interfaces/augment-api-tx.ts(184,277): error TS2304: Cannot find name 'SpCoreVoid'.
Error: src/interfaces/augment-api-tx.ts(367,90): error TS2304: Cannot find name 'PalletProcessValidationBinaryExpressionTreeBooleanExpressionSymbol'.
Error: src/interfaces/augment-api-tx.ts(367,161): error TS2304: Cannot find name 'PalletProcessValidationBinaryExpressionTreeBooleanExpressionSymbol'.
Error: src/interfaces/augment-api-tx.ts(367,337): error TS2304: Cannot find name 'PalletProcessValidationBinaryExpressionTreeBooleanExpressionSymbol'.
Error: src/interfaces/augment-api-tx.ts(405,50): error TS2304: Cannot find name 'DscpPalletTraitsProcessFullyQualifiedId'.
Error: src/interfaces/augment-api-tx.ts(405,211): error TS2304: Cannot find name 'PalletSimpleNftOutput'.
Error: src/interfaces/augment-api-tx.ts(405,237): error TS2304: Cannot find name 'PalletSimpleNftOutput'.
Error: src/interfaces/augment-api-tx.ts(405,354): error TS2304: Cannot find name 'DscpPalletTraitsProcessFullyQualifiedId'.
Error: src/interfaces/augment-api-tx.ts(405,410): error TS2304: Cannot find name 'PalletSimpleNftOutput'.
Error: src/interfaces/augment-api-tx.ts(451,102): error TS2304: Cannot find name 'SpWeightsWeightV2Weight'.
Error: src/interfaces/augment-api-tx.ts(451,227): error TS2304: Cannot find name 'SpWeightsWeightV2Weight'.
Error: src/interfaces/augment-api-tx.ts(534,145): error TS2304: Cannot find name 'SpWeightsWeightV2Weight'.
Error: src/interfaces/augment-api-tx.ts(534,336): error TS2304: Cannot find name 'SpWeightsWeightV2Weight'.
Error: src/interfaces/index.ts(4,15): error TS2306: File '/home/runner/work/dscp-matchmaker-api/dscp-matchmaker-api/src/interfaces/types.ts' is not a module.

It also generates an empty types.ts - I've not added any custom definitions.

metadata.json was generated with curl -H "Content-Type: application/json" -d '{"id":"1", "jsonrpc":"2.0", "method": "state_getMetadata", "params":[]}' http://localhost:9944 hitting our local node.

Is there something I'm missing or getting wrong in my setup?

PR showing the commands used and files generated . Thank you

1
  • we are have a very similar problem. I noticed when i run the generator it gives an error ERROR: No lookup definitions found: Unknown file extension ".ts" for src/interfaces/lookup.ts Nov 13 at 23:01

1 Answer 1

3

Try update to latest version of polkadot typegen and use this

"generate:defs": "node --experimental-specifier-resolution=node --loader ts-node/esm  node_modules/.bin/polkadot-types-from-defs --package dscp-matchmaker-api/interfaces  --input ./src/interfaces --endpoint ./metadata.json",
"generate:meta": "node --experimental-specifier-resolution=node --loader ts-node/esm  node_modules/.bin/polkadot-types-from-chain --endpoint ./metadata.json --output ./src/interfaces"
1
  • tried this an it didnt change anything. still cannot find all the types that are generated in the types-lookup.ts Nov 13 at 21:31

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.