cashscript
cashscript copied to clipboard
Further improve typings for 'unlock' functions
now it gives type hints without the aliases for the different arguments, and gives all the union types which makes everything hard to read:
transfer: (functionParameters_0: string | Uint8Array<ArrayBufferLike> | SignatureTemplate) => Unlocker
spend: (functionParameters_0: string | Uint8Array<ArrayBufferLike>, functionParameters_1: string | Uint8Array<ArrayBufferLike> | SignatureTemplate) => Unlocker
where we would want something like:
transfer: (recipientSig: SignatureType) => Unlocker
spend: (pk: PubKeyType, sig: SignatureType) => Unlocker
Additionally, for type inference in the Contract constructor, it probably makes sense to mark the constructor params as readonly, so that it would be possible to do something like this without running into TS errors:
const inputs = ['a', 'b', 'c'] as const;
const contract = new Contract(p2pkhArtifact, inputs);
We just updated this so that the types are clearer (BytesType instead of string | ... | ...). Unfortunately we're unable to use dynamic labels for the function parameter names (see https://github.com/microsoft/TypeScript/issues/44939).