Skip to content

Brainstorming the typing of .tokenCategory #294

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

Open
mr-zwets opened this issue Mar 12, 2025 · 0 comments
Open

Brainstorming the typing of .tokenCategory #294

mr-zwets opened this issue Mar 12, 2025 · 0 comments

Comments

@mr-zwets
Copy link
Member

This issue is mainly just brainstorming about the type system for CashScript

tokenCategory example

consider the following example

bytes tokenCategoryResultInput0 = tx.inputs[0].tokenCategory;
bytes32 tokenCategoryInput0, bytes capabilityInput0 = tokenCategoryResultInput0.split(32)

tokenCategoryResultInput0 or capabilityInput0 can not be more specific than just bytes because they don't fit the bytesX type.

However in reality tokenCategoryResultInput0 is the union type of bytes0 | bytes32 | bytes33
and we know the type of capabilityInput0 to be 0x | 0x01 | 0x02 or more generic bytes0 | byte

but union types don't exist in CashScript and neither does bytes0 or as const typing

as an aside I noticed

The type byte has been removed. It was an alias of bytes1.

https://docs.soliditylang.org/en/v0.8.3/080-breaking-changes.html#silent-changes-of-the-semantics

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant