Closed hrajchert closed 9 months ago
The changes focus on enhancing type safety and consistency by introducing type guards like TxIdGuard
and branding types such as ContractIdBrand
and TxIdBrand
. These updates aim to ensure precise type checks and clear code semantics. The modifications range from adjusting function signatures to refining types and updating imports to align with the new type safety measures.
Files | Change Summary |
---|---|
packages/adapter/src/io-ts.ts |
Updated preservedBrand function to use generic types and improve type checks. |
packages/runtime/.../rest/src/contract/transaction/details.ts packages/runtime/.../rest/src/contract/transaction/endpoints/collection.ts packages/runtime/.../rest/src/contract/transaction/endpoints/singleton.ts packages/runtime/.../rest/src/contract/transaction/header.ts |
Updated to use TxIdGuard for improved type safety in transaction-related files. |
packages/runtime/core/src/contract/id.ts packages/runtime/core/src/payout/index.ts packages/runtime/core/src/tx/id.ts |
Introduced and utilized ContractIdBrand , TxIdBrand , and TxIdGuard ; updated functions to include txId . |
🐰✨
Changes abound, in code we trust,
Types refined, a must, a must!
With guards and brands, we pave the way,
For safer code, day by day.
Hoppin' through the fields of type,
Our code now strong, without the hype.
🌟🐇
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
In the PR#184 I added the preserveBrand function that helped with the uses of branded types inside recursive data types, but the typing was a little bit off, and it changed the generated documentation from this
to this
This PR:
and moreover it improves the generated output to this:
Note that in order to preserve the type alias (at least in typescript version 4.9.5) we need to define ContractId like this
instead of
Summary by CodeRabbit
TxIdGuard
,ContractIdBrand
,TxIdBrand
) to ensure more robust type checking and validation.