After discussion with @maht0rz, there is supposedly a limitation in o1js that breaks inference of type params for State.from/StateMap.from.
The following looks completely normal to Protokit beginners such as myself:
class NftId extends Field {}
// ...
@state() public nftMetadata = StateMap.from(NftId, Field);
Methods of the state map seem to produce the correct signatures.
this.nftMetadata.get(null!) // Option<Field>
Meanwhile, the documentation mentions the need for explicit type arguments.
- @state() public nftMetadata = StateMap.from(NftId, Field);
+ @state() public nftMetadata = StateMap.from<NftId, Field>(NftId, Field);
However, this seems to work without the explicit type args. Am I missing something? Has this limitation been overcome? If so, I'll put up a PR removing the note from the docs.
After discussion with @maht0rz, there is supposedly a limitation in
o1js
that breaks inference of type params forState.from
/StateMap.from
.The following looks completely normal to Protokit beginners such as myself:
Methods of the state map seem to produce the correct signatures.
Meanwhile, the documentation mentions the need for explicit type arguments.
However, this seems to work without the explicit type args. Am I missing something? Has this limitation been overcome? If so, I'll put up a PR removing the note from the docs.