Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type generation error for nested tuples: Unable to extract location of ';' #5383

Closed
sander2 opened this issue Dec 19, 2022 · 8 comments
Closed

Comments

@sander2
Copy link
Contributor

sander2 commented Dec 19, 2022

We have a storage type that has a key of type ((CurrencyId, CurrencyId), AccountId), i.e. it is a nested tuple. Type generation fails here:

throw new Error(`${type}: Unable to extract location of ';'`);

What seems to be happening is that this code creates the following similarTypes:

similarTypes[0][0]:
'ITuple<[ITuple<[InterbtcPrimitivesCurrencyId, InterbtcPrimitivesCurrencyId]>, AccountId32]>'
similarTypes[0][1]:
'[ITuple<[InterbtcPrimitivesCurrencyId, InterbtcPrimitivesCurrencyId]> | [InterbtcPrimitivesCurrencyId | { Token: any } | { ForeignAsset: any } | { LendToken: any } | { LpToken: any } | { StableLpToken: any } | string | Uint8Array, InterbtcPrimitivesCurrencyId | { Token: any } | { ForeignAsset: any } | { LendToken: any } | { LpToken: any } | { StableLpToken: any } | string | Uint8Array], AccountId32 | string | Uint8Array]'

Note the second item, which has the form [value1, value2, value3]. When setImports is then called, getTypeDef gets called on that type, which calls decodeFixedVec, which expects something of the form [type; len] so the error above is thrown (note the ; instead of a ,).

@bvotteler
Copy link

bvotteler commented Dec 19, 2022

What seems to be happening is that this code creates the following similarTypes

To add some context, it seems like the recursive handling inside util/derived.ts getSimilarTypes method might play a significant factor.

@jacogr
Copy link
Member

jacogr commented Dec 19, 2022

Ummm, this is a weird one. (And strange we have not run into it before). Do you have a chain where we can generate a metadata bundle from to test against (i.e. either via curl or RPC call)

@bvotteler
Copy link

bvotteler commented Dec 19, 2022

Ummm, this is a weird one. (And strange we have not run into it before). Do you have a chain where we can generate a metadata bundle from to test against (i.e. either via curl or RPC call)

It's not live yet, but here's the json file obtained from state_getMetadata.

And the corresponding manual definitions used with it are here if you need them.

@jacogr
Copy link
Member

jacogr commented Dec 19, 2022

Brilliant, the json link is exactly what is needed. (Not 100% sure about the definitions, it depends where it throws the error - but worst-case, can't hurt. I have been lucky in the past not needing them in some kind of reproductions)

@bvotteler
Copy link

it depends where it throws the error

It throws while generating augment-api-query.ts via ts-node --skip-project node_modules/.bin/polkadot-types-from-chain --package <pacakge_name> --endpoint <provided_parachain.json> --output <output_folder>

@sander2
Copy link
Contributor Author

sander2 commented Jan 2, 2023

@jacogr is there anything else we can do to help resolve this asap? This bug has quite a big impact on us since we're no longer able to use polkadotjs for our newest runtimes

Edit: I think I found the problem and I attempted a fix in #5395

@jacogr
Copy link
Member

jacogr commented Mar 12, 2023

Closing on the back of #5395 - please comment if there are still issues.

@jacogr jacogr closed this as completed Mar 12, 2023
@polkadot-js-bot
Copy link

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.

@polkadot-js polkadot-js locked as resolved and limited conversation to collaborators Apr 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants