polkadot-js / api

Promise and RxJS APIs around Polkadot and Substrate based chains via RPC calls. It is dynamically generated based on what the Substrate runtime provides in terms of metadata.
Apache License 2.0
1.07k stars 354 forks source link

Typegen Issue with `sudo` (v7.4.1) #4501

Closed monitz87 closed 2 years ago

monitz87 commented 2 years ago

Having the same issue as #4254 on a custom chain

Snippet:

const transaction = api.tx.sudo.sudo(
  api.tx.rewards.setItnRewardStatus(itnAddress.publicKey, status)
);

Error:

Argument of type 'SubmittableExtrinsic<"promise", ISubmittableResult>' is not assignable to parameter of type 'string | Uint8Array | PolymeshRuntimeCiRuntimeCall | { System: any; } | { Babe: any; } | { Timestamp: any; } | { Indices: any; } | { Authorship: any; } | ... 35 more ... | { ...; }'.
  Type 'SubmittableExtrinsic<"promise", ISubmittableResult>' is missing the following properties from type 'PolymeshRuntimeCiRuntimeCall': isSystem, asSystem, isBabe, asBabe, and 87 more.

Augmented type for the sudo extrinsic:

sudo: AugmentedSubmittable<(call: PolymeshRuntimeCiRuntimeCall | { System: any } | { Babe: any } | { Timestamp: any } | { Indices: any } | { Authorship: any } | { Balances: any } | { Identity: any } | { CddServiceProviders: any } | { PolymeshCommittee: any } | { CommitteeMembership: any } | { TechnicalCommittee: any } | { TechnicalCommitteeMembership: any } | { UpgradeCommittee: any } | { UpgradeCommitteeMembership: any } | { MultiSig: any } | { Bridge: any } | { Staking: any } | { Session: any } | { Grandpa: any } | { ImOnline: any } | { Sudo: any } | { Asset: any } | { CapitalDistribution: any } | { Checkpoint: any } | { ComplianceManager: any } | { CorporateAction: any } | { CorporateBallot: any } | { Pips: any } | { Portfolio: any } | { ProtocolFee: any } | { Scheduler: any } | { Settlement: any } | { Statistics: any } | { Sto: any } | { Treasury: any } | { Utility: any } | { Base: any } | { ExternalAgents: any } | { Relayer: any } | { Rewards: any } | { TestUtils: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [PolymeshRuntimeCiRuntimeCall]>;

I read through the linked issue but didn't find any solution there. Most of the links posted there lead to 404 error pages

What am I doing wrong? Also, would calling toU8a() on the submittable extrinsic work in the meantime while I try to get the types working correctly?

monitz87 commented 2 years ago

@savudani8 mind if I ask how you got it fixed?

jacogr commented 2 years ago

I don't believe this catches your namespace and maps the Call/Event correctly -

https://github.com/polkadot-js/api/blob/master/packages/types/src/metadata/PortableRegistry/PortableRegistry.ts#L32

Your seems to be polymesh_runtime::ci::runtime::Call (or something like that, would need to check agains the output itself)

monitz87 commented 2 years ago

How can I help you check this?

monitz87 commented 2 years ago

Found it

/**
 * Lookup354: polymesh_runtime_ci::runtime::Call
 **/
daniel-savu commented 2 years ago

@savudani8 mind if I ask how you got it fixed?

@monitz87 In our case simpy upgrading the @polkadot/api version fixed it.

Make sure you're using the latest metadata from your substrate chain to generate the interfaces.

This is a working example in our library that's basically identical to yours and works https://github.com/interlay/interbtc-api/blob/master/src/parachain/issue.ts#L304

monitz87 commented 2 years ago

Thanks @savudani8, but it seems the issue is related to what @jacogr mentioned

@jacogr: I hardcoded '*_runtime_*::runtime::Call', '*_runtime_*::runtime::Event' into the PATHS_ALIAS array and ran the typegen again and it works now. What would be the long term solution here?

polkadot-js-bot commented 2 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue if you think you have a related problem or query.