stacks-network / sbtc-developer-release

sBTC primitives, signer components, helper tools
https://sbtc.tech
MIT License
1.98k stars 23 forks source link

refactor: Split serialization from `Codec` into separate modules #414

Open ldiego08 opened 10 months ago

ldiego08 commented 10 months ago

Summary of changes

This PR proposes to fragment the serialization (Codec) implementation for different primitives from codec.rs into separate modules, i.e.: amount, recoverable_signature, etc., rename some of the interfaces, and document the code more thoroughly.

⚠️ The code added so far seeks to illustrate the proposed structure. I will implement it fully if this makes sense.

Background

While implementing the Codec trait's unit tests, I noted that the code could benefit from a bit more modularity in favor of readability and making unit tests more focused.

Proposed structure

src/
├─ serialize/
│  ├─ amount
│  ├─ recoverable_signature
│  ├─ script
│  ├─ u64

Related PRs

Testing

Run tests normally via cargo make test.

Risks

None.

How were these changes tested?

The tests included produce the same results as the ones in the existing Codec trait implementations, ensuring they work the same.

What future testing should occur?

Checklist: