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

Generated query interfaces do not import Option polkadot type #3976

Closed daniel-savu closed 3 years ago

daniel-savu commented 3 years ago

When updating to v6.0.4 from v5.3.2, I'm getting compilation errors in augment-api-query.ts such as

src/interfaces/augment-api-query.ts:615:92 - error TS2749: 'Option' refers to a value, but is being used as a type here. Did you mean 'typeof Option'?

615       vaults: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<DefaultVault>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
                                                                                               ~~~~~~

src/interfaces/augment-api-query.ts:615:92 - error TS4033: Property 'vaultRegistry' of exported interface has or is using private name 'Option'.

615       vaults: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<DefaultVault>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;

I can see that the Option type is not imported by the auto-generated code in augment-api-query.ts. These errors do not occur in augment-api-rpc.ts, where the Option type is imported from @polkadot/types

jacogr commented 3 years ago

This one (containing metadata v14 and reworking all type handling) is a rough upgrade for me :)

I appreciate the bug reports to pickup stuff I missed.

jacogr commented 3 years ago

It should be fixed in 6.0.5 which is current building on CI and should be available in 10-odd minutes.

Please test once available. If it is still problematic (let's hope not), please send me a link to the repo so I can step through bit by bit.

daniel-savu commented 3 years ago

That fixed it, thanks! I upgraded in the hope that .at(blockhash) queries would be fixed, but it seems like they're still returning undefined. I checked the docs and the syntax hasn't changed. The query that doesn't work uses a custom struct type: https://github.com/interlay/interbtc-api/blob/master/src/parachain/oracle.ts#L122

(The query works without .at)

jacogr commented 3 years ago

Would need to replicate - please do the following -

polkadot-js-bot commented 3 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.